v1.0.5
CI / build-deploy (pull_request) Successful in 21s
CI / notify-on-failure (pull_request) Has been skipped

This commit is contained in:
Timi
2026-08-01 16:51:53 +08:00
parent 1658be7d8d
commit 833a303bb6
24 changed files with 530 additions and 42 deletions
@@ -4,6 +4,7 @@ import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.spring.bean.Page;
import com.imyeyu.spring.mapper.BaseMapper;
import com.imyeyu.spring.mapper.RawMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@@ -31,6 +32,8 @@ public interface AttachmentMapper extends BaseMapper<Attachment, String>, RawMap
List<Attachment> selectByBizId(Attachment.BizType bizType, String bizId, List<String> attachTypes, Page<Attachment> page);
List<Attachment> selectByBizIdList(@Param("bizType") Attachment.BizType bizType, @Param("bizIdList") List<String> bizIdList, @Param("attachTypes") List<String> attachTypes);
long countByBizId(Attachment.BizType bizType, String bizId, List<String> attachTypes);
/**
@@ -9,6 +9,7 @@ import com.imyeyu.spring.service.BaseService;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
/**
* 附件服务
@@ -50,6 +51,16 @@ public interface AttachmentService extends BaseService<Attachment, String> {
*/
List<Attachment> listByBizId(Attachment.BizType bizType, String bizId, String... attachTypes);
/**
* 根据多个业务 ID 批量获取附件。
*
* @param bizType 业务类型
* @param bizIdList 业务 ID 列表
* @param attachTypes 附件类型,可为 null
* @return 按业务 ID 分组的附件列表
*/
Map<String, List<Attachment>> mapByBizIdList(Attachment.BizType bizType, List<String> bizIdList, String... attachTypes);
/**
* 根据业务获取所有附件
*
@@ -43,7 +43,9 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
@@ -310,6 +312,22 @@ public class AttachmentServiceImplement extends AbstractEntityService<Attachment
return mapper.selectByBizId(bizType, bizId, List.of(attachTypes), null);
}
@Override
public Map<String, List<Attachment>> mapByBizIdList(Attachment.BizType bizType, List<String> bizIdList, String... attachTypes) {
if (bizIdList == null || bizIdList.isEmpty()) {
return Map.of();
}
List<String> normalizedBizIdList = bizIdList.stream()
.filter(TimiJava::isNotEmpty)
.distinct()
.toList();
if (normalizedBizIdList.isEmpty()) {
return Map.of();
}
return mapper.selectByBizIdList(bizType, new ArrayList<>(normalizedBizIdList), List.of(attachTypes)).stream()
.collect(Collectors.groupingBy(Attachment::getBizId));
}
@Override
public long countByBizId(Attachment.BizType bizType, String bizId, String... attachTypes) {
return mapper.countByBizId(bizType, bizId, List.of(attachTypes));