package com.product.org.admin.controller; 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.admin.config.SystemCode; 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.service.DimissionHandoverService; import com.product.org.admin.service.idel.IDimissionHandoverService; /** * Copyright LX-BASE * * @Title: DimissionHandoverController * @Project: LX-BASE-SERVER * @Date: 2020年6月11日 下午5:23:36 * @Author: 郑盟 * @Description: 离职交接 */ @RestController @RequestMapping("/api/handover") public class DimissionHandoverController extends AbstractBaseController { @Autowired public DimissionHandoverService dimissionHandoverService; @Autowired PermissionService permissionService; /** * 离职交接详情 * @param request * @return */ @RequestMapping(value = "/find-handover/{version}", method = RequestMethod.POST) public String findHandover(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(fse,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 findHandover = dimissionHandoverService.findHandover(uuids); return OK_List(findHandover); } 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_HANDOVER_ERROR.getValue(),CmnCode.STAFF_DIMISSION_HANDOVER_ERROR.getText()+e.getMessage()); } } /** * 离职交接列表 * @param request * @return */ @RequestMapping(value = "/list-handover/{version}", method = RequestMethod.POST) public String listHandover(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 = dimissionHandoverService.listHandover(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_HANDOVER_ERROR.getValue(),CmnCode.STAFF_DIMISSION_HANDOVER_ERROR.getText()+e.getMessage()); } } /** * 离职交接新增 * @param request * @return */ @RequestMapping(value = "/add-handover/{version}", method = RequestMethod.POST) @ApiVersion(1) public String addHandover(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()); } boolean succ=dimissionHandoverService.addHandover(fse); return succ?OK():error(SystemCode.SYSTEM_HANDOVER_ADD_FAIL.getValue(),SystemCode.SYSTEM_HANDOVER_ADD_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_HANDOVER_ERROR.getValue(),CmnCode.STAFF_DIMISSION_HANDOVER_ERROR.getText()+e.getMessage()); } } /** * 离职交接更新 * @param request * @return */ @RequestMapping(value = "/update-handover/{version}", method = RequestMethod.POST) public String updateHandover(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(fse,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()); } IDimissionHandoverService service=(IDimissionHandoverService)getProxyInstance(dimissionHandoverService); boolean update = service.updateHandover(fse); return update?OK():error(SystemCode.SYSTEM_HANDOVER_UPDATE_FAIL.getValue(),SystemCode.SYSTEM_HANDOVER_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_HANDOVER_ERROR.getValue(),CmnCode.STAFF_DIMISSION_HANDOVER_ERROR.getText()+e.getMessage()); } } /** * 离职交接删除 * @param request * @return * @throws BaseException */ @RequestMapping(value = "/delete-handover/{version}", method = RequestMethod.POST) public String deleteHandover(HttpServletRequest request) throws BaseException { 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(fse,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()); } IDimissionHandoverService service=(IDimissionHandoverService)getProxyInstance(dimissionHandoverService); boolean delete = service.delectHandover(fse); return delete ? OK(): error(SystemCode.SYSTEM_HANDOVER_DELECT_FAIL.getValue(),SystemCode.SYSTEM_HANDOVER_DELECT_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_HANDOVER_ERROR.getValue(),CmnCode.STAFF_DIMISSION_HANDOVER_ERROR.getText()+e.getMessage()); } } }