| | |
| | | FILE_TRANSFER_BYTE_ARRAY_FAIL("文件转化为字节数组失败", ModuleEnum.FILE.getValue() + "062"), |
| | | CLUSTER_FILE_SYNC_ACCEPT_FAIL("集群文件同步方法接收失败", ModuleEnum.FILE.getValue() + "063"), |
| | | CHECK_PREVIEW_FAIL("验证能否在线预览失败", ModuleEnum.FILE.getValue() + "064"), |
| | | GET_USER_SIGNATURE_FAIL("获取用户签名失败", ModuleEnum.FILE.getValue() + "065"), |
| | | ; |
| | | |
| | | private String text; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 集群文件同步方法-接收 |
| | | * 预览验证 |
| | | * @return 结果 |
| | | */ |
| | | @RequestMapping(value = "/check-preview/{version}", method = RequestMethod.POST) |
| | |
| | | return error(FileCode.CHECK_PREVIEW_FAIL); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 预览验证 |
| | | * @return 结果 |
| | | */ |
| | | @RequestMapping(value = "/get-signature/{version}", method = RequestMethod.POST) |
| | | @ApiVersion(1) |
| | | public String getSignature(HttpServletRequest request, HttpServletResponse response) { |
| | | 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 OK(fileManagerService.getSignature(fse)); |
| | | } catch (BaseException e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | e.printStackTrace(); |
| | | return error(e.getCode(), e.getMessage()); |
| | | } catch (Exception e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | e.printStackTrace(); |
| | | return error(FileCode.GET_USER_SIGNATURE_FAIL); |
| | | } |
| | | } |
| | | } |
| | |
| | | import okhttp3.MediaType; |
| | | import okhttp3.MultipartBody; |
| | | import okhttp3.RequestBody; |
| | | import org.apache.commons.codec.binary.Base64; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | String fileFinalName = ""; |
| | | for (Map.Entry<Object, Object> entry : map.entrySet()) { |
| | | fieldFse = fieldMetaEntity.getFieldMeta(fieldName); |
| | | if (fieldFse == null || !Arrays.asList(CmnConst.ATTACHMENT_TYPE, "file-image", FieldType.FILE_ATTACHMENT.getDictValue()).contains(fieldFse.getString(CmnConst.FIELD_TYPE))) { |
| | | if (fieldFse == null || !Arrays.asList(CmnConst.ATTACHMENT_TYPE, "file-image", FieldType.FILE_ATTACHMENT.getDictValue(), FieldType.SIGNATURE.getDictValue()).contains(fieldFse.getString(CmnConst.FIELD_TYPE))) { |
| | | fse.setValue(entry.getKey().toString(), null); |
| | | continue; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | boolean saveInDbFlag = FieldType.FILE_ATTACHMENT.getDictValue().equals(fieldFse.getString("field_type")); |
| | | boolean saveInDbFlag = FieldType.checkSaveInDB(fieldFse.getString("field_type")); |
| | | if (!saveInDbFlag) { |
| | | fileFinalName = FileUtils.uploadFile(tempFile, templateType, clientUuid); |
| | | } else { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取用户签名 |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | public String getSignature(FieldSetEntity fse) throws BaseException { |
| | | String bytes = Base64.encodeBase64String(getFileContent(fse.getUUID())); |
| | | if (bytes == null) { |
| | | return null; |
| | | } |
| | | return "data:image/png;base64," + bytes; |
| | | } |
| | | |
| | | /** |
| | | * 根据附件uuid获取文件 |
| | | * 用完之后需要删除返回的 file (临时文件) |
| | | * |