| | |
| | | package com.product.file.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | 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; |
| | |
| | | @Autowired |
| | | public FileManagerService fileManagerService; |
| | | |
| | | |
| | | /** |
| | | * @param uuid |
| | | * @param response |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 文件记录-新增 |
| | | * |
| | | * @param request 请求 |
| | | * @return 结果 |
| | | */ |
| | | @RequestMapping(value = "/add-file-record-plan/{version}", method = RequestMethod.POST) |
| | | @ApiVersion(1) |
| | | public String addFileRecordPlan(HttpServletRequest request) { |
| | | try { |
| | | FieldSetEntity fse = null; |
| | | Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); |
| | | RequestParameterEntity rpe = (RequestParameterEntity) bean; |
| | | if (null != rpe && null != rpe.getFormData()) { |
| | | fse = rpe.getFormData(); |
| | | } |
| | | if (fse == null) { |
| | | SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText()); |
| | | return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText()); |
| | | } |
| | | FieldSetEntity fs = fileManagerService.addFileRecordPlan(fse); |
| | | return fs != null ? this.OK_List(fs) : this.error(FileCode.ADD_FILE_RECORD_FAIL.getValue(), FileCode.ADD_FILE_RECORD_FAIL.getText()); |
| | | } catch (BaseException e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | return this.error(e.getCode(), e.getMessageInfo()); |
| | | } catch (Exception e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | e.printStackTrace(); |
| | | return error(FileCode.ADD_FILE_RECORD_FAIL.getValue(), FileCode.ADD_FILE_RECORD_FAIL.getText()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 文件记录-文件新增结果回调 |
| | | * |
| | | * @param request 请求 |
| | | * @return 结果 |
| | | */ |
| | | @RequestMapping(value = "/add-file-callback/{version}", method = RequestMethod.POST) |
| | | @ApiVersion(1) |
| | | public String addFileCallback(HttpServletRequest request) { |
| | | try { |
| | | FieldSetEntity fse = null; |
| | | Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); |
| | | RequestParameterEntity rpe = (RequestParameterEntity) bean; |
| | | if (null != rpe && null != rpe.getFormData()) { |
| | | fse = rpe.getFormData(); |
| | | } |
| | | if (fse == null) { |
| | | SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText()); |
| | | return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText()); |
| | | } |
| | | JSONObject data = fileManagerService.addFileCallback(fse); |
| | | JSONObject result = new JSONObject(); |
| | | result.put("data", data); |
| | | result.put("msg", FileCode.SUCCESS.getText()); |
| | | result.put("code", "200"); |
| | | result.put("status", "success"); |
| | | return result.toString(); |
| | | } catch (BaseException e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | return this.error(e.getCode(), e.getMessageInfo()); |
| | | } catch (Exception e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | e.printStackTrace(); |
| | | return error(FileCode.ADD_FILE_CALLBACK_FAIL.getValue(), FileCode.ADD_FILE_CALLBACK_FAIL.getText()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 文件记录-删除准备(状态修改) |
| | | * |
| | | * @param request 请求 |
| | | * @return 结果 |
| | | */ |
| | | @RequestMapping(value = "/del-file-record-plan/{version}", method = RequestMethod.POST) |
| | | @ApiVersion(1) |
| | | public String delFileRecordPlan(HttpServletRequest request) { |
| | | try { |
| | | FieldSetEntity fse = null; |
| | | Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); |
| | | RequestParameterEntity rpe = (RequestParameterEntity) bean; |
| | | if (null != rpe && null != rpe.getFormData()) { |
| | | fse = rpe.getFormData(); |
| | | } |
| | | if (fse == null) { |
| | | SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText()); |
| | | return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText()); |
| | | } |
| | | FieldSetEntity fs = fileManagerService.delFileRecordPlan(fse); |
| | | |
| | | return fs != null ? this.OK_List(fs) : this.error(FileCode.DELETE_FILE_PLAN_FIAL.getValue(), FileCode.DELETE_FILE_PLAN_FIAL.getText()); |
| | | } catch (BaseException e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | return this.error(e.getCode(), e.getMessageInfo()); |
| | | } catch (Exception e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | e.printStackTrace(); |
| | | return error(FileCode.DELETE_FILE_PLAN_FIAL.getValue(), FileCode.DELETE_FILE_PLAN_FIAL.getText()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 文件记录-文件新增结果回调 |
| | | * |
| | | * @param request 请求 |
| | | * @return 结果 |
| | | */ |
| | | @RequestMapping(value = "/del-file-callback/{version}", method = RequestMethod.POST) |
| | | @ApiVersion(1) |
| | | public String delFileCallback(HttpServletRequest request) { |
| | | try { |
| | | FieldSetEntity fse = null; |
| | | Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); |
| | | RequestParameterEntity rpe = (RequestParameterEntity) bean; |
| | | if (null != rpe && null != rpe.getFormData()) { |
| | | fse = rpe.getFormData(); |
| | | } |
| | | if (fse == null) { |
| | | SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText()); |
| | | return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText()); |
| | | } |
| | | JSONObject data = fileManagerService.delFileCallback(fse); |
| | | JSONObject result = new JSONObject(); |
| | | result.put("data", data); |
| | | result.put("msg", FileCode.SUCCESS.getText()); |
| | | result.put("code", "200"); |
| | | result.put("status", "success"); |
| | | return result.toString(); |
| | | } catch (BaseException e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | return this.error(e.getCode(), e.getMessageInfo()); |
| | | } catch (Exception e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | e.printStackTrace(); |
| | | return error(FileCode.DELETE_FILE_CALLBACK_FIAL.getValue(), FileCode.DELETE_FILE_CALLBACK_FIAL.getText()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取客户上传的文件总大小 |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取文件记录信息 |
| | | * |
| | | * @return 结果 |
| | | */ |
| | | @RequestMapping(value = "/get-file-info/{version}", method = RequestMethod.POST) |
| | | @ApiVersion(1) |
| | | public String getFileInfo(HttpServletRequest request) { |
| | | try { |
| | | FieldSetEntity fse = null; |
| | | Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); |
| | | RequestParameterEntity rpe = (RequestParameterEntity) bean; |
| | | if (null != rpe && null != rpe.getFormData()) { |
| | | fse = rpe.getFormData(); |
| | | } |
| | | if (fse == null) { |
| | | SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText()); |
| | | return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText()); |
| | | } |
| | | return BaseUtil.success(fileManagerService.getFileInfo(fse), null); |
| | | } catch (Exception e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | e.printStackTrace(); |
| | | return error(FileCode.CLEAR_NO_USED_DATA_FAIL.getValue(), FileCode.CLEAR_NO_USED_DATA_FAIL.getText()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 文件刪除 |