Commit e8380f77 authored by shiyu's avatar shiyu

校验重复关注

parent 5706a66a
...@@ -54,6 +54,11 @@ public class FollowFansRecordServiceImpl implements FollowFansRecordService { ...@@ -54,6 +54,11 @@ public class FollowFansRecordServiceImpl implements FollowFansRecordService {
if (dto.getFollowerId() == null || dto.getFansId() == null) { if (dto.getFollowerId() == null || dto.getFansId() == null) {
return Result.failed(ResultCode.PARAM_ERROR); return Result.failed(ResultCode.PARAM_ERROR);
} }
//校验是否已有关注记录
if(isFollowed(dto)) {
return Result.failed("已经关注,无需重复操作");
}
Date now = new Date(); Date now = new Date();
FollowFansRecord followFansRecord = new FollowFansRecord(); FollowFansRecord followFansRecord = new FollowFansRecord();
EntityMapper.copyAttribute(dto, followFansRecord); EntityMapper.copyAttribute(dto, followFansRecord);
...@@ -271,4 +276,12 @@ public class FollowFansRecordServiceImpl implements FollowFansRecordService { ...@@ -271,4 +276,12 @@ public class FollowFansRecordServiceImpl implements FollowFansRecordService {
} }
return Result.failed(); return Result.failed();
} }
public boolean isFollowed(FollowFansRecordRequestDto dto) {
FollowFansRecord followFansRecord = followFansRecordDao.findOne(dto);
if (followFansRecord == null) {
return false;
}
return true;
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment