init
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package com.ruoyi.xq.controller.app;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.BeanConvertUtil;
|
||||
import com.ruoyi.xq.domain.UserStatus;
|
||||
import com.ruoyi.xq.dto.app.userstatus.UserStatusInfoAppVo;
|
||||
import com.ruoyi.xq.dto.app.userstatus.UserStatusUpdateAppReq;
|
||||
import com.ruoyi.xq.service.UserStatusService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/userStatus")
|
||||
@Tag(name = "用户状态")
|
||||
public class UserStatusAppController {
|
||||
@Autowired
|
||||
private UserStatusService userStatusService;
|
||||
|
||||
@GetMapping("/info")
|
||||
@Operation(summary = "获取当前用户状态")
|
||||
@Log(title = "获取当前用户状态", businessType = BusinessType.OTHER, isSaveDb = false)
|
||||
public R<UserStatusInfoAppVo> info(){
|
||||
UserStatus userStatus = userStatusService.getByUserId(LoginHelper.getUserId());
|
||||
UserStatusInfoAppVo vo = BeanConvertUtil.convertTo(userStatus, UserStatusInfoAppVo::new);
|
||||
return R.ok(vo);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@Operation(summary = "修改当前用户状态")
|
||||
@Log(title = "修改当前用户状态", businessType = BusinessType.OTHER, isSaveDb = false)
|
||||
public R<Void> update(@RequestBody UserStatusUpdateAppReq req){
|
||||
req.setUserId(LoginHelper.getUserId());
|
||||
userStatusService.updateStatus(req);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@@ -16,14 +17,13 @@ import com.ruoyi.common.core.domain.BaseEntity;
|
||||
* @date 2024-03-28
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("xq_user_status")
|
||||
public class UserStatus extends BaseEntity {
|
||||
public class UserStatus implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
@@ -46,6 +46,7 @@ public class UserStatus extends BaseEntity {
|
||||
/**
|
||||
* 谁可查看资料 1-所有用户 2-VIP用户 3-实名用户 4-实名认证且VIP用户
|
||||
*/
|
||||
@Deprecated
|
||||
private Integer showInfo;
|
||||
/**
|
||||
* 是否允许交换手机号
|
||||
@@ -56,4 +57,7 @@ public class UserStatus extends BaseEntity {
|
||||
*/
|
||||
private Integer allowTransWx;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,16 @@ public class HomePageReq extends PageQuery {
|
||||
@Schema(hidden = true)
|
||||
private LocalDate birthdayEnd;
|
||||
|
||||
|
||||
/**
|
||||
* 查询人是否实名认证
|
||||
*/
|
||||
@Schema(hidden = true)
|
||||
private Integer certStatus = 0;
|
||||
/**
|
||||
* 查询人是否VIP
|
||||
*/
|
||||
@Schema(hidden = true)
|
||||
private Integer vipStatus = 0;
|
||||
@Schema(description = "年龄-开始")
|
||||
private Integer ageBegin;
|
||||
@Schema(description = "年龄-结束")
|
||||
|
||||
@@ -7,6 +7,9 @@ import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
public class HomeUserListVo {
|
||||
@Schema(description = "是否可以查看头像,当不可以查看的时候头像是空")
|
||||
private Boolean showAvatarBool = true;
|
||||
private Integer showAvatar;
|
||||
@Schema(description = "是否开通VIP")
|
||||
private Boolean openVip = false;
|
||||
@Schema(description = "已开通的VIP类型")
|
||||
|
||||
@@ -9,6 +9,8 @@ import java.util.List;
|
||||
@Data
|
||||
public class HomeUserVo {
|
||||
|
||||
@Schema(description = "是否可以查看头像,当不可以查看的时候头像和图片是空")
|
||||
private Boolean showAvatarBool = true;
|
||||
@Schema(description = "用户ID")
|
||||
private Long userId;
|
||||
@Schema(description = "用户编号")
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.ruoyi.xq.dto.app.userstatus;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserStatusInfoAppVo {
|
||||
@Schema(description = "用户ID")
|
||||
private Long userId;
|
||||
/**
|
||||
* 用户号
|
||||
*/
|
||||
@Schema(description = "用户编号")
|
||||
private String usercode;
|
||||
/**
|
||||
* 征婚状态 1-寻找中 2-已脱单 3-隐藏资料
|
||||
*/
|
||||
@Schema(description = "征婚状态 1-寻找中 2-已脱单 3-隐藏资料")
|
||||
private Integer personalsStatus;
|
||||
/**
|
||||
* 谁可查看头像 1-所有用户 2-VIP用户 3-实名用户 4-实名认证且VIP用户 5-不公开
|
||||
*/
|
||||
@Schema(description = "谁可查看头像 1-所有用户 2-VIP用户 3-实名用户 4-实名认证且VIP用户 5-不公开")
|
||||
private Integer showAvatar;
|
||||
/**
|
||||
* 是否允许交换手机号
|
||||
*/
|
||||
@Schema(description = "是否允许交换手机号")
|
||||
private Integer allowTransMobile;
|
||||
/**
|
||||
* 是否允许交换微信
|
||||
*/
|
||||
@Schema(description = "是否允许交换微信")
|
||||
private Integer allowTransWx;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ruoyi.xq.dto.app.userstatus;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserStatusUpdateAppReq {
|
||||
@Schema(description = "用户ID")
|
||||
private Long userId;
|
||||
/**
|
||||
* 征婚状态 1-寻找中 2-已脱单 3-隐藏资料
|
||||
*/
|
||||
@Schema(description = "征婚状态 1-寻找中 2-已脱单 3-隐藏资料")
|
||||
private Integer personalsStatus;
|
||||
/**
|
||||
* 谁可查看头像 1-所有用户 2-VIP用户 3-实名用户 4-实名认证且VIP用户 5-不公开
|
||||
*/
|
||||
@Schema(description = "谁可查看头像 1-所有用户 2-VIP用户 3-实名用户 4-实名认证且VIP用户 5-不公开")
|
||||
private Integer showAvatar;
|
||||
/**
|
||||
* 是否允许交换手机号
|
||||
*/
|
||||
@Schema(description = "是否允许交换手机号")
|
||||
private Integer allowTransMobile;
|
||||
/**
|
||||
* 是否允许交换微信
|
||||
*/
|
||||
@Schema(description = "是否允许交换微信")
|
||||
private Integer allowTransWx;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.ruoyi.xq.enums.userstatus;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
|
||||
// 征婚状态 1-寻找中 2-已脱单 3-隐藏资料
|
||||
@Getter
|
||||
public enum PersonalsStatusEnum {
|
||||
RUNNING(1,"寻找中"),
|
||||
CAO(2,"已脱单"),
|
||||
HIDING(3,"隐藏资料"),
|
||||
;
|
||||
private final Integer code;
|
||||
private final String text;
|
||||
|
||||
PersonalsStatusEnum(Integer code, String text) {
|
||||
this.code = code;
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.ruoyi.xq.enums.userstatus;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
// 谁可查看头像 1-所有用户 2-VIP用户 3-实名用户 4-实名认证且VIP用户 5-不公开
|
||||
@Getter
|
||||
public enum ShowAvatarEnum {
|
||||
ALL(1,"所有用户"),
|
||||
VIP(2,"VIP用户"),
|
||||
CARD(3,"实名用户"),
|
||||
VIP_AND_CARD(4,"实名认证且VIP用户"),
|
||||
NO(5,"不公开"),
|
||||
;
|
||||
private final Integer code;
|
||||
private final String text;
|
||||
|
||||
ShowAvatarEnum(Integer code, String text) {
|
||||
this.code = code;
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@ import com.ruoyi.xq.enums.common.AuditEnum;
|
||||
import com.ruoyi.xq.enums.common.CodeEnum;
|
||||
import com.ruoyi.xq.enums.common.SystemConfigEnum;
|
||||
import com.ruoyi.xq.enums.userinfo.UserGenderEnum;
|
||||
import com.ruoyi.xq.enums.userstatus.PersonalsStatusEnum;
|
||||
import com.ruoyi.xq.enums.userstatus.ShowAvatarEnum;
|
||||
import com.ruoyi.xq.executor.ExecutorConstant;
|
||||
import com.ruoyi.xq.lock.LockKey;
|
||||
import com.ruoyi.xq.service.*;
|
||||
@@ -169,27 +171,27 @@ public class LoginManager {
|
||||
public User registerUser(String mobile,String inviteCode){
|
||||
String cos = systemConfigManager.getSystemConfig(SystemConfigEnum.COS_DOMAIN);
|
||||
String usercode = userCodeGenService.getCodeGen();
|
||||
User add = new User();
|
||||
add.setUsercode(usercode);
|
||||
add.setNickname("用户"+usercode);
|
||||
add.setType(0);
|
||||
add.setPassword(BCrypt.hashpw(usercode+"用户手动滑稽安康黄鼠狼"));
|
||||
add.setMobile(mobile);
|
||||
add.setWxCode(mobile);
|
||||
add.setGender(UserGenderEnum.NONE.getCode());
|
||||
add.setAvatar(cos + UserGenderEnum.NONE.getDefaultAvatar());
|
||||
add.setImToken(IdUtil.simpleUUID());
|
||||
userService.save(add);
|
||||
User user = new User();
|
||||
user.setUsercode(usercode);
|
||||
user.setNickname("用户"+usercode);
|
||||
user.setType(0);
|
||||
user.setPassword(BCrypt.hashpw(usercode+"用户手动滑稽安康黄鼠狼"));
|
||||
user.setMobile(mobile);
|
||||
user.setWxCode(mobile);
|
||||
user.setGender(UserGenderEnum.NONE.getCode());
|
||||
user.setAvatar(cos + UserGenderEnum.NONE.getDefaultAvatar());
|
||||
user.setImToken(IdUtil.simpleUUID());
|
||||
userService.save(user);
|
||||
CreateUserReq req = new CreateUserReq();
|
||||
req.setAccid(add.getId()+"");
|
||||
req.setToken(add.getImToken());
|
||||
req.setName(add.getNickname());
|
||||
req.setAccid(user.getId()+"");
|
||||
req.setToken(user.getImToken());
|
||||
req.setName(user.getNickname());
|
||||
YxCommonR r = imUserClient.createUser(req);
|
||||
if(!r.isSuccess()){
|
||||
/*if(r.getCode() == 414){
|
||||
UpdateTokenReq req1 = new UpdateTokenReq();
|
||||
req1.setAccid(add.getId()+"");
|
||||
req1.setToken(add.getImToken());
|
||||
req1.setAccid(user.getId()+"");
|
||||
req1.setToken(user.getImToken());
|
||||
YxCommonR commonR = imUserClient.updateToken(req1);
|
||||
if(!commonR.isSuccess()){
|
||||
log.error("刷新云token失败,{}", JSON.toJSONString(commonR));
|
||||
@@ -202,7 +204,7 @@ public class LoginManager {
|
||||
}
|
||||
String clientIP = ServletUtils.getClientIP();
|
||||
UserLogin userLogin = new UserLogin();
|
||||
userLogin.setUserId(add.getId());
|
||||
userLogin.setUserId(user.getId());
|
||||
userLogin.setUsercode(usercode);
|
||||
userLogin.setLastLoginIp(clientIP);
|
||||
userLogin.setLastLoginTime(LocalDateTime.now());
|
||||
@@ -211,21 +213,29 @@ public class LoginManager {
|
||||
userLoginService.save(userLogin);
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setUsercode(usercode);
|
||||
userInfo.setUserId(add.getId());
|
||||
userInfo.setUserId(user.getId());
|
||||
userInfoService.save(userInfo);
|
||||
UserAuth userAuth = new UserAuth();
|
||||
userAuth.setUsercode(usercode);
|
||||
userAuth.setUserId(add.getId());
|
||||
userAuth.setPhone(add.getMobile());
|
||||
userAuth.setUserId(user.getId());
|
||||
userAuth.setPhone(user.getMobile());
|
||||
userAuth.setPhoneAuth(AuditEnum.SUCCESS.getCode());
|
||||
userAuthService.save(userAuth);
|
||||
UserExtend userExtend = new UserExtend();
|
||||
userExtend.setUsercode(usercode);
|
||||
userExtend.setUserId(add.getId());
|
||||
userExtend.setUserId(user.getId());
|
||||
BigDecimal vipInviteRate = systemConfigManager.getSystemConfigOfBigDecimal(SystemConfigEnum.VIP_INVITE_RATE);
|
||||
userExtend.setVipInviteRate(vipInviteRate);
|
||||
userExtendService.save(userExtend);
|
||||
return add;
|
||||
UserStatus userStatus = new UserStatus();
|
||||
userStatus.setUserId(user.getId());
|
||||
userStatus.setUsercode(user.getUsercode());
|
||||
userStatus.setPersonalsStatus(PersonalsStatusEnum.RUNNING.getCode());
|
||||
userStatus.setShowAvatar(ShowAvatarEnum.ALL.getCode());
|
||||
userStatus.setShowInfo(1);
|
||||
userStatus.setAllowTransMobile(1);
|
||||
userStatus.setAllowTransWx(1);
|
||||
return user;
|
||||
}
|
||||
|
||||
public void resetPassword(String mobile,String code,String password) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.xq.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.xq.domain.UserStatus;
|
||||
import com.ruoyi.xq.dto.app.userstatus.UserStatusUpdateAppReq;
|
||||
|
||||
/**
|
||||
* 用户状态Service接口
|
||||
@@ -11,4 +12,7 @@ import com.ruoyi.xq.domain.UserStatus;
|
||||
*/
|
||||
public interface UserStatusService extends IService<UserStatus> {
|
||||
|
||||
UserStatus getByUserId(Long userId);
|
||||
|
||||
void updateStatus(UserStatusUpdateAppReq req);
|
||||
}
|
||||
|
||||
@@ -11,10 +11,7 @@ import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.exception.base.BaseException;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.BeanConvertUtil;
|
||||
import com.ruoyi.xq.domain.User;
|
||||
import com.ruoyi.xq.domain.UserInfo;
|
||||
import com.ruoyi.xq.domain.UserPictures;
|
||||
import com.ruoyi.xq.domain.UserVip;
|
||||
import com.ruoyi.xq.domain.*;
|
||||
import com.ruoyi.xq.dto.admin.user.UserAdminVo;
|
||||
import com.ruoyi.xq.dto.admin.user.req.UpdateMobileAdminReq;
|
||||
import com.ruoyi.xq.dto.app.user.HomePageReq;
|
||||
@@ -26,11 +23,9 @@ import com.ruoyi.xq.enums.common.SystemConfigEnum;
|
||||
import com.ruoyi.xq.enums.userinfo.UserGenderEnum;
|
||||
import com.ruoyi.xq.manager.SystemConfigManager;
|
||||
import com.ruoyi.xq.mapper.UserMapper;
|
||||
import com.ruoyi.xq.service.UserInfoService;
|
||||
import com.ruoyi.xq.service.UserPicturesService;
|
||||
import com.ruoyi.xq.service.UserService;
|
||||
import com.ruoyi.xq.service.UserVipService;
|
||||
import com.ruoyi.xq.service.*;
|
||||
import com.ruoyi.xq.util.BirthdayUtil;
|
||||
import com.ruoyi.xq.util.ShowAvatarUtil;
|
||||
import com.ruoyi.yunxin.client.ImUserRefClient;
|
||||
import com.ruoyi.yunxin.req.UpdateUinfoReq;
|
||||
import com.ruoyi.yunxin.resp.YxCommonR;
|
||||
@@ -41,6 +36,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
@@ -65,6 +61,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements Use
|
||||
private UserPicturesService userPicturesService;
|
||||
@Autowired
|
||||
private UserVipService userVipService;
|
||||
@Autowired
|
||||
private UserAuthService userAuthService;
|
||||
@Autowired
|
||||
private UserStatusService userStatusService;
|
||||
|
||||
@Override
|
||||
public MinUser getMinUserById(Long userId){
|
||||
@@ -107,6 +107,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements Use
|
||||
result.setOpenVip(true);
|
||||
result.setVipType(userVip.getVipType());
|
||||
}
|
||||
UserStatus userStatus = userStatusService.getByUserId(userId);
|
||||
boolean showAvatar = this.showAvatar(LoginHelper.getUserId(), userStatus.getShowAvatar());
|
||||
if(!showAvatar){
|
||||
result.setAvatar(null);
|
||||
result.setShowAvatarBool(false);
|
||||
result.setUserPictureList(Collections.emptyList());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -183,19 +190,36 @@ public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements Use
|
||||
return baseMapper.pageAdmin(pageQuery.build(), bo);
|
||||
}
|
||||
|
||||
public boolean showAvatar(Long userId, Integer avatar){
|
||||
if(userId == null){
|
||||
return ShowAvatarUtil.showAvatar(false,false,avatar);
|
||||
}
|
||||
UserAuth userAuth = userAuthService.getByUserId(userId);
|
||||
UserVip userVip = userVipService.getByUserVipMaster(userId);
|
||||
return ShowAvatarUtil.showAvatar(userAuth.getCarAuth()==1,userVip!=null, avatar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<HomeUserListVo> homePage(HomePageReq params) {
|
||||
HomePageReq.VipQuery vipQuery = params.getVipQuery();
|
||||
boolean vip = false; // 是否为VIP
|
||||
boolean card = false; // 是否实名认证
|
||||
Long userId = LoginHelper.getUserId();
|
||||
UserVip userVip = null;
|
||||
if(userId != null){
|
||||
UserAuth userAuth = userAuthService.getByUserId(userId);
|
||||
card = userAuth != null && userAuth.getCarAuth() == 1;
|
||||
userVip = userVipService.getByUserVipMaster(userId);
|
||||
vip = userVip != null;
|
||||
}
|
||||
if(vipQuery != null){
|
||||
if(StringUtils.isNotEmpty(vipQuery.getProfession()) ||
|
||||
vipQuery.getAnnualIncome() != null || vipQuery.getZodiac() != null ||
|
||||
vipQuery.getSign() != null || vipQuery.getChildStatus() != null || vipQuery.getHousingStatus() != null ||
|
||||
vipQuery.getCarStatus() != null || StringUtils.isNotEmpty(vipQuery.getAddressCode())){
|
||||
Long userId = LoginHelper.getUserId();
|
||||
if(userId == null){
|
||||
throw new ServiceException(ErrorEnum.VIP_AUTH);
|
||||
}
|
||||
UserVip userVip = userVipService.getByUserVipMaster(userId);
|
||||
if(userVip == null){
|
||||
throw new ServiceException(ErrorEnum.VIP_AUTH);
|
||||
}
|
||||
@@ -208,14 +232,19 @@ public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements Use
|
||||
userIdArray.add(record.getUserId());
|
||||
record.setBirthdayStr(BirthdayUtil.getMinBirthday(record.getBirthday()));
|
||||
record.setAge(BirthdayUtil.getAge(record.getBirthday()));
|
||||
boolean showAvatarBool = ShowAvatarUtil.showAvatar(vip, card, record.getShowAvatar());
|
||||
record.setShowAvatarBool(showAvatarBool);
|
||||
if(!record.getShowAvatarBool()){
|
||||
record.setAvatar(null);
|
||||
}
|
||||
}
|
||||
List<UserVip> vips = userVipService.listUserVipMaster(userIdArray);
|
||||
Map<Long, UserVip> userVipMap = vips.stream().collect(Collectors.toMap(UserVip::getUserId, Function.identity()));
|
||||
for (HomeUserListVo record : records) {
|
||||
UserVip userVip = userVipMap.get(record.getUserId());
|
||||
UserVip userVipNode = userVipMap.get(record.getUserId());
|
||||
if(userVip != null){
|
||||
record.setOpenVip(true);
|
||||
record.setVipType(userVip.getVipType());
|
||||
record.setVipType(userVipNode.getVipType());
|
||||
}
|
||||
}
|
||||
return page;
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
package com.ruoyi.xq.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.xq.domain.UserStatus;
|
||||
import com.ruoyi.xq.domain.UserVip;
|
||||
import com.ruoyi.xq.dto.app.userstatus.UserStatusUpdateAppReq;
|
||||
import com.ruoyi.xq.enums.ErrorEnum;
|
||||
import com.ruoyi.xq.enums.userstatus.PersonalsStatusEnum;
|
||||
import com.ruoyi.xq.enums.userstatus.ShowAvatarEnum;
|
||||
import com.ruoyi.xq.mapper.UserStatusMapper;
|
||||
import com.ruoyi.xq.service.UserStatusService;
|
||||
import com.ruoyi.xq.service.UserVipService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 用户状态Service业务层处理
|
||||
*
|
||||
@@ -14,8 +25,35 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class UserStatusServiceImpl extends ServiceImpl<UserStatusMapper,UserStatus> implements UserStatusService {
|
||||
@Autowired
|
||||
private UserVipService userVipService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public UserStatus getByUserId(Long userId) {
|
||||
return this.getOne(Wrappers.lambdaQuery(UserStatus.class).eq(UserStatus::getUserId,userId).last("limit 1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(UserStatusUpdateAppReq req) {
|
||||
UserStatus userStatus = this.getByUserId(req.getUserId());
|
||||
if(req.getShowAvatar() != null && !req.getShowAvatar().equals(ShowAvatarEnum.ALL.getCode())){
|
||||
UserVip userVip = userVipService.getByUserVipMaster(req.getUserId());
|
||||
if(userVip == null){
|
||||
throw new ServiceException(ErrorEnum.VIP_AUTH.getText());
|
||||
}
|
||||
}
|
||||
UserStatus update = new UserStatus();
|
||||
update.setId(userStatus.getId());
|
||||
update.setUpdateTime(LocalDateTime.now());
|
||||
update.setPersonalsStatus(req.getPersonalsStatus());
|
||||
update.setAllowTransMobile(req.getAllowTransMobile());
|
||||
update.setAllowTransWx(req.getAllowTransWx());
|
||||
if(req.getPersonalsStatus() != null && (PersonalsStatusEnum.CAO.getCode().equals(req.getPersonalsStatus())
|
||||
|| PersonalsStatusEnum.HIDING.getCode().equals(req.getPersonalsStatus()))){
|
||||
update.setShowAvatar(ShowAvatarEnum.NO.getCode());
|
||||
}else{
|
||||
update.setShowAvatar(req.getShowAvatar());
|
||||
}
|
||||
this.updateById(update);
|
||||
}
|
||||
}
|
||||
|
||||
27
ruoyi-xq/src/main/java/com/ruoyi/xq/util/ShowAvatarUtil.java
Normal file
27
ruoyi-xq/src/main/java/com/ruoyi/xq/util/ShowAvatarUtil.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.ruoyi.xq.util;
|
||||
|
||||
public class ShowAvatarUtil {
|
||||
|
||||
/**
|
||||
* 判断用户是可以查看头像
|
||||
* @param showAvatar 1-所有用户 2-VIP用户 3-实名用户 4-实名认证且VIP用户 5-不公开
|
||||
*/
|
||||
public static boolean showAvatar(boolean vip, boolean cardAuth, Integer showAvatar) {
|
||||
if(showAvatar == null){
|
||||
return true;
|
||||
}
|
||||
if(showAvatar == 1){
|
||||
return true;
|
||||
}
|
||||
if(showAvatar == 2){
|
||||
return vip;
|
||||
}
|
||||
if(showAvatar == 3){
|
||||
return cardAuth;
|
||||
}
|
||||
if(showAvatar == 4){
|
||||
return vip && cardAuth;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user