feat(examine): 优化考核人员列表排序功能并添加数据权限控制
- 在 ExamineUser 类中添加 sortFiled 和 orderBySql 字段,用于自定义排序 - 更新 ExamineUserController,移除不必要的导入 - 修改 ExamineUserMapper.xml,使用 orderBySql 替代固定的排序方式 - 在 ExamineUserServiceImpl 中实现数据权限控制,限制非管理员用户只能查看本部门及子部门的考核人员dev_1.1.0
parent
30c63b8c10
commit
16ef200d39
|
@ -4,8 +4,6 @@ import cn.hutool.core.util.StrUtil;
|
|||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import tech.unissense.pms.business.examine.user.domain.ExamineUser;
|
||||
import tech.unissense.pms.business.examine.user.service.ExamineUserService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import tech.unissense.pms.common.core.controller.BaseController;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package tech.unissense.pms.business.examine.user.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.*;
|
||||
import tech.unissense.pms.common.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -55,10 +54,28 @@ public class ExamineUser extends BaseEntity {
|
|||
private String deptId;
|
||||
|
||||
private String isAsc;
|
||||
private String sortFiled;
|
||||
@Setter(value = AccessLevel.NONE)
|
||||
@Getter(value = AccessLevel.NONE)
|
||||
private String orderBySql;
|
||||
|
||||
|
||||
private List<Integer> userIdList;
|
||||
|
||||
|
||||
|
||||
public String getOrderBySql() {
|
||||
//对排序字段的替换
|
||||
if (StrUtil.isEmpty(sortFiled)) {
|
||||
return null;
|
||||
} else if ("all".equalsIgnoreCase(sortFiled)) {
|
||||
return (StrUtil.format("order by IFNULL(score,ifnull(manage_score,ifnull(self_score,-1))) {}", StrUtil.isNotEmpty(isAsc) ? isAsc : ""));
|
||||
} else if ("manageScore".equalsIgnoreCase(sortFiled)) {
|
||||
return (StrUtil.format("order by ifnull(manage_score,-1) {}", StrUtil.isNotEmpty(isAsc) ? isAsc : ""));
|
||||
} else if ("selfScore".equalsIgnoreCase(sortFiled)) {
|
||||
return (StrUtil.format("order by ifnull(self_score,-1) {}", StrUtil.isNotEmpty(isAsc) ? isAsc : ""));
|
||||
}else if ("score".equalsIgnoreCase(sortFiled)) {
|
||||
return (StrUtil.format("order by ifnull(score,-1) {}", StrUtil.isNotEmpty(isAsc) ? isAsc : ""));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,15 +17,14 @@ import tech.unissense.pms.business.examine.user.service.ExamineUserService;
|
|||
import org.springframework.stereotype.Service;
|
||||
import tech.unissense.pms.business.work.logger.service.IWorkLoggerService;
|
||||
import tech.unissense.pms.common.annotation.DataScope;
|
||||
import tech.unissense.pms.common.core.domain.entity.SysUser;
|
||||
import tech.unissense.pms.common.utils.SecurityUtils;
|
||||
import tech.unissense.pms.common.utils.StringUtils;
|
||||
import tech.unissense.pms.system.service.ISysDictDataService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -102,6 +101,16 @@ public class ExamineUserServiceImpl implements ExamineUserService {
|
|||
@Override
|
||||
@DataScope(deptAlias = "t2", userAlias = "t2")
|
||||
public List<ExamineUser> list(ExamineUser examineUser) {
|
||||
SysUser user = SecurityUtils.getLoginUser().getUser();
|
||||
if (!user.getDeptId().equals(200L)) {
|
||||
String sqlPermission = StringUtils.format(
|
||||
" and ({}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) ))"
|
||||
, "t2", user.getDeptId(), user.getDeptId());
|
||||
|
||||
examineUser.setParams(new HashMap<String, Object>() {{
|
||||
put("dataScope", sqlPermission);
|
||||
}});
|
||||
}
|
||||
return examineUserMapper.list(examineUser);
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
order by ifnull(manage_score,-1) ${isAsc}
|
||||
${orderBySql}
|
||||
</select>
|
||||
<select id="queryByTaskIdAndUserId" resultMap="ExamineUserMap">
|
||||
<include refid="base_query"/>
|
||||
|
|
Loading…
Reference in New Issue