过滤后端 HIQDUCS-666
This commit is contained in:
parent
94260ff02d
commit
9e37adfceb
|
@ -23,12 +23,17 @@ import io.renren.modules.resource.videoPreview.AbstractVideoPreviewService;
|
||||||
import io.renren.modules.resource.videoPreview.VideoPreviewFactory;
|
import io.renren.modules.resource.videoPreview.VideoPreviewFactory;
|
||||||
import io.renren.modules.security.user.SecurityUser;
|
import io.renren.modules.security.user.SecurityUser;
|
||||||
import io.renren.modules.security.user.UserDetail;
|
import io.renren.modules.security.user.UserDetail;
|
||||||
|
import io.renren.modules.sys.dao.SysDeptDao;
|
||||||
import io.renren.modules.sys.dao.SysUserDao;
|
import io.renren.modules.sys.dao.SysUserDao;
|
||||||
import io.renren.modules.sys.dto.SysDeptDTO;
|
import io.renren.modules.sys.dto.SysDeptDTO;
|
||||||
|
import io.renren.modules.sys.dto.SysRoleDTO;
|
||||||
import io.renren.modules.sys.dto.SysUserDTO;
|
import io.renren.modules.sys.dto.SysUserDTO;
|
||||||
|
import io.renren.modules.sys.entity.SysDeptEntity;
|
||||||
import io.renren.modules.sys.entity.SysUserEntity;
|
import io.renren.modules.sys.entity.SysUserEntity;
|
||||||
import io.renren.modules.sys.enums.SuperAdminEnum;
|
import io.renren.modules.sys.enums.SuperAdminEnum;
|
||||||
import io.renren.modules.sys.service.SysDeptService;
|
import io.renren.modules.sys.service.SysDeptService;
|
||||||
|
import io.renren.modules.sys.service.SysRoleService;
|
||||||
|
import io.renren.modules.sys.service.SysRoleUserService;
|
||||||
import io.renren.modules.sys.service.SysUserService;
|
import io.renren.modules.sys.service.SysUserService;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
@ -85,6 +90,17 @@ public class ResourceController {
|
||||||
@Value("${resource.path}")
|
@Value("${resource.path}")
|
||||||
private String uploadPath;
|
private String uploadPath;
|
||||||
|
|
||||||
|
@Value("${big_date.assignee_role_name}")
|
||||||
|
private String roleName0; // 具备审批的角色名称(普通)
|
||||||
|
|
||||||
|
@Value("${big_date.assignee_district_role_name}")
|
||||||
|
private String roleName1; // 具备审批的角色名称(区县)
|
||||||
|
@Value("${big_date.assignee_city_role_name}")
|
||||||
|
private String roleName2; // 具备审批的角色名称(市区)
|
||||||
|
|
||||||
|
@Value("${big_date.assignee_meet_role_id}")
|
||||||
|
private String defaultAssigneeRoleId; // 会客厅审核人角色
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ResourceService resourceService;
|
private ResourceService resourceService;
|
||||||
|
|
||||||
|
@ -99,6 +115,14 @@ public class ResourceController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysUserService sysUserService;
|
private SysUserService sysUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysRoleService sysRoleService;
|
||||||
|
@Autowired
|
||||||
|
private SysRoleUserService sysRoleUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysDeptDao sysDeptDao;
|
||||||
|
|
||||||
@Resource(name = "${hisense.gateway.name}")
|
@Resource(name = "${hisense.gateway.name}")
|
||||||
private ApiGateway apiGateway;
|
private ApiGateway apiGateway;
|
||||||
|
|
||||||
|
@ -126,6 +150,74 @@ public class ResourceController {
|
||||||
@ApiImplicitParam(name = "region", value = "是否过滤只出用户区域内部门", paramType = "query", dataType = "String")
|
@ApiImplicitParam(name = "region", value = "是否过滤只出用户区域内部门", paramType = "query", dataType = "String")
|
||||||
})
|
})
|
||||||
public Result<PageData<ResourceDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
|
public Result<PageData<ResourceDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
|
||||||
|
// 2022.12.16 后台过滤只出所属区域资源
|
||||||
|
Boolean region = params.containsKey("region") ? (Boolean) params.get("region") : false; // 是否需要过滤只出用户所属区域资源
|
||||||
|
while (region) {
|
||||||
|
List<Long> deptIds = new ArrayList<>();
|
||||||
|
UserDetail user = SecurityUser.getUser(); // 当前用户
|
||||||
|
if (SuperAdminEnum.YES.value() != user.getSuperAdmin()) { // 非超级管理员
|
||||||
|
Optional<SysUserDTO> userDTOOptional = Optional.ofNullable(sysUserService.get(user.getId()));
|
||||||
|
if (userDTOOptional.isPresent()) {
|
||||||
|
SysRoleDTO roleDTO0 = sysRoleService.getByName(roleName0); // 部门审核员
|
||||||
|
SysRoleDTO roleDTO1 = sysRoleService.getByName(roleName1); // 区管理员
|
||||||
|
SysRoleDTO roleDTO2 = sysRoleService.getByName(roleName2); // 市管理员
|
||||||
|
List<Long> useIds0 = sysRoleUserService.getUserIdListByRoleId(roleDTO0.getId()); // 部门审核员列表
|
||||||
|
List<Long> useIds1 = sysRoleUserService.getUserIdListByRoleId(roleDTO1.getId()); // 区管理员
|
||||||
|
List<Long> useIds02 = sysRoleUserService.getUserIdListByRoleId(roleDTO2.getId()); // 市管理员
|
||||||
|
List<Long> useIds = sysRoleUserService.getUserIdListByRoleId(Long.parseLong(defaultAssigneeRoleId)); // 运维管理员
|
||||||
|
|
||||||
|
if (useIds.contains(user.getId())) { // 为运维管理员时
|
||||||
|
logger.info("运维管理员出所有资源");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (useIds02.contains(user.getId())) { // 为市管理员
|
||||||
|
logger.info("市管理员");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
SysDeptEntity sysDeptEntity = null;
|
||||||
|
if (userDTOOptional.get().getDeptId() != null) {
|
||||||
|
sysDeptEntity = sysDeptDao.getById(userDTOOptional.get().getDeptId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sysDeptEntity == null || sysDeptEntity.getDistrict() == null) {
|
||||||
|
logger.info("该用户部门信息异常" + user.toString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useIds1.contains(user.getId())) { // 区管理员
|
||||||
|
logger.info("区管理员");
|
||||||
|
SysDeptEntity finalSysDeptEntity = sysDeptEntity;
|
||||||
|
List<Long> deptId = sysDeptDao.getIdFromDistrict(sysDeptEntity.getDistrict());
|
||||||
|
List<Long> temp = new ArrayList<Long>() {
|
||||||
|
{
|
||||||
|
add(finalSysDeptEntity.getId());
|
||||||
|
if (!deptId.isEmpty()) {
|
||||||
|
addAll(deptId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
deptIds.addAll(temp);
|
||||||
|
params.put("deptIds", deptIds.stream().distinct().collect(Collectors.toList()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (useIds0.contains(user.getId())) { // 部门审核员
|
||||||
|
logger.info("部门审核员");
|
||||||
|
SysDeptEntity finalSysDeptEntity1 = sysDeptEntity;
|
||||||
|
List<Long> temp = new ArrayList<Long>() {
|
||||||
|
{
|
||||||
|
add(finalSysDeptEntity1.getId());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
deptIds.addAll(temp);
|
||||||
|
params.put("deptIds", deptIds.stream().distinct().collect(Collectors.toList()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PageData<ResourceDTO> page = resourceService.page(params);
|
PageData<ResourceDTO> page = resourceService.page(params);
|
||||||
page.getList().forEach(item -> {
|
page.getList().forEach(item -> {
|
||||||
item.setInfoList(resourceService.selectAttrsByResourceId(item.getId()));
|
item.setInfoList(resourceService.selectAttrsByResourceId(item.getId()));
|
||||||
|
|
|
@ -62,6 +62,7 @@ import io.renren.modules.sys.entity.SysDeptEntity;
|
||||||
import io.renren.modules.sys.enums.SuperAdminEnum;
|
import io.renren.modules.sys.enums.SuperAdminEnum;
|
||||||
import io.renren.modules.sys.service.SysDeptService;
|
import io.renren.modules.sys.service.SysDeptService;
|
||||||
import io.renren.modules.sys.service.SysRoleService;
|
import io.renren.modules.sys.service.SysRoleService;
|
||||||
|
import io.renren.modules.sys.service.SysRoleUserService;
|
||||||
import io.renren.modules.sys.service.SysUserService;
|
import io.renren.modules.sys.service.SysUserService;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import okhttp3.*;
|
import okhttp3.*;
|
||||||
|
@ -270,6 +271,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysRoleService sysRoleService;
|
private SysRoleService sysRoleService;
|
||||||
|
@Autowired
|
||||||
|
private SysRoleUserService sysRoleUserService;
|
||||||
|
|
||||||
private JdbcTemplate lcJdbcTemplate = JdbcTemplateFactory.getJdbcTemplate();
|
private JdbcTemplate lcJdbcTemplate = JdbcTemplateFactory.getJdbcTemplate();
|
||||||
|
|
||||||
|
@ -312,7 +315,17 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
wrapper.eq(org.apache.commons.lang3.StringUtils.isNotEmpty(params.get("creator").toString()), "creator", params.get("creator").toString());
|
wrapper.eq(org.apache.commons.lang3.StringUtils.isNotEmpty(params.get("creator").toString()), "creator", params.get("creator").toString());
|
||||||
break;
|
break;
|
||||||
case "deptId":
|
case "deptId":
|
||||||
wrapper.eq(org.apache.commons.lang3.StringUtils.isNotEmpty(params.get("deptId").toString()), "dept_id", Long.parseLong(params.get("deptId").toString()));
|
wrapper.eq(org.apache.commons.lang3.StringUtils.isNumeric(params.get("deptId").toString()), "dept_id", Long.parseLong(params.get("deptId").toString()));
|
||||||
|
break;
|
||||||
|
case "deptIds": {
|
||||||
|
List<Long> deptIds = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
deptIds = (List<Long>) params.get("deptIds");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error("", ex);
|
||||||
|
}
|
||||||
|
wrapper.in(deptIds.isEmpty(), "dept_id", deptIds);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -517,20 +530,77 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
Integer pageSize = jsonObject.getInteger("pageSize");
|
Integer pageSize = jsonObject.getInteger("pageSize");
|
||||||
// 2022.12.16 后台过滤只出所属区域资源
|
// 2022.12.16 后台过滤只出所属区域资源
|
||||||
Boolean region = jsonObject.containsKey("region") ? jsonObject.getBooleanValue("region") : false; // 是否需要过滤只出用户所属区域资源
|
Boolean region = jsonObject.containsKey("region") ? jsonObject.getBooleanValue("region") : false; // 是否需要过滤只出用户所属区域资源
|
||||||
if (region) {
|
while (region) {
|
||||||
UserDetail user = SecurityUser.getUser(); // 当前用户
|
UserDetail user = SecurityUser.getUser(); // 当前用户
|
||||||
if (SuperAdminEnum.YES.value() != user.getSuperAdmin()) { // 非超级管理员
|
if (SuperAdminEnum.YES.value() != user.getSuperAdmin()) { // 非超级管理员
|
||||||
Optional<SysUserDTO> userDTOOptional = Optional.ofNullable(sysUserService.get(user.getId()));
|
Optional<SysUserDTO> userDTOOptional = Optional.ofNullable(sysUserService.get(user.getId()));
|
||||||
SysRoleDTO roleDTO0 = sysRoleService.getByName(roleName0);
|
if (userDTOOptional.isPresent()) {
|
||||||
SysRoleDTO roleDTO1 = sysRoleService.getByName(roleName1);
|
SysRoleDTO roleDTO0 = sysRoleService.getByName(roleName0); // 部门审核员
|
||||||
SysRoleDTO roleDTO2 = sysRoleService.getByName(roleName2);
|
SysRoleDTO roleDTO1 = sysRoleService.getByName(roleName1); // 区管理员
|
||||||
userDTOOptional.ifPresent(userDto -> {
|
SysRoleDTO roleDTO2 = sysRoleService.getByName(roleName2); // 市管理员
|
||||||
if (userDto.getDeptId() != null) {
|
List<Long> useIds0 = sysRoleUserService.getUserIdListByRoleId(roleDTO0.getId()); // 部门审核员列表
|
||||||
SysDeptEntity sysDeptEntity = sysDeptDao.getById(userDto.getDeptId());
|
List<Long> useIds1 = sysRoleUserService.getUserIdListByRoleId(roleDTO1.getId()); // 区管理员
|
||||||
|
List<Long> useIds02 = sysRoleUserService.getUserIdListByRoleId(roleDTO2.getId()); // 市管理员
|
||||||
|
List<Long> useIds = sysRoleUserService.getUserIdListByRoleId(Long.parseLong(defaultAssigneeRoleId)); // 运维管理员
|
||||||
|
|
||||||
|
if (useIds.contains(user.getId())) { // 为运维管理员时
|
||||||
|
logger.info("运维管理员出所有资源");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
if (useIds02.contains(user.getId())) { // 为市管理员
|
||||||
|
logger.info("市管理员");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
SysDeptEntity sysDeptEntity = null;
|
||||||
|
if (userDTOOptional.get().getDeptId() != null) {
|
||||||
|
sysDeptEntity = sysDeptDao.getById(userDTOOptional.get().getDeptId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sysDeptEntity == null || sysDeptEntity.getDistrict() == null) {
|
||||||
|
logger.info("该用户部门信息异常" + user.toString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useIds1.contains(user.getId())) { // 区管理员
|
||||||
|
logger.info("区管理员");
|
||||||
|
SysDeptEntity finalSysDeptEntity = sysDeptEntity;
|
||||||
|
List<Long> deptId = sysDeptDao.getIdFromDistrict(sysDeptEntity.getDistrict());
|
||||||
|
List<Long> temp = new ArrayList<Long>() {
|
||||||
|
{
|
||||||
|
add(finalSysDeptEntity.getId());
|
||||||
|
if (!deptId.isEmpty()) {
|
||||||
|
addAll(deptId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
if (!resourceDTO.getDeptIds().isEmpty()) {
|
||||||
|
temp.addAll(resourceDTO.getDeptIds());
|
||||||
|
}
|
||||||
|
resourceDTO.setDeptIds(temp.stream().distinct().collect(Collectors.toList()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (useIds0.contains(user.getId())) { // 部门审核员
|
||||||
|
logger.info("部门审核员");
|
||||||
|
if (userDTOOptional.get().getDeptId() != null) {
|
||||||
|
SysDeptEntity finalSysDeptEntity = sysDeptEntity;
|
||||||
|
List<Long> temp = new ArrayList<Long>() {
|
||||||
|
{
|
||||||
|
add(finalSysDeptEntity.getId());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (!resourceDTO.getDeptIds().isEmpty()) {
|
||||||
|
temp.addAll(resourceDTO.getDeptIds());
|
||||||
|
}
|
||||||
|
resourceDTO.setDeptIds(temp.stream().distinct().collect(Collectors.toList())); // 只出自己部门
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Boolean nonChinese = jsonObject.containsKey("nonChinese") ? jsonObject.getBoolean("nonChinese") : Boolean.FALSE; // 不传默认为中文走全文索引
|
Boolean nonChinese = jsonObject.containsKey("nonChinese") ? jsonObject.getBoolean("nonChinese") : Boolean.FALSE; // 不传默认为中文走全文索引
|
||||||
//默认按上架时间降序排列
|
//默认按上架时间降序排列
|
||||||
String orderField;
|
String orderField;
|
||||||
|
|
|
@ -28,4 +28,21 @@ public class UserDetail implements Serializable {
|
||||||
*/
|
*/
|
||||||
private List<Long> deptIdList;
|
private List<Long> deptIdList;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "UserDetail{" +
|
||||||
|
"id=" + id +
|
||||||
|
", username='" + username + '\'' +
|
||||||
|
", realName='" + realName + '\'' +
|
||||||
|
", headUrl='" + headUrl + '\'' +
|
||||||
|
", gender=" + gender +
|
||||||
|
", email='" + email + '\'' +
|
||||||
|
", mobile='" + mobile + '\'' +
|
||||||
|
", deptId=" + deptId +
|
||||||
|
", password='" + password + '\'' +
|
||||||
|
", status=" + status +
|
||||||
|
", superAdmin=" + superAdmin +
|
||||||
|
", deptIdList=" + deptIdList +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -44,4 +44,6 @@ public interface SysDeptDao extends BaseDao<SysDeptEntity> {
|
||||||
|
|
||||||
Map<String, Object> selectUCSDeptByLCDeptName(@Param("deptName") String deptName);
|
Map<String, Object> selectUCSDeptByLCDeptName(@Param("deptName") String deptName);
|
||||||
|
|
||||||
|
List<Long> getIdFromDistrict(@Param("district") Long district);
|
||||||
|
|
||||||
}
|
}
|
|
@ -34,4 +34,12 @@ public interface SysDeptService extends BaseService<SysDeptEntity> {
|
||||||
|
|
||||||
SysDeptDTO getByName(String name);
|
SysDeptDTO getByName(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询该区域内部门id
|
||||||
|
*
|
||||||
|
* @param district
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Long> getIdFromDistrict(Long district);
|
||||||
|
|
||||||
}
|
}
|
|
@ -51,7 +51,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntit
|
||||||
List<SysDeptEntity> entityList = baseDao.getList(params);
|
List<SysDeptEntity> entityList = baseDao.getList(params);
|
||||||
List<SysDeptDTO> dtoList = ConvertUtils.sourceToTarget(entityList, SysDeptDTO.class);
|
List<SysDeptDTO> dtoList = ConvertUtils.sourceToTarget(entityList, SysDeptDTO.class);
|
||||||
List<SysDeptDTO> result = dtoList.stream().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList());
|
List<SysDeptDTO> result = dtoList.stream().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList());
|
||||||
return new PageData( TreeUtils.build(result), dtoList.size());
|
return new PageData(TreeUtils.build(result), dtoList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -147,6 +147,17 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntit
|
||||||
return ConvertUtils.sourceToTarget(entity, SysDeptDTO.class);
|
return ConvertUtils.sourceToTarget(entity, SysDeptDTO.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询该区域内部门id
|
||||||
|
*
|
||||||
|
* @param district
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Long> getIdFromDistrict(Long district) {
|
||||||
|
return baseDao.getIdFromDistrict(district);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有上级部门ID
|
* 获取所有上级部门ID
|
||||||
|
|
|
@ -43,8 +43,13 @@
|
||||||
<select id="selectLCDeptByRegion" resultType="java.lang.String">
|
<select id="selectLCDeptByRegion" resultType="java.lang.String">
|
||||||
SELECT lc_name FROM t_ucs_lc_dept_rel WHERE district = #{region}
|
SELECT lc_name FROM t_ucs_lc_dept_rel WHERE district = #{region}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectUCSDeptByLCDeptName" resultType="java.util.Map">
|
<select id="selectUCSDeptByLCDeptName" resultType="java.util.Map">
|
||||||
SELECT * FROM t_ucs_lc_dept_rel WHERE lc_name = #{deptName}
|
SELECT * FROM t_ucs_lc_dept_rel WHERE lc_name = #{deptName}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getIdFromDistrict" resultType="java.lang.Long">
|
||||||
|
SELECT id from sys_dept WHERE district = #{district};
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue