| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- package com.goafanti.organization.controller;
- import com.goafanti.common.bo.Result;
- import com.goafanti.common.constant.ErrorConstants;
- import com.goafanti.common.controller.BaseApiController;
- import com.goafanti.common.dao.DepartmentMapper;
- import com.goafanti.common.utils.StringUtils;
- import com.goafanti.organization.bo.OrganizationListOut;
- import com.goafanti.organization.service.OrganizationService;
- 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 javax.annotation.Resource;
- @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 = "/getAllDep" , method = RequestMethod.GET)
- public Result getAllDep(Integer hideSign){
- Result res = new Result();
- res.setData(organizationService.getAllDep(hideSign));
- 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,String depNo) {
- Result res = new Result();
- if(StringUtils.isBlank(name) || StringUtils.isBlank(type) || StringUtils.isBlank(superId)||StringUtils.isBlank(depNo)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"",""));
- return res;
- }
- String olo=departmentMapper.selectDepNoByName(name);
- if(olo!=null){
- res.getError().add(buildError("","部门已存在"));
- return res;
- }
- if (organizationService.checkDepNo(depNo,0)){
- res.getError().add(buildError("","部门编号已存在"));
- return res;
- }
- organizationService.addOrganization(name, managerId, type, superId, remarks,workingHoursType,hideSign,depNo);
- 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 retrialFinanceId,
- String remarks,String id,String abbreviation,String financeId,Integer workingHoursType,Integer hideSign,String depNo){
- Result res = new Result();
- if(StringUtils.isBlank(name) || StringUtils.isBlank(type)
- || StringUtils.isBlank(managerId)|| StringUtils.isBlank(superId)
- || StringUtils.isBlank(status)|| StringUtils.isBlank(remarks)|| StringUtils.isBlank(depNo)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"",""));
- return res;
- }
- if (id ==superId){
- res.getError().add(buildError("不能设置自己为上级"));
- return res;
- }
- if (organizationService.checkDepNo(depNo,1)){
- res.getError().add(buildError("","部门编号已存在"));
- return res;
- }
- int i=organizationService.updateOrganization(name, type, managerId, superId, status, province,
- retrialFinanceId,remarks,id, abbreviation,financeId,workingHoursType,hideSign,depNo);
- 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;
- }
- }
|