fix: 普通纪念币,bug修复,分页问题。

This commit is contained in:
tianyongbao
2026-02-22 18:59:22 +08:00
parent 74176fbcec
commit 380d6d2908
3 changed files with 67 additions and 16 deletions

View File

@@ -29,6 +29,14 @@ public interface CommemorativeCoinMapper
*/ */
public List<CommemorativeCoinVo> selectCommemorativeCoinList(CommemorativeCoinDto commemorativeCoinDto); public List<CommemorativeCoinVo> selectCommemorativeCoinList(CommemorativeCoinDto commemorativeCoinDto);
/**
* 根据ID列表查询流通纪念币及其关联文件
*
* @param ids 流通纪念币ID列表
* @return 流通纪念币集合(包含关联文件)
*/
public List<CommemorativeCoinVo> selectCommemorativeCoinListWithFiles(List<Long> ids);
/** /**
* 新增流通纪念币 * 新增流通纪念币
* *

View File

@@ -2,6 +2,8 @@ package com.intc.collect.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.intc.collect.domain.CollectFile; import com.intc.collect.domain.CollectFile;
import com.intc.collect.mapper.CollectFileMapper; import com.intc.collect.mapper.CollectFileMapper;
@@ -53,7 +55,35 @@ public class CommemorativeCoinServiceImpl implements ICommemorativeCoinService
@Override @Override
public List<CommemorativeCoinVo> selectCommemorativeCoinList(CommemorativeCoinDto commemorativeCoinDto) public List<CommemorativeCoinVo> selectCommemorativeCoinList(CommemorativeCoinDto commemorativeCoinDto)
{ {
return commemorativeCoinMapper.selectCommemorativeCoinList(commemorativeCoinDto); // 第一步:先分页查询主表数据
List<CommemorativeCoinVo> list = commemorativeCoinMapper.selectCommemorativeCoinList(commemorativeCoinDto);
// 如果查询结果为空,直接返回
if (list == null || list.isEmpty())
{
return list;
}
// 第二步提取主表ID列表
List<Long> ids = list.stream().map(CommemorativeCoinVo::getId).collect(Collectors.toList());
// 第三步:批量查询关联的文件信息
List<CommemorativeCoinVo> listWithFiles = commemorativeCoinMapper.selectCommemorativeCoinListWithFiles(ids);
// 第四步:将关联文件数据填充回主表对象
Map<Long, CommemorativeCoinVo> fileMap = listWithFiles.stream()
.collect(Collectors.toMap(CommemorativeCoinVo::getId, vo -> vo));
for (CommemorativeCoinVo vo : list)
{
CommemorativeCoinVo voWithFiles = fileMap.get(vo.getId());
if (voWithFiles != null && voWithFiles.getCollectFileList() != null)
{
vo.setCollectFileList(voWithFiles.getCollectFileList());
}
}
return list;
} }
/** /**

View File

@@ -57,25 +57,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql> </sql>
<select id="selectCommemorativeCoinList" parameterType="CommemorativeCoinDto" resultMap="CommemorativeCoinCollectFileResult"> <select id="selectCommemorativeCoinList" parameterType="CommemorativeCoinDto" resultMap="CommemorativeCoinResult">
<include refid="selectCommemorativeCoinVo"/> select id, type, full_name, short_name, face_value, issue_date, mintage, composition,
issue_year, series, set_number, block_type, shape, create_by,
create_time, update_by, update_time, del_flag, remark,
weight, dimension, thickness, coin_teeth
from col_commemorative_coin
<where> <where>
a.del_flag='0' del_flag='0'
<if test="type != null and type != ''"> and a.type = #{type}</if> <if test="type != null and type != ''"> and type = #{type}</if>
<if test="fullName != null and fullName != ''"> and a.full_name like '%'|| #{fullName}||'%'</if> <if test="fullName != null and fullName != ''"> and full_name like '%'|| #{fullName}||'%'</if>
<if test="name != null and name != ''"> and (a.short_name like '%'|| #{name}||'%' or a.full_name like '%'|| #{name}||'%') </if> <if test="name != null and name != ''"> and (short_name like '%'|| #{name}||'%' or full_name like '%'|| #{name}||'%') </if>
<if test="issueDate != null "> and a.issue_date = #{issueDate}</if> <if test="issueDate != null "> and issue_date = #{issueDate}</if>
<if test="issueYear != null and issueYear != ''"> and a.issue_year like '%'|| #{issueYear}||'%'</if> <if test="issueYear != null and issueYear != ''"> and issue_year like '%'|| #{issueYear}||'%'</if>
<if test="series != null and series != ''"> and a.series = #{series}</if> <if test="series != null and series != ''"> and series = #{series}</if>
<if test="blockType != null and blockType != ''"> and a.block_type = #{blockType}</if> <if test="blockType != null and blockType != ''"> and block_type = #{blockType}</if>
<if test="shape != null and shape != ''"> and a.shape = #{shape}</if> <if test="shape != null and shape != ''"> and shape = #{shape}</if>
<if test="endTime!=null and endTime !=''"> <if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(a.issue_date, 'yyyy-MM-dd') and #{endTime}>=to_char(issue_date, 'yyyy-MM-dd')
</if> </if>
<if test="startTime!=null and startTime !=''"> <if test="startTime!=null and startTime !=''">
and to_char(a.issue_date, 'yyyy-MM-dd')>=#{startTime} and to_char(issue_date, 'yyyy-MM-dd')>=#{startTime}
</if> </if>
</where> </where>
order by issue_date desc
</select>
<select id="selectCommemorativeCoinListWithFiles" parameterType="list" resultMap="CommemorativeCoinCollectFileResult">
<include refid="selectCommemorativeCoinVo"/>
where a.id in
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
order by a.issue_date desc order by a.issue_date desc
</select> </select>