feat: 项目管理和license管理添加排序功能

This commit is contained in:
caiyuchao
2025-09-12 16:34:42 +08:00
parent bf773f6243
commit c6718e6866
6 changed files with 68 additions and 12 deletions

View File

@@ -65,4 +65,10 @@ public class LicensePageReqVO extends PageParam {
@Schema(description = "创建时间") @Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime; private LocalDateTime[] createTime;
@Schema(description = "排列字段")
private String sortField;
@Schema(description = "排列顺序")
private String sortOrder;
} }

View File

@@ -76,4 +76,10 @@ public class ProjectPageReqVO extends PageParam {
@Schema(description = "客户ID", example = "111") @Schema(description = "客户ID", example = "111")
private Long customerId; private Long customerId;
@Schema(description = "排列字段")
private String sortField;
@Schema(description = "排列顺序")
private String sortOrder;
} }

View File

@@ -576,6 +576,9 @@ public class LicenseServiceImpl implements LicenseService {
@Override @Override
public PageResult<LicenseRespVO> getLicensePage(LicensePageReqVO pageReqVO) { public PageResult<LicenseRespVO> getLicensePage(LicensePageReqVO pageReqVO) {
if (StrUtil.isNotBlank(pageReqVO.getSortField())) {
pageReqVO.setSortField(StrUtil.toUnderlineCase(pageReqVO.getSortField()));
}
IPage<LicenseRespVO> page = licenseMapper.queryPage(new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO); IPage<LicenseRespVO> page = licenseMapper.queryPage(new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO);
PageResult<LicenseRespVO> voPageResult = BeanUtils.toBean(new PageResult<>(page.getRecords(), page.getTotal()), LicenseRespVO.class); PageResult<LicenseRespVO> voPageResult = BeanUtils.toBean(new PageResult<>(page.getRecords(), page.getTotal()), LicenseRespVO.class);

View File

@@ -118,6 +118,9 @@ public class ProjectServiceImpl implements ProjectService {
@Override @Override
public PageResult<ProjectRespVO> getProjectPage(ProjectPageReqVO pageReqVO) { public PageResult<ProjectRespVO> getProjectPage(ProjectPageReqVO pageReqVO) {
if (StrUtil.isNotBlank(pageReqVO.getSortField())) {
pageReqVO.setSortField(StrUtil.toUnderlineCase(pageReqVO.getSortField()));
}
IPage<ProjectRespVO> page = projectMapper.queryPage(new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO); IPage<ProjectRespVO> page = projectMapper.queryPage(new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO);
for (ProjectRespVO record : page.getRecords()) { for (ProjectRespVO record : page.getRecords()) {

View File

@@ -95,7 +95,16 @@
<if test="query.projectName != null and query.projectName != ''"> <if test="query.projectName != null and query.projectName != ''">
AND p.name LIKE CONCAT('%',#{query.projectName},'%') AND p.name LIKE CONCAT('%',#{query.projectName},'%')
</if> </if>
ORDER BY
l.application_time DESC <choose>
<when test="query.sortField != null and query.sortField != '' and query.sortOrder != null and query.sortOrder != ''">
ORDER BY
${query.sortField} ${query.sortOrder}
</when>
<otherwise>
ORDER BY
l.application_time DESC
</otherwise>
</choose>
</select> </select>
</mapper> </mapper>

View File

@@ -20,14 +20,34 @@
<sql id="queryProjects"> <sql id="queryProjects">
SELECT SELECT
p.*, p.*
c.serial_no
FROM FROM
crm_project p (
LEFT JOIN crm_license_server c ON p.id = c.project_id SELECT
AND c.deleted = 0 p.*,
WHERE l.serial_no,
p.deleted = 0 ifnull( pc.comment_num, 0 ) comment_num,
ifnull( pl.apply_count, 0 ) apply_count
FROM
crm_project p
LEFT JOIN ( SELECT project_id, GROUP_CONCAT( serial_no ) serial_no FROM crm_license_server WHERE deleted = 0 GROUP BY project_id ) l ON p.id = l.project_id
LEFT JOIN ( SELECT c.project_id, count( c.id ) comment_num FROM crm_comment c WHERE c.deleted = 0 GROUP BY c.project_id ) pc ON p.id = pc.project_id
LEFT JOIN (
SELECT
l.project_id,
count( lh.id ) + 1 apply_count
FROM
crm_license_server l
LEFT JOIN crm_license_server_history lh ON l.id = lh.license_id
AND lh.deleted = 0
WHERE
l.deleted = 0
GROUP BY
l.project_id
) pl ON p.id = pl.project_id
WHERE
p.deleted = 0
) p
<if test="query.customerId != null"> <if test="query.customerId != null">
AND p.customer_id = #{query.customerId} AND p.customer_id = #{query.customerId}
</if> </if>
@@ -65,15 +85,24 @@
AND p.env_info LIKE CONCAT('%',#{query.envInfo},'%') AND p.env_info LIKE CONCAT('%',#{query.envInfo},'%')
</if> </if>
<if test="query.serialNo != null and query.serialNo != ''"> <if test="query.serialNo != null and query.serialNo != ''">
AND c.serial_no LIKE CONCAT('%',#{query.serialNo},'%') AND p.serial_no LIKE CONCAT('%',#{query.serialNo},'%')
</if> </if>
<if test="query.technicalOwner != null"> <if test="query.technicalOwner != null">
AND (p.technical_owner_a = #{query.technicalOwner} AND (p.technical_owner_a = #{query.technicalOwner}
OR p.technical_owner_b = #{query.technicalOwner} OR p.technical_owner_b = #{query.technicalOwner}
OR p.technical_owner_c = #{query.technicalOwner}) OR p.technical_owner_c = #{query.technicalOwner})
</if> </if>
ORDER BY <choose>
p.create_time DESC <when test="query.sortField != null and query.sortField != '' and query.sortOrder != null and query.sortOrder != ''">
ORDER BY
${query.sortField} ${query.sortOrder}
</when>
<otherwise>
ORDER BY
p.create_time DESC
</otherwise>
</choose>
</sql> </sql>
<select id="getLicenseProjects" resultType="org.agt.module.license.controller.admin.project.vo.ProjectRespVO"> <select id="getLicenseProjects" resultType="org.agt.module.license.controller.admin.project.vo.ProjectRespVO">