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