diff --git a/src/main/java/com/biutag/supervision/pojo/param/PoliceQueryParam.java b/src/main/java/com/biutag/supervision/pojo/param/PoliceQueryParam.java index f2126ae..489ede4 100644 --- a/src/main/java/com/biutag/supervision/pojo/param/PoliceQueryParam.java +++ b/src/main/java/com/biutag/supervision/pojo/param/PoliceQueryParam.java @@ -15,4 +15,8 @@ public class PoliceQueryParam extends BasePage { // 当前单位及其所有子单位 private Boolean departBranch; private String roleId; + // 排序字段 + private String sortField; + // 排序顺序(ASC 或 DESC) + private String sortOrder; } diff --git a/src/main/java/com/biutag/supervision/service/SupPoliceService.java b/src/main/java/com/biutag/supervision/service/SupPoliceService.java index 5b23c4b..53f60ac 100644 --- a/src/main/java/com/biutag/supervision/service/SupPoliceService.java +++ b/src/main/java/com/biutag/supervision/service/SupPoliceService.java @@ -50,6 +50,23 @@ public class SupPoliceService extends ServiceImpl { } } queryWrapper.apply(StrUtil.isNotBlank(param.getRoleId()), String.format("find_in_set( '%s', u.role_id) > 0", param.getRoleId())); + if (param.getSortField() != null && param.getSortOrder() != null) { + if (param.getSortField().equals("depart")) { + if (param.getSortOrder().equals("ASC")) { + queryWrapper.orderByAsc("d.short_name"); + } else if (param.getSortOrder().equals("DESC")) { + queryWrapper.orderByDesc("d.short_name"); + } + } else if (param.getSortField().equals("property")) { + if (param.getSortOrder().equals("ASC")) { + queryWrapper.orderByAsc("p.person_type"); + } else if (param.getSortOrder().equals("DESC")) { + queryWrapper.orderByDesc("p.person_type"); + } + } + } + queryWrapper.orderByDesc("field(p.job,'辅警','民警','四级机构副职','四级机构正职','三级机构副职','三级机构正职二','三级机构正职一','二级机构副职','二级机构正职二','二级机构正职一','市局领导副职','市局领导正职')"); + queryWrapper.orderByDesc("field(p.position,'副职','正职')"); queryWrapper.orderByAsc("d.level").orderByDesc("p.position").orderByDesc("p.sort_id").orderByAsc("p.person_status"); return baseMapper.queryPage(Page.of(param.getCurrent(), param.getSize()), queryWrapper); }