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")