|
|
@@ -2,6 +2,7 @@ package com.goafanti.organization.controller;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
@@ -9,6 +10,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import com.goafanti.common.bo.Result;
|
|
|
import com.goafanti.common.constant.ErrorConstants;
|
|
|
import com.goafanti.common.controller.BaseApiController;
|
|
|
+import com.goafanti.common.dao.OrganizationManagementMapper;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
import com.goafanti.organization.bo.OrganizationListOut;
|
|
|
import com.goafanti.organization.service.OrganizationService;
|
|
|
@@ -18,6 +20,8 @@ import com.goafanti.organization.service.OrganizationService;
|
|
|
public class OrganizationManagementController extends BaseApiController{
|
|
|
@Resource
|
|
|
private OrganizationService organizationService;
|
|
|
+ @Autowired
|
|
|
+ private OrganizationManagementMapper organizationManagementMapper;
|
|
|
/**部门组织管理列表 **/
|
|
|
@RequestMapping(value = "/listOrganizationManagement" , method = RequestMethod.POST)
|
|
|
public Result listOrganizationManagement(OrganizationListOut olo, Integer pageNo,
|
|
|
@@ -39,7 +43,12 @@ public class OrganizationManagementController extends BaseApiController{
|
|
|
Result res = new Result();
|
|
|
if(StringUtils.isBlank(name) || StringUtils.isBlank(type)
|
|
|
|| StringUtils.isBlank(superId)){
|
|
|
- res.getError().add(buildError("组织名称、组织类型、上级组织不能为空"));
|
|
|
+ res.getError().add(buildError("","组织名称、组织类型、上级组织不能为空"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ String olo=organizationManagementMapper.selectDepNoByName(name);
|
|
|
+ if(olo!=null){
|
|
|
+ res.getError().add(buildError("","部门已存在"));
|
|
|
return res;
|
|
|
}
|
|
|
organizationService.addOrganization(name, managerId, type, superId, remarks);
|
|
|
@@ -79,7 +88,14 @@ public class OrganizationManagementController extends BaseApiController{
|
|
|
public Result deleteById(String id){
|
|
|
Result res = new Result();
|
|
|
if(StringUtils.isBlank(id)){
|
|
|
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "id"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ OrganizationListOut olo=organizationManagementMapper.selectAllById(id);
|
|
|
+ String superId=olo.getName();
|
|
|
+ int subordinate=organizationManagementMapper.selectCountBySuperId(superId);
|
|
|
+ if(subordinate>0){
|
|
|
+ res.getError().add(buildError("","存在下级组织不能删除"));
|
|
|
return res;
|
|
|
}
|
|
|
organizationService.deleteById(id);
|