generated from youfool-project/youfool-prj-springboot3-template
fix: CW-4 queryList N+1改为批量查询 + LB-1 @JsonFormat使用DateUtil常量
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
bcf9d79523
commit
ba49f7ecb8
|
|
@ -73,14 +73,22 @@ public class ClueTransferServiceImpl extends ServiceImpl<ClueTransferRecordMappe
|
|||
wrapper.orderByDesc(ClueTransferRecordEntity::getTransferredAt);
|
||||
Page<ClueTransferRecordEntity> entityPage = this.page(page, wrapper);
|
||||
|
||||
// 批量查询关联线索
|
||||
List<String> clueIds = entityPage.getRecords().stream()
|
||||
.map(ClueTransferRecordEntity::getClueId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
Map<String, MonitoringClueEntity> clueMap = clueIds.isEmpty() ? Map.of()
|
||||
: monitoringClueMapper.selectBatchIds(clueIds).stream()
|
||||
.collect(Collectors.toMap(MonitoringClueEntity::getId, c -> c));
|
||||
|
||||
// 转换为VO
|
||||
Page<ClueTransferDetailVO> voPage = new Page<>(entityPage.getCurrent(),
|
||||
entityPage.getSize(), entityPage.getTotal());
|
||||
List<ClueTransferDetailVO> voList = entityPage.getRecords().stream().map(entity -> {
|
||||
ClueTransferDetailVO vo = new ClueTransferDetailVO();
|
||||
BeanUtils.copyProperties(entity, vo);
|
||||
// 补充线索编码
|
||||
MonitoringClueEntity clue = monitoringClueMapper.selectById(entity.getClueId());
|
||||
MonitoringClueEntity clue = clueMap.get(entity.getClueId());
|
||||
if (clue != null) {
|
||||
vo.setClueCode(clue.getClueCode());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.chinaweal.youfool.framework.springboot.mybatis.plus.SuperEntity;
|
||||
import com.chinaweal.youfool.framework.springboot.common.util.DateUtil;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
|
@ -49,7 +50,7 @@ public class LawClauseEntity extends SuperEntity {
|
|||
@TableField("effective_status")
|
||||
private Integer effectiveStatus;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = DateUtil.DATE_DEFAULT_FORMAT, timezone = "GMT+8")
|
||||
@TableField("publish_date")
|
||||
private LocalDate publishDate;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.chinaweal.youfool.prj.modules.law.entity.req;
|
||||
|
||||
import com.chinaweal.youfool.framework.springboot.common.util.DateUtil;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
|
@ -54,6 +55,6 @@ public class LawClauseSaveReq {
|
|||
/**
|
||||
* 发布日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = DateUtil.DATE_DEFAULT_FORMAT, timezone = "GMT+8")
|
||||
private LocalDate publishDate;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue