超级管理员挂载能力时 无部门id问题

This commit is contained in:
wangliwen 2022-08-01 14:36:59 +08:00
parent 8b51c0f378
commit 124940fc04
1 changed files with 19 additions and 0 deletions

View File

@ -23,17 +23,21 @@ import io.renren.modules.resourceMountApply.dto.TResourceMountApplyDTO;
import io.renren.modules.resourceMountApply.dto.TResourceUndercarriageApplyDTO; import io.renren.modules.resourceMountApply.dto.TResourceUndercarriageApplyDTO;
import io.renren.modules.resourceMountApply.service.TResourceMountApplyService; import io.renren.modules.resourceMountApply.service.TResourceMountApplyService;
import io.renren.modules.security.user.SecurityUser; import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.sys.dto.SysDeptDTO;
import io.renren.modules.sys.dto.SysUserDTO; import io.renren.modules.sys.dto.SysUserDTO;
import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysUserService; import io.renren.modules.sys.service.SysUserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.activiti.engine.TaskService; import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task; import org.activiti.engine.task.Task;
import org.activiti.engine.task.TaskQuery; import org.activiti.engine.task.TaskQuery;
import org.apache.commons.lang3.StringUtils;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -65,6 +69,11 @@ public class ResourceMountController {
protected TaskService taskService; protected TaskService taskService;
@Autowired @Autowired
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
@Autowired
private SysDeptService sysDeptService;
@Value("${big_date.name}")
private String bigDateDeptName; // 大数据局名称
private static final String apply_key = "resourcemountapply"; // 资源上架 private static final String apply_key = "resourcemountapply"; // 资源上架
@ -114,6 +123,16 @@ public class ResourceMountController {
logger.error("资源上架异常", e); logger.error("资源上架异常", e);
} }
if (StringUtils.isEmpty(tResourceBatchMountApplyDTO.getDeptId())) {
Optional<SysUserDTO> userDTO = Optional.ofNullable(sysUserService.get(Long.valueOf(tResourceBatchMountApplyDTO.getUserId())));
userDTO.ifPresent(user -> {
if (user.getSuperAdmin() == 1) {
SysDeptDTO deptDTO = sysDeptService.getByName(bigDateDeptName);
tResourceMountApplyDTO.setDeptId(deptDTO.getId().toString());
}
});
}
ValidatorUtils.validateEntity(tResourceMountApplyDTO, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(tResourceMountApplyDTO, AddGroup.class, DefaultGroup.class);
tResourceMountApplyService.save(tResourceMountApplyDTO); // 保存单条资源申请记录 tResourceMountApplyService.save(tResourceMountApplyDTO); // 保存单条资源申请记录
if (tResourceMountApplyDTO.getId() == null) { if (tResourceMountApplyDTO.getId() == null) {