diff --git a/core/src/main/java/com/dite/znpt/domain/entity/RegulationEntity.java b/core/src/main/java/com/dite/znpt/domain/entity/RegulationEntity.java index 00f93ac..25f144f 100644 --- a/core/src/main/java/com/dite/znpt/domain/entity/RegulationEntity.java +++ b/core/src/main/java/com/dite/znpt/domain/entity/RegulationEntity.java @@ -45,7 +45,7 @@ public class RegulationEntity extends AuditableEntity implements Serializable { private String regulationType; @ExcelProperty("制度状态") - @ApiModelProperty("制度状态:DRAFT-草案,PUBLISHED-已发布,ARCHIVED-已归档") + @ApiModelProperty("制度状态:DRAFT-草案,APPROVED-已公示,PUBLISHED-已发布,ARCHIVED-已归档") @TableField("status") private String status; @@ -92,4 +92,8 @@ public class RegulationEntity extends AuditableEntity implements Serializable { @TableField(exist = false) @ApiModelProperty("当前用户确认状态:pending-待确认,confirmed-已确认") private String confirmStatus; + + @TableField(exist = false) + @ApiModelProperty("创建人姓名") + private String createByName; } \ No newline at end of file diff --git a/core/src/main/java/com/dite/znpt/mapper/RegulationDraftMapper.java b/core/src/main/java/com/dite/znpt/mapper/RegulationDraftMapper.java deleted file mode 100644 index 075e3ae..0000000 --- a/core/src/main/java/com/dite/znpt/mapper/RegulationDraftMapper.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.dite.znpt.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.dite.znpt.domain.entity.RegulationDraftEntity; -import org.apache.ibatis.annotations.Mapper; - -/** - * 制度草案Mapper接口 - */ -@Mapper -public interface RegulationDraftMapper extends BaseMapper { -} \ No newline at end of file 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 8005192..8b5d072 100644 --- a/core/src/main/java/com/dite/znpt/mapper/RegulationMapper.java +++ b/core/src/main/java/com/dite/znpt/mapper/RegulationMapper.java @@ -1,8 +1,10 @@ package com.dite.znpt.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.dite.znpt.domain.entity.RegulationEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * @author wangna @@ -11,4 +13,15 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface RegulationMapper extends BaseMapper { + + /** + * 分页查询制度列表(包含创建人姓名) + * @param page 分页参数 + * @param status 状态 + * @param type 类型 + * @return 分页结果 + */ + Page selectRegulationListWithCreator(Page page, + @Param("status") String status, + @Param("type") String type); } \ No newline at end of file diff --git a/core/src/main/java/com/dite/znpt/mapper/RegulationTypeMapper.java b/core/src/main/java/com/dite/znpt/mapper/RegulationTypeMapper.java new file mode 100644 index 0000000..1065361 --- /dev/null +++ b/core/src/main/java/com/dite/znpt/mapper/RegulationTypeMapper.java @@ -0,0 +1,24 @@ +package com.dite.znpt.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.dite.znpt.domain.entity.RegulationTypeEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 制度类型Mapper接口 + * @author wangna + * @date 2025/07/29 + */ +@Mapper +public interface RegulationTypeMapper extends BaseMapper { + + /** + * 分页查询制度类型列表(包含创建人姓名) + * @param page 分页参数 + * @param typeName 类型名称 + * @return 分页结果 + */ + Page selectRegulationTypeListWithCreator(Page page, @Param("typeName") String typeName); +} \ 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 27a9f90..27cfe85 100644 --- a/core/src/main/java/com/dite/znpt/service/RegulationService.java +++ b/core/src/main/java/com/dite/znpt/service/RegulationService.java @@ -3,7 +3,6 @@ package com.dite.znpt.service; import com.baomidou.mybatisplus.extension.service.IService; import com.dite.znpt.domain.entity.RegulationEntity; import com.dite.znpt.domain.Result; -import com.dite.znpt.domain.dto.RegulationConfirmDTO; /** * @author wangna @@ -29,6 +28,20 @@ public interface RegulationService extends IService { */ Result createRegulationProposal(RegulationEntity regulation); + /** + * 更新制度提案 + * @param regulation 制度信息 + * @return 结果 + */ + Result updateRegulationProposal(RegulationEntity regulation); + + /** + * 删除制度提案 + * @param regulationId 制度ID + * @return 结果 + */ + Result deleteRegulationProposal(String regulationId); + /** * 获取制度详情 * @param regulationId 制度ID @@ -42,4 +55,11 @@ public interface RegulationService extends IService { * @return 结果 */ Result confirmRegulation(String regulationId); + + /** + * 公示制度 + * @param regulationId 制度ID + * @return 结果 + */ + Result approveRegulation(String regulationId); } \ No newline at end of file diff --git a/core/src/main/java/com/dite/znpt/service/RegulationTypeService.java b/core/src/main/java/com/dite/znpt/service/RegulationTypeService.java new file mode 100644 index 0000000..cba5e41 --- /dev/null +++ b/core/src/main/java/com/dite/znpt/service/RegulationTypeService.java @@ -0,0 +1,43 @@ +package com.dite.znpt.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.dite.znpt.domain.entity.RegulationTypeEntity; +import com.dite.znpt.domain.Result; + +/** + * 制度类型Service接口 + * @author wangna + * @date 2025/07/29 + */ +public interface RegulationTypeService extends IService { + + /** + * 获取制度类型列表 + * @param page 页码 + * @param size 页大小 + * @param typeName 类型名称 + * @return 结果 + */ + Result getRegulationTypes(Integer page, Integer size, String typeName); + + /** + * 创建制度类型 + * @param regulationType 制度类型信息 + * @return 结果 + */ + Result createRegulationType(RegulationTypeEntity regulationType); + + /** + * 更新制度类型 + * @param regulationType 制度类型信息 + * @return 结果 + */ + Result updateRegulationType(RegulationTypeEntity regulationType); + + /** + * 删除制度类型 + * @param typeId 类型ID + * @return 结果 + */ + Result deleteRegulationType(String typeId); +} \ No newline at end of file diff --git a/core/src/main/java/com/dite/znpt/service/RoleMenuService.java b/core/src/main/java/com/dite/znpt/service/RoleMenuService.java index f7f150b..aa837f5 100644 --- a/core/src/main/java/com/dite/znpt/service/RoleMenuService.java +++ b/core/src/main/java/com/dite/znpt/service/RoleMenuService.java @@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.dite.znpt.domain.entity.RoleMenuEntity; import com.dite.znpt.domain.vo.RoleMenuReq; -import java.util.List; /** * @author Bear.G @@ -12,6 +11,5 @@ import java.util.List; * @description */ public interface RoleMenuService extends IService { - void bindRoleMenu(RoleMenuReq req); } 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 82d1442..bdc09c6 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 @@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.dite.znpt.domain.Result; import com.dite.znpt.domain.entity.RegulationEntity; import com.dite.znpt.domain.entity.RegulationConfirmationEntity; -import com.dite.znpt.domain.dto.RegulationConfirmDTO; import com.dite.znpt.domain.vo.UserResp; import com.dite.znpt.mapper.RegulationMapper; import com.dite.znpt.service.RegulationService; @@ -36,52 +35,45 @@ public class RegulationServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(RegulationEntity::getStatus, "DRAFT"); - wrapper.le(RegulationEntity::getCreateTime, tenDaysAgo); + wrapper.eq(RegulationEntity::getStatus, "APPROVED"); + wrapper.le(RegulationEntity::getUpdateTime, tenDaysAgo); wrapper.eq(RegulationEntity::getDelFlag, "0"); - java.util.List drafts = this.list(wrapper); + java.util.List approvedRegulations = this.list(wrapper); - for (RegulationEntity draft : drafts) { + for (RegulationEntity regulation : approvedRegulations) { // 更新制度状态和发布信息 - draft.setStatus("PUBLISHED"); - draft.setPublishTime(LocalDateTime.now()); - draft.setEffectiveTime(LocalDateTime.now()); // 设置生效时间为当前时间 - draft.setUpdateTime(LocalDateTime.now()); - draft.setUpdateBy("系统自动发布"); + regulation.setStatus("PUBLISHED"); + regulation.setPublishTime(LocalDateTime.now()); + regulation.setEffectiveTime(LocalDateTime.now()); // 设置生效时间为当前时间 + regulation.setUpdateTime(LocalDateTime.now()); + regulation.setUpdateBy("系统自动发布"); - this.updateById(draft); + this.updateById(regulation); } - if (!drafts.isEmpty()) { - System.out.println("自动发布完成,共发布 " + drafts.size() + " 个制度"); + if (!approvedRegulations.isEmpty()) { + System.out.println("自动发布完成,共发布 " + approvedRegulations.size() + " 个制度"); } } @Override + @Transactional(readOnly = true) public Result getRegulationList(Integer page, Integer pageSize, String status, String type) { try { Page pageParam = new Page<>(page, pageSize); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - if (status != null && !status.isEmpty()) { - wrapper.eq(RegulationEntity::getStatus, status); - } - if (type != null && !type.isEmpty()) { - wrapper.eq(RegulationEntity::getRegulationType, type); - } - wrapper.eq(RegulationEntity::getDelFlag, "0"); - wrapper.orderByDesc(RegulationEntity::getCreateTime); - - Page result = this.page(pageParam, wrapper); + // 使用关联查询获取创建人姓名 + Page result = this.baseMapper.selectRegulationListWithCreator(pageParam, status, type); // 如果是获取已发布的制度,需要添加确认状态 if (status != null && "PUBLISHED".equals(status)) { @@ -113,11 +105,10 @@ public class RegulationServiceImpl extends ServiceImpl implements RegulationTypeService { + + @Autowired + private RegulationMapper regulationMapper; + + @Override + @Transactional(readOnly = true) + public Result getRegulationTypes(Integer page, Integer size, String typeName) { + try { + Page pageParam = new Page<>(page, size); + + // 使用连表查询获取创建人姓名 + Page result = this.baseMapper.selectRegulationTypeListWithCreator(pageParam, typeName); + + return Result.ok(result); + } catch (Exception e) { + return Result.error("获取制度类型列表失败:" + e.getMessage()); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result createRegulationType(RegulationTypeEntity regulationType) { + try { + regulationType.setTypeId(java.util.UUID.randomUUID().toString()); + regulationType.setCreateTime(LocalDateTime.now()); + String userId = StpUtil.getLoginIdAsString(); + regulationType.setCreateBy(userId); + regulationType.setUpdateTime(LocalDateTime.now()); + regulationType.setUpdateBy(userId); + regulationType.setDelFlag("0"); + + // 如果没有设置排序顺序,设置为当前最大值+1 + if (regulationType.getSortOrder() == null) { + Integer maxSortOrder = this.lambdaQuery() + .eq(RegulationTypeEntity::getDelFlag, "0") + .orderByDesc(RegulationTypeEntity::getSortOrder) + .last("LIMIT 1") + .oneOpt() + .map(RegulationTypeEntity::getSortOrder) + .orElse(0); + regulationType.setSortOrder(maxSortOrder + 1); + } + + this.save(regulationType); + return Result.okM("制度类型创建成功"); + } catch (Exception e) { + return Result.error("制度类型创建失败:" + e.getMessage()); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result updateRegulationType(RegulationTypeEntity regulationType) { + try { + RegulationTypeEntity existing = this.getById(regulationType.getTypeId()); + if (existing == null) { + return Result.error("制度类型不存在"); + } + + regulationType.setUpdateTime(LocalDateTime.now()); + regulationType.setUpdateBy(cn.dev33.satoken.stp.StpUtil.getLoginIdAsString()); + + this.updateById(regulationType); + return Result.okM("制度类型更新成功"); + } catch (Exception e) { + return Result.error("制度类型更新失败:" + e.getMessage()); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result deleteRegulationType(String typeId) { + try { + RegulationTypeEntity regulationType = this.getById(typeId); + if (regulationType == null) { + return Result.error("制度类型不存在"); + } + + // 检查是否有制度使用此类型 + String typeName = regulationType.getTypeName(); + + // 检查制度表中是否有使用此类型的记录(包括所有状态) + long regulationCount = regulationMapper.selectCount( + new LambdaQueryWrapper() + .eq(RegulationEntity::getRegulationType, typeName) + .eq(RegulationEntity::getDelFlag, "0") + ); + // 如果有制度使用此类型,则不允许删除 + if (regulationCount > 0) { + return Result.error("该制度类型正在被使用,无法删除。请先删除或修改使用该类型的制度。"); + } + + regulationType.setDelFlag("1"); + this.updateById(regulationType); + return Result.okM("制度类型删除成功"); + } catch (Exception e) { + return Result.error("制度类型删除失败:" + e.getMessage()); + } + } +} \ No newline at end of file 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 262b8b4..e51639f 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 @@ -2,7 +2,6 @@ package com.dite.znpt.web.controller; import com.dite.znpt.domain.Result; import com.dite.znpt.domain.entity.RegulationEntity; -import com.dite.znpt.domain.dto.RegulationConfirmDTO; import com.dite.znpt.service.RegulationService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -37,6 +36,19 @@ public class RegulationController { return regulationService.createRegulationProposal(regulation); } + @ApiOperation(value = "更新制度提案", httpMethod = "PUT") + @PutMapping("/proposal/{regulationId}") + public Result updateRegulationProposal(@PathVariable String regulationId, @RequestBody RegulationEntity regulation) { + regulation.setRegulationId(regulationId); + return regulationService.updateRegulationProposal(regulation); + } + + @ApiOperation(value = "删除制度提案", httpMethod = "DELETE") + @DeleteMapping("/proposal/{regulationId}") + public Result deleteRegulationProposal(@PathVariable String regulationId) { + return regulationService.deleteRegulationProposal(regulationId); + } + @ApiOperation(value = "获取制度详情", httpMethod = "GET") @GetMapping("/{regulationId}") public Result getRegulationDetail(@PathVariable String regulationId) { @@ -49,4 +61,15 @@ public class RegulationController { return regulationService.confirmRegulation(regulationId); } + /** + * 点击确认公示后原本的制度草案就会进入十天公示期 + * @param regulationId + * @return + */ + @ApiOperation(value = "公示制度", httpMethod = "POST") + @PostMapping("/{regulationId}/approve") + public Result approveRegulation(@PathVariable String regulationId) { + return regulationService.approveRegulation(regulationId); + } + } \ No newline at end of file diff --git a/web/src/main/java/com/dite/znpt/web/controller/RegulationTypeController.java b/web/src/main/java/com/dite/znpt/web/controller/RegulationTypeController.java new file mode 100644 index 0000000..6d1c230 --- /dev/null +++ b/web/src/main/java/com/dite/znpt/web/controller/RegulationTypeController.java @@ -0,0 +1,50 @@ +package com.dite.znpt.web.controller; + +import com.dite.znpt.domain.Result; +import com.dite.znpt.domain.entity.RegulationTypeEntity; +import com.dite.znpt.service.RegulationTypeService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 制度类型Controller + * @author wangna + * @date 2025/07/29 + */ +@Api(tags = "制度类型管理") +@RestController +@RequestMapping("/regulation/types") +public class RegulationTypeController { + + @Autowired + private RegulationTypeService regulationTypeService; + + @ApiOperation(value = "获取制度类型列表", httpMethod = "GET") + @GetMapping + public Result getRegulationTypes(@RequestParam(defaultValue = "1") int page, + @RequestParam(defaultValue = "10") int size, + @RequestParam(required = false) String typeName) { + return regulationTypeService.getRegulationTypes(page, size, typeName); + } + + @ApiOperation(value = "创建制度类型", httpMethod = "POST") + @PostMapping + public Result createRegulationType(@RequestBody RegulationTypeEntity regulationType) { + return regulationTypeService.createRegulationType(regulationType); + } + + @ApiOperation(value = "更新制度类型", httpMethod = "PUT") + @PutMapping("/{typeId}") + public Result updateRegulationType(@PathVariable String typeId, @RequestBody RegulationTypeEntity regulationType) { + regulationType.setTypeId(typeId); + return regulationTypeService.updateRegulationType(regulationType); + } + + @ApiOperation(value = "删除制度类型", httpMethod = "DELETE") + @DeleteMapping("/{typeId}") + public Result deleteRegulationType(@PathVariable String typeId) { + return regulationTypeService.deleteRegulationType(typeId); + } +} \ No newline at end of file