From 0744e48eb941af2875241baf3ac06cbca6f6b240 Mon Sep 17 00:00:00 2001 From: Kould <91525956+KKould@users.noreply.github.com> Date: Sun, 10 Jul 2022 22:31:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?style(entity,dto,service,...):=20=E5=AE=9E?= =?UTF-8?q?=E4=BD=93=E7=AD=89pojo=E4=B8=BB=E9=94=AE=E5=8F=98=E4=B8=BALong?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 主要对article实体等pojo主键变为Long类型,并对其涉及到的代码作一系列适配 article部分代码对service实现返回map做一系列修正 --- .../rymcu/forest/config/BaseShiroRealm.java | 6 +- .../exception/ContentNotExistException.java | 24 +++ .../exception/DataDuplicationException.java | 25 +++ .../core/exception/UltraViresException.java | 26 +++ .../forest/core/service/log/VisitAspect.java | 2 +- .../service/security/AuthorshipAspect.java | 2 +- .../java/com/rymcu/forest/dto/ArticleDTO.java | 7 +- .../com/rymcu/forest/dto/ArticleTagDTO.java | 11 +- .../java/com/rymcu/forest/dto/Author.java | 4 +- .../com/rymcu/forest/dto/NotificationDTO.java | 4 +- .../rymcu/forest/dto/PortfolioArticleDTO.java | 10 +- .../com/rymcu/forest/dto/PortfolioDTO.java | 7 +- .../java/com/rymcu/forest/dto/UserDTO.java | 4 +- .../com/rymcu/forest/dto/UserInfoDTO.java | 4 +- .../java/com/rymcu/forest/entity/Article.java | 7 +- .../rymcu/forest/entity/ArticleThumbsUp.java | 4 +- .../com/rymcu/forest/entity/BankAccount.java | 4 +- .../java/com/rymcu/forest/entity/Comment.java | 13 +- .../java/com/rymcu/forest/entity/Follow.java | 10 +- .../com/rymcu/forest/entity/Notification.java | 10 +- .../com/rymcu/forest/entity/Portfolio.java | 7 +- .../java/com/rymcu/forest/entity/Sponsor.java | 7 +- .../java/com/rymcu/forest/entity/User.java | 4 +- .../com/rymcu/forest/entity/UserExtend.java | 2 +- .../rymcu/forest/lucene/model/UserLucene.java | 4 +- .../service/impl/UserLuceneServiceImpl.java | 2 +- .../rymcu/forest/mapper/ArticleMapper.java | 40 ++-- .../rymcu/forest/mapper/CommentMapper.java | 2 +- .../com/rymcu/forest/mapper/FollowMapper.java | 6 +- .../forest/mapper/NotificationMapper.java | 14 +- .../rymcu/forest/mapper/PortfolioMapper.java | 16 +- .../com/rymcu/forest/mapper/RoleMapper.java | 2 +- .../rymcu/forest/mapper/SponsorMapper.java | 2 +- .../com/rymcu/forest/mapper/TagMapper.java | 8 +- .../com/rymcu/forest/mapper/UserMapper.java | 14 +- .../rymcu/forest/service/ArticleService.java | 20 +- .../forest/service/BankAccountService.java | 2 +- .../rymcu/forest/service/FollowService.java | 2 +- .../forest/service/NotificationService.java | 12 +- .../forest/service/PortfolioService.java | 8 +- .../com/rymcu/forest/service/RoleService.java | 2 +- .../service/TransactionRecordService.java | 4 +- .../com/rymcu/forest/service/UserService.java | 8 +- .../service/impl/ArticleServiceImpl.java | 181 ++++++++---------- .../service/impl/BankAccountServiceImpl.java | 4 +- .../service/impl/FollowServiceImpl.java | 2 +- .../service/impl/NotificationServiceImpl.java | 12 +- .../service/impl/PortfolioServiceImpl.java | 10 +- .../forest/service/impl/RoleServiceImpl.java | 2 +- .../impl/TransactionRecordServiceImpl.java | 4 +- .../forest/service/impl/UserServiceImpl.java | 8 +- .../rymcu/forest/util/NotificationUtils.java | 16 +- .../web/api/admin/AdminArticleController.java | 7 +- .../forest/web/api/admin/AdminController.java | 2 +- .../web/api/article/ArticleController.java | 49 ++--- .../web/api/bank/BankAccountController.java | 2 +- .../forest/web/api/bank/WalletController.java | 4 +- .../web/api/common/CommonApiController.java | 6 +- .../notification/NotificationController.java | 2 +- .../api/portfolio/PortfolioController.java | 8 +- .../web/api/user/UserInfoController.java | 2 +- src/main/java/mapper/ArticleMapper.xml | 2 +- 62 files changed, 393 insertions(+), 302 deletions(-) create mode 100644 src/main/java/com/rymcu/forest/core/exception/ContentNotExistException.java create mode 100644 src/main/java/com/rymcu/forest/core/exception/DataDuplicationException.java create mode 100644 src/main/java/com/rymcu/forest/core/exception/UltraViresException.java diff --git a/src/main/java/com/rymcu/forest/config/BaseShiroRealm.java b/src/main/java/com/rymcu/forest/config/BaseShiroRealm.java index bdd6323..2ddf682 100644 --- a/src/main/java/com/rymcu/forest/config/BaseShiroRealm.java +++ b/src/main/java/com/rymcu/forest/config/BaseShiroRealm.java @@ -1,5 +1,6 @@ package com.rymcu.forest.config; +import com.fasterxml.jackson.annotation.JsonFormat; import com.rymcu.forest.core.constant.ShiroConstants; import com.rymcu.forest.core.exception.CaptchaException; import com.rymcu.forest.entity.Permission; @@ -106,7 +107,8 @@ public class BaseShiroRealm extends AuthorizingRealm { private static final long serialVersionUID = 1L; - private Integer id; // 编号 + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; // 编号 private String account; // 登录名 private String name; // 姓名 private boolean mobileLogin; // 是否手机登录 @@ -120,7 +122,7 @@ public class BaseShiroRealm extends AuthorizingRealm { this.mobileLogin = mobileLogin; } - public Integer getId() { + public Long getId() { return id; } diff --git a/src/main/java/com/rymcu/forest/core/exception/ContentNotExistException.java b/src/main/java/com/rymcu/forest/core/exception/ContentNotExistException.java new file mode 100644 index 0000000..4afaf5b --- /dev/null +++ b/src/main/java/com/rymcu/forest/core/exception/ContentNotExistException.java @@ -0,0 +1,24 @@ +package com.rymcu.forest.core.exception; + +public class ContentNotExistException extends RuntimeException{ + private static final long serialVersionUID = 3206734387536223284L; + + public ContentNotExistException() { + } + + public ContentNotExistException(String message) { + super(message); + } + + public ContentNotExistException(String message, Throwable cause) { + super(message, cause); + } + + public ContentNotExistException(Throwable cause) { + super(cause); + } + + public ContentNotExistException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/src/main/java/com/rymcu/forest/core/exception/DataDuplicationException.java b/src/main/java/com/rymcu/forest/core/exception/DataDuplicationException.java new file mode 100644 index 0000000..6d50510 --- /dev/null +++ b/src/main/java/com/rymcu/forest/core/exception/DataDuplicationException.java @@ -0,0 +1,25 @@ +package com.rymcu.forest.core.exception; + +public class DataDuplicationException extends RuntimeException { + + private static final long serialVersionUID = 3206744387536223284L; + + public DataDuplicationException() { + } + + public DataDuplicationException(String message) { + super(message); + } + + public DataDuplicationException(String message, Throwable cause) { + super(message, cause); + } + + public DataDuplicationException(Throwable cause) { + super(cause); + } + + public DataDuplicationException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/src/main/java/com/rymcu/forest/core/exception/UltraViresException.java b/src/main/java/com/rymcu/forest/core/exception/UltraViresException.java new file mode 100644 index 0000000..6734208 --- /dev/null +++ b/src/main/java/com/rymcu/forest/core/exception/UltraViresException.java @@ -0,0 +1,26 @@ +package com.rymcu.forest.core.exception; + +public class UltraViresException extends RuntimeException { + + private static final long serialVersionUID = 3206744387536228284L; + + public UltraViresException() { + super(); + } + + public UltraViresException(String message) { + super(message); + } + + public UltraViresException(String message, Throwable cause) { + super(message, cause); + } + + public UltraViresException(Throwable cause) { + super(cause); + } + + protected UltraViresException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/src/main/java/com/rymcu/forest/core/service/log/VisitAspect.java b/src/main/java/com/rymcu/forest/core/service/log/VisitAspect.java index ce0ed4f..e1c9c26 100644 --- a/src/main/java/com/rymcu/forest/core/service/log/VisitAspect.java +++ b/src/main/java/com/rymcu/forest/core/service/log/VisitAspect.java @@ -90,7 +90,7 @@ public class VisitAspect { if (StringUtils.isBlank(param) || "undefined".equals(param) || "null".equals(param)) { break; } - Integer id = Integer.parseInt(param); + Long id = Long.parseLong(param); articleService.incrementArticleViewCount(id); break; default: diff --git a/src/main/java/com/rymcu/forest/core/service/security/AuthorshipAspect.java b/src/main/java/com/rymcu/forest/core/service/security/AuthorshipAspect.java index 92fd989..a344aea 100644 --- a/src/main/java/com/rymcu/forest/core/service/security/AuthorshipAspect.java +++ b/src/main/java/com/rymcu/forest/core/service/security/AuthorshipAspect.java @@ -76,7 +76,7 @@ public class AuthorshipAspect { } HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); String idArticle; - Integer idAuthor = 0; + Long idAuthor = 0l; if (isAjax(request)) { Object[] objects = joinPoint.getArgs(); JSONObject jsonObject; diff --git a/src/main/java/com/rymcu/forest/dto/ArticleDTO.java b/src/main/java/com/rymcu/forest/dto/ArticleDTO.java index 530998c..baad171 100644 --- a/src/main/java/com/rymcu/forest/dto/ArticleDTO.java +++ b/src/main/java/com/rymcu/forest/dto/ArticleDTO.java @@ -1,6 +1,7 @@ package com.rymcu.forest.dto; import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.util.Date; @@ -11,13 +12,15 @@ import java.util.List; */ @Data public class ArticleDTO { - private Integer idArticle; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idArticle; /** 文章标题 */ private String articleTitle; /** 文章缩略图 */ private String articleThumbnailUrl; /** 文章作者id */ - private Integer articleAuthorId; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long articleAuthorId; /** 文章作者 */ private String articleAuthorName; /** 文章作者头像 */ diff --git a/src/main/java/com/rymcu/forest/dto/ArticleTagDTO.java b/src/main/java/com/rymcu/forest/dto/ArticleTagDTO.java index c825537..c43cc23 100644 --- a/src/main/java/com/rymcu/forest/dto/ArticleTagDTO.java +++ b/src/main/java/com/rymcu/forest/dto/ArticleTagDTO.java @@ -1,5 +1,6 @@ package com.rymcu.forest.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; /** @@ -7,12 +8,13 @@ import lombok.Data; */ @Data public class ArticleTagDTO { - - private Integer idArticleTag; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idArticleTag; private Integer idTag; - private Integer idArticle; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idArticle; private String tagTitle; @@ -22,5 +24,6 @@ public class ArticleTagDTO { private String tagIconPath; - private Integer tagAuthorId; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long tagAuthorId; } diff --git a/src/main/java/com/rymcu/forest/dto/Author.java b/src/main/java/com/rymcu/forest/dto/Author.java index 3782f01..c0c06f8 100644 --- a/src/main/java/com/rymcu/forest/dto/Author.java +++ b/src/main/java/com/rymcu/forest/dto/Author.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 Author { - private Integer idUser; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idUser; private String userNickname; diff --git a/src/main/java/com/rymcu/forest/dto/NotificationDTO.java b/src/main/java/com/rymcu/forest/dto/NotificationDTO.java index d661521..47bd524 100644 --- a/src/main/java/com/rymcu/forest/dto/NotificationDTO.java +++ b/src/main/java/com/rymcu/forest/dto/NotificationDTO.java @@ -1,5 +1,6 @@ package com.rymcu.forest.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import com.rymcu.forest.entity.Notification; import lombok.Data; import lombok.EqualsAndHashCode; @@ -11,7 +12,8 @@ import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = false) public class NotificationDTO extends Notification { - private Integer idNotification; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idNotification; private String dataTitle; diff --git a/src/main/java/com/rymcu/forest/dto/PortfolioArticleDTO.java b/src/main/java/com/rymcu/forest/dto/PortfolioArticleDTO.java index 6a37646..776e685 100644 --- a/src/main/java/com/rymcu/forest/dto/PortfolioArticleDTO.java +++ b/src/main/java/com/rymcu/forest/dto/PortfolioArticleDTO.java @@ -1,5 +1,6 @@ package com.rymcu.forest.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.util.List; @@ -10,11 +11,14 @@ import java.util.List; @Data public class PortfolioArticleDTO { - private Integer id; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; - private Integer idPortfolio; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idPortfolio; - private Integer idArticle; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idArticle; private String headImgUrl; diff --git a/src/main/java/com/rymcu/forest/dto/PortfolioDTO.java b/src/main/java/com/rymcu/forest/dto/PortfolioDTO.java index bf8cbd1..13363b2 100644 --- a/src/main/java/com/rymcu/forest/dto/PortfolioDTO.java +++ b/src/main/java/com/rymcu/forest/dto/PortfolioDTO.java @@ -1,5 +1,6 @@ package com.rymcu.forest.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.util.Date; @@ -10,11 +11,13 @@ import java.util.Date; @Data public class PortfolioDTO { - private Integer idPortfolio; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idPortfolio; /** 作品集头像 */ private String headImgUrl; /** 作品集作者 */ - private Integer portfolioAuthorId; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long portfolioAuthorId; /** 作品集作者 */ private String portfolioAuthorName; /** 作品集作者头像 */ diff --git a/src/main/java/com/rymcu/forest/dto/UserDTO.java b/src/main/java/com/rymcu/forest/dto/UserDTO.java index 469a457..c67affe 100644 --- a/src/main/java/com/rymcu/forest/dto/UserDTO.java +++ b/src/main/java/com/rymcu/forest/dto/UserDTO.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 UserDTO { - private Integer idUser; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idUser; private String account; diff --git a/src/main/java/com/rymcu/forest/dto/UserInfoDTO.java b/src/main/java/com/rymcu/forest/dto/UserInfoDTO.java index aa1b041..e41efee 100644 --- a/src/main/java/com/rymcu/forest/dto/UserInfoDTO.java +++ b/src/main/java/com/rymcu/forest/dto/UserInfoDTO.java @@ -1,6 +1,7 @@ package com.rymcu.forest.dto; import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import javax.persistence.Column; @@ -13,7 +14,8 @@ import java.util.Date; @Data public class UserInfoDTO implements Serializable { - private Integer idUser; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idUser; private String account; diff --git a/src/main/java/com/rymcu/forest/entity/Article.java b/src/main/java/com/rymcu/forest/entity/Article.java index a929ee3..88fd893 100644 --- a/src/main/java/com/rymcu/forest/entity/Article.java +++ b/src/main/java/com/rymcu/forest/entity/Article.java @@ -1,5 +1,6 @@ package com.rymcu.forest.entity; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import javax.persistence.Column; @@ -19,13 +20,15 @@ public class Article implements Serializable,Cloneable { @Id @GeneratedValue(generator = "JDBC") @Column(name = "id") - private Integer idArticle; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idArticle; /** 文章标题 */ private String articleTitle; /** 文章缩略图 */ private String articleThumbnailUrl; /** 文章作者id */ - private Integer articleAuthorId; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long articleAuthorId; /** 文章类型 */ private String articleType; /** 文章标签 */ diff --git a/src/main/java/com/rymcu/forest/entity/ArticleThumbsUp.java b/src/main/java/com/rymcu/forest/entity/ArticleThumbsUp.java index b7729dd..2d6f72a 100644 --- a/src/main/java/com/rymcu/forest/entity/ArticleThumbsUp.java +++ b/src/main/java/com/rymcu/forest/entity/ArticleThumbsUp.java @@ -1,5 +1,6 @@ package com.rymcu.forest.entity; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import javax.persistence.Column; @@ -29,7 +30,8 @@ public class ArticleThumbsUp implements Serializable, Cloneable { /** * 用户表主键 */ - private Integer idUser; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idUser; /** * 点赞时间 */ diff --git a/src/main/java/com/rymcu/forest/entity/BankAccount.java b/src/main/java/com/rymcu/forest/entity/BankAccount.java index 3c3374a..f7498a9 100644 --- a/src/main/java/com/rymcu/forest/entity/BankAccount.java +++ b/src/main/java/com/rymcu/forest/entity/BankAccount.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; @@ -29,7 +30,8 @@ public class BankAccount { /** 账户余额 */ private BigDecimal accountBalance; /** 账户所有者 */ - private Integer accountOwner; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long accountOwner; /** 创建时间 */ @JSONField(format = "yyyy-MM-dd HH:mm:ss") private Date createdTime; diff --git a/src/main/java/com/rymcu/forest/entity/Comment.java b/src/main/java/com/rymcu/forest/entity/Comment.java index 3431f74..d1f4bbb 100644 --- a/src/main/java/com/rymcu/forest/entity/Comment.java +++ b/src/main/java/com/rymcu/forest/entity/Comment.java @@ -1,5 +1,6 @@ package com.rymcu.forest.entity; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import javax.persistence.Column; @@ -19,22 +20,26 @@ public class Comment implements Serializable,Cloneable { @Id @GeneratedValue(generator = "JDBC") @Column(name = "id") - private Integer idComment; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idComment; /** 评论内容 */ @Column(name = "comment_content") private String commentContent; /** 作者 id */ @Column(name = "comment_author_id") - private Integer commentAuthorId; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long commentAuthorId; /** 文章 id */ @Column(name = "comment_article_id") - private Integer commentArticleId; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long commentArticleId; /** 锚点 url */ @Column(name = "comment_sharp_url") private String commentSharpUrl; /** 父评论 id */ @Column(name = "comment_original_comment_id") - private Integer commentOriginalCommentId; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long commentOriginalCommentId; /** 状态 */ @Column(name = "comment_status") private String commentStatus; diff --git a/src/main/java/com/rymcu/forest/entity/Follow.java b/src/main/java/com/rymcu/forest/entity/Follow.java index 471fe44..6e9d081 100644 --- a/src/main/java/com/rymcu/forest/entity/Follow.java +++ b/src/main/java/com/rymcu/forest/entity/Follow.java @@ -1,5 +1,6 @@ package com.rymcu.forest.entity; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import javax.persistence.Column; @@ -18,13 +19,16 @@ public class Follow implements Serializable,Cloneable { @Id @GeneratedValue(generator = "JDBC") @Column(name = "id") - private Integer idFollow; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idFollow; /** 关注者 id */ @Column(name = "follower_id") - private Integer followerId; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long followerId; /** 关注数据 id */ @Column(name = "following_id") - private Integer followingId; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long followingId; /** 0:用户,1:标签,2:帖子收藏,3:帖子关注 */ @Column(name = "following_type") private String followingType; diff --git a/src/main/java/com/rymcu/forest/entity/Notification.java b/src/main/java/com/rymcu/forest/entity/Notification.java index 809f070..a54927e 100644 --- a/src/main/java/com/rymcu/forest/entity/Notification.java +++ b/src/main/java/com/rymcu/forest/entity/Notification.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; @@ -23,12 +24,14 @@ public class Notification implements Serializable,Cloneable { @Id @GeneratedValue(generator = "JDBC") @Column(name = "id") - private Integer idNotification; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idNotification; /** * 用户id */ @Column(name = "id_user") - private Integer idUser; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idUser; /** * 数据类型 */ @@ -38,7 +41,8 @@ public class Notification implements Serializable,Cloneable { * 数据id */ @Column(name = "data_id") - private Integer dataId; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long dataId; /** * 数据摘要 */ diff --git a/src/main/java/com/rymcu/forest/entity/Portfolio.java b/src/main/java/com/rymcu/forest/entity/Portfolio.java index 8165a4f..c628b6f 100644 --- a/src/main/java/com/rymcu/forest/entity/Portfolio.java +++ b/src/main/java/com/rymcu/forest/entity/Portfolio.java @@ -1,5 +1,6 @@ package com.rymcu.forest.entity; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import javax.persistence.*; @@ -15,14 +16,16 @@ public class Portfolio { @Id @GeneratedValue(generator = "JDBC") @Column(name = "id") - private Integer idPortfolio; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idPortfolio; /** 作品集头像 */ @Column(name = "portfolio_head_img_url") private String headImgUrl; /** 作品集名称 */ private String portfolioTitle; /** 作品集作者 */ - private Integer portfolioAuthorId; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long portfolioAuthorId; /** 作品集介绍 */ private String portfolioDescription; /** 作品集介绍 Html */ diff --git a/src/main/java/com/rymcu/forest/entity/Sponsor.java b/src/main/java/com/rymcu/forest/entity/Sponsor.java index a9eeaef..edb8b4a 100644 --- a/src/main/java/com/rymcu/forest/entity/Sponsor.java +++ b/src/main/java/com/rymcu/forest/entity/Sponsor.java @@ -1,5 +1,6 @@ package com.rymcu.forest.entity; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import javax.persistence.GeneratedValue; @@ -28,11 +29,13 @@ public class Sponsor implements Serializable, Cloneable { /** * 数据主键 */ - private Integer dataId; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long dataId; /** * 赞赏人 */ - private Integer sponsor; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long sponsor; /** * 赞赏日期 */ diff --git a/src/main/java/com/rymcu/forest/entity/User.java b/src/main/java/com/rymcu/forest/entity/User.java index 642bc03..7429770 100644 --- a/src/main/java/com/rymcu/forest/entity/User.java +++ b/src/main/java/com/rymcu/forest/entity/User.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 org.apache.ibatis.type.JdbcType; import tk.mybatis.mapper.annotation.ColumnType; @@ -21,7 +22,8 @@ public class User implements Serializable,Cloneable { @Id @Column(name = "id") @GeneratedValue(generator = "JDBC") - private Integer idUser; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idUser; /** * 登录账号 diff --git a/src/main/java/com/rymcu/forest/entity/UserExtend.java b/src/main/java/com/rymcu/forest/entity/UserExtend.java index b4e339a..7df4944 100644 --- a/src/main/java/com/rymcu/forest/entity/UserExtend.java +++ b/src/main/java/com/rymcu/forest/entity/UserExtend.java @@ -13,7 +13,7 @@ import javax.persistence.Table; public class UserExtend { @Id - private Integer idUser; + private Long idUser; private String github; diff --git a/src/main/java/com/rymcu/forest/lucene/model/UserLucene.java b/src/main/java/com/rymcu/forest/lucene/model/UserLucene.java index 6946e33..708494a 100644 --- a/src/main/java/com/rymcu/forest/lucene/model/UserLucene.java +++ b/src/main/java/com/rymcu/forest/lucene/model/UserLucene.java @@ -1,5 +1,6 @@ package com.rymcu.forest.lucene.model; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -22,7 +23,8 @@ import javax.persistence.Column; public class UserLucene { /** 用户编号 */ - private Integer idUser; + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long idUser; /** 昵称 */ private String nickname; diff --git a/src/main/java/com/rymcu/forest/lucene/service/impl/UserLuceneServiceImpl.java b/src/main/java/com/rymcu/forest/lucene/service/impl/UserLuceneServiceImpl.java index d88d557..4481e7f 100644 --- a/src/main/java/com/rymcu/forest/lucene/service/impl/UserLuceneServiceImpl.java +++ b/src/main/java/com/rymcu/forest/lucene/service/impl/UserLuceneServiceImpl.java @@ -161,7 +161,7 @@ public class UserLuceneServiceImpl implements UserLuceneService { } resList.add( UserLucene.builder() - .idUser(Integer.valueOf(hitDoc.get("id"))) + .idUser(Long.valueOf(hitDoc.get("id"))) .nickname(titleValue.toString()) .signature(baikeValue.toString()) .score(String.valueOf(score)) diff --git a/src/main/java/com/rymcu/forest/mapper/ArticleMapper.java b/src/main/java/com/rymcu/forest/mapper/ArticleMapper.java index 8ae9083..53aa3e5 100644 --- a/src/main/java/com/rymcu/forest/mapper/ArticleMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/ArticleMapper.java @@ -30,7 +30,7 @@ public interface ArticleMapper extends Mapper
{ * @param type * @return */ - ArticleDTO selectArticleDTOById(@Param("id") Integer id, @Param("type") int type); + ArticleDTO selectArticleDTOById(@Param("id") Long id, @Param("type") int type); /** * 保存文章内容 @@ -39,7 +39,7 @@ public interface ArticleMapper extends Mapper
{ * @param articleContentHtml * @return */ - Integer insertArticleContent(@Param("idArticle") Integer idArticle, @Param("articleContent") String articleContent, @Param("articleContentHtml") String articleContentHtml); + Integer insertArticleContent(@Param("idArticle") Long idArticle, @Param("articleContent") String articleContent, @Param("articleContentHtml") String articleContentHtml); /** * 更新文章内容 @@ -48,14 +48,14 @@ public interface ArticleMapper extends Mapper
{ * @param articleContentHtml * @return */ - Integer updateArticleContent(@Param("idArticle") Integer idArticle, @Param("articleContent") String articleContent, @Param("articleContentHtml") String articleContentHtml); + Integer updateArticleContent(@Param("idArticle") Long idArticle, @Param("articleContent") String articleContent, @Param("articleContentHtml") String articleContentHtml); /** * 获取文章正文内容 * @param idArticle * @return */ - ArticleContent selectArticleContent(@Param("idArticle") Integer idArticle); + ArticleContent selectArticleContent(@Param("idArticle") Long idArticle); /** * 获取主题下文章列表 @@ -76,21 +76,21 @@ public interface ArticleMapper extends Mapper
{ * @param idUser * @return */ - List selectUserArticles(@Param("idUser") Integer idUser); + List selectUserArticles(@Param("idUser") Long idUser); /** * 删除文章标签 * @param id * @return */ - Integer deleteTagArticle(@Param("id") Integer id); + Integer deleteTagArticle(@Param("id") Long id); /** * 获取文章标签列表 * @param idArticle * @return */ - List selectTags(@Param("idArticle") Integer idArticle); + List selectTags(@Param("idArticle") Long idArticle); /** * 更新文章浏览数 @@ -98,28 +98,28 @@ public interface ArticleMapper extends Mapper
{ * @param articleViewCount * @return */ - Integer updateArticleViewCount(@Param("id") Integer id, @Param("articleViewCount") Integer articleViewCount); + Integer updateArticleViewCount(@Param("id") Long id, @Param("articleViewCount") Integer articleViewCount); /** * 获取草稿列表 * @param idUser * @return */ - List selectDrafts(@Param("idUser") Integer idUser); + List selectDrafts(@Param("idUser") Long idUser); /** * 删除未使用的文章标签 * @param idArticleTag * @return */ - Integer deleteUnusedArticleTag(@Param("idArticleTag") Integer idArticleTag); + Integer deleteUnusedArticleTag(@Param("idArticleTag") Long idArticleTag); /** * 查询作品集下文章 * @param idPortfolio * @return */ - List selectArticlesByIdPortfolio(@Param("idPortfolio") Integer idPortfolio); + List selectArticlesByIdPortfolio(@Param("idPortfolio") Long idPortfolio); /** * 查询作品集未绑定文章 @@ -128,14 +128,14 @@ public interface ArticleMapper extends Mapper
{ * @param idUser * @return */ - List selectUnbindArticlesByIdPortfolio(@Param("idPortfolio") Integer idPortfolio, @Param("searchText") String searchText, @Param("idUser") Integer idUser); + List selectUnbindArticlesByIdPortfolio(@Param("idPortfolio") Long idPortfolio, @Param("searchText") String searchText, @Param("idUser") Long idUser); /** * 查询文章所属作品集列表 * @param idArticle * @return */ - List selectPortfolioArticles(@Param("idArticle") Integer idArticle); + List selectPortfolioArticles(@Param("idArticle") Long idArticle); /** * 更新文章标签 @@ -143,21 +143,21 @@ public interface ArticleMapper extends Mapper
{ * @param tags * @return */ - Integer updateArticleTags(@Param("idArticle") Integer idArticle, @Param("tags") String tags); + Integer updateArticleTags(@Param("idArticle") Long idArticle, @Param("tags") String tags); /** * 判断是否有评论 * @param id * @return */ - boolean existsCommentWithPrimaryKey(@Param("id") Integer id); + boolean existsCommentWithPrimaryKey(@Param("id") Long id); /** * 删除关联作品集数据 * @param id * @return */ - Integer deleteLinkedPortfolioData(@Param("id") Integer id); + Integer deleteLinkedPortfolioData(@Param("id") Long id); /** * 更新文章连接及预览内容 @@ -167,7 +167,7 @@ public interface ArticleMapper extends Mapper
{ * @param articlePreviewContent * @return */ - Integer updateArticleLinkAndPreviewContent(@Param("idArticle") Integer idArticle, @Param("articleLink") String articleLink, @Param("articlePermalink") String articlePermalink, @Param("articlePreviewContent") String articlePreviewContent); + Integer updateArticleLinkAndPreviewContent(@Param("idArticle") Long idArticle, @Param("articleLink") String articleLink, @Param("articlePermalink") String articlePermalink, @Param("articlePreviewContent") String articlePreviewContent); /** * 根据专题主键及当前文章排序号获取专题下文章大纲 @@ -175,7 +175,7 @@ public interface ArticleMapper extends Mapper
{ * @param sortNo * @return */ - List selectPortfolioArticlesByIdPortfolioAndSortNo(@Param("idPortfolio") Integer idPortfolio, @Param("sortNo") Integer sortNo); + List selectPortfolioArticlesByIdPortfolioAndSortNo(@Param("idPortfolio") Long idPortfolio, @Param("sortNo") Integer sortNo); /** * 更新文章优选状态 @@ -183,13 +183,13 @@ public interface ArticleMapper extends Mapper
{ * @param articlePerfect * @return */ - int updatePerfect(@Param("idArticle") Integer idArticle, @Param("articlePerfect") String articlePerfect); + int updatePerfect(@Param("idArticle") Long idArticle, @Param("articlePerfect") String articlePerfect); /** * 删除文章关联文章内容表信息 * @param idArticle */ - void deleteArticleContent(@Param("idArticle") Integer idArticle); + void deleteArticleContent(@Param("idArticle") Long idArticle); /** * 获取公告 diff --git a/src/main/java/com/rymcu/forest/mapper/CommentMapper.java b/src/main/java/com/rymcu/forest/mapper/CommentMapper.java index 4969ece..8f4b76e 100644 --- a/src/main/java/com/rymcu/forest/mapper/CommentMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/CommentMapper.java @@ -39,7 +39,7 @@ public interface CommentMapper extends Mapper { * @param commentSharpUrl * @return */ - Integer updateCommentSharpUrl(@Param("idComment") Integer idComment, @Param("commentSharpUrl") String commentSharpUrl); + Integer updateCommentSharpUrl(@Param("idComment") Long idComment, @Param("commentSharpUrl") String commentSharpUrl); /** * 获取评论列表数据 diff --git a/src/main/java/com/rymcu/forest/mapper/FollowMapper.java b/src/main/java/com/rymcu/forest/mapper/FollowMapper.java index a99a955..5a8af00 100644 --- a/src/main/java/com/rymcu/forest/mapper/FollowMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/FollowMapper.java @@ -18,19 +18,19 @@ public interface FollowMapper extends Mapper { * @param followingType * @return */ - Boolean isFollow(@Param("followingId") Integer followingId, @Param("followerId") Integer followerId, @Param("followingType") String followingType); + Boolean isFollow(@Param("followingId") Integer followingId, @Param("followerId") Long followerId, @Param("followingType") String followingType); /** * 查询用户粉丝 * @param idUser * @return */ - List selectUserFollowersByUser(@Param("idUser") Integer idUser); + List selectUserFollowersByUser(@Param("idUser") Long idUser); /** * 查询用户关注用户 * @param idUser * @return */ - List selectUserFollowingsByUser(@Param("idUser") Integer idUser); + List selectUserFollowingsByUser(@Param("idUser") Long idUser); } diff --git a/src/main/java/com/rymcu/forest/mapper/NotificationMapper.java b/src/main/java/com/rymcu/forest/mapper/NotificationMapper.java index d0257eb..2a9a67e 100644 --- a/src/main/java/com/rymcu/forest/mapper/NotificationMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/NotificationMapper.java @@ -17,14 +17,14 @@ public interface NotificationMapper extends Mapper { * @param idUser * @return */ - List selectUnreadNotifications(@Param("idUser") Integer idUser); + List selectUnreadNotifications(@Param("idUser") Long idUser); /** * 获取消息数据 * @param idUser * @return */ - List selectNotifications(@Param("idUser") Integer idUser); + List selectNotifications(@Param("idUser") Long idUser); /** * 获取消息数据 @@ -33,7 +33,7 @@ public interface NotificationMapper extends Mapper { * @param dataType * @return */ - Notification selectNotification(@Param("idUser") Integer idUser, @Param("dataId") Integer dataId, @Param("dataType") String dataType); + Notification selectNotification(@Param("idUser") Long idUser, @Param("dataId") Long dataId, @Param("dataType") String dataType); /** * 创建消息通知 @@ -43,21 +43,21 @@ public interface NotificationMapper extends Mapper { * @param dataSummary * @return */ - Integer insertNotification(@Param("idUser") Integer idUser, @Param("dataId") Integer dataId, @Param("dataType") String dataType, @Param("dataSummary") String dataSummary); + Integer insertNotification(@Param("idUser") Long idUser, @Param("dataId") Long dataId, @Param("dataType") String dataType, @Param("dataSummary") String dataSummary); /** * 标记消息已读 * @param id * @return */ - Integer readNotification(@Param("id") Integer id); + Integer readNotification(@Param("id") Long id); /** * 标记所有消息已读 * @param idUser * @return */ - Integer readAllNotification(@Param("idUser") Integer idUser); + Integer readAllNotification(@Param("idUser") Long idUser); /** * 删除相关未读消息 @@ -65,5 +65,5 @@ public interface NotificationMapper extends Mapper { * @param dataType * @return */ - Integer deleteUnreadNotification(@Param("dataId") Integer dataId, @Param("dataType") String dataType); + Integer deleteUnreadNotification(@Param("dataId") Long dataId, @Param("dataType") String dataType); } diff --git a/src/main/java/com/rymcu/forest/mapper/PortfolioMapper.java b/src/main/java/com/rymcu/forest/mapper/PortfolioMapper.java index c926b1c..8d9c1fa 100644 --- a/src/main/java/com/rymcu/forest/mapper/PortfolioMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/PortfolioMapper.java @@ -16,7 +16,7 @@ public interface PortfolioMapper extends Mapper { * @param idUser * @return */ - List selectUserPortfoliosByIdUser(@Param("idUser") Integer idUser); + List selectUserPortfoliosByIdUser(@Param("idUser") Long idUser); /** * 查询作品集 @@ -24,14 +24,14 @@ public interface PortfolioMapper extends Mapper { * @param type * @return */ - PortfolioDTO selectPortfolioDTOById(@Param("id") Integer id, @Param("type") Integer type); + PortfolioDTO selectPortfolioDTOById(@Param("id") Long id, @Param("type") Integer type); /** * 统计作品集下文章数 * @param idPortfolio * @return */ - Integer selectCountArticleNumber(@Param("idPortfolio") Integer idPortfolio); + Integer selectCountArticleNumber(@Param("idPortfolio") Long idPortfolio); /** * 查询文章是否已绑定 @@ -39,7 +39,7 @@ public interface PortfolioMapper extends Mapper { * @param idPortfolio * @return */ - Integer selectCountPortfolioArticle(@Param("idArticle") Integer idArticle, @Param("idPortfolio") Integer idPortfolio); + Integer selectCountPortfolioArticle(@Param("idArticle") Long idArticle, @Param("idPortfolio") Long idPortfolio); /** * 插入文章与作品集绑定数据 @@ -48,14 +48,14 @@ public interface PortfolioMapper extends Mapper { * @param maxSortNo * @return */ - Integer insertPortfolioArticle(@Param("idArticle") Integer idArticle, @Param("idPortfolio") Integer idPortfolio, @Param("maxSortNo") Integer maxSortNo); + Integer insertPortfolioArticle(@Param("idArticle") Long idArticle, @Param("idPortfolio") Long idPortfolio, @Param("maxSortNo") Integer maxSortNo); /** * 查询作品集下最大排序号 * @param idPortfolio * @return */ - Integer selectMaxSortNo(@Param("idPortfolio") Integer idPortfolio); + Integer selectMaxSortNo(@Param("idPortfolio") Long idPortfolio); /** * 更新文章排序号 @@ -64,7 +64,7 @@ public interface PortfolioMapper extends Mapper { * @param sortNo * @return */ - Integer updateArticleSortNo(@Param("idPortfolio") Integer idPortfolio, @Param("idArticle") Integer idArticle, @Param("sortNo") Integer sortNo); + Integer updateArticleSortNo(@Param("idPortfolio") Long idPortfolio, @Param("idArticle") Long idArticle, @Param("sortNo") Integer sortNo); /** * 取消绑定文章 @@ -72,7 +72,7 @@ public interface PortfolioMapper extends Mapper { * @param idArticle * @return */ - Integer unbindArticle(@Param("idPortfolio") Integer idPortfolio, @Param("idArticle") Integer idArticle); + Integer unbindArticle(@Param("idPortfolio") Long idPortfolio, @Param("idArticle") Long idArticle); /** * 获取作品集列表数据 diff --git a/src/main/java/com/rymcu/forest/mapper/RoleMapper.java b/src/main/java/com/rymcu/forest/mapper/RoleMapper.java index 813d7fd..89d2a4b 100644 --- a/src/main/java/com/rymcu/forest/mapper/RoleMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/RoleMapper.java @@ -8,7 +8,7 @@ import java.util.List; public interface RoleMapper extends Mapper { - List selectRoleByIdUser(@Param("id") Integer id); + List selectRoleByIdUser(@Param("id") Long id); Role selectRoleByInputCode(@Param("inputCode") String inputCode); diff --git a/src/main/java/com/rymcu/forest/mapper/SponsorMapper.java b/src/main/java/com/rymcu/forest/mapper/SponsorMapper.java index 7f36c26..9fb07a5 100644 --- a/src/main/java/com/rymcu/forest/mapper/SponsorMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/SponsorMapper.java @@ -13,5 +13,5 @@ public interface SponsorMapper extends Mapper { * @param idArticle * @return */ - Integer updateArticleSponsorCount(@Param("idArticle") Integer idArticle); + Integer updateArticleSponsorCount(@Param("idArticle") Long idArticle); } diff --git a/src/main/java/com/rymcu/forest/mapper/TagMapper.java b/src/main/java/com/rymcu/forest/mapper/TagMapper.java index b4b1138..63a1500 100644 --- a/src/main/java/com/rymcu/forest/mapper/TagMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/TagMapper.java @@ -18,7 +18,7 @@ public interface TagMapper extends Mapper { * @param idArticle * @return */ - Integer insertTagArticle(@Param("idTag") Integer idTag, @Param("idArticle") Integer idArticle); + Integer insertTagArticle(@Param("idTag") Integer idTag, @Param("idArticle") Long idArticle); /** * 统计标签使用数(文章) @@ -26,7 +26,7 @@ public interface TagMapper extends Mapper { * @param idArticle * @return */ - Integer selectCountTagArticleById(@Param("idTag") Integer idTag, @Param("idArticle") Integer idArticle); + Integer selectCountTagArticleById(@Param("idTag") Integer idTag, @Param("idArticle") Long idArticle); /** * 获取用户标签数 @@ -34,7 +34,7 @@ public interface TagMapper extends Mapper { * @param idTag * @return */ - Integer selectCountUserTagById(@Param("idUser") Integer idUser, @Param("idTag") Integer idTag); + Integer selectCountUserTagById(@Param("idUser") Long idUser, @Param("idTag") Integer idTag); /** * 插入用户标签信息 @@ -43,7 +43,7 @@ public interface TagMapper extends Mapper { * @param type * @return */ - Integer insertUserTag(@Param("idTag") Integer idTag, @Param("idUser") Integer idUser, @Param("type") Integer type); + Integer insertUserTag(@Param("idTag") Integer idTag, @Param("idUser") Long idUser, @Param("type") Integer type); /** * 删除未使用标签 diff --git a/src/main/java/com/rymcu/forest/mapper/UserMapper.java b/src/main/java/com/rymcu/forest/mapper/UserMapper.java index d2f42e8..2cdfef5 100644 --- a/src/main/java/com/rymcu/forest/mapper/UserMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/UserMapper.java @@ -28,7 +28,7 @@ public interface UserMapper extends Mapper { * @param idRole * @return */ - Integer insertUserRole(@Param("idUser") Integer idUser, @Param("idRole") Integer idRole); + Integer insertUserRole(@Param("idUser") Long idUser, @Param("idRole") Integer idRole); /** * 根据账号获取获取用户信息 @@ -57,7 +57,7 @@ public interface UserMapper extends Mapper { * @param idUser * @return */ - Integer selectRoleWeightsByUser(@Param("idUser") Integer idUser); + Integer selectRoleWeightsByUser(@Param("idUser") Long idUser); /** * 更新用户权限 @@ -73,7 +73,7 @@ public interface UserMapper extends Mapper { * @param status * @return */ - Integer updateStatus(@Param("idUser") Integer idUser, @Param("status") String status); + Integer updateStatus(@Param("idUser") Long idUser, @Param("status") String status); /** * 根据昵称获取重名用户数量 @@ -99,7 +99,7 @@ public interface UserMapper extends Mapper { * @param sex * @return */ - Integer updateUserInfo(@Param("idUser") Integer idUser, @Param("nickname") String nickname, @Param("avatarType") String avatarType, @Param("avatarUrl") String avatarUrl, @Param("signature") String signature, @Param("sex") String sex); + Integer updateUserInfo(@Param("idUser") Long idUser, @Param("nickname") String nickname, @Param("avatarType") String avatarType, @Param("avatarUrl") String avatarUrl, @Param("signature") String signature, @Param("sex") String sex); /** * 验证昵称是否重复 @@ -107,20 +107,20 @@ public interface UserMapper extends Mapper { * @param nickname * @return */ - Integer checkNicknameByIdUser(@Param("idUser") Integer idUser, @Param("nickname") String nickname); + Integer checkNicknameByIdUser(@Param("idUser") Long idUser, @Param("nickname") String nickname); /** * 根据用户 ID 获取作者信息 * @param id * @return */ - Author selectAuthor(@Param("id") Integer id); + Author selectAuthor(@Param("id") Long id); /** * 更新用户最后登录时间 * @param idUser * @return */ - Integer updateLastLoginTime(@Param("idUser") Integer idUser); + Integer updateLastLoginTime(@Param("idUser") Long idUser); /** * 更换邮箱 diff --git a/src/main/java/com/rymcu/forest/service/ArticleService.java b/src/main/java/com/rymcu/forest/service/ArticleService.java index 83174df..84f997f 100644 --- a/src/main/java/com/rymcu/forest/service/ArticleService.java +++ b/src/main/java/com/rymcu/forest/service/ArticleService.java @@ -29,7 +29,7 @@ public interface ArticleService extends Service
{ * @param type * @return * */ - ArticleDTO findArticleDTOById(Integer id, Integer type); + ArticleDTO findArticleDTOById(Long id, Integer type); /** * 查询主题下文章列表 @@ -50,7 +50,7 @@ public interface ArticleService extends Service
{ * @param idUser * @return * */ - List findUserArticlesByIdUser(Integer idUser); + List findUserArticlesByIdUser(Long idUser); /** * 新增/更新文章 @@ -60,7 +60,7 @@ public interface ArticleService extends Service
{ * @throws BaseApiException * @return * */ - Map postArticle(ArticleDTO article, HttpServletRequest request) throws UnsupportedEncodingException, BaseApiException; + Long postArticle(ArticleDTO article, HttpServletRequest request) throws UnsupportedEncodingException, BaseApiException; /** * 删除文章 @@ -68,13 +68,13 @@ public interface ArticleService extends Service
{ * @return * @throws BaseApiException * */ - Map delete(Integer id) throws BaseApiException; + Integer delete(Long id) throws BaseApiException; /** * 增量文章浏览数 * @param id */ - void incrementArticleViewCount(Integer id); + void incrementArticleViewCount(Long id); /** * 获取分享链接数据 @@ -82,7 +82,7 @@ public interface ArticleService extends Service
{ * @throws BaseApiException * @return */ - Map share(Integer id) throws BaseApiException; + public String share(Integer id) throws BaseApiException; /** * 查询草稿文章类别 @@ -96,7 +96,7 @@ public interface ArticleService extends Service
{ * @param idPortfolio * @return */ - List findArticlesByIdPortfolio(Integer idPortfolio); + List findArticlesByIdPortfolio(Long idPortfolio); /** * 查询作品集下未绑定文章 @@ -105,7 +105,7 @@ public interface ArticleService extends Service
{ * @param idUser * @return */ - List selectUnbindArticles(Integer idPortfolio, String searchText, Integer idUser); + List selectUnbindArticles(Long idPortfolio, String searchText, Long idUser); /** * 更新文章标签 @@ -115,7 +115,7 @@ public interface ArticleService extends Service
{ * @throws UnsupportedEncodingException * @throws BaseApiException */ - Map updateTags(Integer idArticle, String tags) throws UnsupportedEncodingException, BaseApiException; + Boolean updateTags(Long idArticle, String tags) throws UnsupportedEncodingException, BaseApiException; /** * 更新文章优选状态 @@ -123,7 +123,7 @@ public interface ArticleService extends Service
{ * @param articlePerfect * @return */ - Map updatePerfect(Integer idArticle, String articlePerfect); + Boolean updatePerfect(Long idArticle, String articlePerfect); /** * 获取公告列表 diff --git a/src/main/java/com/rymcu/forest/service/BankAccountService.java b/src/main/java/com/rymcu/forest/service/BankAccountService.java index 1794336..d90323e 100644 --- a/src/main/java/com/rymcu/forest/service/BankAccountService.java +++ b/src/main/java/com/rymcu/forest/service/BankAccountService.java @@ -24,7 +24,7 @@ public interface BankAccountService extends Service { * @param idUser * @return */ - BankAccountDTO findBankAccountByIdUser(Integer idUser); + BankAccountDTO findBankAccountByIdUser(Long idUser); /** * 根据账户查询银行账户信息 diff --git a/src/main/java/com/rymcu/forest/service/FollowService.java b/src/main/java/com/rymcu/forest/service/FollowService.java index d821fcc..94ba856 100644 --- a/src/main/java/com/rymcu/forest/service/FollowService.java +++ b/src/main/java/com/rymcu/forest/service/FollowService.java @@ -42,7 +42,7 @@ public interface FollowService extends Service { * @param followingId * @return */ - List findByFollowingId(String followType, Integer followingId); + List findByFollowingId(String followType, Long followingId); diff --git a/src/main/java/com/rymcu/forest/service/NotificationService.java b/src/main/java/com/rymcu/forest/service/NotificationService.java index 1b3e461..034611f 100644 --- a/src/main/java/com/rymcu/forest/service/NotificationService.java +++ b/src/main/java/com/rymcu/forest/service/NotificationService.java @@ -17,14 +17,14 @@ public interface NotificationService extends Service { * @param idUser * @return */ - List findUnreadNotifications(Integer idUser); + List findUnreadNotifications(Long idUser); /** * 获取消息数据 * @param idUser * @return */ - List findNotifications(Integer idUser); + List findNotifications(Long idUser); /** * 获取消息数据 @@ -33,7 +33,7 @@ public interface NotificationService extends Service { * @param dataType * @return */ - Notification findNotification(Integer idUser, Integer dataId, String dataType); + Notification findNotification(Long idUser, Long dataId, String dataType); /** * 创建系统通知 @@ -43,14 +43,14 @@ public interface NotificationService extends Service { * @param dataSummary * @return */ - Integer save(Integer idUser, Integer dataId, String dataType, String dataSummary); + Integer save(Long idUser, Long dataId, String dataType, String dataSummary); /** * 标记消息已读 * @param id * @return */ - Integer readNotification(Integer id); + Integer readNotification(Long id); /** * 标记所有消息已读 @@ -65,5 +65,5 @@ public interface NotificationService extends Service { * @param dataType * @return */ - Integer deleteUnreadNotification(Integer dataId, String dataType); + Integer deleteUnreadNotification(Long dataId, String dataType); } diff --git a/src/main/java/com/rymcu/forest/service/PortfolioService.java b/src/main/java/com/rymcu/forest/service/PortfolioService.java index bae6059..13e83b8 100644 --- a/src/main/java/com/rymcu/forest/service/PortfolioService.java +++ b/src/main/java/com/rymcu/forest/service/PortfolioService.java @@ -27,7 +27,7 @@ public interface PortfolioService extends Service { * @param type * @return */ - PortfolioDTO findPortfolioDTOById(Integer idPortfolio, Integer type); + PortfolioDTO findPortfolioDTOById(Long idPortfolio, Integer type); /** * 保持/更新作品集 @@ -47,7 +47,7 @@ public interface PortfolioService extends Service { * @throws BaseApiException * @return */ - Map findUnbindArticles(Integer page, Integer rows, String searchText, Integer idPortfolio) throws BaseApiException; + Map findUnbindArticles(Integer page, Integer rows, String searchText, Long idPortfolio) throws BaseApiException; /** * 绑定文章 @@ -69,14 +69,14 @@ public interface PortfolioService extends Service { * @param idArticle * @return */ - Map unbindArticle(Integer idPortfolio, Integer idArticle); + Map unbindArticle(Long idPortfolio, Long idArticle); /** * 删除作品集 * @param idPortfolio * @return */ - Map deletePortfolio(Integer idPortfolio) throws BaseApiException; + Map deletePortfolio(Long idPortfolio) throws BaseApiException; /** * 获取作品集列表数据 diff --git a/src/main/java/com/rymcu/forest/service/RoleService.java b/src/main/java/com/rymcu/forest/service/RoleService.java index f5db02d..3afa2ce 100644 --- a/src/main/java/com/rymcu/forest/service/RoleService.java +++ b/src/main/java/com/rymcu/forest/service/RoleService.java @@ -27,7 +27,7 @@ public interface RoleService extends Service { * @param idUser * @return * */ - List findByIdUser(Integer idUser); + List findByIdUser(Long idUser); /** * 更新用户状态 diff --git a/src/main/java/com/rymcu/forest/service/TransactionRecordService.java b/src/main/java/com/rymcu/forest/service/TransactionRecordService.java index e5da803..6d8f7e0 100644 --- a/src/main/java/com/rymcu/forest/service/TransactionRecordService.java +++ b/src/main/java/com/rymcu/forest/service/TransactionRecordService.java @@ -36,7 +36,7 @@ public interface TransactionRecordService extends Service { * @return * @throws Exception */ - TransactionRecord userTransfer(Integer toUserId, Integer formUserId, TransactionEnum transactionType) throws Exception; + TransactionRecord userTransfer(Long toUserId, Long formUserId, TransactionEnum transactionType) throws Exception; /** * 社区银行转账/奖励发放 @@ -45,7 +45,7 @@ public interface TransactionRecordService extends Service { * @return * @throws Exception */ - TransactionRecord bankTransfer(Integer idUser, TransactionEnum transactionType) throws Exception; + TransactionRecord bankTransfer(Long idUser, TransactionEnum transactionType) throws Exception; /** * 发放新手奖励 diff --git a/src/main/java/com/rymcu/forest/service/UserService.java b/src/main/java/com/rymcu/forest/service/UserService.java index 161669b..fa6dbcb 100644 --- a/src/main/java/com/rymcu/forest/service/UserService.java +++ b/src/main/java/com/rymcu/forest/service/UserService.java @@ -71,7 +71,7 @@ public interface UserService extends Service { * @param status 状态 * @return Map * */ - Map updateStatus(Integer idUser, String status); + Map updateStatus(Long idUser, String status); /** * 获取用户信息 @@ -93,21 +93,21 @@ public interface UserService extends Service { * @param nickname * @return */ - Map checkNickname(Integer idUser, String nickname); + Map checkNickname(Long idUser, String nickname); /** * 获取用户权限 * @param idUser * @return */ - Integer findRoleWeightsByUser(Integer idUser); + Integer findRoleWeightsByUser(Long idUser); /** * 查询作者信息 * @param idUser * @return */ - Author selectAuthor(Integer idUser); + Author selectAuthor(Long idUser); /** * 更新用户扩展信息 diff --git a/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java index f0bc2f2..90b2c83 100644 --- a/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java @@ -1,6 +1,9 @@ package com.rymcu.forest.service.impl; import com.rymcu.forest.core.constant.NotificationConstant; +import com.rymcu.forest.core.exception.ContentNotExistException; +import com.rymcu.forest.core.exception.DataDuplicationException; +import com.rymcu.forest.core.exception.UltraViresException; import com.rymcu.forest.core.service.AbstractService; import com.rymcu.forest.dto.*; import com.rymcu.forest.entity.Article; @@ -68,7 +71,7 @@ public class ArticleServiceImpl extends AbstractService
implements Arti } @Override - public ArticleDTO findArticleDTOById(Integer id, Integer type) { + public ArticleDTO findArticleDTOById(Long id, Integer type) { ArticleDTO articleDTO = articleMapper.selectArticleDTOById(id, type); if (articleDTO == null) { return null; @@ -90,7 +93,7 @@ public class ArticleServiceImpl extends AbstractService
implements Arti } @Override - public List findUserArticlesByIdUser(Integer idUser) { + public List findUserArticlesByIdUser(Long idUser) { List list = articleMapper.selectUserArticles(idUser); list.forEach(articleDTO -> genArticle(articleDTO, 0)); return list; @@ -98,16 +101,7 @@ public class ArticleServiceImpl extends AbstractService
implements Arti @Override @Transactional(rollbackFor = {UnsupportedEncodingException.class, BaseApiException.class}) - public Map postArticle(ArticleDTO article, HttpServletRequest request) throws UnsupportedEncodingException, BaseApiException { - Map map = new HashMap(1); - if (StringUtils.isBlank(article.getArticleTitle())) { - map.put("message", "标题不能为空!"); - return map; - } - if (StringUtils.isBlank(article.getArticleContent())) { - map.put("message", "正文不能为空!"); - return map; - } + public Long postArticle(ArticleDTO article, HttpServletRequest request) throws UnsupportedEncodingException, BaseApiException { boolean isUpdate = false; String articleTitle = article.getArticleTitle(); String articleTags = article.getArticleTags(); @@ -122,14 +116,14 @@ public class ArticleServiceImpl extends AbstractService
implements Arti if (StringUtils.isNotBlank(reservedTag)) { Integer roleWeights = userService.findRoleWeightsByUser(user.getIdUser()); if (roleWeights > ADMIN_ROLE_WEIGHTS) { - map.put("message", StringEscapeUtils.unescapeJava(reservedTag) + "标签为系统保留标签!"); - return map; + throw new UltraViresException(StringEscapeUtils.unescapeJava(reservedTag) + "标签为系统保留标签!"); } else { notification = true; } } Article newArticle; - if (article.getIdArticle() == null || article.getIdArticle() == 0) { + Long idArticle = article.getIdArticle(); + if (idArticle == null || idArticle == 0) { newArticle = new Article(); newArticle.setArticleTitle(articleTitle); newArticle.setArticleAuthorId(user.getIdUser()); @@ -140,7 +134,7 @@ public class ArticleServiceImpl extends AbstractService
implements Arti articleMapper.insertSelective(newArticle); articleMapper.insertArticleContent(newArticle.getIdArticle(), articleContent, articleContentHtml); } else { - newArticle = articleMapper.selectByPrimaryKey(article.getIdArticle()); + newArticle = articleMapper.selectByPrimaryKey(idArticle); // 如果文章之前状态为草稿则应视为新发布文章 if (DEFAULT_STATUS.equals(newArticle.getArticleStatus())) { isUpdate = true; @@ -151,38 +145,38 @@ public class ArticleServiceImpl extends AbstractService
implements Arti newArticle.setUpdatedTime(new Date()); articleMapper.updateArticleContent(newArticle.getIdArticle(), articleContent, articleContentHtml); } - + Long newArticleId = newArticle.getIdArticle(); // 发送相关通知 if (DEFAULT_STATUS.equals(newArticle.getArticleStatus())) { // 发送系统通知 if (notification) { - NotificationUtils.sendAnnouncement(newArticle.getIdArticle(), NotificationConstant.Article, newArticle.getArticleTitle()); + NotificationUtils.sendAnnouncement(newArticleId, NotificationConstant.Article, newArticle.getArticleTitle()); } else { // 发送关注通知 StringBuilder dataSummary = new StringBuilder(); if (isUpdate) { dataSummary.append(user.getNickname()).append("更新了文章: ").append(newArticle.getArticleTitle()); - NotificationUtils.sendArticlePush(newArticle.getIdArticle(), NotificationConstant.UpdateArticle, dataSummary.toString(), newArticle.getArticleAuthorId()); + NotificationUtils.sendArticlePush(newArticleId, NotificationConstant.UpdateArticle, dataSummary.toString(), newArticle.getArticleAuthorId()); } else { dataSummary.append(user.getNickname()).append("发布了文章: ").append(newArticle.getArticleTitle()); - NotificationUtils.sendArticlePush(newArticle.getIdArticle(), NotificationConstant.PostArticle, dataSummary.toString(), newArticle.getArticleAuthorId()); + NotificationUtils.sendArticlePush(newArticleId, NotificationConstant.PostArticle, dataSummary.toString(), newArticle.getArticleAuthorId()); } } // 草稿不更新索引 if (isUpdate) { - log.info("更新文章索引,id={}", newArticle.getIdArticle()); - luceneService.updateArticle(newArticle.getIdArticle().toString()); + log.info("更新文章索引,id={}", newArticleId); + luceneService.updateArticle(newArticleId.toString()); } else { - log.info("写入文章索引,id={}", newArticle.getIdArticle()); - luceneService.writeArticle(newArticle.getIdArticle().toString()); + log.info("写入文章索引,id={}", newArticleId); + luceneService.writeArticle(newArticleId.toString()); } // 更新文章链接 - newArticle.setArticlePermalink(domain + "/article/" + newArticle.getIdArticle()); - newArticle.setArticleLink("/article/" + newArticle.getIdArticle()); + newArticle.setArticlePermalink(domain + "/article/" + newArticleId); + newArticle.setArticleLink("/article/" + newArticleId); } else { // 更新文章链接 - newArticle.setArticlePermalink(domain + "/draft/" + newArticle.getIdArticle()); - newArticle.setArticleLink("/draft/" + newArticle.getIdArticle()); + newArticle.setArticlePermalink(domain + "/draft/" + newArticleId); + newArticle.setArticleLink("/draft/" + newArticleId); } tagService.saveTagArticle(newArticle, articleContentHtml); @@ -194,66 +188,24 @@ public class ArticleServiceImpl extends AbstractService
implements Arti newArticle.setArticlePreviewContent(previewContent); } articleMapper.updateByPrimaryKeySelective(newArticle); - - map.put("id", newArticle.getIdArticle()); - return map; - } - - private String checkTags(String articleTags) { - // 判断文章是否有标签 - if (StringUtils.isBlank(articleTags)) { - return ""; - } - // 判断是否存在系统配置的保留标签词 - Condition condition = new Condition(Tag.class); - condition.createCriteria().andEqualTo("tagReservation", "1"); - List tags = tagService.findByCondition(condition); - if (tags.isEmpty()) { - return ""; - } else { - String[] articleTagArr = articleTags.split(","); - for (Tag tag : tags) { - if (StringUtils.isBlank(tag.getTagTitle())) { - continue; - } - - for (String articleTag : articleTagArr) { - if (StringUtils.isBlank(articleTag)) { - continue; - } - if (articleTag.equals(tag.getTagTitle())) { - return tag.getTagTitle(); - } - } - } - } - - return ""; + return newArticleId; } @Override @Transactional(rollbackFor = Exception.class) - public Map delete(Integer id) throws BaseApiException { - Map map = new HashMap(1); - int result; + public Integer delete(Long id) throws BaseApiException { // 判断是否有评论 - boolean isHavComment = articleMapper.existsCommentWithPrimaryKey(id); - if (isHavComment) { - map.put("message", "已有评论的文章不允许删除!"); - } else { + if (!articleMapper.existsCommentWithPrimaryKey(id)) { // 删除关联数据(作品集关联关系,标签关联关系) deleteLinkedData(id); // 删除文章 - result = articleMapper.deleteByPrimaryKey(id); + int result = articleMapper.deleteByPrimaryKey(id); luceneService.deleteArticle(id.toString()); - if (result < 1) { - map.put("message", "删除失败!"); - } - } - return map; + return result; + } else throw new DataDuplicationException("已有评论的文章不允许删除!"); } - private void deleteLinkedData(Integer id) { + private void deleteLinkedData(Long id) { // 删除关联作品集 articleMapper.deleteLinkedPortfolioData(id); // 删除引用标签记录 @@ -266,22 +218,20 @@ public class ArticleServiceImpl extends AbstractService
implements Arti @Override @Transactional(rollbackFor = Exception.class) - public void incrementArticleViewCount(Integer id) { + public void incrementArticleViewCount(Long id) { Article article = articleMapper.selectByPrimaryKey(id); Integer articleViewCount = article.getArticleViewCount() + 1; articleMapper.updateArticleViewCount(article.getIdArticle(), articleViewCount); } @Override - public Map share(Integer id) throws BaseApiException { + public String share(Integer id) throws BaseApiException { Article article = articleMapper.selectByPrimaryKey(id); User user = UserUtils.getCurrentUserByToken(); if (Objects.isNull(user)) { throw new BaseApiException(ErrorCode.INVALID_TOKEN); } - Map map = new HashMap(2); - map.put("shareUrl", article.getArticlePermalink() + "?s=" + user.getAccount()); - return map; + return article.getArticlePermalink() + "?s=" + user.getAccount(); } @Override @@ -296,14 +246,14 @@ public class ArticleServiceImpl extends AbstractService
implements Arti } @Override - public List findArticlesByIdPortfolio(Integer idPortfolio) { + public List findArticlesByIdPortfolio(Long idPortfolio) { List list = articleMapper.selectArticlesByIdPortfolio(idPortfolio); list.forEach(articleDTO -> genArticle(articleDTO, 0)); return list; } @Override - public List selectUnbindArticles(Integer idPortfolio, String searchText, Integer idUser) { + public List selectUnbindArticles(Long idPortfolio, String searchText, Long idUser) { List list = articleMapper.selectUnbindArticlesByIdPortfolio(idPortfolio, searchText, idUser); list.forEach(articleDTO -> genArticle(articleDTO, 0)); return list; @@ -311,32 +261,23 @@ public class ArticleServiceImpl extends AbstractService
implements Arti @Override @Transactional(rollbackFor = Exception.class) - public Map updateTags(Integer idArticle, String tags) throws UnsupportedEncodingException, BaseApiException { - Map map = new HashMap(2); + public Boolean updateTags(Long idArticle, String tags) throws UnsupportedEncodingException, BaseApiException { Article article = articleMapper.selectByPrimaryKey(idArticle); - if (Objects.nonNull(article)) { - article.setArticleTags(tags); - articleMapper.updateArticleTags(idArticle, tags); - tagService.saveTagArticle(article, ""); - map.put("success", true); - } else { - map.put("success", false); - map.put("message", "更新失败,文章不存在!"); + if (!Objects.nonNull(article)) { + throw new ContentNotExistException("更新失败,文章不存在!"); } - return map; + article.setArticleTags(tags); + articleMapper.updateArticleTags(idArticle, tags); + tagService.saveTagArticle(article, ""); + return true; } @Override - public Map updatePerfect(Integer idArticle, String articlePerfect) { - Map map = new HashMap(2); - int result = articleMapper.updatePerfect(idArticle, articlePerfect); - if (result == 0) { - map.put("success", false); - map.put("message", "设置优选文章失败!"); - } else { - map.put("success", true); + public Boolean updatePerfect(Long idArticle, String articlePerfect) { + if (articleMapper.updatePerfect(idArticle, articlePerfect) == 0) { + throw new ContentNotExistException("设置优选文章失败!"); } - return map; + return true; } @Override @@ -387,4 +328,36 @@ public class ArticleServiceImpl extends AbstractService
implements Arti author.setUserAccount(user.getAccount()); return author; } + + private String checkTags(String articleTags) { + // 判断文章是否有标签 + if (StringUtils.isBlank(articleTags)) { + return ""; + } + // 判断是否存在系统配置的保留标签词 + Condition condition = new Condition(Tag.class); + condition.createCriteria().andEqualTo("tagReservation", "1"); + List tags = tagService.findByCondition(condition); + if (tags.isEmpty()) { + return ""; + } else { + String[] articleTagArr = articleTags.split(","); + for (Tag tag : tags) { + if (StringUtils.isBlank(tag.getTagTitle())) { + continue; + } + + for (String articleTag : articleTagArr) { + if (StringUtils.isBlank(articleTag)) { + continue; + } + if (articleTag.equals(tag.getTagTitle())) { + return tag.getTagTitle(); + } + } + } + } + + return ""; + } } diff --git a/src/main/java/com/rymcu/forest/service/impl/BankAccountServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/BankAccountServiceImpl.java index 7bd4ba5..7ee2b2f 100644 --- a/src/main/java/com/rymcu/forest/service/impl/BankAccountServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/BankAccountServiceImpl.java @@ -37,7 +37,7 @@ public class BankAccountServiceImpl extends AbstractService impleme } @Override - public BankAccountDTO findBankAccountByIdUser(Integer idUser) { + public BankAccountDTO findBankAccountByIdUser(Long idUser) { BankAccount bankAccount = new BankAccount(); bankAccount.setAccountOwner(idUser); String defaultAccountType = "0"; @@ -79,7 +79,7 @@ public class BankAccountServiceImpl extends AbstractService impleme BankAccount bankAccount = new BankAccount(); bankAccount.setIdBank(1); bankAccount.setAccountType("1"); - bankAccount.setAccountOwner(2); + bankAccount.setAccountOwner(2L); return bankAccountMapper.selectOne(bankAccount); } diff --git a/src/main/java/com/rymcu/forest/service/impl/FollowServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/FollowServiceImpl.java index 5985562..e069c0c 100644 --- a/src/main/java/com/rymcu/forest/service/impl/FollowServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/FollowServiceImpl.java @@ -51,7 +51,7 @@ public class FollowServiceImpl extends AbstractService implements Follow } @Override - public List findByFollowingId(String followType, Integer followingId) { + public List findByFollowingId(String followType, Long followingId) { Follow follow = new Follow(); follow.setFollowingType(followType); follow.setFollowingId(followingId); diff --git a/src/main/java/com/rymcu/forest/service/impl/NotificationServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/NotificationServiceImpl.java index 18143ea..82b256e 100644 --- a/src/main/java/com/rymcu/forest/service/impl/NotificationServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/NotificationServiceImpl.java @@ -28,12 +28,12 @@ public class NotificationServiceImpl extends AbstractService imple private final static String UN_READ = "0"; @Override - public List findUnreadNotifications(Integer idUser) { + public List findUnreadNotifications(Long idUser) { return notificationMapper.selectUnreadNotifications(idUser); } @Override - public List findNotifications(Integer idUser) { + public List findNotifications(Long idUser) { List list = notificationMapper.selectNotifications(idUser); list.forEach(notification -> { NotificationDTO notificationDTO = NotificationUtils.genNotification(notification); @@ -57,19 +57,19 @@ public class NotificationServiceImpl extends AbstractService imple } @Override - public Notification findNotification(Integer idUser, Integer dataId, String dataType) { + public Notification findNotification(Long idUser, Long dataId, String dataType) { return notificationMapper.selectNotification(idUser, dataId, dataType); } @Override @Transactional(rollbackFor = Exception.class) - public Integer save(Integer idUser, Integer dataId, String dataType, String dataSummary) { + public Integer save(Long idUser, Long dataId, String dataType, String dataSummary) { return notificationMapper.insertNotification(idUser, dataId, dataType, dataSummary); } @Override @Transactional(rollbackFor = Exception.class) - public Integer readNotification(Integer id) { + public Integer readNotification(Long id) { return notificationMapper.readNotification(id); } @@ -79,7 +79,7 @@ public class NotificationServiceImpl extends AbstractService imple } @Override - public Integer deleteUnreadNotification(Integer dataId, String dataType) { + public Integer deleteUnreadNotification(Long dataId, String dataType) { return notificationMapper.deleteUnreadNotification(dataId, dataType); } } diff --git a/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java index c0de668..8e067bd 100644 --- a/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java @@ -4,7 +4,6 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.rymcu.forest.core.service.AbstractService; import com.rymcu.forest.dto.*; -import com.rymcu.forest.entity.Article; import com.rymcu.forest.entity.Portfolio; import com.rymcu.forest.entity.User; import com.rymcu.forest.lucene.model.PortfolioLucene; @@ -53,7 +52,7 @@ public class PortfolioServiceImpl extends AbstractService implements } @Override - public PortfolioDTO findPortfolioDTOById(Integer idPortfolio, Integer type) { + public PortfolioDTO findPortfolioDTOById(Long idPortfolio, Integer type) { PortfolioDTO portfolio = portfolioMapper.selectPortfolioDTOById(idPortfolio,type); if (portfolio == null) { return new PortfolioDTO(); @@ -68,6 +67,7 @@ public class PortfolioServiceImpl extends AbstractService implements @Override public Portfolio postPortfolio(Portfolio portfolio) throws BaseApiException { User user = UserUtils.getCurrentUserByToken(); + assert user != null; if (StringUtils.isNotBlank(portfolio.getHeadImgType())) { String headImgUrl = UploadController.uploadBase64File(portfolio.getHeadImgUrl(), 0); portfolio.setHeadImgUrl(headImgUrl); @@ -98,7 +98,7 @@ public class PortfolioServiceImpl extends AbstractService implements } @Override - public Map findUnbindArticles(Integer page, Integer rows, String searchText, Integer idPortfolio) throws BaseApiException { + public Map findUnbindArticles(Integer page, Integer rows, String searchText, Long idPortfolio) throws BaseApiException { Map map = new HashMap(1); User user = UserUtils.getCurrentUserByToken(); Portfolio portfolio = portfolioMapper.selectByPrimaryKey(idPortfolio); @@ -153,7 +153,7 @@ public class PortfolioServiceImpl extends AbstractService implements } @Override - public Map unbindArticle(Integer idPortfolio, Integer idArticle) { + public Map unbindArticle(Long idPortfolio, Long idArticle) { Map map = new HashMap(1); if (idPortfolio == null || idPortfolio.equals(0)) { map.put("message", "作品集数据异常"); @@ -171,7 +171,7 @@ public class PortfolioServiceImpl extends AbstractService implements } @Override - public Map deletePortfolio(Integer idPortfolio) throws BaseApiException { + public Map deletePortfolio(Long idPortfolio) throws BaseApiException { Map map = new HashMap(1); if (idPortfolio == null || idPortfolio.equals(0)) { map.put("message", "作品集数据异常"); diff --git a/src/main/java/com/rymcu/forest/service/impl/RoleServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/RoleServiceImpl.java index cc0e387..7a0df7b 100644 --- a/src/main/java/com/rymcu/forest/service/impl/RoleServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/RoleServiceImpl.java @@ -32,7 +32,7 @@ public class RoleServiceImpl extends AbstractService implements RoleServic } @Override - public List findByIdUser(Integer idUser) { + public List findByIdUser(Long idUser) { return roleMapper.selectRoleByIdUser(idUser); } diff --git a/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java index 4a2f7cb..c1f3837 100644 --- a/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java @@ -70,7 +70,7 @@ public class TransactionRecordServiceImpl extends AbstractService implements UserServic @Override @Transactional(rollbackFor = Exception.class) - public Map updateStatus(Integer idUser, String status) { + public Map updateStatus(Long idUser, String status) { Map map = new HashMap(2); Integer result = userMapper.updateStatus(idUser, status); if (result == 0) { @@ -231,7 +231,7 @@ public class UserServiceImpl extends AbstractService implements UserServic } @Override - public Map checkNickname(Integer idUser, String nickname) { + public Map checkNickname(Long idUser, String nickname) { Map map = new HashMap(2); Integer number = userMapper.checkNicknameByIdUser(idUser, nickname); if (number > 0) { @@ -241,12 +241,12 @@ public class UserServiceImpl extends AbstractService implements UserServic } @Override - public Integer findRoleWeightsByUser(Integer idUser) { + public Integer findRoleWeightsByUser(Long idUser) { return userMapper.selectRoleWeightsByUser(idUser); } @Override - public Author selectAuthor(Integer idUser) { + public Author selectAuthor(Long idUser) { return userMapper.selectAuthor(idUser); } diff --git a/src/main/java/com/rymcu/forest/util/NotificationUtils.java b/src/main/java/com/rymcu/forest/util/NotificationUtils.java index 93de7d0..56a1c87 100644 --- a/src/main/java/com/rymcu/forest/util/NotificationUtils.java +++ b/src/main/java/com/rymcu/forest/util/NotificationUtils.java @@ -29,7 +29,7 @@ public class NotificationUtils { private static ArticleService articleService = SpringContextHolder.getBean(ArticleService.class); private static CommentService commentService = SpringContextHolder.getBean(CommentService.class); - public static void sendAnnouncement(Integer dataId, String dataType, String dataSummary) { + public static void sendAnnouncement(Long dataId, String dataType, String dataSummary) { ExecutorService executor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue()); CompletableFuture.supplyAsync(() -> { try { @@ -44,7 +44,7 @@ public class NotificationUtils { }, executor); } - public static void saveNotification(Integer idUser, Integer dataId, String dataType, String dataSummary) { + public static void saveNotification(Long idUser, Long dataId, String dataType, String dataSummary) { ExecutorService executor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue()); CompletableFuture.supplyAsync(() -> { try { @@ -70,7 +70,7 @@ public class NotificationUtils { } - public static void sendArticlePush(Integer dataId, String dataType, String dataSummary, Integer articleAuthorId) { + public static void sendArticlePush(Long dataId, String dataType, String dataSummary, Long articleAuthorId) { ExecutorService executor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue()); CompletableFuture.supplyAsync(() -> { try { @@ -154,12 +154,10 @@ public class NotificationUtils { private static String getFollowLink(String followingType, String id) { StringBuilder url = new StringBuilder(); url.append(Utils.getProperty("resource.domain")); - switch (followingType) { - case "0": - url = url.append("/user/").append(id); - break; - default: - url.append("/notification"); + if ("0".equals(followingType)) { + url.append("/user/").append(id); + } else { + url.append("/notification"); } return url.toString(); } diff --git a/src/main/java/com/rymcu/forest/web/api/admin/AdminArticleController.java b/src/main/java/com/rymcu/forest/web/api/admin/AdminArticleController.java index 8d14194..9b2cac8 100644 --- a/src/main/java/com/rymcu/forest/web/api/admin/AdminArticleController.java +++ b/src/main/java/com/rymcu/forest/web/api/admin/AdminArticleController.java @@ -26,8 +26,9 @@ public class AdminArticleController { private ArticleService articleService; @PatchMapping("/update-perfect") - public GlobalResult updatePerfect(@RequestBody Article article) { - Map map = articleService.updatePerfect(article.getIdArticle(), article.getArticlePerfect()); - return GlobalResultGenerator.genSuccessResult(map); + public GlobalResult updatePerfect(@RequestBody Article article) { + Long idArticle = article.getIdArticle(); + String articlePerfect = article.getArticlePerfect(); + return GlobalResultGenerator.genSuccessResult(articleService.updatePerfect(idArticle, articlePerfect)); } } diff --git a/src/main/java/com/rymcu/forest/web/api/admin/AdminController.java b/src/main/java/com/rymcu/forest/web/api/admin/AdminController.java index b4a297a..a8ec9f4 100644 --- a/src/main/java/com/rymcu/forest/web/api/admin/AdminController.java +++ b/src/main/java/com/rymcu/forest/web/api/admin/AdminController.java @@ -54,7 +54,7 @@ public class AdminController { } @GetMapping("/user/{idUser}/role") - public GlobalResult> userRole(@PathVariable Integer idUser){ + public GlobalResult> userRole(@PathVariable Long idUser){ List roles = roleService.findByIdUser(idUser); return GlobalResultGenerator.genSuccessResult(roles); } diff --git a/src/main/java/com/rymcu/forest/web/api/article/ArticleController.java b/src/main/java/com/rymcu/forest/web/api/article/ArticleController.java index a21f5e8..8408da5 100644 --- a/src/main/java/com/rymcu/forest/web/api/article/ArticleController.java +++ b/src/main/java/com/rymcu/forest/web/api/article/ArticleController.java @@ -43,61 +43,52 @@ public class ArticleController { private SponsorService sponsorService; @GetMapping("/detail/{idArticle}") - public GlobalResult> detail(@PathVariable Integer idArticle, @RequestParam(defaultValue = "2") Integer type) { - ArticleDTO articleDTO = articleService.findArticleDTOById(idArticle, type); - Map map = new HashMap<>(1); - map.put("article", articleDTO); - return GlobalResultGenerator.genSuccessResult(map); + public GlobalResult detail(@PathVariable Long idArticle, @RequestParam(defaultValue = "2") Integer type) { + ArticleDTO dto = articleService.findArticleDTOById(idArticle, type); + return GlobalResultGenerator.genSuccessResult(dto); } @PostMapping("/post") - public GlobalResult postArticle(@RequestBody ArticleDTO article, HttpServletRequest request) throws BaseApiException, UnsupportedEncodingException { - Map map = articleService.postArticle(article, request); - return GlobalResultGenerator.genSuccessResult(map); + public GlobalResult postArticle(@RequestBody ArticleDTO article, HttpServletRequest request) throws BaseApiException, UnsupportedEncodingException { + return GlobalResultGenerator.genSuccessResult(articleService.postArticle(article, request)); } @PutMapping("/post") @AuthorshipInterceptor(moduleName = Module.ARTICLE) - public GlobalResult updateArticle(@RequestBody ArticleDTO article, HttpServletRequest request) throws BaseApiException, UnsupportedEncodingException { - Map map = articleService.postArticle(article, request); - return GlobalResultGenerator.genSuccessResult(map); + public GlobalResult updateArticle(@RequestBody ArticleDTO article, HttpServletRequest request) throws BaseApiException, UnsupportedEncodingException { + return GlobalResultGenerator.genSuccessResult(articleService.postArticle(article, request)); } @DeleteMapping("/delete/{idArticle}") @AuthorshipInterceptor(moduleName = Module.ARTICLE) - public GlobalResult delete(@PathVariable Integer idArticle) throws BaseApiException { - Map map = articleService.delete(idArticle); - return GlobalResultGenerator.genSuccessResult(map); + public GlobalResult delete(@PathVariable Long idArticle) throws BaseApiException { + return GlobalResultGenerator.genSuccessResult(articleService.delete(idArticle)); } @GetMapping("/{idArticle}/comments") - public GlobalResult> commons(@PathVariable Integer idArticle) { - List commentDTOList = commentService.getArticleComments(idArticle); - Map map = new HashMap<>(1); - map.put("comments", commentDTOList); - return GlobalResultGenerator.genSuccessResult(map); + public GlobalResult> commons(@PathVariable Integer idArticle) { + return GlobalResultGenerator.genSuccessResult(commentService.getArticleComments(idArticle)); } @GetMapping("/drafts") - public GlobalResult drafts(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) throws BaseApiException { + public GlobalResult> drafts(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) throws BaseApiException { PageHelper.startPage(page, rows); List list = articleService.findDrafts(); - PageInfo pageInfo = new PageInfo(list); - Map map = Utils.getArticlesGlobalResult(pageInfo); - return GlobalResultGenerator.genSuccessResult(map); + PageInfo pageInfo = new PageInfo<>(list); + return GlobalResultGenerator.genSuccessResult(pageInfo); } @GetMapping("/{idArticle}/share") - public GlobalResult share(@PathVariable Integer idArticle) throws BaseApiException { - Map map = articleService.share(idArticle); - return GlobalResultGenerator.genSuccessResult(map); + public GlobalResult share(@PathVariable Integer idArticle) throws BaseApiException { + return GlobalResultGenerator.genSuccessResult(articleService.share(idArticle)); } @PostMapping("/update-tags") @AuthorshipInterceptor(moduleName = Module.ARTICLE_TAG) - public GlobalResult updateTags(@RequestBody Article article) throws BaseApiException, UnsupportedEncodingException { - Map map = articleService.updateTags(article.getIdArticle(), article.getArticleTags()); - return GlobalResultGenerator.genSuccessResult(map); + public GlobalResult updateTags(@RequestBody Article article) throws BaseApiException, UnsupportedEncodingException { + Long idArticle = article.getIdArticle(); + String articleTags = article.getArticleTags(); + return GlobalResultGenerator.genSuccessResult(articleService.updateTags(idArticle, articleTags)); } @PostMapping("/thumbs-up") diff --git a/src/main/java/com/rymcu/forest/web/api/bank/BankAccountController.java b/src/main/java/com/rymcu/forest/web/api/bank/BankAccountController.java index fd399ab..37f1d87 100644 --- a/src/main/java/com/rymcu/forest/web/api/bank/BankAccountController.java +++ b/src/main/java/com/rymcu/forest/web/api/bank/BankAccountController.java @@ -43,7 +43,7 @@ public class BankAccountController { } @GetMapping("/{idUser}") - public GlobalResult detail(@PathVariable Integer idUser) { + public GlobalResult detail(@PathVariable Long idUser) { BankAccountDTO bankAccount = bankAccountService.findBankAccountByIdUser(idUser); return GlobalResultGenerator.genSuccessResult(bankAccount); } diff --git a/src/main/java/com/rymcu/forest/web/api/bank/WalletController.java b/src/main/java/com/rymcu/forest/web/api/bank/WalletController.java index 44cb23c..9714ee6 100644 --- a/src/main/java/com/rymcu/forest/web/api/bank/WalletController.java +++ b/src/main/java/com/rymcu/forest/web/api/bank/WalletController.java @@ -33,7 +33,7 @@ public class WalletController { @GetMapping("/{idUser}") @SecurityInterceptor - public GlobalResult detail(@PathVariable Integer idUser) { + public GlobalResult detail(@PathVariable Long idUser) { BankAccountDTO bankAccount = bankAccountService.findBankAccountByIdUser(idUser); return GlobalResultGenerator.genSuccessResult(bankAccount); } @@ -44,7 +44,7 @@ public class WalletController { String idUser = request.getParameter("idUser"); String startDate = request.getParameter("startDate"); String endDate = request.getParameter("endDate"); - BankAccountDTO bankAccount = bankAccountService.findBankAccountByIdUser(Integer.valueOf(idUser)); + BankAccountDTO bankAccount = bankAccountService.findBankAccountByIdUser(Long.valueOf(idUser)); PageHelper.startPage(page, rows); List list = bankAccountService.findUserTransactionRecords(bankAccount.getBankAccount(), startDate, endDate); PageInfo pageInfo = new PageInfo(list); 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 490a1c8..1d31609 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,7 +106,7 @@ public class CommonApiController { @GetMapping("/article/{id}") @VisitLogger - public GlobalResult> article(@PathVariable Integer id) { + public GlobalResult> article(@PathVariable Long id) { ArticleDTO articleDTO = articleService.findArticleDTOById(id, 1); Map map = new HashMap<>(1); map.put("article", articleDTO); @@ -121,7 +121,7 @@ public class CommonApiController { @GetMapping("/portfolio/{id}") @VisitLogger - public GlobalResult> portfolio(@PathVariable Integer id) { + public GlobalResult> portfolio(@PathVariable Long id) { PortfolioDTO portfolioDTO = portfolioService.findPortfolioDTOById(id, 1); Map map = new HashMap<>(1); map.put("portfolio", portfolioDTO); @@ -129,7 +129,7 @@ public class CommonApiController { } @GetMapping("/portfolio/{id}/articles") - public GlobalResult articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable Integer id) { + public GlobalResult articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable Long id) { PageHelper.startPage(page, rows); List list = articleService.findArticlesByIdPortfolio(id); PageInfo pageInfo = new PageInfo(list); diff --git a/src/main/java/com/rymcu/forest/web/api/notification/NotificationController.java b/src/main/java/com/rymcu/forest/web/api/notification/NotificationController.java index ac8e403..4150e3f 100644 --- a/src/main/java/com/rymcu/forest/web/api/notification/NotificationController.java +++ b/src/main/java/com/rymcu/forest/web/api/notification/NotificationController.java @@ -57,7 +57,7 @@ public class NotificationController { } @PutMapping("/read/{id}") - public GlobalResult read(@PathVariable Integer id) { + public GlobalResult read(@PathVariable Long id) { Integer result = notificationService.readNotification(id); if (result == 0) { return GlobalResultGenerator.genErrorResult("标记已读失败"); diff --git a/src/main/java/com/rymcu/forest/web/api/portfolio/PortfolioController.java b/src/main/java/com/rymcu/forest/web/api/portfolio/PortfolioController.java index bff6c14..d81c7ef 100644 --- a/src/main/java/com/rymcu/forest/web/api/portfolio/PortfolioController.java +++ b/src/main/java/com/rymcu/forest/web/api/portfolio/PortfolioController.java @@ -26,7 +26,7 @@ public class PortfolioController { private PortfolioService portfolioService; @GetMapping("/detail/{idPortfolio}") - public GlobalResult detail(@PathVariable Integer idPortfolio,@RequestParam(defaultValue = "0") Integer type) { + public GlobalResult detail(@PathVariable Long idPortfolio,@RequestParam(defaultValue = "0") Integer type) { PortfolioDTO portfolio = portfolioService.findPortfolioDTOById(idPortfolio, type); Map map = new HashMap<>(1); map.put("portfolio", portfolio); @@ -48,7 +48,7 @@ public class PortfolioController { @GetMapping("/{idPortfolio}/unbind-articles") @AuthorshipInterceptor(moduleName = Module.PORTFOLIO) - public GlobalResult unbindArticles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @RequestParam(defaultValue = "") String searchText,@PathVariable Integer idPortfolio) throws BaseApiException { + public GlobalResult unbindArticles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @RequestParam(defaultValue = "") String searchText,@PathVariable Long idPortfolio) throws BaseApiException { Map map = portfolioService.findUnbindArticles(page, rows, searchText, idPortfolio); return GlobalResultGenerator.genSuccessResult(map); } @@ -69,14 +69,14 @@ public class PortfolioController { @DeleteMapping("/unbind-article") @AuthorshipInterceptor(moduleName = Module.PORTFOLIO) - public GlobalResult unbindArticle(Integer idArticle,Integer idPortfolio) { + public GlobalResult unbindArticle(Long idArticle, Long idPortfolio) { Map map = portfolioService.unbindArticle(idPortfolio,idArticle); return GlobalResultGenerator.genSuccessResult(map); } @DeleteMapping("/delete") @AuthorshipInterceptor(moduleName = Module.PORTFOLIO) - public GlobalResult delete(Integer idPortfolio) throws BaseApiException { + public GlobalResult delete(Long idPortfolio) throws BaseApiException { Map map = portfolioService.deletePortfolio(idPortfolio); return GlobalResultGenerator.genSuccessResult(map); } diff --git a/src/main/java/com/rymcu/forest/web/api/user/UserInfoController.java b/src/main/java/com/rymcu/forest/web/api/user/UserInfoController.java index 94e8746..7a6f826 100644 --- a/src/main/java/com/rymcu/forest/web/api/user/UserInfoController.java +++ b/src/main/java/com/rymcu/forest/web/api/user/UserInfoController.java @@ -41,7 +41,7 @@ public class UserInfoController { @GetMapping("/check-nickname") @SecurityInterceptor - public GlobalResult checkNickname(@RequestParam Integer idUser, @RequestParam String nickname) { + public GlobalResult checkNickname(@RequestParam Long idUser, @RequestParam String nickname) { Map map = userService.checkNickname(idUser, nickname); return GlobalResultGenerator.genSuccessResult(map); } diff --git a/src/main/java/mapper/ArticleMapper.xml b/src/main/java/mapper/ArticleMapper.xml index 3e9d852..d17086c 100644 --- a/src/main/java/mapper/ArticleMapper.xml +++ b/src/main/java/mapper/ArticleMapper.xml @@ -5,7 +5,7 @@ - + From 89aef7a87b2c1c3d24b03d2b9ca02b7494b03b1f Mon Sep 17 00:00:00 2001 From: ronger Date: Wed, 13 Jul 2022 22:21:33 +0800 Subject: [PATCH 2/2] =?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")