|
@@ -6,6 +6,8 @@ import com.rf.psychological.security.AesEncryptUtils;
|
|
import com.rf.psychological.security.SafetyProcess;
|
|
import com.rf.psychological.security.SafetyProcess;
|
|
import com.rf.psychological.structure.dao.model.StructureEntity;
|
|
import com.rf.psychological.structure.dao.model.StructureEntity;
|
|
import com.rf.psychological.structure.service.StructureService;
|
|
import com.rf.psychological.structure.service.StructureService;
|
|
|
|
+import com.rf.psychological.user.dao.model.UserEntity;
|
|
|
|
+import com.rf.psychological.user.service.UserService;
|
|
import com.rf.psychological.utils.Result;
|
|
import com.rf.psychological.utils.Result;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -30,6 +32,9 @@ public class StructureController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private StructureService service;
|
|
private StructureService service;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private UserService userService;
|
|
@ApiOperation(value = "新增/编辑组织架构",notes = "structureNo 组织架构编号;structureName:组织架构名称;parentStructureNo:上级组织架构编号")
|
|
@ApiOperation(value = "新增/编辑组织架构",notes = "structureNo 组织架构编号;structureName:组织架构名称;parentStructureNo:上级组织架构编号")
|
|
@PostMapping("/save")
|
|
@PostMapping("/save")
|
|
@SafetyProcess
|
|
@SafetyProcess
|
|
@@ -40,7 +45,7 @@ public class StructureController extends BaseController {
|
|
return fail("组织架构编号为空");
|
|
return fail("组织架构编号为空");
|
|
}
|
|
}
|
|
if(StringUtils.isBlank(entity.getStructureName())){
|
|
if(StringUtils.isBlank(entity.getStructureName())){
|
|
- return fail("组织架构编号为空");
|
|
|
|
|
|
+ return fail("组织架构名称为空");
|
|
}
|
|
}
|
|
if(StringUtils.isBlank(entity.getParentStructureNo())){
|
|
if(StringUtils.isBlank(entity.getParentStructureNo())){
|
|
entity.setParentStructureNo("0");
|
|
entity.setParentStructureNo("0");
|
|
@@ -54,9 +59,20 @@ public class StructureController extends BaseController {
|
|
@DeleteMapping("delete/{id}")
|
|
@DeleteMapping("delete/{id}")
|
|
public Result delete(@PathVariable String id ){
|
|
public Result delete(@PathVariable String id ){
|
|
//TODO 检查组织架构下是否存在用户
|
|
//TODO 检查组织架构下是否存在用户
|
|
-
|
|
|
|
- this.service.deleteById(id);
|
|
|
|
- return success();
|
|
|
|
|
|
+ StructureEntity entity = this.service.findById(id);
|
|
|
|
+ if(entity == null){
|
|
|
|
+ return fail("组织架构不存在");
|
|
|
|
+ }
|
|
|
|
+ List<String> structureNos = this.service.findStructureNoByIdRecursion(entity.getStructureNo());
|
|
|
|
+ if(structureNos != null && structureNos.size()>0){
|
|
|
|
+ return fail(entity.getStructureName()+"下存在子级组织架构,不能删除");
|
|
|
|
+ }
|
|
|
|
+ List<UserEntity> userEntityList = this.userService.findByStructureNo(entity.getStructureNo());
|
|
|
|
+ if(userEntityList != null && userEntityList.size()>0){
|
|
|
|
+ return fail(entity.getStructureName()+"下存在用户,不能删除");
|
|
|
|
+ }
|
|
|
|
+ this.service.deleteById(id);
|
|
|
|
+ return success();
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "查询详情")
|
|
@ApiOperation(value = "查询详情")
|