bug: 修改默认排序规则,分页查询

This commit is contained in:
wxyclub
2023-11-22 18:22:35 +08:00
parent ab0b8e7890
commit f3d0b6ca9c
8 changed files with 47 additions and 33 deletions
@@ -215,14 +215,14 @@ public class SarLawsInformation extends BasePage implements Serializable {
*/ */
@ApiModelProperty(value = "排序字段") @ApiModelProperty(value = "排序字段")
@TableField(exist = false) @TableField(exist = false)
private String sortField = "ID"; private String sortField = "uploadTime";
/** /**
* 排序方式 * 排序方式
*/ */
@ApiModelProperty(value = "排序方式") @ApiModelProperty(value = "排序方式")
@TableField(exist = false) @TableField(exist = false)
private String sortMode = "asc"; private String sortMode = "desc";
/** /**
* 收藏ID * 收藏ID
@@ -175,8 +175,8 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
String sortField = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(page.getSortField()),"_").toUpperCase(); String sortField = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(page.getSortField()),"_").toUpperCase();
page.setSortField(sortField); page.setSortField(sortField);
} else { } else {
page.setSortField("ID"); page.setSortField("UPLOAD_TIME");
page.setSortMode("asc"); page.setSortMode("desc");
} }
// 查询树节点及其子节点 // 查询树节点及其子节点
if (StringUtils.isNotBlank(page.getTreeNodeId())) { if (StringUtils.isNotBlank(page.getTreeNodeId())) {
@@ -17,7 +17,7 @@ import java.util.List;
@Mapper @Mapper
public interface SarLawsTopicMapper extends BaseMapper<SarLawsTopic> { public interface SarLawsTopicMapper extends BaseMapper<SarLawsTopic> {
List<Integer> queryByPageCount(SarLawsTopicVO page); Integer queryByPageCount(SarLawsTopicVO page);
List<SarLawsTopicVO> queryByPage(SarLawsTopicVO page); List<SarLawsTopicVO> queryByPage(SarLawsTopicVO page);
@@ -234,9 +234,9 @@ public class SarLawsTopicVO extends BasePage {
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date modifyTime; private Date modifyTime;
private String sortField = "ID"; private String sortField = "startTime";
private String sortMode = "asc"; private String sortMode = "desc";
// 排序字段 // 排序字段
private String startTimeBegin; private String startTimeBegin;
@@ -214,10 +214,10 @@ public class SarLawsTopicServiceImpl extends ServiceImpl<SarLawsTopicMapper, Sar
String sortField = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(page.getSortField()),"_").toUpperCase(); String sortField = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(page.getSortField()),"_").toUpperCase();
page.setSortField(sortField); page.setSortField(sortField);
} else { } else {
page.setSortField("ID"); page.setSortField("START_TIME");
page.setSortMode("asc"); page.setSortMode("desc");
} }
int rowCount = this.baseMapper.queryByPageCount(page).size(); int rowCount = this.baseMapper.queryByPageCount(page);
page.getPager().setRowCount(rowCount); page.getPager().setRowCount(rowCount);
List<SarLawsTopicVO> sarLawsTopicVOList = this.baseMapper.queryByPage(page); List<SarLawsTopicVO> sarLawsTopicVOList = this.baseMapper.queryByPage(page);
for (SarLawsTopicVO lawsTopicVO : sarLawsTopicVOList) { for (SarLawsTopicVO lawsTopicVO : sarLawsTopicVOList) {
@@ -54,6 +54,12 @@
<if test="meetingOrganizer != null and meetingOrganizer != ''" > <if test="meetingOrganizer != null and meetingOrganizer != ''" >
and MEETING_ORGANIZER like concat('%',#{meetingOrganizer},'%') and MEETING_ORGANIZER like concat('%',#{meetingOrganizer},'%')
</if> </if>
<if test="meetingTimeBegin!= null and meetingTimeEnd == null">
and MEETING_TIME &gt;= DATE_FORMAT(#{meetingTimeBegin}, '%Y-%m-%d')
</if>
<if test="meetingTimeBegin == null and meetingTimeEnd != null">
and MEETING_TIME &lt;= DATE_FORMAT(#{meetingTimeEnd}, '%Y-%m-%d')
</if>
<if test="meetingTimeBegin != null and meetingTimeEnd != null"> <if test="meetingTimeBegin != null and meetingTimeEnd != null">
and MEETING_TIME between DATE_FORMAT(#{meetingTimeBegin}, '%Y-%m-%d') and DATE_FORMAT(#{meetingTimeEnd}, '%Y-%m-%d') and MEETING_TIME between DATE_FORMAT(#{meetingTimeBegin}, '%Y-%m-%d') and DATE_FORMAT(#{meetingTimeEnd}, '%Y-%m-%d')
</if> </if>
@@ -90,24 +96,24 @@
</sql> </sql>
<select id="queryByPageCount" resultType="java.lang.Integer"> <select id="queryByPageCount" resultType="java.lang.Integer">
select count(1) from ( select count(1) from (
select count(1) from inside_outside_meeting iom join meeting_topic mt on iom.ID = mt.MEETING_ID select count(1)
from (select * from inside_outside_meeting where VALID_FLAG = 0 <include refid="Base_Where_Clause" /> ) iom
left join meeting_topic mt on iom.ID = mt.MEETING_ID
where iom.VALID_FLAG = 0 where iom.VALID_FLAG = 0
<include refid="Base_Where_Clause"/>
<include refid="MeetingTopic_where" /> <include refid="MeetingTopic_where" />
group by iom.ID group by iom.ID
) subquery ) a
</select> </select>
<select id="queryByPage" resultMap="BaseResultMap" parameterType="com.adc.da.slrs.InsideOntSideMeeting.entity.InsideOutsideMeetingVO"> <select id="queryByPage" resultMap="BaseResultMap" parameterType="com.adc.da.slrs.InsideOntSideMeeting.entity.InsideOutsideMeetingVO">
select <include refid="Base_Column_Join_MeetingTopic_List" /> select <include refid="Base_Column_Join_MeetingTopic_List" />
from (select <include refid="Base_Column_List" />,( from (select <include refid="Base_Column_List" />,(
select GROUP_CONCAT(AGENDA_NAME SEPARATOR ',') from meeting_topic where inside_outside_meeting.ID = meeting_topic.MEETING_ID select GROUP_CONCAT(AGENDA_NAME SEPARATOR ',') from meeting_topic where inside_outside_meeting.ID = meeting_topic.MEETING_ID
) as agendaNameStr from inside_outside_meeting where VALID_FLAG = 0 ) as agendaNameStr from inside_outside_meeting where VALID_FLAG = 0 <include refid="Base_Where_Clause"/>
<if test="sortField != 'AGENDA_NAME'"> <if test="sortField != 'AGENDA_NAME'">
order by ${sortField} ${sortMode} order by ${sortField} ${sortMode}
</if> </if>
limit ${pager.startIndex-1},${pageSize}) iom left join meeting_topic mt on iom.ID = mt.MEETING_ID limit ${pager.startIndex-1},${pageSize}) iom left join meeting_topic mt on iom.ID = mt.MEETING_ID
where iom.VALID_FLAG = 0 where iom.VALID_FLAG = 0
<include refid="Base_Where_Clause" />
<include refid="MeetingTopic_where" /> <include refid="MeetingTopic_where" />
order by order by
<choose> <choose>
@@ -52,6 +52,12 @@
<if test="name != null and name != ''"> <if test="name != null and name != ''">
and `NAME` like concat('%',#{name},'%') and `NAME` like concat('%',#{name},'%')
</if> </if>
<if test="uploadTimeBegin != null and uploadTimeEnd == null">
and UPLOAD_TIME &gt;= DATE_FORMAT(#{uploadTimeBegin}, '%Y-%m-%d')
</if>
<if test="uploadTimeBegin == null and uploadTimeEnd!= null">
and UPLOAD_TIME &lt;= DATE_FORMAT(#{uploadTimeEnd}, '%Y-%m-%d')
</if>
<if test="uploadTimeBegin != null and uploadTimeEnd != null"> <if test="uploadTimeBegin != null and uploadTimeEnd != null">
and UPLOAD_TIME between DATE_FORMAT(#{uploadTimeBegin}, '%Y-%m-%d') and DATE_FORMAT(#{uploadTimeEnd}, '%Y-%m-%d') and UPLOAD_TIME between DATE_FORMAT(#{uploadTimeBegin}, '%Y-%m-%d') and DATE_FORMAT(#{uploadTimeEnd}, '%Y-%m-%d')
</if> </if>
@@ -114,6 +114,12 @@
<if test="participatingUnit != null and participatingUnit != ''" > <if test="participatingUnit != null and participatingUnit != ''" >
and PARTICIPATING_UNIT like concat('%',#{participatingUnit},'%') and PARTICIPATING_UNIT like concat('%',#{participatingUnit},'%')
</if> </if>
<if test="startTimeBegin!= null and startTimeEnd == null">
and START_TIME &gt;= DATE_FORMAT(#{startTimeBegin}, '%Y-%m-%d')
</if>
<if test="startTimeBegin == null and startTimeEnd != null" >
and START_TIME &lt;= DATE_FORMAT(#{startTimeEnd}, '%Y-%m-%d')
</if>
<if test="startTimeBegin != null and startTimeEnd != null"> <if test="startTimeBegin != null and startTimeEnd != null">
and START_TIME between DATE_FORMAT(#{startTimeBegin}, '%Y-%m-%d') and DATE_FORMAT(#{startTimeEnd}, '%Y-%m-%d') and START_TIME between DATE_FORMAT(#{startTimeBegin}, '%Y-%m-%d') and DATE_FORMAT(#{startTimeEnd}, '%Y-%m-%d')
</if> </if>
@@ -135,12 +141,6 @@
<if test="meetingAddress != null and meetingAddress != ''"> <if test="meetingAddress != null and meetingAddress != ''">
and sltm.MEETING_ADDRESS like concat('%',#{meetingAddress},'%') and sltm.MEETING_ADDRESS like concat('%',#{meetingAddress},'%')
</if> </if>
<!-- <if test="participantsList != null and participantsList.size() > 0" >-->
<!-- and PARTICIPANTS in-->
<!-- <foreach collection="participantsList" separator="," open="(" close=")" item="participant">-->
<!-- #{participant}-->
<!-- </foreach>-->
<!-- </if>-->
<if test="participants != null and participants != ''"> <if test="participants != null and participants != ''">
and sltm.PARTICIPANTS like concat('%',#{participants},'%') and sltm.PARTICIPANTS like concat('%',#{participants},'%')
</if> </if>
@@ -182,26 +182,28 @@
</sql> </sql>
<select id="queryByPageCount" resultType="java.lang.Integer"> <select id="queryByPageCount" resultType="java.lang.Integer">
select count(slt.ID) from sar_laws_topic slt left join sar_laws_topic_meeting sltm on slt.ID = sltm.LAWS_TOPIC_ID select count(1) from (
left join sar_laws_contact_information slci1 on slt.ID = slci1.LAWS_TOPIC_ID and slci1.GROUP_TYPE = 'topicGroup' select count(slt.ID) from (select * from sar_laws_topic where VALID_FLAG = 0 <include refid="Base_Where_Clause"/>) slt
left join sar_laws_contact_information slci2 on slt.ID = slci2.LAWS_TOPIC_ID and slci2.GROUP_TYPE = 'inside' left join sar_laws_topic_meeting sltm on slt.ID = sltm.LAWS_TOPIC_ID
where slt.VALID_FLAG = 0 left join sar_laws_contact_information slci1 on slt.ID = slci1.LAWS_TOPIC_ID and slci1.GROUP_TYPE = 'topicGroup'
<include refid="Base_Where_Clause"/> left join sar_laws_contact_information slci2 on slt.ID = slci2.LAWS_TOPIC_ID and slci2.GROUP_TYPE = 'inside'
<include refid="TopicMeeting_where" /> where slt.VALID_FLAG = 0
<include refid="ContactInformation_where" /> <include refid="TopicMeeting_where" />
group by slt.ID <include refid="ContactInformation_where" />
group by slt.ID
) a
</select> </select>
<select id="queryByPage" resultMap="BaseResultMap"> <select id="queryByPage" resultMap="BaseResultMap">
select <include refid="Base_Join_Column_List" /> select <include refid="Base_Join_Column_List" />
from sar_laws_topic slt left join sar_laws_topic_meeting sltm on slt.ID = sltm.LAWS_TOPIC_ID from (select <include refid="Base_Column_List" /> from sar_laws_topic where VALID_FLAG = 0 <include refid="Base_Where_Clause"/>
order by ${sortField} ${sortMode} limit ${pager.startIndex-1},${pageSize}) slt
left join sar_laws_topic_meeting sltm on slt.ID = sltm.LAWS_TOPIC_ID
left join sar_laws_contact_information slci1 on slt.ID = slci1.LAWS_TOPIC_ID and slci1.GROUP_TYPE = 'topicGroup' left join sar_laws_contact_information slci1 on slt.ID = slci1.LAWS_TOPIC_ID and slci1.GROUP_TYPE = 'topicGroup'
left join sar_laws_contact_information slci2 on slt.ID = slci2.LAWS_TOPIC_ID and slci2.GROUP_TYPE = 'inside' left join sar_laws_contact_information slci2 on slt.ID = slci2.LAWS_TOPIC_ID and slci2.GROUP_TYPE = 'inside'
where slt.VALID_FLAG = 0 where slt.VALID_FLAG = 0
<include refid="Base_Where_Clause"/>
<include refid="TopicMeeting_where" /> <include refid="TopicMeeting_where" />
<include refid="ContactInformation_where" /> <include refid="ContactInformation_where" />
order by slt.${sortField} ${sortMode} order by slt.${sortField} ${sortMode}
limit ${pager.startIndex-1},${pageSize}
</select> </select>
<select id="getLawsTopicByIds" resultMap="BaseResultMap"> <select id="getLawsTopicByIds" resultMap="BaseResultMap">
select <include refid="Base_Join_Column_List" /> select <include refid="Base_Join_Column_List" />