diff --git a/core/src/main/java/com/dite/znpt/mapper/RegulationMapper.java b/core/src/main/java/com/dite/znpt/mapper/RegulationMapper.java index dc23993..d8c7506 100644 --- a/core/src/main/java/com/dite/znpt/mapper/RegulationMapper.java +++ b/core/src/main/java/com/dite/znpt/mapper/RegulationMapper.java @@ -21,11 +21,15 @@ public interface RegulationMapper extends BaseMapper { * @param type 类型 * @param title 提案标题 * @param proposer 提案人 + * @param confirmStatus 确认状态 + * @param userId 当前用户ID * @return 分页结果 */ Page selectRegulationListWithCreator(Page page, @Param("status") String status, @Param("type") String type, @Param("title") String title, - @Param("proposer") String proposer); + @Param("proposer") String proposer, + @Param("confirmStatus") String confirmStatus, + @Param("userId") String userId); } \ No newline at end of file diff --git a/core/src/main/java/com/dite/znpt/service/RegulationService.java b/core/src/main/java/com/dite/znpt/service/RegulationService.java index b24957f..25652f9 100644 --- a/core/src/main/java/com/dite/znpt/service/RegulationService.java +++ b/core/src/main/java/com/dite/znpt/service/RegulationService.java @@ -19,9 +19,10 @@ public interface RegulationService extends IService { * @param type 类型 * @param title 提案标题 * @param proposer 提案人 + * @param confirmStatus 确认状态 * @return 结果 */ - Result getRegulationList(Integer page, Integer pageSize, String status, String type, String title, String proposer); + Result getRegulationList(Integer page, Integer pageSize, String status, String type, String title, String proposer, String confirmStatus); /** * 创建制度提案 diff --git a/core/src/main/java/com/dite/znpt/service/impl/RegulationServiceImpl.java b/core/src/main/java/com/dite/znpt/service/impl/RegulationServiceImpl.java index f0cb608..1781248 100644 --- a/core/src/main/java/com/dite/znpt/service/impl/RegulationServiceImpl.java +++ b/core/src/main/java/com/dite/znpt/service/impl/RegulationServiceImpl.java @@ -68,28 +68,13 @@ public class RegulationServiceImpl extends ServiceImpl pageParam = new Page<>(page, pageSize); + String userId = StpUtil.getLoginIdAsString(); - // 使用关联查询获取创建人姓名 - Page result = this.baseMapper.selectRegulationListWithCreator(pageParam, status, type, title, proposer); - - // 如果是获取已发布的制度,需要添加确认状态 - if (status != null && "PUBLISHED".equals(status)) { - String userId = StpUtil.getLoginIdAsString(); - java.util.List confirmedIds = regulationConfirmationService.lambdaQuery() - .eq(RegulationConfirmationEntity::getConfirmerId, userId) - .eq(RegulationConfirmationEntity::getStatus, "CONFIRMED") - .eq(RegulationConfirmationEntity::getDelFlag, "0") - .list() - .stream() - .map(RegulationConfirmationEntity::getRegulationId) - .toList(); - for (RegulationEntity reg : result.getRecords()) { - reg.setConfirmStatus(confirmedIds.contains(reg.getRegulationId()) ? "confirmed" : "pending"); - } - } + // 使用关联查询获取创建人姓名和确认状态 + Page result = this.baseMapper.selectRegulationListWithCreator(pageParam, status, type, title, proposer, confirmStatus, userId); return Result.ok(result); } catch (Exception e) { diff --git a/core/src/main/resources/mapper/RegulationMapper.xml b/core/src/main/resources/mapper/RegulationMapper.xml index d3b6177..c70a410 100644 --- a/core/src/main/resources/mapper/RegulationMapper.xml +++ b/core/src/main/resources/mapper/RegulationMapper.xml @@ -7,10 +7,17 @@ SELECT r.*, u.name as createByName, - rt.type_name as regulationType + rt.type_name as regulationType, + CASE + WHEN rc.status IS NOT NULL THEN rc.status + ELSE 'PENDING' + END as confirmStatus FROM regulation r LEFT JOIN user u ON r.create_by COLLATE utf8mb4_general_ci = u.user_id COLLATE utf8mb4_general_ci LEFT JOIN regulation_type rt ON r.regulation_type = rt.type_name + LEFT JOIN regulation_confirmation rc ON r.regulation_id = rc.regulation_id + AND rc.confirmer_id = #{userId} + AND rc.del_flag = '0' r.del_flag = '0' @@ -25,6 +32,16 @@ AND u.name LIKE CONCAT('%', #{proposer}, '%') + + + + AND rc.status = 'CONFIRMED' + + + AND rc.status IS NULL + + + ORDER BY r.create_time DESC diff --git a/web/src/main/java/com/dite/znpt/web/controller/RegulationController.java b/web/src/main/java/com/dite/znpt/web/controller/RegulationController.java index c27dc10..19e770b 100644 --- a/web/src/main/java/com/dite/znpt/web/controller/RegulationController.java +++ b/web/src/main/java/com/dite/znpt/web/controller/RegulationController.java @@ -28,8 +28,9 @@ public class RegulationController { @RequestParam(required = false) String status, @RequestParam(required = false) String type, @RequestParam(required = false) String title, - @RequestParam(required = false) String proposer) { - return regulationService.getRegulationList(page, size, status, type, title, proposer); + @RequestParam(required = false) String proposer, + @RequestParam(required = false) String confirmStatus) { + return regulationService.getRegulationList(page, size, status, type, title, proposer, confirmStatus); } @ApiOperation(value = "创建制度提案", httpMethod = "POST")