diff --git a/renren-admin/src/main/java/io/renren/common/controller/ResourceMountController.java b/renren-admin/src/main/java/io/renren/common/controller/ResourceMountController.java index 268a1b3f..53f4ae88 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/ResourceMountController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/ResourceMountController.java @@ -23,17 +23,21 @@ import io.renren.modules.resourceMountApply.dto.TResourceMountApplyDTO; import io.renren.modules.resourceMountApply.dto.TResourceUndercarriageApplyDTO; import io.renren.modules.resourceMountApply.service.TResourceMountApplyService; 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.service.SysDeptService; import io.renren.modules.sys.service.SysUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.activiti.engine.TaskService; import org.activiti.engine.task.Task; import org.activiti.engine.task.TaskQuery; +import org.apache.commons.lang3.StringUtils; import org.codehaus.jackson.map.ObjectMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -65,6 +69,11 @@ public class ResourceMountController { protected TaskService taskService; @Autowired private JdbcTemplate jdbcTemplate; + @Autowired + private SysDeptService sysDeptService; + + @Value("${big_date.name}") + private String bigDateDeptName; // 大数据局名称 private static final String apply_key = "resourcemountapply"; // 资源上架 @@ -114,6 +123,16 @@ public class ResourceMountController { logger.error("资源上架异常", e); } + if (StringUtils.isEmpty(tResourceBatchMountApplyDTO.getDeptId())) { + Optional 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); tResourceMountApplyService.save(tResourceMountApplyDTO); // 保存单条资源申请记录 if (tResourceMountApplyDTO.getId() == null) {