关注未关注优化
This commit is contained in:
parent
305bc4eb86
commit
b5a86154e5
@ -210,11 +210,11 @@ public class AuthApi {
|
|||||||
@GetMapping("/api/auth/getFollowMes")
|
@GetMapping("/api/auth/getFollowMes")
|
||||||
@OperLog(operModule = "获取关注目标作者的所有粉丝",operType = OperType.QUERY,operDesc = "获取关注目标作者的所有粉丝")
|
@OperLog(operModule = "获取关注目标作者的所有粉丝",operType = OperType.QUERY,operDesc = "获取关注目标作者的所有粉丝")
|
||||||
public ResultBean getFollowMes(String authorId) {
|
public ResultBean getFollowMes(String authorId) {
|
||||||
|
String myId = String.valueOf(request.getAttribute("authorId"));
|
||||||
|
|
||||||
//关注我的列表
|
//关注我的列表
|
||||||
List<FollowVo> followMes = followService.selectFollowMeList(authorId);
|
List<FollowVo> followMes = followService.selectFollowMeList(authorId,myId);
|
||||||
followMes.stream().forEach(followVo -> {
|
|
||||||
followVo.setIsFollowMe(Boolean.TRUE);
|
|
||||||
});
|
|
||||||
return ResultBean.success(followMes);
|
return ResultBean.success(followMes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,12 +223,28 @@ public class AuthApi {
|
|||||||
@GetMapping("/api/auth/getMyFollows")
|
@GetMapping("/api/auth/getMyFollows")
|
||||||
@OperLog(operModule = "getMyFollows",operType = OperType.QUERY,operDesc = "获取关注目标作者的所有粉丝")
|
@OperLog(operModule = "getMyFollows",operType = OperType.QUERY,operDesc = "获取关注目标作者的所有粉丝")
|
||||||
public ResultBean getMyFollows(String authorId) {
|
public ResultBean getMyFollows(String authorId) {
|
||||||
|
String myId = String.valueOf(request.getAttribute("authorId"));
|
||||||
|
|
||||||
//关注我的列表
|
//关注我的列表
|
||||||
List<FollowVo> myFollows = followService.selectMyFollowList(authorId);
|
List<FollowVo> myFollows = followService.selectMyFollowList(authorId,myId);
|
||||||
return ResultBean.success(myFollows);
|
return ResultBean.success(myFollows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取关注目标互相关注的人")
|
||||||
|
@ApiOperationSupport(order = 1)
|
||||||
|
@GetMapping("/api/auth/getMyFriends")
|
||||||
|
@OperLog(operModule = "getMyFriends",operType = OperType.QUERY,operDesc = "获取关注目标互相关注的人")
|
||||||
|
public ResultBean getMyFriends(String authorId) {
|
||||||
|
//关注我的列表
|
||||||
|
List<FollowVo> myFollows = followService.getMyFriends(authorId);
|
||||||
|
myFollows.stream().forEach(followVo -> {
|
||||||
|
followVo.setIsFollow(Boolean.TRUE);
|
||||||
|
followVo.setIsFollowMe(Boolean.TRUE);
|
||||||
|
});
|
||||||
|
return ResultBean.success(myFollows);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "获取作者信息")
|
@ApiOperation(value = "获取作者信息")
|
||||||
@ApiOperationSupport(order = 1)
|
@ApiOperationSupport(order = 1)
|
||||||
|
@ -26,8 +26,10 @@ public interface FollowMapper extends BaseMapper<Follow> {
|
|||||||
|
|
||||||
List<FollowVo> selectFollowList(@Param("followDto") FollowDto followDto);
|
List<FollowVo> selectFollowList(@Param("followDto") FollowDto followDto);
|
||||||
|
|
||||||
List<FollowVo> selectMyFollowList(@Param("authorId") String authorId);
|
//查询用户为authorId的粉丝列表 再传入一个数值 看和当前数值的关联关系 例如我看对方明天 想知道对方和我的关系
|
||||||
List<FollowVo> selectFollowMeList(@Param("authorId") String authorId);
|
List<FollowVo> selectMyFollowList(@Param("authorId") String authorId,@Param("targetId") String targetId);
|
||||||
|
List<FollowVo> selectFollowMeList(@Param("authorId") String authorId,@Param("targetId") String targetId);
|
||||||
|
List<FollowVo> getMyFriends(@Param("authorId")String authorId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,18 @@
|
|||||||
business_follow
|
business_follow
|
||||||
WHERE
|
WHERE
|
||||||
follow_id = b.AUTHOR_ID
|
follow_id = b.AUTHOR_ID
|
||||||
AND author_id = #{authorId}
|
AND author_id = #{targetId}
|
||||||
) AS isFollowMe
|
) AS isFollowMe
|
||||||
|
,
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
count(1)
|
||||||
|
FROM
|
||||||
|
business_follow
|
||||||
|
WHERE
|
||||||
|
follow_id = #{targetId}
|
||||||
|
AND author_id = b.AUTHOR_ID
|
||||||
|
) AS isFollow
|
||||||
FROM
|
FROM
|
||||||
business_follow a
|
business_follow a
|
||||||
LEFT JOIN business_author b ON a.author_id = b.author_id
|
LEFT JOIN business_author b ON a.author_id = b.author_id
|
||||||
@ -77,9 +87,19 @@
|
|||||||
FROM
|
FROM
|
||||||
business_follow
|
business_follow
|
||||||
WHERE
|
WHERE
|
||||||
follow_id = #{authorId}
|
follow_id = #{targetId}
|
||||||
AND author_id = b.AUTHOR_ID
|
AND author_id = b.AUTHOR_ID
|
||||||
) AS isFollow
|
) AS isFollow
|
||||||
|
,
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
count(1)
|
||||||
|
FROM
|
||||||
|
business_follow
|
||||||
|
WHERE
|
||||||
|
follow_id = b.AUTHOR_ID
|
||||||
|
AND author_id = #{targetId}
|
||||||
|
) AS isFollowMe
|
||||||
FROM
|
FROM
|
||||||
business_follow a
|
business_follow a
|
||||||
LEFT JOIN business_author b ON a.follow_id = b.author_id
|
LEFT JOIN business_author b ON a.follow_id = b.author_id
|
||||||
@ -89,5 +109,23 @@
|
|||||||
ORDER BY
|
ORDER BY
|
||||||
a.create_time DESC
|
a.create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getMyFriends" resultType="com.dd.admin.business.follow.domain.FollowVo"
|
||||||
|
parameterType="java.lang.String">
|
||||||
|
SELECT
|
||||||
|
b.AUTHOR_ID,
|
||||||
|
b.AUTHOR_NAME,
|
||||||
|
b.AVATAR_URL,
|
||||||
|
b.DESCRIPTION
|
||||||
|
FROM
|
||||||
|
business_author b
|
||||||
|
LEFT JOIN
|
||||||
|
-- 通过business_follow表自连接,找出既存在A关注B,又存在B关注A的情况
|
||||||
|
business_follow f1 ON b.AUTHOR_ID = f1.author_id
|
||||||
|
LEFT JOIN
|
||||||
|
business_follow f2 ON b.AUTHOR_ID = f2.follow_id
|
||||||
|
WHERE f1.follow_id = #{authorId}
|
||||||
|
AND f2.author_id = #{authorId}
|
||||||
|
order by f1.create_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -30,8 +30,9 @@ public interface FollowService extends IService<Follow> {
|
|||||||
Follow selectOneByFollowId(String authorId,String followId);
|
Follow selectOneByFollowId(String authorId,String followId);
|
||||||
|
|
||||||
|
|
||||||
List<FollowVo> selectMyFollowList( String authorId);
|
List<FollowVo> selectMyFollowList( String authorId,String targetId);
|
||||||
List<FollowVo> selectFollowMeList(String authorId);
|
List<FollowVo> selectFollowMeList(String authorId,String targetId);
|
||||||
|
List<FollowVo> getMyFriends(String authorId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -52,13 +52,18 @@ public class FollowServiceImpl extends ServiceImpl<FollowMapper, Follow> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FollowVo> selectMyFollowList(String authorId) {
|
public List<FollowVo> selectMyFollowList(String authorId,String targetId) {
|
||||||
return baseMapper.selectMyFollowList(authorId);
|
return baseMapper.selectMyFollowList(authorId,targetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FollowVo> selectFollowMeList(String authorId) {
|
public List<FollowVo> selectFollowMeList(String authorId,String targetId) {
|
||||||
return baseMapper.selectFollowMeList(authorId);
|
return baseMapper.selectFollowMeList(authorId,targetId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<FollowVo> getMyFriends(String authorId) {
|
||||||
|
return baseMapper.getMyFriends(authorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user