From d91068f8691c7869d8f5d895e4df39f725295007 Mon Sep 17 00:00:00 2001 From: zhizhi wu <2377881365@qq.com> Date: Tue, 23 Jun 2020 15:39:24 +0800 Subject: [PATCH 1/2] wps --- .../java/com/ccsens/tall/bean/dto/WpsDto.java | 76 +++++++++---------- .../ccsens/tall/bean/vo/ProjectMessageVo.java | 2 +- .../com/ccsens/tall/web/WpsController.java | 28 ++++--- 3 files changed, 57 insertions(+), 49 deletions(-) diff --git a/tall/src/main/java/com/ccsens/tall/bean/dto/WpsDto.java b/tall/src/main/java/com/ccsens/tall/bean/dto/WpsDto.java index 5b1f93cc..82150847 100644 --- a/tall/src/main/java/com/ccsens/tall/bean/dto/WpsDto.java +++ b/tall/src/main/java/com/ccsens/tall/bean/dto/WpsDto.java @@ -16,18 +16,20 @@ import javax.validation.constraints.NotNull; @Data @ApiModel("wps相关请求参数") public class WpsDto { + private String _w_signature; + private String appid; + + @ApiModel("回调通知请求") @Data public static class Notify{ @NotNull @ApiModelProperty("请求签名") - @JsonProperty("_w_signature") - private String signature; + private String _w_signature; @NotNull @ApiModelProperty("应用id") - @JsonProperty("_w_appid") - private String appId; + private String _w_appid; } @ApiModel("回调通知请求body") @Data @@ -39,23 +41,16 @@ public class WpsDto { @ApiModelProperty("信息内容") private String body; } - public static class NotifyResult{ - private Integer counts; - private String result; - private String detail; - } @ApiModel("获取所有历史版本文件信息请求") @Data public static class FileHistory{ @NotNull @ApiModelProperty("请求签名") - @JsonProperty("_w_signature") - private String signature; + private String _w_signature; @NotNull @ApiModelProperty("应用id") - @JsonProperty("_w_appid") - private String appId; + private String _w_appid; } @ApiModel("获取所有历史版本文件信息body请求") @Data @@ -76,12 +71,10 @@ public class WpsDto { public static class FileRename{ @NotNull @ApiModelProperty("请求签名") - @JsonProperty("_w_signature") - private String signature; + private String _w_signature; @NotNull @ApiModelProperty("应用id") - @JsonProperty("_w_appid") - private String appId; + private String _w_appid; } @ApiModel("获取特定版本的文件信息请求") @Data @@ -96,12 +89,10 @@ public class WpsDto { public static class FileVersion{ @NotNull @ApiModelProperty("请求签名") - @JsonProperty("_w_signature") - private String signature; + private String _w_signature; @NotNull @ApiModelProperty("应用id") - @JsonProperty("_w_appid") - private String appId; + private String _w_appid; } @ApiModel("获取文件元数据请求") @@ -109,12 +100,26 @@ public class WpsDto { public static class FileInfo{ @NotNull @ApiModelProperty("请求签名") - @JsonProperty("_w_signature") - private String signature; + private String _w_signature; @NotNull @ApiModelProperty("应用id") - @JsonProperty("_w_appid") - private String appId; + private String _w_appid; + + public String get_w_signature() { + return _w_signature; + } + + public void set_w_signature(String _w_signature) { + this._w_signature = _w_signature; + } + + public String get_w_appid() { + return _w_appid; + } + + public void set_w_appid(String _w_appid) { + this._w_appid = _w_appid; + } } @ApiModel("上传文件新版本请求") @@ -122,15 +127,12 @@ public class WpsDto { public static class FileSave{ @NotNull @ApiModelProperty("请求签名") - @JsonProperty("_w_signature") - private String signature; + private String _w_signature; @NotNull @ApiModelProperty("应用id") - @JsonProperty("_w_appid") - private String appId; + private String _w_appid; @ApiModelProperty("业务处理路径") - @JsonProperty("_w_url") - private String url; + private String _w_url; } @ApiModel("获取用户信息请求") @@ -138,12 +140,10 @@ public class WpsDto { public static class UserInfo{ @NotNull @ApiModelProperty("请求签名") - @JsonProperty("_w_signature") - private String signature; + private String _w_signature; @NotNull @ApiModelProperty("应用id") - @JsonProperty("_w_appid") - private String appId; + private String _w_appid; } @ApiModel("获取用户信息body请求") @Data @@ -156,11 +156,9 @@ public class WpsDto { public static class FileNew{ @NotNull @ApiModelProperty("请求签名") - @JsonProperty("_w_signature") - private String signature; + private String _w_signature; @NotNull @ApiModelProperty("应用id") - @JsonProperty("_w_appid") - private String appId; + private String _w_appid; } } diff --git a/tall/src/main/java/com/ccsens/tall/bean/vo/ProjectMessageVo.java b/tall/src/main/java/com/ccsens/tall/bean/vo/ProjectMessageVo.java index dfccc08e..030bd562 100644 --- a/tall/src/main/java/com/ccsens/tall/bean/vo/ProjectMessageVo.java +++ b/tall/src/main/java/com/ccsens/tall/bean/vo/ProjectMessageVo.java @@ -39,7 +39,7 @@ public class ProjectMessageVo { private Byte readStatus; @ApiModelProperty("消息内容") List messages; - @JsonFormat(pattern="yyyy-MM-dd HH:mm") + @JsonFormat(pattern="yyyy-MM-dd HH:mm", timezone = "Asia/Shanghai") @ApiModelProperty("发送时间") private Date createTime; } diff --git a/tall/src/main/java/com/ccsens/tall/web/WpsController.java b/tall/src/main/java/com/ccsens/tall/web/WpsController.java index 92f6bb64..738d4a31 100644 --- a/tall/src/main/java/com/ccsens/tall/web/WpsController.java +++ b/tall/src/main/java/com/ccsens/tall/web/WpsController.java @@ -14,7 +14,11 @@ import com.ccsens.util.exception.BaseException; import io.swagger.annotations.*; import lombok.Data; import lombok.extern.slf4j.Slf4j; +import org.springframework.data.repository.query.Param; +import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; @@ -40,13 +44,19 @@ public class WpsController { @Resource private IUserService userService; + @InitBinder + protected void initBinder(WebDataBinder binder) { + // 解决下划线开头参数无法映射到实体的问题 + binder.setFieldMarkerPrefix(null); + } + @ApiOperation(value = "获取文件元数据", notes = "在预览或编辑的时候,通过接口校验权限并获取文件信息") @ApiImplicitParams({ }) @GetMapping(value = "file/info", produces = {"application/json;charset=UTF-8"}) - public WpsVo.FileInfo fileInfo(HttpServletRequest request, @Valid WpsDto.FileInfo fileInfo) throws Exception { + public WpsVo.FileInfo fileInfo(HttpServletRequest request, WpsDto.FileInfo fileInfo) throws Exception { log.info("获取文件元数据请求参数:{}", fileInfo); - WpsHeader header = checkSignature(request, fileInfo.getSignature()); + WpsHeader header = checkSignature(request, fileInfo.get_w_signature()); // 判断登录,查询userid WpsVo.FileInfo fileInfoVo = wpsService.getFileInfo(header.getFileId(), header.getToken()); log.info("获取文件元数据返回:{}", fileInfoVo); @@ -67,7 +77,7 @@ public class WpsController { log.info("请求参数中没有用户ID"); throw new BaseException(CodeEnum.PARAM_ERROR); } - WpsHeader header = checkSignature(request, userInfo.getSignature()); + WpsHeader header = checkSignature(request, userInfo.get_w_signature()); List infos = userService.queryUserInfos(body.getIds()); log.info("获取用户信息:{}", infos); return WpsVo.UserInfo.getInstance(infos); @@ -79,7 +89,7 @@ public class WpsController { @PostMapping(value = "file/save", produces = {"application/json;charset=UTF-8"}) public WpsVo.FileSave fileSave(HttpServletRequest request, @Valid WpsDto.FileSave fileSave, @RequestBody Part file) throws Exception { log.info("上传文件新版本请求参数:{}", fileSave); - WpsHeader header = checkSignature(request, fileSave.getSignature()); + WpsHeader header = checkSignature(request, fileSave.get_w_signature()); WpsVo.FileSave save = wpsService.fileSave(header.getToken(), header.getFileId(), fileSave, file); log.info("上传文件新版本返回:{}", save); @@ -108,7 +118,7 @@ public class WpsController { @GetMapping(value = "file/version/{version}", produces = {"application/json;charset=UTF-8"}) public WpsVo.FileBase fileVersion(HttpServletRequest request, @PathVariable("version") Integer version, WpsDto.FileVersion fileVersion) throws Exception { log.info("上传文件新版本请求参数:{}", fileVersion); - WpsHeader header = checkSignature(request, fileVersion.getSignature()); + WpsHeader header = checkSignature(request, fileVersion.get_w_signature()); WpsVo.FileBase base = wpsService.fileVersion(header.getToken(), Long.parseLong(header.getFileId()), version); log.info("版本{}的文件信息:{}", version, base); return base; @@ -121,7 +131,7 @@ public class WpsController { public JsonResponse fileRename(HttpServletRequest request, WpsDto.FileRename fileRename, @RequestBody WpsDto.FileRenameBody renameBody) throws Exception { log.info("上传文件新版本请求参数:{}", fileRename); - WpsHeader header = checkSignature(request, fileRename.getSignature()); + WpsHeader header = checkSignature(request, fileRename.get_w_signature()); wpsService.fileRename(header.getToken(), Long.parseLong(header.getFileId()), renameBody); return JsonResponse.newInstance().ok(); } @@ -132,7 +142,7 @@ public class WpsController { @PostMapping(value = "file/history", produces = {"application/json;charset=UTF-8"}) public WpsVo.FileHistory fileHistory(HttpServletRequest request, WpsDto.FileHistory history, @RequestBody WpsDto.FileHistoryBody body) throws Exception { log.info("获取所有历史版本文件信息请求参数:{}, {}", history, body); - WpsHeader header = checkSignature(request, history.getSignature()); + WpsHeader header = checkSignature(request, history.get_w_signature()); List histories = wpsService.queryFileHistory(header.getToken(), body); log.info("所有历史版本返回信息:{}", histories); return new WpsVo.FileHistory(histories); @@ -143,7 +153,7 @@ public class WpsController { @PostMapping(value = "file/new", produces = {"application/json;charset=UTF-8"}) public WpsVo.FileNew fileNew(HttpServletRequest request, WpsDto.FileNew fileNew, String name, Part file) throws Exception { log.info("上传文件新版本请求参数:{}", fileNew); - WpsHeader header = checkSignature(request, fileNew.getSignature()); + WpsHeader header = checkSignature(request, fileNew.get_w_signature()); WpsVo.FileNew fileNewVo = wpsService.fileNew(header.getToken(), header.getFileId(), name, file); log.info("文件新建返回:{}", fileNewVo); return fileNewVo; @@ -154,7 +164,7 @@ public class WpsController { @PostMapping(value = "onnotify", produces = {"application/json;charset=UTF-8"}) public JsonResponse onnotify(HttpServletRequest request, WpsDto.Notify notify, @RequestBody WpsDto.NotifyBody body) throws Exception { log.info("wps通知请求参数:{},{}", notify, body); - WpsHeader header = checkSignature(request, notify.getSignature()); + WpsHeader header = checkSignature(request, notify.get_w_signature()); wpsService.notify(header.getToken(), body); log.info("wps通知完成"); return JsonResponse.newInstance().ok(); From 136b318b6ff6b93aff8c9bc408022de213652974 Mon Sep 17 00:00:00 2001 From: zhizhi wu <2377881365@qq.com> Date: Wed, 24 Jun 2020 10:05:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=97=B6=E5=8C=BA=E8=AE=BE=E7=BD=AEGMT-5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ccsens/tall/bean/vo/ProjectMessageVo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tall/src/main/java/com/ccsens/tall/bean/vo/ProjectMessageVo.java b/tall/src/main/java/com/ccsens/tall/bean/vo/ProjectMessageVo.java index 030bd562..03b464cd 100644 --- a/tall/src/main/java/com/ccsens/tall/bean/vo/ProjectMessageVo.java +++ b/tall/src/main/java/com/ccsens/tall/bean/vo/ProjectMessageVo.java @@ -39,7 +39,7 @@ public class ProjectMessageVo { private Byte readStatus; @ApiModelProperty("消息内容") List messages; - @JsonFormat(pattern="yyyy-MM-dd HH:mm", timezone = "Asia/Shanghai") + @JsonFormat(pattern="yyyy-MM-dd HH:mm", timezone = "GMT-5") @ApiModelProperty("发送时间") private Date createTime; }