fix store diary page
This commit is contained in:
@@ -15,8 +15,8 @@ import com.imyeyu.java.TimiJava;
|
|||||||
import com.imyeyu.java.bean.timi.TimiException;
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
import com.imyeyu.spring.annotation.AOPLog;
|
||||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||||
import com.imyeyu.spring.bean.Page;
|
|
||||||
import com.imyeyu.spring.bean.PageResult;
|
import com.imyeyu.spring.bean.PageResult;
|
||||||
|
import com.imyeyu.api.modules.gao.vo.GaoStoreDiaryPage;
|
||||||
import com.imyeyu.spring.util.ResponseView;
|
import com.imyeyu.spring.util.ResponseView;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@@ -49,12 +49,12 @@ public class GaoStoreDiaryController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STORE_DIARY_READ)
|
@RequireGaoPermission(GaoPermissionCode.STORE_DIARY_READ)
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
public PageResult<Article> list(@RequestBody Page<Article> page) {
|
public PageResult<Article> list(@RequestBody GaoStoreDiaryPage page) {
|
||||||
TimiException.required(page, "未找到分页参数");
|
TimiException.required(page, "未找到分页参数");
|
||||||
Article example = TimiJava.defaultIfNull(page.getEqualsExample(), new Article());
|
TimiException.required(page.getBeginCreatedAt(), "未找到门店日记开始时间");
|
||||||
example.setBizType(Article.BizType.GAO_STORE_DIARY);
|
TimiException.required(page.getEndCreatedAt(), "未找到门店日记结束时间");
|
||||||
example.setBizId(storeScopeService.resolveStoreId(example.getBizId()));
|
TimiException.requiredTrue(page.getBeginCreatedAt() < page.getEndCreatedAt(), "门店日记时间范围无效");
|
||||||
page.setEqualsExample(example);
|
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
|
||||||
return service.page(page);
|
return service.page(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.imyeyu.api.modules.gao.service;
|
package com.imyeyu.api.modules.gao.service;
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.entity.Article;
|
import com.imyeyu.api.modules.common.entity.Article;
|
||||||
import com.imyeyu.spring.bean.Page;
|
|
||||||
import com.imyeyu.spring.bean.PageResult;
|
import com.imyeyu.spring.bean.PageResult;
|
||||||
|
import com.imyeyu.api.modules.gao.vo.GaoStoreDiaryPage;
|
||||||
|
|
||||||
/// GAO 门店日记服务
|
/// GAO 门店日记服务
|
||||||
///
|
///
|
||||||
@@ -14,7 +14,7 @@ public interface GaoStoreDiaryService {
|
|||||||
///
|
///
|
||||||
/// @param page 分页查询条件
|
/// @param page 分页查询条件
|
||||||
/// @return 门店日记分页结果
|
/// @return 门店日记分页结果
|
||||||
PageResult<Article> page(Page<Article> page);
|
PageResult<Article> page(GaoStoreDiaryPage page);
|
||||||
|
|
||||||
/// 查询门店日记详情
|
/// 查询门店日记详情
|
||||||
///
|
///
|
||||||
|
|||||||
+8
-2
@@ -7,6 +7,8 @@ import com.imyeyu.api.modules.common.mapper.ArticleMapper;
|
|||||||
import com.imyeyu.api.modules.common.service.ArticleService;
|
import com.imyeyu.api.modules.common.service.ArticleService;
|
||||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoStoreDiaryService;
|
import com.imyeyu.api.modules.gao.service.GaoStoreDiaryService;
|
||||||
|
import com.imyeyu.api.modules.gao.mapper.GaoStoreDiaryMapper;
|
||||||
|
import com.imyeyu.api.modules.gao.vo.GaoStoreDiaryPage;
|
||||||
import com.imyeyu.java.TimiJava;
|
import com.imyeyu.java.TimiJava;
|
||||||
import com.imyeyu.java.bean.timi.TimiException;
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.spring.bean.Page;
|
import com.imyeyu.spring.bean.Page;
|
||||||
@@ -26,10 +28,14 @@ public class GaoStoreDiaryServiceImplement implements GaoStoreDiaryService {
|
|||||||
private final ArticleService articleService;
|
private final ArticleService articleService;
|
||||||
private final AttachmentService attachmentService;
|
private final AttachmentService attachmentService;
|
||||||
private final ArticleMapper articleMapper;
|
private final ArticleMapper articleMapper;
|
||||||
|
private final GaoStoreDiaryMapper diaryMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<Article> page(Page<Article> page) {
|
public PageResult<Article> page(GaoStoreDiaryPage page) {
|
||||||
return articleService.page(page);
|
PageResult<Article> result = new PageResult<>();
|
||||||
|
result.setTotal(diaryMapper.countByMonth(page));
|
||||||
|
result.setList(diaryMapper.selectByMonth(page));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.imyeyu.api.modules.gao.vo;
|
||||||
|
|
||||||
|
import com.imyeyu.java.bean.BasePage;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/// GAO 门店日记月份分页查询请求
|
||||||
|
///
|
||||||
|
/// @author Codex
|
||||||
|
/// @since 2026-08-31
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class GaoStoreDiaryPage extends BasePage {
|
||||||
|
|
||||||
|
/// 门店 ID
|
||||||
|
private String storeId;
|
||||||
|
|
||||||
|
/// 创建时间起点,包含
|
||||||
|
private Long beginCreatedAt;
|
||||||
|
|
||||||
|
/// 创建时间终点,不包含
|
||||||
|
private Long endCreatedAt;
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.imyeyu.api.modules.gao.mapper.GaoStoreDiaryMapper">
|
||||||
|
<sql id="monthWhere">
|
||||||
|
`biz_type` = 'GAO_STORE_DIARY'
|
||||||
|
AND `biz_id` = #{storeId}
|
||||||
|
AND `created_at` >= #{beginCreatedAt}
|
||||||
|
AND `created_at` < #{endCreatedAt}
|
||||||
|
AND (`deleted_at` IS NULL OR FLOOR(UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000) < `deleted_at`)
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectByMonth" resultType="com.imyeyu.api.modules.common.entity.Article">
|
||||||
|
SELECT
|
||||||
|
`id`,
|
||||||
|
`biz_type`,
|
||||||
|
`biz_id`,
|
||||||
|
`title`,
|
||||||
|
`description`,
|
||||||
|
`content_type`,
|
||||||
|
`reads`,
|
||||||
|
`likes`,
|
||||||
|
`status`,
|
||||||
|
`updated_by`,
|
||||||
|
`created_at`,
|
||||||
|
`updated_at`,
|
||||||
|
`deleted_at`
|
||||||
|
FROM `article`
|
||||||
|
WHERE
|
||||||
|
<include refid="monthWhere"/>
|
||||||
|
ORDER BY `created_at` DESC, `id` DESC
|
||||||
|
LIMIT #{offset}, #{limit}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="countByMonth" resultType="long">
|
||||||
|
SELECT COUNT(1)
|
||||||
|
FROM `article`
|
||||||
|
WHERE
|
||||||
|
<include refid="monthWhere"/>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user