制度代码最终版

This commit is contained in:
wangna0328 2025-08-04 22:17:46 +08:00
parent 6ceda40d18
commit 75dd5815d2
5 changed files with 32 additions and 24 deletions

View File

@ -21,11 +21,15 @@ public interface RegulationMapper extends BaseMapper<RegulationEntity> {
* @param type 类型
* @param title 提案标题
* @param proposer 提案人
* @param confirmStatus 确认状态
* @param userId 当前用户ID
* @return 分页结果
*/
Page<RegulationEntity> selectRegulationListWithCreator(Page<RegulationEntity> 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);
}

View File

@ -19,9 +19,10 @@ public interface RegulationService extends IService<RegulationEntity> {
* @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);
/**
* 创建制度提案

View File

@ -68,28 +68,13 @@ public class RegulationServiceImpl extends ServiceImpl<RegulationMapper, Regulat
@Override
@Transactional(readOnly = true)
public Result getRegulationList(Integer page, Integer pageSize, String status, String type, String title, String proposer) {
public Result getRegulationList(Integer page, Integer pageSize, String status, String type, String title, String proposer, String confirmStatus) {
try {
Page<RegulationEntity> pageParam = new Page<>(page, pageSize);
String userId = StpUtil.getLoginIdAsString();
// 使用关联查询获取创建人姓名
Page<RegulationEntity> result = this.baseMapper.selectRegulationListWithCreator(pageParam, status, type, title, proposer);
// 如果是获取已发布的制度需要添加确认状态
if (status != null && "PUBLISHED".equals(status)) {
String userId = StpUtil.getLoginIdAsString();
java.util.List<String> 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<RegulationEntity> result = this.baseMapper.selectRegulationListWithCreator(pageParam, status, type, title, proposer, confirmStatus, userId);
return Result.ok(result);
} catch (Exception e) {

View File

@ -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'
<where>
r.del_flag = '0'
<if test="status != null and status != ''">
@ -25,6 +32,16 @@
<if test="proposer != null and proposer != ''">
AND u.name LIKE CONCAT('%', #{proposer}, '%')
</if>
<if test="confirmStatus != null and confirmStatus != ''">
<choose>
<when test="confirmStatus == 'CONFIRMED'">
AND rc.status = 'CONFIRMED'
</when>
<when test="confirmStatus == 'PENDING'">
AND rc.status IS NULL
</when>
</choose>
</if>
</where>
ORDER BY r.create_time DESC
</select>

View File

@ -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")