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.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
@@ -16,9 +17,8 @@ import com.ruoyi.common.core.domain.BaseEntity;
|
|||||||
* @date 2024-03-28
|
* @date 2024-03-28
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@TableName("xq_user_status")
|
@TableName("xq_user_status")
|
||||||
public class UserStatus extends BaseEntity {
|
public class UserStatus implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID=1L;
|
private static final long serialVersionUID=1L;
|
||||||
|
|
||||||
@@ -46,6 +46,7 @@ public class UserStatus extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 谁可查看资料 1-所有用户 2-VIP用户 3-实名用户 4-实名认证且VIP用户
|
* 谁可查看资料 1-所有用户 2-VIP用户 3-实名用户 4-实名认证且VIP用户
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
private Integer showInfo;
|
private Integer showInfo;
|
||||||
/**
|
/**
|
||||||
* 是否允许交换手机号
|
* 是否允许交换手机号
|
||||||
@@ -56,4 +57,7 @@ public class UserStatus extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private Integer allowTransWx;
|
private Integer allowTransWx;
|
||||||
|
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,16 @@ public class HomePageReq extends PageQuery {
|
|||||||
@Schema(hidden = true)
|
@Schema(hidden = true)
|
||||||
private LocalDate birthdayEnd;
|
private LocalDate birthdayEnd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询人是否实名认证
|
||||||
|
*/
|
||||||
|
@Schema(hidden = true)
|
||||||
|
private Integer certStatus = 0;
|
||||||
|
/**
|
||||||
|
* 查询人是否VIP
|
||||||
|
*/
|
||||||
|
@Schema(hidden = true)
|
||||||
|
private Integer vipStatus = 0;
|
||||||
@Schema(description = "年龄-开始")
|
@Schema(description = "年龄-开始")
|
||||||
private Integer ageBegin;
|
private Integer ageBegin;
|
||||||
@Schema(description = "年龄-结束")
|
@Schema(description = "年龄-结束")
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import java.time.LocalDate;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class HomeUserListVo {
|
public class HomeUserListVo {
|
||||||
|
@Schema(description = "是否可以查看头像,当不可以查看的时候头像是空")
|
||||||
|
private Boolean showAvatarBool = true;
|
||||||
|
private Integer showAvatar;
|
||||||
@Schema(description = "是否开通VIP")
|
@Schema(description = "是否开通VIP")
|
||||||
private Boolean openVip = false;
|
private Boolean openVip = false;
|
||||||
@Schema(description = "已开通的VIP类型")
|
@Schema(description = "已开通的VIP类型")
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import java.util.List;
|
|||||||
@Data
|
@Data
|
||||||
public class HomeUserVo {
|
public class HomeUserVo {
|
||||||
|
|
||||||
|
@Schema(description = "是否可以查看头像,当不可以查看的时候头像和图片是空")
|
||||||
|
private Boolean showAvatarBool = true;
|
||||||
@Schema(description = "用户ID")
|
@Schema(description = "用户ID")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
@Schema(description = "用户编号")
|
@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.CodeEnum;
|
||||||
import com.ruoyi.xq.enums.common.SystemConfigEnum;
|
import com.ruoyi.xq.enums.common.SystemConfigEnum;
|
||||||
import com.ruoyi.xq.enums.userinfo.UserGenderEnum;
|
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.executor.ExecutorConstant;
|
||||||
import com.ruoyi.xq.lock.LockKey;
|
import com.ruoyi.xq.lock.LockKey;
|
||||||
import com.ruoyi.xq.service.*;
|
import com.ruoyi.xq.service.*;
|
||||||
@@ -169,27 +171,27 @@ public class LoginManager {
|
|||||||
public User registerUser(String mobile,String inviteCode){
|
public User registerUser(String mobile,String inviteCode){
|
||||||
String cos = systemConfigManager.getSystemConfig(SystemConfigEnum.COS_DOMAIN);
|
String cos = systemConfigManager.getSystemConfig(SystemConfigEnum.COS_DOMAIN);
|
||||||
String usercode = userCodeGenService.getCodeGen();
|
String usercode = userCodeGenService.getCodeGen();
|
||||||
User add = new User();
|
User user = new User();
|
||||||
add.setUsercode(usercode);
|
user.setUsercode(usercode);
|
||||||
add.setNickname("用户"+usercode);
|
user.setNickname("用户"+usercode);
|
||||||
add.setType(0);
|
user.setType(0);
|
||||||
add.setPassword(BCrypt.hashpw(usercode+"用户手动滑稽安康黄鼠狼"));
|
user.setPassword(BCrypt.hashpw(usercode+"用户手动滑稽安康黄鼠狼"));
|
||||||
add.setMobile(mobile);
|
user.setMobile(mobile);
|
||||||
add.setWxCode(mobile);
|
user.setWxCode(mobile);
|
||||||
add.setGender(UserGenderEnum.NONE.getCode());
|
user.setGender(UserGenderEnum.NONE.getCode());
|
||||||
add.setAvatar(cos + UserGenderEnum.NONE.getDefaultAvatar());
|
user.setAvatar(cos + UserGenderEnum.NONE.getDefaultAvatar());
|
||||||
add.setImToken(IdUtil.simpleUUID());
|
user.setImToken(IdUtil.simpleUUID());
|
||||||
userService.save(add);
|
userService.save(user);
|
||||||
CreateUserReq req = new CreateUserReq();
|
CreateUserReq req = new CreateUserReq();
|
||||||
req.setAccid(add.getId()+"");
|
req.setAccid(user.getId()+"");
|
||||||
req.setToken(add.getImToken());
|
req.setToken(user.getImToken());
|
||||||
req.setName(add.getNickname());
|
req.setName(user.getNickname());
|
||||||
YxCommonR r = imUserClient.createUser(req);
|
YxCommonR r = imUserClient.createUser(req);
|
||||||
if(!r.isSuccess()){
|
if(!r.isSuccess()){
|
||||||
/*if(r.getCode() == 414){
|
/*if(r.getCode() == 414){
|
||||||
UpdateTokenReq req1 = new UpdateTokenReq();
|
UpdateTokenReq req1 = new UpdateTokenReq();
|
||||||
req1.setAccid(add.getId()+"");
|
req1.setAccid(user.getId()+"");
|
||||||
req1.setToken(add.getImToken());
|
req1.setToken(user.getImToken());
|
||||||
YxCommonR commonR = imUserClient.updateToken(req1);
|
YxCommonR commonR = imUserClient.updateToken(req1);
|
||||||
if(!commonR.isSuccess()){
|
if(!commonR.isSuccess()){
|
||||||
log.error("刷新云token失败,{}", JSON.toJSONString(commonR));
|
log.error("刷新云token失败,{}", JSON.toJSONString(commonR));
|
||||||
@@ -202,7 +204,7 @@ public class LoginManager {
|
|||||||
}
|
}
|
||||||
String clientIP = ServletUtils.getClientIP();
|
String clientIP = ServletUtils.getClientIP();
|
||||||
UserLogin userLogin = new UserLogin();
|
UserLogin userLogin = new UserLogin();
|
||||||
userLogin.setUserId(add.getId());
|
userLogin.setUserId(user.getId());
|
||||||
userLogin.setUsercode(usercode);
|
userLogin.setUsercode(usercode);
|
||||||
userLogin.setLastLoginIp(clientIP);
|
userLogin.setLastLoginIp(clientIP);
|
||||||
userLogin.setLastLoginTime(LocalDateTime.now());
|
userLogin.setLastLoginTime(LocalDateTime.now());
|
||||||
@@ -211,21 +213,29 @@ public class LoginManager {
|
|||||||
userLoginService.save(userLogin);
|
userLoginService.save(userLogin);
|
||||||
UserInfo userInfo = new UserInfo();
|
UserInfo userInfo = new UserInfo();
|
||||||
userInfo.setUsercode(usercode);
|
userInfo.setUsercode(usercode);
|
||||||
userInfo.setUserId(add.getId());
|
userInfo.setUserId(user.getId());
|
||||||
userInfoService.save(userInfo);
|
userInfoService.save(userInfo);
|
||||||
UserAuth userAuth = new UserAuth();
|
UserAuth userAuth = new UserAuth();
|
||||||
userAuth.setUsercode(usercode);
|
userAuth.setUsercode(usercode);
|
||||||
userAuth.setUserId(add.getId());
|
userAuth.setUserId(user.getId());
|
||||||
userAuth.setPhone(add.getMobile());
|
userAuth.setPhone(user.getMobile());
|
||||||
userAuth.setPhoneAuth(AuditEnum.SUCCESS.getCode());
|
userAuth.setPhoneAuth(AuditEnum.SUCCESS.getCode());
|
||||||
userAuthService.save(userAuth);
|
userAuthService.save(userAuth);
|
||||||
UserExtend userExtend = new UserExtend();
|
UserExtend userExtend = new UserExtend();
|
||||||
userExtend.setUsercode(usercode);
|
userExtend.setUsercode(usercode);
|
||||||
userExtend.setUserId(add.getId());
|
userExtend.setUserId(user.getId());
|
||||||
BigDecimal vipInviteRate = systemConfigManager.getSystemConfigOfBigDecimal(SystemConfigEnum.VIP_INVITE_RATE);
|
BigDecimal vipInviteRate = systemConfigManager.getSystemConfigOfBigDecimal(SystemConfigEnum.VIP_INVITE_RATE);
|
||||||
userExtend.setVipInviteRate(vipInviteRate);
|
userExtend.setVipInviteRate(vipInviteRate);
|
||||||
userExtendService.save(userExtend);
|
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) {
|
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.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.ruoyi.xq.domain.UserStatus;
|
import com.ruoyi.xq.domain.UserStatus;
|
||||||
|
import com.ruoyi.xq.dto.app.userstatus.UserStatusUpdateAppReq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户状态Service接口
|
* 用户状态Service接口
|
||||||
@@ -11,4 +12,7 @@ import com.ruoyi.xq.domain.UserStatus;
|
|||||||
*/
|
*/
|
||||||
public interface UserStatusService extends IService<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.exception.base.BaseException;
|
||||||
import com.ruoyi.common.helper.LoginHelper;
|
import com.ruoyi.common.helper.LoginHelper;
|
||||||
import com.ruoyi.common.utils.BeanConvertUtil;
|
import com.ruoyi.common.utils.BeanConvertUtil;
|
||||||
import com.ruoyi.xq.domain.User;
|
import com.ruoyi.xq.domain.*;
|
||||||
import com.ruoyi.xq.domain.UserInfo;
|
|
||||||
import com.ruoyi.xq.domain.UserPictures;
|
|
||||||
import com.ruoyi.xq.domain.UserVip;
|
|
||||||
import com.ruoyi.xq.dto.admin.user.UserAdminVo;
|
import com.ruoyi.xq.dto.admin.user.UserAdminVo;
|
||||||
import com.ruoyi.xq.dto.admin.user.req.UpdateMobileAdminReq;
|
import com.ruoyi.xq.dto.admin.user.req.UpdateMobileAdminReq;
|
||||||
import com.ruoyi.xq.dto.app.user.HomePageReq;
|
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.enums.userinfo.UserGenderEnum;
|
||||||
import com.ruoyi.xq.manager.SystemConfigManager;
|
import com.ruoyi.xq.manager.SystemConfigManager;
|
||||||
import com.ruoyi.xq.mapper.UserMapper;
|
import com.ruoyi.xq.mapper.UserMapper;
|
||||||
import com.ruoyi.xq.service.UserInfoService;
|
import com.ruoyi.xq.service.*;
|
||||||
import com.ruoyi.xq.service.UserPicturesService;
|
|
||||||
import com.ruoyi.xq.service.UserService;
|
|
||||||
import com.ruoyi.xq.service.UserVipService;
|
|
||||||
import com.ruoyi.xq.util.BirthdayUtil;
|
import com.ruoyi.xq.util.BirthdayUtil;
|
||||||
|
import com.ruoyi.xq.util.ShowAvatarUtil;
|
||||||
import com.ruoyi.yunxin.client.ImUserRefClient;
|
import com.ruoyi.yunxin.client.ImUserRefClient;
|
||||||
import com.ruoyi.yunxin.req.UpdateUinfoReq;
|
import com.ruoyi.yunxin.req.UpdateUinfoReq;
|
||||||
import com.ruoyi.yunxin.resp.YxCommonR;
|
import com.ruoyi.yunxin.resp.YxCommonR;
|
||||||
@@ -41,6 +36,7 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@@ -65,6 +61,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements Use
|
|||||||
private UserPicturesService userPicturesService;
|
private UserPicturesService userPicturesService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserVipService userVipService;
|
private UserVipService userVipService;
|
||||||
|
@Autowired
|
||||||
|
private UserAuthService userAuthService;
|
||||||
|
@Autowired
|
||||||
|
private UserStatusService userStatusService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MinUser getMinUserById(Long userId){
|
public MinUser getMinUserById(Long userId){
|
||||||
@@ -107,6 +107,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements Use
|
|||||||
result.setOpenVip(true);
|
result.setOpenVip(true);
|
||||||
result.setVipType(userVip.getVipType());
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,19 +190,36 @@ public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements Use
|
|||||||
return baseMapper.pageAdmin(pageQuery.build(), bo);
|
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
|
@Override
|
||||||
public Page<HomeUserListVo> homePage(HomePageReq params) {
|
public Page<HomeUserListVo> homePage(HomePageReq params) {
|
||||||
HomePageReq.VipQuery vipQuery = params.getVipQuery();
|
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(vipQuery != null){
|
||||||
if(StringUtils.isNotEmpty(vipQuery.getProfession()) ||
|
if(StringUtils.isNotEmpty(vipQuery.getProfession()) ||
|
||||||
vipQuery.getAnnualIncome() != null || vipQuery.getZodiac() != null ||
|
vipQuery.getAnnualIncome() != null || vipQuery.getZodiac() != null ||
|
||||||
vipQuery.getSign() != null || vipQuery.getChildStatus() != null || vipQuery.getHousingStatus() != null ||
|
vipQuery.getSign() != null || vipQuery.getChildStatus() != null || vipQuery.getHousingStatus() != null ||
|
||||||
vipQuery.getCarStatus() != null || StringUtils.isNotEmpty(vipQuery.getAddressCode())){
|
vipQuery.getCarStatus() != null || StringUtils.isNotEmpty(vipQuery.getAddressCode())){
|
||||||
Long userId = LoginHelper.getUserId();
|
|
||||||
if(userId == null){
|
if(userId == null){
|
||||||
throw new ServiceException(ErrorEnum.VIP_AUTH);
|
throw new ServiceException(ErrorEnum.VIP_AUTH);
|
||||||
}
|
}
|
||||||
UserVip userVip = userVipService.getByUserVipMaster(userId);
|
|
||||||
if(userVip == null){
|
if(userVip == null){
|
||||||
throw new ServiceException(ErrorEnum.VIP_AUTH);
|
throw new ServiceException(ErrorEnum.VIP_AUTH);
|
||||||
}
|
}
|
||||||
@@ -208,14 +232,19 @@ public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements Use
|
|||||||
userIdArray.add(record.getUserId());
|
userIdArray.add(record.getUserId());
|
||||||
record.setBirthdayStr(BirthdayUtil.getMinBirthday(record.getBirthday()));
|
record.setBirthdayStr(BirthdayUtil.getMinBirthday(record.getBirthday()));
|
||||||
record.setAge(BirthdayUtil.getAge(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);
|
List<UserVip> vips = userVipService.listUserVipMaster(userIdArray);
|
||||||
Map<Long, UserVip> userVipMap = vips.stream().collect(Collectors.toMap(UserVip::getUserId, Function.identity()));
|
Map<Long, UserVip> userVipMap = vips.stream().collect(Collectors.toMap(UserVip::getUserId, Function.identity()));
|
||||||
for (HomeUserListVo record : records) {
|
for (HomeUserListVo record : records) {
|
||||||
UserVip userVip = userVipMap.get(record.getUserId());
|
UserVip userVipNode = userVipMap.get(record.getUserId());
|
||||||
if(userVip != null){
|
if(userVip != null){
|
||||||
record.setOpenVip(true);
|
record.setOpenVip(true);
|
||||||
record.setVipType(userVip.getVipType());
|
record.setVipType(userVipNode.getVipType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return page;
|
return page;
|
||||||
|
|||||||
@@ -1,11 +1,22 @@
|
|||||||
package com.ruoyi.xq.service.impl;
|
package com.ruoyi.xq.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
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.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.mapper.UserStatusMapper;
|
||||||
import com.ruoyi.xq.service.UserStatusService;
|
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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户状态Service业务层处理
|
* 用户状态Service业务层处理
|
||||||
*
|
*
|
||||||
@@ -14,8 +25,35 @@ import org.springframework.stereotype.Service;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class UserStatusServiceImpl extends ServiceImpl<UserStatusMapper,UserStatus> implements UserStatusService {
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,11 +22,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</select>
|
</select>
|
||||||
<select id="homePageApp" resultType="com.ruoyi.xq.dto.app.user.vo.HomeUserListVo">
|
<select id="homePageApp" resultType="com.ruoyi.xq.dto.app.user.vo.HomeUserListVo">
|
||||||
select t1.id as user_id, t1.avatar, t1.gender, t1.nickname, t1.birthday, t1.residence_city_name,
|
select t1.id as user_id, t1.avatar, t1.gender, t1.nickname, t1.birthday, t1.residence_city_name,
|
||||||
t1.education, t1.profession, if(t2.card_num_auth = 1, 1, 0) as cardNumAuthBool
|
t1.education, t1.profession, if(t2.card_num_auth = 1, 1, 0) as cardNumAuthBool,t4.show_avatar
|
||||||
from xq_user t1
|
from xq_user t1
|
||||||
join xq_user_auth t2 on t1.id = t2.user_id
|
join xq_user_auth t2 on t1.id = t2.user_id
|
||||||
join xq_user_info t3 on t1.id = t3.user_id
|
join xq_user_info t3 on t1.id = t3.user_id
|
||||||
where t1.type = 0 and t1.status = 0 and t1.finish_base_status = 1
|
join xq_user_status t4 on t1.id = t4.user_id
|
||||||
|
where t1.type = 0 and t1.status = 0 and t1.finish_base_status = 1 and t4.personals_status = 1
|
||||||
<if test="params.birthdayBegin != null">
|
<if test="params.birthdayBegin != null">
|
||||||
and t1.birthday >= #{params.birthdayBegin}
|
and t1.birthday >= #{params.birthdayBegin}
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
Reference in New Issue
Block a user