| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- package com.goafanti.organization.controller;
- import javax.annotation.Resource;
- import com.goafanti.common.dao.DepartmentMapper;
- 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.utils.StringUtils;
- import com.goafanti.organization.bo.OrganizationListOut;
- import com.goafanti.organization.service.OrganizationService;
- @RestController
- @RequestMapping("/api/admin/organization")
- public class AdminOrganizationController extends BaseApiController{
- @Resource
- private OrganizationService organizationService;
- @Autowired
- private DepartmentMapper departmentMapper;
- /**部门组织管理列表 **/
- @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.GET)
- public Result selectsuperId(Integer hideSign){
- Result res = new Result();
- res.setData(organizationService.selectSuperId(hideSign));
- return res;
- }
- /**部门组织管理上级组织查询 **/
- @RequestMapping(value = "/selectSuperIdS" , method = RequestMethod.GET)
- public Result selectsuperIdS(){
- Result res = new Result();
- res.setData(organizationService.selectSuperId(1));
- return res;
- }
- /**部门组织管理新增**/
- @RequestMapping(value = "/addOrganization" , method = RequestMethod.POST)
- public Result addOrganization(String name, String managerId, String type, String superId, String remarks,
- Integer workingHoursType,Integer hideSign) {
- Result res = new Result();
- if(StringUtils.isBlank(name) || StringUtils.isBlank(type) || StringUtils.isBlank(superId)){
- res.getError().add(buildError("","组织名称、组织类型、上级组织不能为空"));
- return res;
- }
- String olo=departmentMapper.selectDepNoByName(name);
- if(olo!=null){
- res.getError().add(buildError("","部门已存在"));
- return res;
- }
- String sdepNo=departmentMapper.selectDepNo(superId);
- int count=departmentMapper.selectDepNoCount(superId);
- if((count+1)>99){
- res.getError().add(buildError("","每层最多存在99个子类"));
- return res;
- }
- organizationService.addOrganization(name, managerId, type, superId, remarks,sdepNo,count,workingHoursType,hideSign);
- 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 Result selectAllById(String id){
- Result res = new Result();
- res.data(organizationService.selectAllById(id)) ;
- return res;
- }
- /**修改信息**/
- @RequestMapping(value = "/updateOrganization" , method = RequestMethod.POST)
- public Result updateOrganization(String name, String type, String managerId, String superId, String status,Integer province,
- String remarks,String id,String abbreviation,String financeId,Integer workingHoursType,Integer hideSign){
- 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;
- }
- String sdepNo=departmentMapper.selectDepNo(superId);//No
- int count=departmentMapper.selectDepNoCount(superId);//14
- if((count+1)>99){
- res.getError().add(buildError("","每层最多存在99个子类"));
- return res;
- }
- int i=organizationService.updateOrganization(name, type, managerId, superId, status, province,remarks,id,
- sdepNo,count,abbreviation,financeId,workingHoursType,hideSign);
- return res.data(i);
- }
- /**删除列表信息**/
- @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=departmentMapper.selectAllById(id);
- String superId=olo.getName();*/
- int subordinate=departmentMapper.selectCountBySuperId(id);
- if(subordinate>0){
- res.getError().add(buildError("","存在下级组织不能删除"));
- return res;
- }
- int adminCount=departmentMapper.selectUserById(id);
- if(adminCount>0){
- res.getError().add(buildError("","部门被用户选定不能删除"));
- return res;
- }
- organizationService.deleteById(id);
- return res;
- }
- }
|