package com.product.org.admin.controller;
|
|
import com.product.admin.util.ResultInfo;
|
import com.product.common.lang.StringUtils;
|
import com.product.core.cache.DataPoolCacheImpl;
|
import com.product.core.config.CoreConst;
|
import com.product.core.controller.support.AbstractBaseController;
|
import com.product.core.entity.FieldSetEntity;
|
import com.product.core.entity.RequestParameterEntity;
|
import com.product.core.exception.BaseException;
|
import com.product.core.permission.PermissionService;
|
import com.product.core.spring.context.SpringMVCContextHolder;
|
import com.product.core.transfer.Transactional;
|
import com.product.module.sys.config.SystemErrorCode;
|
import com.product.module.sys.entity.SystemUser;
|
import com.product.module.sys.version.ApiVersion;
|
import com.product.org.admin.config.CmnConst;
|
import com.product.org.admin.config.SystemCode;
|
import com.product.org.admin.service.SystemOrgLevelsService;
|
import com.product.org.admin.service.idel.ISystemOrgLevelsService;
|
|
import com.product.util.BaseUtil;
|
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.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpSession;
|
|
/**
|
* Copyright © 2020 LX-BASE
|
*
|
* @Title: SystemOrgLevelsController
|
* @Project: LX-BASE-SERVER
|
* @Date: 2020年5月29日17:58:42
|
* @Author: Mr.Xu
|
* @Description: 组织架构管理
|
*/
|
@RestController
|
@RequestMapping("/api/org/levels")
|
public class SystemOrgLevelsController extends AbstractBaseController {
|
|
@Autowired
|
private SystemOrgLevelsService systemOrgLevelsService;
|
@Autowired
|
PermissionService permissionService;
|
|
/**
|
* 公司列表查询接口
|
*
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/list-company/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String listCompany(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = null;
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
if (bean != null) {
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
fse = reqp.getFormData();
|
}
|
if (bean == null || fse == null) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
}
|
// 判断表名是否正常
|
// if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_ORG_LEVELS.equals(fse.getTableName())) {
|
// SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
// return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
// }
|
fse.setValue(CmnConst.ORG_LEVEL_TYPE, 0);
|
return ResultInfo.success(systemOrgLevelsService.listOrgLevels(fse));
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(e.getCode(), e.getMessageInfo());
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
e.printStackTrace();
|
return this.error(SystemCode.SYSTEM_GET_COMPANYLIST_FAIL.getValue(),
|
SystemCode.SYSTEM_GET_COMPANYLIST_FAIL.getText());
|
}
|
}
|
|
/**
|
* 查询公司详情
|
*
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/find-company/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String findCompany(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = null;
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
if (bean != null) {
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
fse = reqp.getFormData();
|
}
|
if (bean == null || fse == null) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
}
|
// 判断表名是否正常
|
if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_ORG_LEVELS.equals(fse.getTableName())) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
}
|
orgLevelOperPermission(true,0,fse);
|
// 判断参数是否正常
|
if (StringUtils.isEmpty(fse.getString(CmnConst.UUID))) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
|
return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
|
}
|
// 添加机构类型
|
fse.setValue(CmnConst.ORG_LEVEL_TYPE, 0);
|
return OK_List(systemOrgLevelsService.findOrgLevel(fse));
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(e.getCode(), e.getMessageInfo());
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
e.printStackTrace();
|
return this.error(SystemCode.SYSTEM_GET_COMPANYINFO_FAIL.getValue(),
|
SystemCode.SYSTEM_GET_COMPANYINFO_FAIL.getText());
|
}
|
}
|
|
/***
|
* 公司新增接口
|
*
|
* @param request
|
* @param response
|
* @param session
|
* @return
|
*/
|
@RequestMapping(value = "/add-company/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String addCompany(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
|
try {
|
FieldSetEntity fse = null;
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
if (bean != null) {
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
fse = reqp.getFormData();
|
}
|
if (bean == null || fse == null) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
}
|
// 判断表名是否正常
|
if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_ORG_LEVELS.equals(fse.getTableName())) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
}
|
orgLevelOperPermission(false,0,fse);
|
ISystemOrgLevelsService service=(ISystemOrgLevelsService) getProxyInstance(systemOrgLevelsService);
|
return OK_Add(service.addCompany(fse));
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(e.getCode(), e.getMessage());
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
e.printStackTrace();
|
return this.error(SystemCode.SYSTEM_ADD_COMPANY_FAIL.getValue(),
|
SystemCode.SYSTEM_ADD_COMPANY_FAIL.getText());
|
}
|
}
|
|
/**
|
* 公司更新接口
|
*
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/update-company/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
@Transactional
|
public String updateCompany(HttpServletRequest request) {
|
|
try {
|
FieldSetEntity fse = null;
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
if (bean != null) {
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
fse = reqp.getFormData();
|
}
|
if (bean == null || fse == null) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
}
|
|
// 判断表名是否正常
|
if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_ORG_LEVELS.equals(fse.getTableName())) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
}
|
orgLevelOperPermission(false,0,fse);
|
ISystemOrgLevelsService service = (ISystemOrgLevelsService) getProxyInstance(systemOrgLevelsService);
|
boolean succ = service.updateCompany(fse);
|
return succ ? OK()
|
: error(SystemCode.SYSTEM_COMANY_UPDATE_FAIL.getValue(),
|
SystemCode.SYSTEM_COMANY_UPDATE_FAIL.getText());
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
DataPoolCacheImpl.getInstance().reloadCodeManager(CmnConst.PRODUCT_SYS_ORG_LEVELS, "org_level_code");
|
DataPoolCacheImpl.getInstance().reloadCodeManager(CmnConst.PRODUCT_SYS_STAFFS, "tricode");
|
return error(e.getCode(), e.getMessage());
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
e.printStackTrace();
|
DataPoolCacheImpl.getInstance().reloadCodeManager(CmnConst.PRODUCT_SYS_ORG_LEVELS, "org_level_code");
|
DataPoolCacheImpl.getInstance().reloadCodeManager(CmnConst.PRODUCT_SYS_STAFFS, "tricode");
|
return this.error(SystemCode.SYSTEM_COMANY_UPDATE_FAIL.getValue(),
|
SystemCode.SYSTEM_COMANY_UPDATE_FAIL.getText());
|
}
|
}
|
|
/***
|
* 公司删除接口
|
*
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/delete-company/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String deleteCompany(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = null;
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
if (bean != null) {
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
fse = reqp.getFormData();
|
}
|
if (bean == null || fse == null) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
}
|
// 判断表名是否正常
|
if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_ORG_LEVELS.equals(fse.getTableName())) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
}
|
orgLevelOperPermission(false,0, fse);
|
ISystemOrgLevelsService service=(ISystemOrgLevelsService)getProxyInstance(systemOrgLevelsService);
|
return service.deleteCompany(fse) ? OK()
|
: error(SystemCode.SYSTEM_COMANY_DELETE_FAIL.getValue(),
|
SystemCode.SYSTEM_COMANY_DELETE_FAIL.getText());
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(e.getCode(), e.getMessageInfo());
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
e.printStackTrace();
|
return this.error(SystemCode.SYSTEM_COMANY_DELETE_FAIL.getValue(),
|
SystemCode.SYSTEM_COMANY_DELETE_FAIL.getText());
|
}
|
}
|
|
/**
|
* 查询部门列表 根据公司
|
*
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/list-department/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String listDepartment(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = null;
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
if (bean != null) {
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
fse = reqp.getFormData();
|
}
|
if (bean == null || fse == null) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
}
|
// 判断表名是否正常
|
if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_ORG_LEVELS.equals(fse.getTableName())) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
}
|
// // 判断参数是否正常
|
// if (StringUtils.isEmpty(fse.getString(CmnConst.ORG_LEVEL_CODE))) {
|
// SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
|
// return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
|
// }
|
|
// 添加机构类型
|
fse.setValue(CmnConst.ORG_LEVEL_TYPE, 1);
|
return ResultInfo.success(systemOrgLevelsService.listOrgLevels(fse));
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(e.getCode(), e.getMessage());
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
e.printStackTrace();
|
return this.error(SystemCode.SYSTEM_GET_DEPARTMENTLIST_FAIL.getValue(),
|
SystemCode.SYSTEM_GET_DEPARTMENTLIST_FAIL.getText());
|
}
|
}
|
|
/**
|
* 查询部门详情
|
*
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/find-department/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String findDepartment(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = null;
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
if (bean != null) {
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
fse = reqp.getFormData();
|
}
|
if (bean == null || fse == null) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
}
|
// 判断表名是否正常
|
if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_ORG_LEVELS.equals(fse.getTableName())) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
}
|
orgLevelOperPermission(false,1, fse);
|
// 判断参数是否正常
|
if (StringUtils.isEmpty(fse.getString(CmnConst.UUID))) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
|
return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
|
}
|
// 添加机构类型
|
fse.setValue(CmnConst.ORG_LEVEL_TYPE, 1);
|
return OK_List(systemOrgLevelsService.findOrgLevel(fse));
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(e.getCode(), e.getMessageInfo());
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
e.printStackTrace();
|
return this.error(SystemCode.SYSTEM_GET_DEPARTMENTINFO_FAIL.getValue(),
|
SystemCode.SYSTEM_GET_DEPARTMENTINFO_FAIL.getText());
|
}
|
}
|
|
/***
|
* 部门新增接口
|
*
|
* @param request
|
* @param response
|
* @param session
|
* @return
|
*/
|
@RequestMapping(value = "/add-department/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String addDepartment(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
|
try {
|
FieldSetEntity fse = null;
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
if (bean != null) {
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
fse = reqp.getFormData();
|
}
|
if (bean == null || fse == null) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
}
|
// 判断表名是否正常
|
if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_ORG_LEVELS.equals(fse.getTableName())) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
}
|
orgLevelOperPermission(false,1, fse);
|
// 判断参数是否正常
|
if (StringUtils.isEmpty(fse.getString(CmnConst.ORG_LEVEL_CODE_PARENT))) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
|
return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
|
}
|
|
ISystemOrgLevelsService service=(ISystemOrgLevelsService) getProxyInstance(systemOrgLevelsService);
|
String uuid = service.addDepartment(fse);
|
return OK_Add(uuid);
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(e.getCode(), e.getMessage());
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
e.printStackTrace();
|
return this.error(SystemCode.SYSTEM_ADD_DEPARTMENT_FAIL.getValue(),
|
SystemCode.SYSTEM_ADD_DEPARTMENT_FAIL.getText());
|
}
|
}
|
|
/**
|
* 部门更新接口
|
*
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/update-department/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String updateDepartment(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = null;
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
if (bean != null) {
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
fse = reqp.getFormData();
|
}
|
if (bean == null || fse == null) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
}
|
orgLevelOperPermission(false,1, fse);
|
// 判断表名是否正常
|
if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_ORG_LEVELS.equals(fse.getTableName())) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
}
|
ISystemOrgLevelsService service =(ISystemOrgLevelsService) getProxyInstance(systemOrgLevelsService);
|
boolean succ = service.updateDepartment(fse);
|
return succ ? OK()
|
: error(SystemCode.SYSTEM_DEPARTMENT_UPDATE_FAIL.getValue(),
|
SystemCode.SYSTEM_DEPARTMENT_UPDATE_FAIL.getText());
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(e.getCode(), e.getMessage());
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
e.printStackTrace();
|
return this.error(SystemCode.SYSTEM_DEPARTMENT_UPDATE_FAIL.getValue(),
|
SystemCode.SYSTEM_DEPARTMENT_UPDATE_FAIL.getText());
|
}
|
}
|
|
/***
|
* 部门删除接口
|
*
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/delete-department/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String deleteDepartment(HttpServletRequest request) {
|
boolean resulst = false;
|
try {
|
FieldSetEntity fse = null;
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
if (bean != null) {
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
fse = reqp.getFormData();
|
}
|
if (bean == null || fse == null) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
}
|
// 判断表名是否正常
|
if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_ORG_LEVELS.equals(fse.getTableName())) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
|
}
|
orgLevelOperPermission(false,1, fse);
|
// 存在下级不能删除
|
if (!systemOrgLevelsService.verifyOrgChildExists(fse.getString(CmnConst.UUID))) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_ORG_UPDATE_EXIST_CHILDREN_FAIL.getValue(),
|
SystemCode.SYSTEM_ORG_UPDATE_EXIST_CHILDREN_FAIL.getText());
|
return this.error(SystemCode.SYSTEM_ORG_UPDATE_EXIST_CHILDREN_FAIL.getValue(),
|
SystemCode.SYSTEM_ORG_UPDATE_EXIST_CHILDREN_FAIL.getText());
|
} else {
|
resulst = systemOrgLevelsService.delete(CmnConst.PRODUCT_SYS_ORG_LEVELS,
|
new String[] { fse.getString(CmnConst.UUID) });
|
}
|
if(resulst){
|
return OK();
|
}
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_DEPARTMENT_DELETE_FAIL.getValue(),SystemCode.SYSTEM_DEPARTMENT_DELETE_FAIL.getText());
|
return error(SystemCode.SYSTEM_DEPARTMENT_DELETE_FAIL.getValue(),SystemCode.SYSTEM_DEPARTMENT_DELETE_FAIL.getText());
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(e.getCode(), e.getMessage());
|
} catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(SystemCode.SYSTEM_DEPARTMENT_DELETE_FAIL.getValue(),
|
SystemCode.SYSTEM_DEPARTMENT_DELETE_FAIL.getText());
|
}
|
}
|
public void orgLevelOperPermission(boolean superAdmin,int org_level_type, FieldSetEntity fse) throws BaseException {
|
SystemUser currentUser = SpringMVCContextHolder.getCurrentUser();
|
if (currentUser == null || !currentUser.isManager()) {
|
throw new BaseException(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText(), this.getClass(), "private String systemVersionOperPermission");
|
}
|
System.out.println(currentUser.getOrg_level_uuid());
|
Integer userType = currentUser.getUserType();
|
if (currentUser.getUserType() == 1 && superAdmin && org_level_type==0) {
|
// 超级管理员
|
return;
|
} else {
|
// 其他管理员
|
FieldSetEntity currentCompany = currentUser.getCurrentCompany();
|
if (currentCompany == null || StringUtils.isEmpty(currentCompany.getString(CmnConst.ORG_LEVEL_CODE))) {
|
throw new BaseException(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText(), this.getClass(), "private void orgLevelOperPermission(boolean superAdmin)");
|
}
|
String uuid = currentCompany.getUUID();
|
String filter = " uuid ='"+uuid+"' ";
|
// 平台管理员
|
if (userType == 4 && org_level_type==0) {
|
String clientUuid = currentUser.getClientUuid();
|
if (!StringUtils.isEmpty(clientUuid)) {
|
filter += " or (client_uuid in ('" + clientUuid.replace(",", "','") + "') and org_level_code = (select org_level_code FROM product_sys_org_levels where uuid ='" + fse.getUUID() + "'))";
|
}
|
} else if (userType == 3 || userType == 2) {
|
// 隐藏管理员
|
filter += " or ( uuid='" + fse.getUUID()+"' and org_level_code in ( select org_level_code FROM product_sys_org_levels where org_level_code like concat((select org_level_code FROM product_sys_org_levels where uuid = '" + uuid + "'),'%')) )";
|
} else {
|
throw new BaseException(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText(), this.getClass(), "private void orgLevelOperPermission(boolean superAdmin)");
|
}
|
if (!permissionService.validDataPermission(fse, filter)) {
|
throw new BaseException(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText(), this.getClass(), "private void orgLevelOperPermission(boolean superAdmin)");
|
}
|
}
|
}
|
}
|