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 = "排序字段")
@TableField(exist = false)
private String sortField = "ID";
private String sortField = "uploadTime";
/**
* 排序方式
*/
@ApiModelProperty(value = "排序方式")
@TableField(exist = false)
private String sortMode = "asc";
private String sortMode = "desc";
/**
* 收藏ID
@@ -175,8 +175,8 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
String sortField = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(page.getSortField()),"_").toUpperCase();
page.setSortField(sortField);
} else {
page.setSortField("ID");
page.setSortMode("asc");
page.setSortField("UPLOAD_TIME");
page.setSortMode("desc");
}
// 查询树节点及其子节点
if (StringUtils.isNotBlank(page.getTreeNodeId())) {
@@ -17,7 +17,7 @@ import java.util.List;
@Mapper
public interface SarLawsTopicMapper extends BaseMapper<SarLawsTopic> {
List<Integer> queryByPageCount(SarLawsTopicVO page);
Integer queryByPageCount(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")
private Date modifyTime;
private String sortField = "ID";
private String sortField = "startTime";
private String sortMode = "asc";
private String sortMode = "desc";
// 排序字段
private String startTimeBegin;
@@ -214,10 +214,10 @@ public class SarLawsTopicServiceImpl extends ServiceImpl<SarLawsTopicMapper, Sar
String sortField = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(page.getSortField()),"_").toUpperCase();
page.setSortField(sortField);
} else {
page.setSortField("ID");
page.setSortMode("asc");
page.setSortField("START_TIME");
page.setSortMode("desc");
}
int rowCount = this.baseMapper.queryByPageCount(page).size();
int rowCount = this.baseMapper.queryByPageCount(page);
page.getPager().setRowCount(rowCount);
List<SarLawsTopicVO> sarLawsTopicVOList = this.baseMapper.queryByPage(page);
for (SarLawsTopicVO lawsTopicVO : sarLawsTopicVOList) {
@@ -54,6 +54,12 @@
<if test="meetingOrganizer != null and meetingOrganizer != ''" >
and MEETING_ORGANIZER like concat('%',#{meetingOrganizer},'%')
</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">
and MEETING_TIME between DATE_FORMAT(#{meetingTimeBegin}, '%Y-%m-%d') and DATE_FORMAT(#{meetingTimeEnd}, '%Y-%m-%d')
</if>
@@ -90,24 +96,24 @@
</sql>
<select id="queryByPageCount" resultType="java.lang.Integer">
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
<include refid="Base_Where_Clause"/>
<include refid="MeetingTopic_where" />
group by iom.ID
) subquery
group by iom.ID
) a
</select>
<select id="queryByPage" resultMap="BaseResultMap" parameterType="com.adc.da.slrs.InsideOntSideMeeting.entity.InsideOutsideMeetingVO">
select <include refid="Base_Column_Join_MeetingTopic_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
) 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'">
order by ${sortField} ${sortMode}
</if>
limit ${pager.startIndex-1},${pageSize}) iom left join meeting_topic mt on iom.ID = mt.MEETING_ID
where iom.VALID_FLAG = 0
<include refid="Base_Where_Clause" />
<include refid="MeetingTopic_where" />
order by
<choose>
@@ -52,6 +52,12 @@
<if test="name != null and name != ''">
and `NAME` like concat('%',#{name},'%')
</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">
and UPLOAD_TIME between DATE_FORMAT(#{uploadTimeBegin}, '%Y-%m-%d') and DATE_FORMAT(#{uploadTimeEnd}, '%Y-%m-%d')
</if>
@@ -114,6 +114,12 @@
<if test="participatingUnit != null and participatingUnit != ''" >
and PARTICIPATING_UNIT like concat('%',#{participatingUnit},'%')
</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">
and START_TIME between DATE_FORMAT(#{startTimeBegin}, '%Y-%m-%d') and DATE_FORMAT(#{startTimeEnd}, '%Y-%m-%d')
</if>
@@ -135,12 +141,6 @@
<if test="meetingAddress != null and meetingAddress != ''">
and sltm.MEETING_ADDRESS like concat('%',#{meetingAddress},'%')
</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 != ''">
and sltm.PARTICIPANTS like concat('%',#{participants},'%')
</if>
@@ -182,26 +182,28 @@
</sql>
<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
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'
where slt.VALID_FLAG = 0
<include refid="Base_Where_Clause"/>
<include refid="TopicMeeting_where" />
<include refid="ContactInformation_where" />
group by slt.ID
select count(1) from (
select count(slt.ID) from (select * from sar_laws_topic where VALID_FLAG = 0 <include refid="Base_Where_Clause"/>) 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 slci2 on slt.ID = slci2.LAWS_TOPIC_ID and slci2.GROUP_TYPE = 'inside'
where slt.VALID_FLAG = 0
<include refid="TopicMeeting_where" />
<include refid="ContactInformation_where" />
group by slt.ID
) a
</select>
<select id="queryByPage" resultMap="BaseResultMap">
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 slci2 on slt.ID = slci2.LAWS_TOPIC_ID and slci2.GROUP_TYPE = 'inside'
where slt.VALID_FLAG = 0
<include refid="Base_Where_Clause"/>
<include refid="TopicMeeting_where" />
<include refid="ContactInformation_where" />
order by slt.${sortField} ${sortMode}
limit ${pager.startIndex-1},${pageSize}
</select>
<select id="getLawsTopicByIds" resultMap="BaseResultMap">
select <include refid="Base_Join_Column_List" />