package com.product.org.admin.controller;
|
|
import java.util.Date;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
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.product.core.config.CoreConst;
|
import com.product.core.controller.support.AbstractBaseController;
|
import com.product.core.entity.DataTableEntity;
|
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.module.sys.config.SystemErrorCode;
|
import com.product.module.sys.version.ApiVersion;
|
import com.product.org.admin.config.CmnCode;
|
import com.product.org.admin.config.CmnConst;
|
import com.product.admin.config.SystemCode;
|
import com.product.common.lang.StringUtils;
|
import com.product.org.admin.service.ChangeDimissionService;
|
import com.product.org.admin.service.idel.IChangeDimissionService;
|
|
/**
|
* Copyright LX-BASE
|
*
|
* @Title: ChangeDimissionController
|
* @Project: LX-BASE-SERVER
|
* @Date: 2020年6月10日 下午3:46:32
|
* @Author: 郑盟
|
* @Description: 离职表配置
|
*/
|
@RestController
|
@RequestMapping("/api/dimission")
|
public class ChangeDimissionController extends AbstractBaseController {
|
|
|
@Autowired
|
public ChangeDimissionService changeDimissionService;
|
|
@Autowired
|
PermissionService permissionService;
|
|
/**
|
* 离职申请详情
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/find-dimission/{version}", method = RequestMethod.POST)
|
public String findDimission(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());
|
}
|
|
String uuids = fse.getString("uuid");
|
//验证UUID是否为空
|
if (StringUtils.isEmpty(uuids)) {
|
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());
|
}
|
//数据操作的权限验证
|
if(!permissionService.validDataPermission(CmnConst.PRODUCT_SYS_STAFF_TERMINATION,uuids,CoreConst.DATA_PERMISSION_VALID_TYPE_ORG)) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(),SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText());
|
return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText());
|
}
|
FieldSetEntity findDict = changeDimissionService.findDimission(uuids);
|
return OK_List(findDict);
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(e.getCode(), e.getMessageInfo());
|
} catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(CmnCode.STAFF_DIMISSION_ERROR.getValue(),CmnCode.STAFF_DIMISSION_ERROR.getText()+e.getMessage());
|
}
|
}
|
|
/**
|
* 离职申请列表
|
*/
|
@RequestMapping(value = "/list-dimission/{version}", method = RequestMethod.POST)
|
public String listDimission(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());
|
}
|
DataTableEntity dt = changeDimissionService.listDimission(fse);
|
return OK_List(dt);
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(e.getCode(), e.getMessageInfo());
|
} catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(CmnCode.STAFF_DIMISSION_ERROR.getValue(),CmnCode.STAFF_DIMISSION_ERROR.getText()+e.getMessage());
|
}
|
}
|
|
/**
|
* 离职申请新增
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/add-dimission/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String addDimission(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());
|
}
|
fse.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
|
fse.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
|
|
IChangeDimissionService service=(IChangeDimissionService)getProxyInstance(changeDimissionService);
|
String uuid = service.addDimission(fse);
|
if (StringUtils.isEmpty(uuid)) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_DIMISSION_ADD_FAIL.getValue(),SystemCode.SYSTEM_DIMISSION_ADD_FAIL.getText());
|
return error(SystemCode.SYSTEM_DIMISSION_ADD_FAIL.getValue(),SystemCode.SYSTEM_DIMISSION_ADD_FAIL.getText());
|
}
|
return OK_Add(uuid);
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(e.getCode(), e.getMessageInfo());
|
} catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(CmnCode.STAFF_DIMISSION_ERROR.getValue(),CmnCode.STAFF_DIMISSION_ERROR.getText()+e.getMessage());
|
}
|
}
|
|
/**
|
* 根据人员UUID获取人员信息
|
*/
|
@RequestMapping(value = "/find-staff/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String getStaff(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("staff_uuid"))) { //杜洪波 updateTime 2020-12-17 09:48:00
|
return error(SystemCode.SYSTEM_STAFF_FIND_FAIL.getValue(), SystemCode.SYSTEM_STAFF_FIND_FAIL.getText());
|
}
|
FieldSetEntity fss = changeDimissionService.getStaff(fse.getString("staff_uuid"));
|
return OK_List(fss);
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(e.getCode(), e.getMessageInfo());
|
} catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(CmnCode.STAFF_DIMISSION_ERROR.getValue(),CmnCode.STAFF_DIMISSION_ERROR.getText()+e.getMessage());
|
}
|
}
|
|
/**
|
* 离职申请修改
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/update-dimission/{version}", method = RequestMethod.POST)
|
public String updateDimission(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(!permissionService.validDataPermission(CmnConst.PRODUCT_SYS_STAFF_TERMINATION,fse.getUUID(),CoreConst.DATA_PERMISSION_VALID_TYPE_ORG)) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(),SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText());
|
return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText());
|
}
|
fse.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
|
fse.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
|
|
boolean update = changeDimissionService.updateDimission(fse);
|
if (update) {
|
return OK();
|
}
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_DIMISSION_UPDATE_FAIL.getValue(),SystemCode.SYSTEM_DIMISSION_UPDATE_FAIL.getText());
|
return error(SystemCode.SYSTEM_DIMISSION_UPDATE_FAIL.getValue(),SystemCode.SYSTEM_DIMISSION_UPDATE_FAIL.getText());
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(e.getCode(), e.getMessageInfo());
|
} catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(CmnCode.STAFF_DIMISSION_ERROR.getValue(),CmnCode.STAFF_DIMISSION_ERROR.getText()+e.getMessage());
|
}
|
}
|
|
/**
|
* 离职申请删除
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/delete-dimission/{version}", method = RequestMethod.POST)
|
public String deleteDimission(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(!permissionService.validDataPermission(CmnConst.PRODUCT_SYS_STAFF_TERMINATION,fse.getUUID(),CoreConst.DATA_PERMISSION_VALID_TYPE_ORG)) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(),SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText());
|
return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText());
|
}
|
|
IChangeDimissionService service=(IChangeDimissionService)getProxyInstance(changeDimissionService);
|
boolean succ = service.deleteDimission(fse.getString("uuid") );
|
if (succ) {
|
return OK();
|
}
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_DIMISSION_DELETE_FAIL.getValue(),SystemCode.SYSTEM_DIMISSION_DELETE_FAIL.getText());
|
return error(SystemCode.SYSTEM_DIMISSION_DELETE_FAIL.getValue(),SystemCode.SYSTEM_DIMISSION_DELETE_FAIL.getText());
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(SystemCode.SYSTEM_DIMISSION_DELETE_FAIL.getValue(), SystemCode.SYSTEM_DIMENSION_DELETE_FAIL.getText());
|
} catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(CmnCode.STAFF_DIMISSION_ERROR.getValue(),CmnCode.STAFF_DIMISSION_ERROR.getText()+e.getMessage()+e.getMessage());
|
}
|
}
|
|
}
|