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.common.lang.StringUtils;
|
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.org.admin.config.SystemCode;
|
import com.product.org.admin.service.StaffRegularEmployeeService;
|
import com.product.org.admin.service.idel.IStaffRegularEmployeeService;
|
|
/**
|
* 人员转正
|
* Copyright LX-BASE
|
* @Title: LX-BASE-
|
* @Project: StaffRegularEmployeeController
|
* @Date: 2020-08-10 10:34
|
* @Author: 杜洪波
|
* @Description:
|
*/
|
@RestController
|
@RequestMapping("/api/staffRegularEmployee")
|
public class StaffRegularEmployeeController extends AbstractBaseController{
|
|
@Autowired
|
private StaffRegularEmployeeService staffRegularEmployeeService;
|
|
@Autowired
|
PermissionService permissionService;
|
|
/**
|
* 人员转正信息列表
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/list-regularEmployee/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String listStaffRegularEmployee(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(CmnConst.PAGESIZE))|| StringUtils.isEmpty(fse.getString(CmnConst.CPAGE))) {
|
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());
|
}
|
DataTableEntity dt=staffRegularEmployeeService.listStaffRegularEmployee(fse.getInteger("cpage"), fse.getInteger("pagesize"),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_REGULAREEMPLOYEE_ERROR.getValue(),CmnCode.STAFF_REGULAREEMPLOYEE_ERROR.getText()+e.getMessage());
|
}
|
}
|
|
/**
|
* 人员转正信息详情
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/find-regularEmployee/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String findStaffRegularEmployee(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("uuid"))) { //杜洪波 updateTime 2020-12-17 09:48:00
|
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("product_sys_staff_complete_probation",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());
|
}
|
FieldSetEntity fs=staffRegularEmployeeService.findStaffRegularEmployee(fse.getString("uuid"));
|
return OK_List(fs);
|
} 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_REGULAREEMPLOYEE_ERROR.getValue(),CmnCode.STAFF_REGULAREEMPLOYEE_ERROR.getText()+e.getMessage());
|
}
|
}
|
|
/**
|
* 新增人员转正信息
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/add-regularEmployee/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String addStaffRegularEmployee(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());
|
|
IStaffRegularEmployeeService service=(IStaffRegularEmployeeService)getProxyInstance(staffRegularEmployeeService);
|
String uuid=service.addRegularEmployee(fse);
|
return OK_Add(uuid);
|
} 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_REGULAREEMPLOYEE_ERROR.getValue(),CmnCode.STAFF_REGULAREEMPLOYEE_ERROR.getText()+e.getMessage());
|
}
|
}
|
|
/**
|
* 修改人员转正信息
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/update-regularEmployee/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String updateStaffRegularEmployee(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("product_sys_staff_complete_probation",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.UPDATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
|
fse.setValue(CmnConst.UPDATED_UTC_DATETIME, new Date());
|
boolean succ=staffRegularEmployeeService.updateRegularEmployee(fse);
|
if (succ) {
|
return OK();
|
}
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_STAFF_REGULAR_EMPLOYEE_UPDATE_FAIL.getValue(), SystemCode.SYSTEM_STAFF_REGULAR_EMPLOYEE_UPDATE_FAIL.getText());
|
return error(SystemCode.SYSTEM_STAFF_REGULAR_EMPLOYEE_UPDATE_FAIL.getValue(), SystemCode.SYSTEM_STAFF_REGULAR_EMPLOYEE_UPDATE_FAIL.getText());
|
} 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_REGULAREEMPLOYEE_ERROR.getValue(),CmnCode.STAFF_REGULAREEMPLOYEE_ERROR.getText()+e.getMessage());
|
}
|
}
|
|
/**
|
* 删除人员转正信息
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/delete-regularEmployee/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String deleteStaffRegularEmployee(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("product_sys_staff_complete_probation",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());
|
}
|
IStaffRegularEmployeeService service=(IStaffRegularEmployeeService)getProxyInstance(staffRegularEmployeeService);
|
boolean succ=service.deleteRegularEmployee(fse.getString("uuid"));
|
if (succ) {
|
return OK();
|
}
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_STAFF_REGULAR_EMPLOYEE_DELETE_FAIL.getValue(), SystemCode.SYSTEM_STAFF_REGULAR_EMPLOYEE_DELETE_FAIL.getText());
|
return error(SystemCode.SYSTEM_STAFF_REGULAR_EMPLOYEE_DELETE_FAIL.getValue(), SystemCode.SYSTEM_STAFF_REGULAR_EMPLOYEE_DELETE_FAIL.getText());
|
} 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_REGULAREEMPLOYEE_ERROR.getValue(),CmnCode.STAFF_REGULAREEMPLOYEE_ERROR.getText()+e.getMessage());
|
}
|
}
|
}
|