重复喜欢,需要幂等

This commit is contained in:
kuang.yife 2024-02-19 14:48:01 +08:00
parent 2195eaad01
commit 2a0c46100a
1 changed files with 8 additions and 0 deletions

View File

@ -29,6 +29,14 @@ public class TbUserFollowAppController {
@ApiOperation(value = "关注用户", httpMethod = "POST")
public Result<String> addSave(@RequestBody TbUserFollow tbUserFollow)
{
// 判断是否已经关注了对方
long count = tbUserFollowService.lambdaQuery()
.eq(TbUserFollow::getFollowUserId, tbUserFollow.getFollowUserId())
.eq(TbUserFollow::getUserId, tbUserFollow.getUserId())
.count();
if(count > 0){
return Result.success("重复关注,忽略");
}
// 判断用户是否也关注自己
TbUserFollow followUser = tbUserFollowService.lambdaQuery()
.eq(TbUserFollow::getFollowUserId, tbUserFollow.getUserId())