From 89aef7a87b2c1c3d24b03d2b9ca02b7494b03b1f Mon Sep 17 00:00:00 2001 From: ronger Date: Wed, 13 Jul 2022 22:21:33 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20style(entity,dto,service,...):=20?= =?UTF-8?q?=E5=AE=9E=E4=BD=93=E7=AD=89pojo=E4=B8=BB=E9=94=AE=E5=8F=98?= =?UTF-8?q?=E4=B8=BALong=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/rymcu/forest/dto/TokenUser.java | 4 +++- src/main/java/com/rymcu/forest/entity/LoginRecord.java | 7 +++++-- src/main/java/com/rymcu/forest/entity/Visit.java | 7 +++++-- .../java/com/rymcu/forest/service/LoginRecordService.java | 2 +- .../rymcu/forest/service/impl/LoginRecordServiceImpl.java | 2 +- .../rymcu/forest/web/api/common/CommonApiController.java | 6 ++---- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/rymcu/forest/dto/TokenUser.java b/src/main/java/com/rymcu/forest/dto/TokenUser.java index 387f770..339e7bd 100644 --- a/src/main/java/com/rymcu/forest/dto/TokenUser.java +++ b/src/main/java/com/rymcu/forest/dto/TokenUser.java @@ -1,5 +1,6 @@ package com.rymcu.forest.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; /** @@ -8,7 +9,8 @@ import lombok.Data; @Data public class TokenUser { - private Integer idUser; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idUser; private String account; diff --git a/src/main/java/com/rymcu/forest/entity/LoginRecord.java b/src/main/java/com/rymcu/forest/entity/LoginRecord.java index 36825cd..776f57c 100644 --- a/src/main/java/com/rymcu/forest/entity/LoginRecord.java +++ b/src/main/java/com/rymcu/forest/entity/LoginRecord.java @@ -1,6 +1,7 @@ package com.rymcu.forest.entity; import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import javax.persistence.Column; @@ -22,7 +23,8 @@ public class LoginRecord implements Serializable,Cloneable { @Id @GeneratedValue(generator = "JDBC") @Column(name = "id") - private Integer id; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; /** IP */ @Column(name = "login_ip") private String loginIp; @@ -43,7 +45,8 @@ public class LoginRecord implements Serializable,Cloneable { private String loginBrowser; /** 用户 id */ @Column(name = "id_user") - private Integer idUser; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idUser; /** 创建时间 */ @Column(name = "created_time") @JSONField(format = "yyyy-MM-dd HH:mm:ss") diff --git a/src/main/java/com/rymcu/forest/entity/Visit.java b/src/main/java/com/rymcu/forest/entity/Visit.java index f1f2aa1..f8beb08 100644 --- a/src/main/java/com/rymcu/forest/entity/Visit.java +++ b/src/main/java/com/rymcu/forest/entity/Visit.java @@ -1,6 +1,7 @@ package com.rymcu.forest.entity; import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import javax.persistence.Column; @@ -22,7 +23,8 @@ public class Visit implements Serializable,Cloneable { @Id @GeneratedValue(generator = "JDBC") @Column(name = "id") - private Integer id; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; /** 浏览链接 */ @Column(name = "visit_url") private String visitUrl; @@ -40,7 +42,8 @@ public class Visit implements Serializable,Cloneable { private String visitDeviceId; /** 浏览者 id */ @Column(name = "visit_user_id") - private Integer visitUserId; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long visitUserId; /** 上游链接 */ @Column(name = "visit_referer_url") private String visitRefererUrl; diff --git a/src/main/java/com/rymcu/forest/service/LoginRecordService.java b/src/main/java/com/rymcu/forest/service/LoginRecordService.java index 9d618fe..2c7ac33 100644 --- a/src/main/java/com/rymcu/forest/service/LoginRecordService.java +++ b/src/main/java/com/rymcu/forest/service/LoginRecordService.java @@ -18,7 +18,7 @@ public interface LoginRecordService extends Service { * @param idUser * @return */ - LoginRecord saveLoginRecord(Integer idUser); + LoginRecord saveLoginRecord(Long idUser); /** * 获取用户登录记录 diff --git a/src/main/java/com/rymcu/forest/service/impl/LoginRecordServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/LoginRecordServiceImpl.java index b253b36..8d7e33e 100644 --- a/src/main/java/com/rymcu/forest/service/impl/LoginRecordServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/LoginRecordServiceImpl.java @@ -33,7 +33,7 @@ public class LoginRecordServiceImpl extends AbstractService impleme @Override @Transactional(rollbackFor = Exception.class) - public LoginRecord saveLoginRecord(Integer idUser) { + public LoginRecord saveLoginRecord(Long idUser) { HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); String ip = Utils.getIpAddress(request); String ua = request.getHeader("user-agent"); diff --git a/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java b/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java index 1d31609..0ad2e31 100644 --- a/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java +++ b/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java @@ -106,11 +106,9 @@ public class CommonApiController { @GetMapping("/article/{id}") @VisitLogger - public GlobalResult> article(@PathVariable Long id) { + public GlobalResult article(@PathVariable Long id) { ArticleDTO articleDTO = articleService.findArticleDTOById(id, 1); - Map map = new HashMap<>(1); - map.put("article", articleDTO); - return GlobalResultGenerator.genSuccessResult(map); + return GlobalResultGenerator.genSuccessResult(articleDTO); } @PatchMapping("/forget-password")