Browse Source

部门管理部分需求修改

Michael 8 years ago
parent
commit
a08426596a

+ 2 - 0
src/main/java/com/goafanti/common/dao/OrganizationManagementMapper.java

@@ -101,4 +101,6 @@ public interface OrganizationManagementMapper {
 	List<OrganizationListOut> selectIDNBySuperId(String superId);
 	
 	int updateByNumber(OrganizationListOut olo);
+	
+	int selectCountBySuperId(String superId);
 }

+ 7 - 0
src/main/java/com/goafanti/common/mapper/OrganizationManagementMapper.xml

@@ -530,4 +530,11 @@
 	    where
 	    id=#{id,jdbcType=VARCHAR}
   	</update>
+  	<select id="selectCountBySuperId" parameterType="String" resultType="java.lang.Integer">
+  		select
+		count(0)
+		from organization_management
+		where
+		super_id=#{superId,jdbcType=VARCHAR}
+  	</select>
 </mapper>

+ 18 - 2
src/main/java/com/goafanti/organization/controller/OrganizationManagementController.java

@@ -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);