✨ 粉丝与关注用户列表功能
This commit is contained in:
parent
9ce6616fd3
commit
04f2b3626c
@ -1,9 +1,12 @@
|
||||
package com.rymcu.vertical.mapper;
|
||||
|
||||
import com.rymcu.vertical.core.mapper.Mapper;
|
||||
import com.rymcu.vertical.dto.UserDTO;
|
||||
import com.rymcu.vertical.entity.Follow;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author ronger
|
||||
*/
|
||||
@ -16,4 +19,18 @@ public interface FollowMapper extends Mapper<Follow> {
|
||||
* @return
|
||||
*/
|
||||
Boolean isFollow(@Param("followingId") Integer followingId, @Param("followerId") Integer followerId, @Param("followingType") String followingType);
|
||||
|
||||
/**
|
||||
* 查询用户粉丝
|
||||
* @param idUser
|
||||
* @return
|
||||
*/
|
||||
List<UserDTO> selectUserFollowersByUser(@Param("idUser") Integer idUser);
|
||||
|
||||
/**
|
||||
* 查询用户关注用户
|
||||
* @param idUser
|
||||
* @return
|
||||
*/
|
||||
List<UserDTO> selectUserFollowingsByUser(@Param("idUser") Integer idUser);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.rymcu.vertical.service;
|
||||
|
||||
import com.rymcu.vertical.core.service.Service;
|
||||
import com.rymcu.vertical.dto.UserDTO;
|
||||
import com.rymcu.vertical.entity.Follow;
|
||||
import com.rymcu.vertical.web.api.exception.BaseApiException;
|
||||
|
||||
@ -42,4 +43,20 @@ public interface FollowService extends Service<Follow> {
|
||||
* @return
|
||||
*/
|
||||
List<Follow> findByFollowingId(String followType, Integer followingId);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询用户粉丝
|
||||
* @param userDTO
|
||||
* @return
|
||||
*/
|
||||
List<UserDTO> findUserFollowersByUser(UserDTO userDTO);
|
||||
|
||||
/**
|
||||
* 查询用户关注用户
|
||||
* @param userDTO
|
||||
* @return
|
||||
*/
|
||||
List<UserDTO> findUserFollowingsByUser(UserDTO userDTO);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.rymcu.vertical.service.impl;
|
||||
|
||||
import com.rymcu.vertical.core.constant.NotificationConstant;
|
||||
import com.rymcu.vertical.core.service.AbstractService;
|
||||
import com.rymcu.vertical.dto.UserDTO;
|
||||
import com.rymcu.vertical.entity.Follow;
|
||||
import com.rymcu.vertical.entity.User;
|
||||
import com.rymcu.vertical.mapper.FollowMapper;
|
||||
@ -56,4 +57,16 @@ public class FollowServiceImpl extends AbstractService<Follow> implements Follow
|
||||
follow.setFollowingId(followingId);
|
||||
return followMapper.select(follow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> findUserFollowersByUser(UserDTO userDTO) {
|
||||
List<UserDTO> list = followMapper.selectUserFollowersByUser(userDTO.getIdUser());
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> findUserFollowingsByUser(UserDTO userDTO) {
|
||||
List<UserDTO> list = followMapper.selectUserFollowingsByUser(userDTO.getIdUser());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import com.rymcu.vertical.dto.ArticleDTO;
|
||||
import com.rymcu.vertical.dto.PortfolioDTO;
|
||||
import com.rymcu.vertical.dto.UserDTO;
|
||||
import com.rymcu.vertical.service.ArticleService;
|
||||
import com.rymcu.vertical.service.FollowService;
|
||||
import com.rymcu.vertical.service.PortfolioService;
|
||||
import com.rymcu.vertical.service.UserService;
|
||||
import com.rymcu.vertical.util.Utils;
|
||||
@ -32,6 +33,8 @@ public class UserController {
|
||||
private ArticleService articleService;
|
||||
@Resource
|
||||
private PortfolioService portfolioService;
|
||||
@Resource
|
||||
private FollowService followService;
|
||||
|
||||
@GetMapping("/{nickname}")
|
||||
@VisitLogger
|
||||
@ -69,4 +72,36 @@ public class UserController {
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
|
||||
@GetMapping("/{nickname}/followers")
|
||||
public GlobalResult userFollowers(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String nickname){
|
||||
UserDTO userDTO = userService.findUserDTOByNickname(nickname);
|
||||
if (userDTO == null){
|
||||
return GlobalResultGenerator.genErrorResult("用户不存在!");
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<UserDTO> list = followService.findUserFollowersByUser(userDTO);
|
||||
PageInfo<UserDTO> pageInfo = new PageInfo(list);
|
||||
Map map = new HashMap(2);
|
||||
map.put("users", list);
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
|
||||
@GetMapping("/{nickname}/followings")
|
||||
public GlobalResult userFollowings(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String nickname){
|
||||
UserDTO userDTO = userService.findUserDTOByNickname(nickname);
|
||||
if (userDTO == null){
|
||||
return GlobalResultGenerator.genErrorResult("用户不存在!");
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<UserDTO> list = followService.findUserFollowingsByUser(userDTO);
|
||||
PageInfo<UserDTO> pageInfo = new PageInfo(list);
|
||||
Map map = new HashMap(2);
|
||||
map.put("users", list);
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -138,6 +138,6 @@
|
||||
select exists (select * from vertical_comment where comment_article_id = #{id})
|
||||
</select>
|
||||
<select id="selectPortfolioArticlesByIdPortfolioAndSortNo" resultMap="DTOResultMap">
|
||||
select va.article_title, va.id, va.article_permalink from vertical_portfolio_article vpa join vertical_article va on va.id = vpa.id_vertical_article where id_vertical_portfolio = #{idPortfolio} and sort_no > (#{sortNo} - 2) order by sort_no limit 20
|
||||
select va.article_title, va.id, va.article_permalink from vertical_portfolio_article vpa join vertical_article va on va.id = vpa.id_vertical_article where id_vertical_portfolio = #{idPortfolio} order by sort_no
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user