|
|
@@ -5,6 +5,8 @@ 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.UserRecommendMapper;
|
|
|
+import cn.reghao.tnb.user.app.model.po.UserRecommend;
|
|
|
import cn.reghao.tnb.user.app.service.UserMessageService;
|
|
|
import cn.reghao.tnb.user.app.service.UserRelationService;
|
|
|
import cn.reghao.tnb.user.app.service.UserProfileService;
|
|
|
@@ -30,16 +32,18 @@ public class UserServiceImpl implements UserService {
|
|
|
private final UserVipService userVipService;
|
|
|
private final UserProfileService userProfileService;
|
|
|
private final UserMessageService userMessageService;
|
|
|
- private IDObfuscation userIdObfuscation;
|
|
|
+ private final IDObfuscation userIdObfuscation;
|
|
|
+ private UserRecommendMapper userRecommendMapper;
|
|
|
|
|
|
public UserServiceImpl(UserRelationService userRelationService, UserVipService userVipService,
|
|
|
UserProfileService userProfileService, UserMessageService userMessageService,
|
|
|
- IDObfuscation userIdObfuscation) {
|
|
|
+ IDObfuscation userIdObfuscation, UserRecommendMapper userRecommendMapper) {
|
|
|
this.userRelationService = userRelationService;
|
|
|
this.userVipService = userVipService;
|
|
|
this.userProfileService = userProfileService;
|
|
|
this.userMessageService = userMessageService;
|
|
|
this.userIdObfuscation = userIdObfuscation;
|
|
|
+ this.userRecommendMapper = userRecommendMapper;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -66,4 +70,30 @@ public class UserServiceImpl implements UserService {
|
|
|
public void sendUserMessage(UserMessageDto userMessageDto) {
|
|
|
userMessageService.addMessage(userMessageDto);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getRecommendMode(long userId) {
|
|
|
+ Integer mode = userRecommendMapper.findByUserId(userId);
|
|
|
+ if (mode == null) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ return mode;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setRecommendMode(long userId, boolean mode) {
|
|
|
+ int modeInt = 0;
|
|
|
+ if (mode) {
|
|
|
+ modeInt = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer mode1 = userRecommendMapper.findByUserId(userId);
|
|
|
+ if (mode1 == null) {
|
|
|
+ UserRecommend userRecommend = new UserRecommend(userId, modeInt);
|
|
|
+ userRecommendMapper.save(userRecommend);
|
|
|
+ } else if (mode1 != modeInt) {
|
|
|
+ userRecommendMapper.updateMode(userId, mode1);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|