Compare commits
2 Commits
a50dbd89ce
...
75dd5815d2
Author | SHA1 | Date |
---|---|---|
|
75dd5815d2 | |
|
6ceda40d18 |
|
@ -42,7 +42,7 @@ public class RegulationEntity extends AuditableEntity implements Serializable {
|
|||
@ExcelProperty("制度类型")
|
||||
@ApiModelProperty("制度类型")
|
||||
@TableField("regulation_type")
|
||||
private String regulationType;
|
||||
private String type;
|
||||
|
||||
@ExcelProperty("制度状态")
|
||||
@ApiModelProperty("制度状态:DRAFT-草案,APPROVED-已公示,PUBLISHED-已发布,ARCHIVED-已归档")
|
||||
|
@ -96,4 +96,8 @@ public class RegulationEntity extends AuditableEntity implements Serializable {
|
|||
@TableField(exist = false)
|
||||
@ApiModelProperty("创建人姓名")
|
||||
private String createByName;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty("制度类型")
|
||||
private String regulationType;
|
||||
}
|
|
@ -33,10 +33,10 @@ public class RegulationTypeEntity extends AuditableEntity implements Serializabl
|
|||
@TableField("type_name")
|
||||
private String typeName;
|
||||
|
||||
@ExcelProperty("状态")
|
||||
@ApiModelProperty("状态:ENABLED-启用,DISABLED-禁用")
|
||||
@TableField("status")
|
||||
private String status;
|
||||
@ExcelProperty("是否启用")
|
||||
@ApiModelProperty("是否启用(1-启用,0-禁用)")
|
||||
@TableField("is_enabled")
|
||||
private String isEnabled;
|
||||
|
||||
@ExcelProperty("排序顺序")
|
||||
@ApiModelProperty("排序顺序")
|
||||
|
@ -55,5 +55,5 @@ public class RegulationTypeEntity extends AuditableEntity implements Serializabl
|
|||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty("创建人姓名")
|
||||
private String createByName;
|
||||
private String createrName;
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
|
||||
/**
|
||||
* 创建制度提案
|
||||
|
|
|
@ -16,7 +16,7 @@ public interface RegulationTypeService extends IService<RegulationTypeEntity> {
|
|||
* @param page 页码
|
||||
* @param size 页大小
|
||||
* @param typeName 类型名称
|
||||
* @param status 状态
|
||||
* @param status 是否启用(1-启用,0-禁用)
|
||||
* @param remark 备注
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
|
@ -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) {
|
||||
|
@ -203,6 +188,11 @@ public class RegulationServiceImpl extends ServiceImpl<RegulationMapper, Regulat
|
|||
}
|
||||
}
|
||||
|
||||
// 设置制度类型名称
|
||||
if (regulation.getType() != null && !regulation.getType().isEmpty()) {
|
||||
regulation.setRegulationType(regulation.getType());
|
||||
}
|
||||
|
||||
return Result.ok(regulation);
|
||||
} catch (Exception e) {
|
||||
return Result.error("获取制度详情失败:" + e.getMessage());
|
||||
|
|
|
@ -109,7 +109,7 @@ public class RegulationTypeServiceImpl extends ServiceImpl<RegulationTypeMapper,
|
|||
// 检查制度表中是否有使用此类型的记录(包括所有状态)
|
||||
long regulationCount = regulationMapper.selectCount(
|
||||
new LambdaQueryWrapper<RegulationEntity>()
|
||||
.eq(RegulationEntity::getRegulationType, typeName)
|
||||
.eq(RegulationEntity::getType, typeName)
|
||||
.eq(RegulationEntity::getDelFlag, "0")
|
||||
);
|
||||
// 如果有制度使用此类型,则不允许删除
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.dite.znpt.mapper.RegulationMapper">
|
||||
|
||||
<!-- 分页查询制度列表(包含创建人姓名和制度类型名称) -->
|
||||
<select id="selectRegulationListWithCreator" resultType="com.dite.znpt.domain.entity.RegulationEntity">
|
||||
SELECT
|
||||
r.*,
|
||||
u.name as createByName,
|
||||
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 != ''">
|
||||
AND r.status = #{status}
|
||||
</if>
|
||||
<if test="type != null and type != ''">
|
||||
AND r.regulation_type = #{type}
|
||||
</if>
|
||||
<if test="title != null and title != ''">
|
||||
AND r.title LIKE CONCAT('%', #{title}, '%')
|
||||
</if>
|
||||
<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>
|
||||
|
||||
</mapper>
|
|
@ -3,24 +3,24 @@
|
|||
<mapper namespace="com.dite.znpt.mapper.RegulationTypeMapper">
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
rt.type_id, rt.type_name, rt.status, rt.sort_order, rt.remark, rt.del_flag,
|
||||
rt.type_id, rt.type_name, rt.is_enabled, rt.sort_order, rt.remark, rt.del_flag,
|
||||
rt.create_by, rt.create_time, rt.update_by, rt.update_time
|
||||
</sql>
|
||||
|
||||
<select id="selectRegulationTypeListWithCreator" resultType="com.dite.znpt.domain.entity.RegulationTypeEntity">
|
||||
SELECT
|
||||
rt.type_id, rt.type_name, rt.status, rt.sort_order, rt.remark, rt.del_flag,
|
||||
rt.type_id, rt.type_name, rt.is_enabled, rt.sort_order, rt.remark, rt.del_flag,
|
||||
rt.create_by, rt.create_time, rt.update_by, rt.update_time,
|
||||
u.name as createByName
|
||||
u.name as createrName
|
||||
FROM regulation_type rt
|
||||
LEFT JOIN user u ON rt.create_by = u.user_id
|
||||
LEFT JOIN user u ON rt.create_by COLLATE utf8mb4_general_ci = u.user_id COLLATE utf8mb4_general_ci
|
||||
<where>
|
||||
rt.del_flag = '0'
|
||||
<if test="typeName != null and typeName != ''">
|
||||
AND rt.type_name LIKE concat('%', #{typeName}, '%')
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND rt.status = #{status}
|
||||
AND rt.is_enabled = #{status}
|
||||
</if>
|
||||
<if test="remark != null and remark != ''">
|
||||
AND rt.remark LIKE concat('%', #{remark}, '%')
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue