package com.product.administration.controller; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; 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.administration.config.CmnConst; import com.product.administration.config.SystemCode; import com.product.administration.service.SendFileRegisterService; 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.module.sys.version.ApiVersion; /** * 发文登记薄 * @author 86151 * */ @RequestMapping("/api/send-file-register") @RestController public class SendFileRegisterController extends AbstractBaseController{ @Autowired SendFileRegisterService sendFileRegisterService; /** * 发文登记列表 * @param response * @param request * @return */ @RequestMapping(value = "/list-file-register/{version}", method = RequestMethod.POST) @ApiVersion(1) public String listFileRegister(HttpServletResponse response,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) { return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } //判断表名是否正常 if (!CmnConst.PRODUCT_OA_SEND_FILE.equals(fse.getTableName())) { return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } DataTableEntity dt=sendFileRegisterService.listFileRegister(fse.getInteger("cpage"),fse.getInteger("pagesize"),fse); return OK_List(dt); } catch (BaseException e) { e.printStackTrace(); return this.error(e.getCode(),e.getMessage()); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.SYSTEM_EARLY_WARNING_LIST_FAIL.getValue(), SystemCode.SYSTEM_EARLY_WARNING_LIST_FAIL.getText()+e.getMessage()); } } /** * 发文登记详情 * @param response * @param request * @return */ @RequestMapping(value = "/find-file-register/{version}", method = RequestMethod.POST) @ApiVersion(1) public String findFileRegister(HttpServletResponse response,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) { return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } //判断表名是否正常 if (!CmnConst.PRODUCT_OA_SEND_FILE.equals(fse.getTableName())) { return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } //判断uuid是否为空 if (StringUtils.isEmpty(fse.getUUID())) { return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } FieldSetEntity fseInfo=sendFileRegisterService.findFileRegister(fse.getUUID()); return OK_List(fseInfo); } catch (BaseException e) { e.printStackTrace(); return this.error(e.getCode(),e.getMessage()); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.SYSTEM_EARLY_WARNING_LIST_FAIL.getValue(), SystemCode.SYSTEM_EARLY_WARNING_LIST_FAIL.getText()+e.getMessage()); } } /** * 发文补登 * @param response * @param request * @return */ @RequestMapping(value="/add-file-register/{version}", method = RequestMethod.POST) @ApiVersion(1) public String addFileRegister(HttpServletResponse response, 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) { return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } //判断表名是否正常 if (!CmnConst.PRODUCT_OA_SEND_FILE.equals(fse.getTableName())) { return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } //判断uuid是否为空 if (StringUtils.isEmpty(fse.getUUID())) { return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } return OK_List(sendFileRegisterService.findFileRegister(fse.getUUID())); } catch (BaseException e) { e.printStackTrace(); return this.error(e.getCode(),e.getMessage()); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.SYSTEM_EARLY_WARNING_LIST_FAIL.getValue(), SystemCode.SYSTEM_EARLY_WARNING_LIST_FAIL.getText()+e.getMessage()); } } /** * 发文补登修改 * @param response * @param request * @return */ @RequestMapping(value="/update-file-register/{version}", method = RequestMethod.POST) @ApiVersion(1) public String updateFileRegister(HttpServletResponse response, 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) { return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } //判断表名是否正常 if (!CmnConst.PRODUCT_OA_SEND_FILE.equals(fse.getTableName())) { return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } //判断uuid是否为空 if (StringUtils.isEmpty(fse.getUUID())) { return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } boolean succ=sendFileRegisterService.updateFileRegister(fse); if (succ) { return OK(); }else { return error("SystemCode.FILE_RegIster_UPDATE_FAIL.getValue()", "SystemCode.FILE_RegIster_UPDATE_FAIL.getText()"); } } catch (BaseException e) { e.printStackTrace(); return this.error(e.getCode(),e.getMessage()); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.SYSTEM_EARLY_WARNING_LIST_FAIL.getValue(), SystemCode.SYSTEM_EARLY_WARNING_LIST_FAIL.getText()+e.getMessage()); } } /** * 发文删除 * @param response * @param request * @return */ @RequestMapping(value="/delete-file-register/{version}", method = RequestMethod.POST) @ApiVersion(1) public String deleteFileRegister(HttpServletResponse response, 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) { return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } //判断表名是否正常 if (!CmnConst.PRODUCT_OA_SEND_FILE.equals(fse.getTableName())) { return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } //判断uuid是否为空 if (StringUtils.isEmpty(fse.getUUID())) { return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } boolean succ=sendFileRegisterService.deleteFileRegister(fse.getUUID()); if (succ) { return OK(); }else { return error("SystemCode.FILE_RegIster_DELETE_FAIL.getValue()", "SystemCode.FILE_RegIster_DELETE_FAIL.getText()"); } } catch (BaseException e) { e.printStackTrace(); return this.error(e.getCode(),e.getMessage()); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.SYSTEM_EARLY_WARNING_LIST_FAIL.getValue(), SystemCode.SYSTEM_EARLY_WARNING_LIST_FAIL.getText()+e.getMessage()); } } }