From 686cbb925eeadce062836816406a94a3e3ff3c6b Mon Sep 17 00:00:00 2001 From: ronger Date: Wed, 8 Apr 2020 12:05:02 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E9=80=9A=E8=BF=87=20UserService=20?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E6=9F=A5=E8=AF=A2=E4=BD=9C=E8=80=85=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/rymcu/vertical/dto/Author.java | 4 ++-- .../java/com/rymcu/vertical/mapper/ArticleMapper.java | 8 -------- src/main/java/com/rymcu/vertical/mapper/UserMapper.java | 7 +++++++ src/main/java/com/rymcu/vertical/service/UserService.java | 8 ++++++++ .../rymcu/vertical/service/impl/ArticleServiceImpl.java | 2 +- .../com/rymcu/vertical/service/impl/UserServiceImpl.java | 6 ++++++ src/main/java/mapper/ArticleMapper.xml | 8 -------- src/main/java/mapper/UserMapper.xml | 8 ++++++++ 8 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/rymcu/vertical/dto/Author.java b/src/main/java/com/rymcu/vertical/dto/Author.java index 1f6a567..9b40ee3 100644 --- a/src/main/java/com/rymcu/vertical/dto/Author.java +++ b/src/main/java/com/rymcu/vertical/dto/Author.java @@ -8,12 +8,12 @@ import lombok.Data; @Data public class Author { - private String idUser; + private Integer idUser; private String userNickname; private String userAvatarURL; - private Integer userArticleCount; + private String userArticleCount; } diff --git a/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java b/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java index 959525f..4135199 100644 --- a/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java +++ b/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java @@ -3,7 +3,6 @@ package com.rymcu.vertical.mapper; import com.rymcu.vertical.core.mapper.Mapper; import com.rymcu.vertical.dto.ArticleDTO; import com.rymcu.vertical.dto.ArticleTagDTO; -import com.rymcu.vertical.dto.Author; import com.rymcu.vertical.entity.Article; import com.rymcu.vertical.entity.ArticleContent; import org.apache.ibatis.annotations.Param; @@ -23,13 +22,6 @@ public interface ArticleMapper extends Mapper
{ */ List selectArticles(@Param("searchText") String searchText, @Param("tag") String tag); - /** - * 根据用户 ID 获取作者信息 - * @param id - * @return - */ - Author selectAuthor(@Param("id") Integer id); - /** * 根据文章 ID 查询文章 * @param id diff --git a/src/main/java/com/rymcu/vertical/mapper/UserMapper.java b/src/main/java/com/rymcu/vertical/mapper/UserMapper.java index 6096eab..ce95279 100644 --- a/src/main/java/com/rymcu/vertical/mapper/UserMapper.java +++ b/src/main/java/com/rymcu/vertical/mapper/UserMapper.java @@ -1,6 +1,7 @@ package com.rymcu.vertical.mapper; import com.rymcu.vertical.core.mapper.Mapper; +import com.rymcu.vertical.dto.Author; import com.rymcu.vertical.dto.UserDTO; import com.rymcu.vertical.dto.UserInfoDTO; import com.rymcu.vertical.entity.User; @@ -106,4 +107,10 @@ public interface UserMapper extends Mapper { * @return */ Integer checkNicknameByIdUser(@Param("idUser") Integer idUser, @Param("nickname") String nickname); + /** + * 根据用户 ID 获取作者信息 + * @param id + * @return + */ + Author selectAuthor(@Param("id") Integer id); } \ No newline at end of file diff --git a/src/main/java/com/rymcu/vertical/service/UserService.java b/src/main/java/com/rymcu/vertical/service/UserService.java index e817abc..f2fb61b 100644 --- a/src/main/java/com/rymcu/vertical/service/UserService.java +++ b/src/main/java/com/rymcu/vertical/service/UserService.java @@ -1,6 +1,7 @@ package com.rymcu.vertical.service; import com.rymcu.vertical.core.service.Service; +import com.rymcu.vertical.dto.Author; import com.rymcu.vertical.dto.UserDTO; import com.rymcu.vertical.dto.UserInfoDTO; import com.rymcu.vertical.entity.User; @@ -100,4 +101,11 @@ public interface UserService extends Service { * @return */ Integer findRoleWeightsByUser(Integer idUser); + + /** + * 查询作者信息 + * @param idUser + * @return + */ + Author selectAuthor(Integer idUser); } diff --git a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java index 2a077fc..8a6a80e 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java @@ -264,7 +264,7 @@ public class ArticleServiceImpl extends AbstractService
implements Arti } private ArticleDTO genArticle(ArticleDTO article, Integer type) { - Author author = articleMapper.selectAuthor(article.getArticleAuthorId()); + Author author = userService.selectAuthor(article.getArticleAuthorId()); article.setArticleAuthor(author); article.setTimeAgo(Utils.getTimeAgo(article.getUpdatedTime())); List tags = articleMapper.selectTags(article.getIdArticle()); diff --git a/src/main/java/com/rymcu/vertical/service/impl/UserServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/UserServiceImpl.java index 8180eb5..dc8ef02 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/UserServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/UserServiceImpl.java @@ -2,6 +2,7 @@ package com.rymcu.vertical.service.impl; import com.rymcu.vertical.core.service.AbstractService; import com.rymcu.vertical.core.service.redis.RedisService; +import com.rymcu.vertical.dto.Author; import com.rymcu.vertical.dto.TokenUser; import com.rymcu.vertical.dto.UserDTO; import com.rymcu.vertical.dto.UserInfoDTO; @@ -207,4 +208,9 @@ public class UserServiceImpl extends AbstractService implements UserServic public Integer findRoleWeightsByUser(Integer idUser) { return userMapper.selectRoleWeightsByUser(idUser); } + + @Override + public Author selectAuthor(Integer idUser) { + return userMapper.selectAuthor(idUser); + } } diff --git a/src/main/java/mapper/ArticleMapper.xml b/src/main/java/mapper/ArticleMapper.xml index f294d88..407ec77 100644 --- a/src/main/java/mapper/ArticleMapper.xml +++ b/src/main/java/mapper/ArticleMapper.xml @@ -38,11 +38,6 @@ - - - - - @@ -78,9 +73,6 @@ - select count(*) from vertical_user where nickname = #{nickname} and id != #{idUser} + \ No newline at end of file