diff --git a/pom.xml b/pom.xml
index 9bb7524..bc7d597 100644
--- a/pom.xml
+++ b/pom.xml
@@ -198,7 +198,7 @@
com.imyeyu.java
timi-java
- 0.0.7
+ 0.0.9
com.imyeyu.utils
diff --git a/src/main/java/com/imyeyu/api/modules/common/mapper/AttachmentMapper.java b/src/main/java/com/imyeyu/api/modules/common/mapper/AttachmentMapper.java
index 0579732..2513b5d 100644
--- a/src/main/java/com/imyeyu/api/modules/common/mapper/AttachmentMapper.java
+++ b/src/main/java/com/imyeyu/api/modules/common/mapper/AttachmentMapper.java
@@ -34,6 +34,8 @@ public interface AttachmentMapper extends BaseMapper, RawMap
List selectAllByBizIdList(Attachment.BizType bizType, Collection bizIdList, List attachTypes);
+ List selectImageByBizIdList(Attachment.BizType bizType, Collection bizIdList, String attachType);
+
long countByBizId(Attachment.BizType bizType, String bizId, List attachTypes);
@Select("SELECT * FROM attachment WHERE `is_destroyed` = FALSE AND `destroy_at` < " + UNIX_TIME)
diff --git a/src/main/java/com/imyeyu/api/modules/common/service/AttachmentService.java b/src/main/java/com/imyeyu/api/modules/common/service/AttachmentService.java
index 597eda4..ac5b48c 100644
--- a/src/main/java/com/imyeyu/api/modules/common/service/AttachmentService.java
+++ b/src/main/java/com/imyeyu/api/modules/common/service/AttachmentService.java
@@ -45,6 +45,12 @@ public interface AttachmentService extends BaseService {
*/
List listByBizId(Attachment.BizType bizType, String bizId, String... attachTypes);
+ default Map mapFirstImageByIdList(Attachment.BizType bizType, Collection bizIdList) {
+ return mapFirstImageByIdList(bizType, bizIdList, null);
+ }
+
+ Map mapFirstImageByIdList(Attachment.BizType bizType, Collection bizIdList, String attachType);
+
/**
* 根据多个业务 ID 批量获取附件
*
diff --git a/src/main/java/com/imyeyu/api/modules/common/service/implement/AttachmentServiceImplement.java b/src/main/java/com/imyeyu/api/modules/common/service/implement/AttachmentServiceImplement.java
index 87e1317..a515e6f 100644
--- a/src/main/java/com/imyeyu/api/modules/common/service/implement/AttachmentServiceImplement.java
+++ b/src/main/java/com/imyeyu/api/modules/common/service/implement/AttachmentServiceImplement.java
@@ -34,10 +34,12 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
+import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -244,9 +246,14 @@ public class AttachmentServiceImplement extends AbstractEntityService mapFirstImageByIdList(Attachment.BizType bizType, Collection bizIdList, String attachType) {
+ return mapper.selectImageByBizIdList(bizType, new HashSet<>(bizIdList), attachType).stream().collect(Collectors.toMap(Attachment::getBizId, Function.identity()));
+ }
+
@Override
public Map> mapByBizIdList(Attachment.BizType bizType, Collection bizIdList, String... attachTypes) {
- return mapper.selectAllByBizIdList(bizType, bizIdList, List.of(attachTypes)).stream().collect(Collectors.groupingBy(Attachment::getBizId));
+ return mapper.selectAllByBizIdList(bizType, new HashSet<>(bizIdList), List.of(attachTypes)).stream().collect(Collectors.groupingBy(Attachment::getBizId));
}
@Override
diff --git a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoStoreDiaryController.java b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoStoreDiaryController.java
index aa30554..9d66a39 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoStoreDiaryController.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoStoreDiaryController.java
@@ -8,6 +8,7 @@ import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.service.GaoStoreDiaryService;
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
+import com.imyeyu.api.modules.gao.vo.GaoStoreDiaryPage;
import com.imyeyu.api.modules.user.entity.User;
import com.imyeyu.api.modules.user.service.UserLoginService;
import com.imyeyu.api.modules.user.service.UserService;
@@ -16,7 +17,6 @@ import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.PageResult;
-import com.imyeyu.api.modules.gao.vo.GaoStoreDiaryPage;
import com.imyeyu.spring.util.ResponseView;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
@@ -25,6 +25,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
+import java.util.List;
+import java.util.Map;
+
/// GAO 门店日记接口
///
/// @author Codex
@@ -55,7 +58,16 @@ public class GaoStoreDiaryController {
TimiException.required(page.getEndCreatedAt(), "未找到门店日记结束时间");
TimiException.requiredTrue(page.getBeginCreatedAt() < page.getEndCreatedAt(), "门店日记时间范围无效");
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
- return service.page(page);
+ PageResult result = service.page(page);
+ {
+ List articleIdList = result.getList().stream().map(Article::getId).toList();
+ Map attachMap = attachmentService.mapFirstImageByIdList(Attachment.BizType.ARTICLE, articleIdList);
+ for (Article article : result.getList()) {
+ Attachment attachment = attachMap.get(article.getId());
+ article.setAttachmentList(TimiJava.ofList(attachment));
+ }
+ }
+ return result;
}
/// 查询门店日记详情
diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/GaoStoreDiaryService.java b/src/main/java/com/imyeyu/api/modules/gao/service/GaoStoreDiaryService.java
index b01a3b7..1d44ab9 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/service/GaoStoreDiaryService.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/service/GaoStoreDiaryService.java
@@ -1,8 +1,8 @@
package com.imyeyu.api.modules.gao.service;
import com.imyeyu.api.modules.common.entity.Article;
-import com.imyeyu.spring.bean.PageResult;
import com.imyeyu.api.modules.gao.vo.GaoStoreDiaryPage;
+import com.imyeyu.spring.bean.PageResult;
/// GAO 门店日记服务
///
diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoStoreDiaryServiceImplement.java b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoStoreDiaryServiceImplement.java
index 9ce6188..81c93c0 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoStoreDiaryServiceImplement.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoStoreDiaryServiceImplement.java
@@ -6,12 +6,11 @@ import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.mapper.ArticleMapper;
import com.imyeyu.api.modules.common.service.ArticleService;
import com.imyeyu.api.modules.common.service.AttachmentService;
-import com.imyeyu.api.modules.gao.service.GaoStoreDiaryService;
import com.imyeyu.api.modules.gao.mapper.GaoStoreDiaryMapper;
+import com.imyeyu.api.modules.gao.service.GaoStoreDiaryService;
import com.imyeyu.api.modules.gao.vo.GaoStoreDiaryPage;
import com.imyeyu.java.TimiJava;
import com.imyeyu.java.bean.timi.TimiException;
-import com.imyeyu.spring.bean.Page;
import com.imyeyu.spring.bean.PageResult;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
diff --git a/src/main/resources/mapper/timi-server/common/AttachmentMapper.xml b/src/main/resources/mapper/timi-server/common/AttachmentMapper.xml
index 0eed0ad..6add6f2 100644
--- a/src/main/resources/mapper/timi-server/common/AttachmentMapper.xml
+++ b/src/main/resources/mapper/timi-server/common/AttachmentMapper.xml
@@ -1,6 +1,54 @@
+