Explorar o código

添加一个 UserService#contactContain 方法检测用户是否在 UserContact 中

reghao hai 6 meses
pai
achega
21ee6ddf88

+ 1 - 0
user/user-api/src/main/java/cn/reghao/tnb/user/api/iface/UserService.java

@@ -16,4 +16,5 @@ public interface UserService {
     void sendUserMessage(UserMessageDto userMessageDto);
     int getRecommendMode(long userId);
     boolean setRecommendMode(long userId, int mode);
+    boolean contactContain(long userId, long friendId);
 }

+ 9 - 1
user/user-service/src/main/java/cn/reghao/tnb/user/app/rpc/UserServiceImpl.java

@@ -4,6 +4,7 @@ import cn.reghao.tnb.account.api.iface.AccountQuery;
 import cn.reghao.tnb.user.api.dto.UserCard;
 import cn.reghao.tnb.user.api.dto.UserMessageDto;
 import cn.reghao.tnb.user.api.iface.UserService;
+import cn.reghao.tnb.user.app.db.mapper.UserContactMapper;
 import cn.reghao.tnb.user.app.db.mapper.UserRecommendMapper;
 import cn.reghao.tnb.user.app.model.po.UserRecommend;
 import cn.reghao.tnb.user.app.service.UserMessageService;
@@ -32,15 +33,17 @@ public class UserServiceImpl implements UserService {
     private final UserProfileService userProfileService;
     private final UserMessageService userMessageService;
     private final UserRecommendMapper userRecommendMapper;
+    private UserContactMapper userContactMapper;
 
     public UserServiceImpl(UserRelationService userRelationService, UserVipService userVipService,
                            UserProfileService userProfileService, UserMessageService userMessageService,
-                           UserRecommendMapper userRecommendMapper) {
+                           UserRecommendMapper userRecommendMapper, UserContactMapper userContactMapper) {
         this.userRelationService = userRelationService;
         this.userVipService = userVipService;
         this.userProfileService = userProfileService;
         this.userMessageService = userMessageService;
         this.userRecommendMapper = userRecommendMapper;
+        this.userContactMapper = userContactMapper;
     }
 
     @Override
@@ -93,4 +96,9 @@ public class UserServiceImpl implements UserService {
 
         return changed;
     }
+
+    @Override
+    public boolean contactContain(long userId, long friendId) {
+        return userContactMapper.findByOwnerAndFriendId(userId, friendId) != null;
+    }
 }