| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- 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;
- 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;
- @RestController
- @RequestMapping("api/admin/organization")
- 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,
- Integer pageSize){
- Result res = new Result();
- res.setData(organizationService.listOrganizationManagement(olo, pageNo, pageSize));
- return res;
- }
- /**部门组织管理上级组织查询 **/
- @RequestMapping(value = "/selectSuperId" , method = RequestMethod.POST)
- public Result selectsuperId(){
- Result res = new Result();
- res.setData(organizationService.selectSuperId());
- return res;
- }
- /**部门组织管理新增**/
- @RequestMapping(value = "/addOrganization" , method = RequestMethod.POST)
- public Result addOrganization(String name, String managerId, String type, String superId, String remarks) throws Exception{
- Result res = new Result();
- if(StringUtils.isBlank(name) || StringUtils.isBlank(type)
- || StringUtils.isBlank(superId)){
- 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);
- return res;
- }
- /**负责人自动补全查询**/
- @RequestMapping(value = "/selectName" , method = RequestMethod.POST)
- public Result selectName(String name){
- Result res = new Result();
- res.setData(organizationService.selectName(name));
- return res;
- }
- /**编辑页面数据读取**/
- @RequestMapping(value = "/selectAllById" , method = RequestMethod.POST)
- public OrganizationListOut selectAllById(String id){
- OrganizationListOut res = organizationService.selectAllById(id);
- return res;
- }
- /**修改信息**/
- @RequestMapping(value = "/updateOrganization" , method = RequestMethod.POST)
- public Result updateOrganization(String name, String type, String managerId, String superId, String status,
- String remarks,String id){
- Result res = new Result();
- if(StringUtils.isBlank(name) || StringUtils.isBlank(type)
- || StringUtils.isBlank(managerId)|| StringUtils.isBlank(superId)
- || StringUtils.isBlank(status)|| StringUtils.isBlank(remarks)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
- return res;
- }
- organizationService.updateOrganization(name, type, managerId, superId, status, remarks,id);
- return res;
- }
-
-
- /**删除列表信息**/
- @RequestMapping(value = "/deleteById" , method = RequestMethod.POST)
- public Result deleteById(String id){
- Result res = new Result();
- if(StringUtils.isBlank(id)){
- 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);
- return res;
- }
-
- }
|