package com.product.admin.controller;
|
|
import com.product.admin.config.CmnConst;
|
import com.product.admin.config.SystemCode;
|
import com.product.admin.service.CompanyUserGroupService;
|
import com.product.common.lang.StringUtils;
|
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.spring.context.SpringMVCContextHolder;
|
import com.product.module.sys.version.ApiVersion;
|
import com.product.util.BaseUtil;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
/**
|
* @Author cheng
|
* @Description 单位用户组
|
* @Date 2021/6/29 14:22
|
* @Version 1.0
|
*/
|
@RestController
|
@RequestMapping("/api/company")
|
public class CompanyUserGroupController extends AbstractBaseController {
|
|
@Autowired
|
CompanyUserGroupService companyUserGroupService;
|
|
/**
|
* 单位用户组详情列表
|
*
|
* @param request
|
* @return
|
*/
|
@PostMapping("/get-company-user-group/{version}")
|
@ApiVersion(1)
|
public String getCompanyUserGroup(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_COMPANY_USER_GROUP.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());
|
}
|
|
return BaseUtil.success(companyUserGroupService.getCompanyUserGroup(fse), null);
|
} catch (BaseException e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.GET_COMPANY_USER_GROUP_FIAL.getValue(), SystemCode.GET_COMPANY_USER_GROUP_FIAL.getText() + e.getMessage());
|
}
|
}
|
|
/**
|
* 单位用户组保存
|
*
|
* @param request
|
* @return
|
*/
|
@PostMapping("/save-company-user-group/{version}")
|
@ApiVersion(1)
|
public String saveCompanyUserGroup(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_COMPANY_USER_GROUP.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());
|
}
|
|
return OK_Add(companyUserGroupService.saveCompanyUserGroup(fse));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.SAVE_COMPANY_USER_GROUP_FIAL.getValue(), SystemCode.SAVE_COMPANY_USER_GROUP_FIAL.getText() + e.getMessage());
|
}
|
}
|
|
/**
|
* 删除单位人员组
|
*
|
* @param request
|
* @return
|
*/
|
@PostMapping("/del-company-user-group/{version}")
|
@ApiVersion(1)
|
public String deleteCompanyUserGroup(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_COMPANY_USER_GROUP.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());
|
}
|
|
return companyUserGroupService.deleteCompanyUserGroup(fse) ? OK() : error(SystemCode.DEL_COMPANY_USER_GROUP_FIAL.getValue(), SystemCode.DEL_COMPANY_USER_GROUP_FIAL.getText());
|
} catch (BaseException e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.DEL_COMPANY_USER_GROUP_FIAL.getValue(), SystemCode.DEL_COMPANY_USER_GROUP_FIAL.getText() + e.getMessage());
|
}
|
}
|
|
@PostMapping("/get-staff-levelAll/{version}")
|
@ApiVersion(1)
|
public String getStaffOrgLevelAll(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 (StringUtils.isEmpty(fse.getString("user_ids"))) {
|
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());
|
}
|
|
return OK_List(companyUserGroupService.getStaffLevelAll(fse));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.GET_STAFF_LEVEL_ALL_FIAL.getValue(), SystemCode.GET_STAFF_LEVEL_ALL_FIAL.getText() + e.getMessage());
|
}
|
}
|
}
|