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);
|
wrapper.orderByDesc(ClueTransferRecordEntity::getTransferredAt);
|
||||||
Page<ClueTransferRecordEntity> entityPage = this.page(page, wrapper);
|
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
|
// 转换为VO
|
||||||
Page<ClueTransferDetailVO> voPage = new Page<>(entityPage.getCurrent(),
|
Page<ClueTransferDetailVO> voPage = new Page<>(entityPage.getCurrent(),
|
||||||
entityPage.getSize(), entityPage.getTotal());
|
entityPage.getSize(), entityPage.getTotal());
|
||||||
List<ClueTransferDetailVO> voList = entityPage.getRecords().stream().map(entity -> {
|
List<ClueTransferDetailVO> voList = entityPage.getRecords().stream().map(entity -> {
|
||||||
ClueTransferDetailVO vo = new ClueTransferDetailVO();
|
ClueTransferDetailVO vo = new ClueTransferDetailVO();
|
||||||
BeanUtils.copyProperties(entity, vo);
|
BeanUtils.copyProperties(entity, vo);
|
||||||
// 补充线索编码
|
MonitoringClueEntity clue = clueMap.get(entity.getClueId());
|
||||||
MonitoringClueEntity clue = monitoringClueMapper.selectById(entity.getClueId());
|
|
||||||
if (clue != null) {
|
if (clue != null) {
|
||||||
vo.setClueCode(clue.getClueCode());
|
vo.setClueCode(clue.getClueCode());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
import com.chinaweal.youfool.framework.springboot.mybatis.plus.SuperEntity;
|
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 com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
@ -49,7 +50,7 @@ public class LawClauseEntity extends SuperEntity {
|
||||||
@TableField("effective_status")
|
@TableField("effective_status")
|
||||||
private Integer effectiveStatus;
|
private Integer effectiveStatus;
|
||||||
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = DateUtil.DATE_DEFAULT_FORMAT, timezone = "GMT+8")
|
||||||
@TableField("publish_date")
|
@TableField("publish_date")
|
||||||
private LocalDate publishDate;
|
private LocalDate publishDate;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.chinaweal.youfool.prj.modules.law.entity.req;
|
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 com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
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;
|
private LocalDate publishDate;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue