|
|
@@ -4,8 +4,7 @@ import cn.reghao.tnb.account.api.iface.AccountQuery;
|
|
|
import cn.reghao.tnb.user.api.dto.UserCard;
|
|
|
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.model.vo.MyVip;
|
|
|
import cn.reghao.tnb.user.app.service.UserRelationService;
|
|
|
import cn.reghao.tnb.user.app.service.UserProfileService;
|
|
|
import cn.reghao.tnb.user.app.service.UserVipService;
|
|
|
@@ -29,16 +28,13 @@ public class UserServiceImpl implements UserService {
|
|
|
private final UserRelationService userRelationService;
|
|
|
private final UserVipService userVipService;
|
|
|
private final UserProfileService userProfileService;
|
|
|
- private final UserRecommendMapper userRecommendMapper;
|
|
|
private final UserContactMapper userContactMapper;
|
|
|
|
|
|
public UserServiceImpl(UserRelationService userRelationService, UserVipService userVipService,
|
|
|
- UserProfileService userProfileService, UserRecommendMapper userRecommendMapper,
|
|
|
- UserContactMapper userContactMapper) {
|
|
|
+ UserProfileService userProfileService, UserContactMapper userContactMapper) {
|
|
|
this.userRelationService = userRelationService;
|
|
|
this.userVipService = userVipService;
|
|
|
this.userProfileService = userProfileService;
|
|
|
- this.userRecommendMapper = userRecommendMapper;
|
|
|
this.userContactMapper = userContactMapper;
|
|
|
}
|
|
|
|
|
|
@@ -64,23 +60,21 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
|
@Override
|
|
|
public int getRecommendMode(long userId) {
|
|
|
- Integer mode = userRecommendMapper.findByUserId(userId);
|
|
|
- if (mode == null) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- return mode;
|
|
|
+ MyVip myVip = userVipService.getMyVip();
|
|
|
+ return myVip != null ? myVip.getRcmdMode() : 0;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public boolean setRecommendMode(long userId, int mode) {
|
|
|
boolean changed = true;
|
|
|
- Integer currentMode = userRecommendMapper.findByUserId(userId);
|
|
|
- if (currentMode == null) {
|
|
|
- UserRecommend userRecommend = new UserRecommend(userId, mode);
|
|
|
- userRecommendMapper.save(userRecommend);
|
|
|
- } else if (currentMode != mode) {
|
|
|
- userRecommendMapper.updateMode(userId, mode);
|
|
|
+ MyVip myVip = userVipService.getMyVip();
|
|
|
+ if (!myVip.isVip()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ int currentMode = myVip.getRcmdMode();
|
|
|
+ if (currentMode != mode) {
|
|
|
+ userVipService.updateRcmdMode(userId, mode);
|
|
|
} else {
|
|
|
changed = false;
|
|
|
}
|