init
This commit is contained in:
@@ -6,6 +6,7 @@ import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.enums.UserType;
|
||||
@@ -14,10 +15,7 @@ import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.system.service.SysLoginService;
|
||||
import com.ruoyi.xq.domain.User;
|
||||
import com.ruoyi.xq.domain.UserAuth;
|
||||
import com.ruoyi.xq.domain.UserInfo;
|
||||
import com.ruoyi.xq.domain.UserLogin;
|
||||
import com.ruoyi.xq.domain.*;
|
||||
import com.ruoyi.xq.enums.common.AuditEnum;
|
||||
import com.ruoyi.xq.enums.common.CodeEnum;
|
||||
import com.ruoyi.xq.enums.common.SystemConfigEnum;
|
||||
@@ -66,6 +64,8 @@ public class CaiLoginManager {
|
||||
private ImUserClient imUserClient;
|
||||
@Autowired
|
||||
private SmsVerifyService smsVerifyService;
|
||||
@Autowired
|
||||
private UserExtendService userExtendService;
|
||||
|
||||
public String login(String username,String password){
|
||||
User user = userService.getByUsername(username);
|
||||
@@ -128,7 +128,6 @@ public class CaiLoginManager {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void dealInviteId(User user){
|
||||
String inviteCode = user.getInviteCode();
|
||||
if(StringUtils.isEmpty(inviteCode)){
|
||||
@@ -138,34 +137,16 @@ public class CaiLoginManager {
|
||||
if(inviteUser == null){
|
||||
return;
|
||||
}
|
||||
String key = LockKey.getDealInviteLockKey(user.getId());
|
||||
RLock lock = redissonClient.getLock(key);
|
||||
if(lock.isLocked()){
|
||||
log.warn("点击太快了,等一等,dealInviteId");
|
||||
return;
|
||||
}
|
||||
lock.lock(5,TimeUnit.SECONDS);
|
||||
try {
|
||||
/*UserInvite check = userInviteService.getByUserId(user.getId());
|
||||
if(check == null){
|
||||
UserInvite userInvite = new UserInvite();
|
||||
userInvite.setUserId(user.getId());
|
||||
userInvite.setInviteId(user.getInviteId());
|
||||
userInviteService.save(userInvite);
|
||||
}else{
|
||||
userInviteService.update(Wrappers.lambdaUpdate(UserInvite.class)
|
||||
.eq(UserInvite::getId,check.getId())
|
||||
.set(UserInvite::getInviteId,user.getInviteId())
|
||||
.set(UserInvite::getRewardCoinTotal,0L));
|
||||
}*/
|
||||
}finally {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
userService.update(Wrappers.lambdaUpdate(User.class)
|
||||
.eq(User::getId,user.getId())
|
||||
.set(User::getInviteId, inviteUser.getId()));
|
||||
userExtendService.update(Wrappers.lambdaUpdate(UserExtend.class)
|
||||
.eq(UserExtend::getUserId, user.getId())
|
||||
.set(UserExtend::getInviteId, inviteUser.getId())
|
||||
.set(UserExtend::getInviteCode, inviteUser.getUsercode()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
@@ -248,8 +229,13 @@ public class CaiLoginManager {
|
||||
UserAuth userAuth = new UserAuth();
|
||||
userAuth.setUsercode(usercode);
|
||||
userAuth.setUserId(add.getId());
|
||||
userAuth.setPhone(add.getMobile());
|
||||
userAuth.setPhoneAuth(AuditEnum.SUCCESS.getCode());
|
||||
userAuthService.save(userAuth);
|
||||
UserExtend userExtend = new UserExtend();
|
||||
userExtend.setUsercode(usercode);
|
||||
userExtend.setUserId(add.getId());
|
||||
userExtendService.save(userExtend);
|
||||
return add;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,301 @@
|
||||
package com.ruoyi.xq.manager;
|
||||
|
||||
import com.ruoyi.xq.dto.app.user.CurrentUserInfoVo;
|
||||
import lombok.Data;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.BeanConvertUtil;
|
||||
import com.ruoyi.xq.domain.*;
|
||||
import com.ruoyi.xq.dto.app.common.UserPicturesDTO;
|
||||
import com.ruoyi.xq.dto.app.user.AddPicturesReq;
|
||||
import com.ruoyi.xq.dto.app.user.UpdateBaseInfoReq;
|
||||
import com.ruoyi.xq.dto.app.user.UpdateUserAuthInfoReq;
|
||||
import com.ruoyi.xq.dto.app.user.UpdateUserFullInfoReq;
|
||||
import com.ruoyi.xq.dto.app.user.vo.*;
|
||||
import com.ruoyi.xq.enums.common.AuditEnum;
|
||||
import com.ruoyi.xq.enums.user.UserAuthTypeEnum;
|
||||
import com.ruoyi.xq.enums.user.UserInfoAuditTypeEnum;
|
||||
import com.ruoyi.xq.lock.LockKey;
|
||||
import com.ruoyi.xq.service.*;
|
||||
import com.ruoyi.xq.util.AgeUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CurrentUserManager {
|
||||
public CurrentUserInfoVo currentInfo() {
|
||||
return null;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private UserPicturesService userPicturesService;
|
||||
@Autowired
|
||||
private UserInfoService userInfoService;
|
||||
@Autowired
|
||||
private UserAuthService userAuthService;
|
||||
@Autowired
|
||||
private UserAuthAuditService userAuthAuditService;
|
||||
@Autowired
|
||||
private UserInfoAuditService userInfoAuditService;
|
||||
|
||||
|
||||
public CurrentUserFullInfoVo currentFullInfo(){
|
||||
Long userId = LoginHelper.getUserId();
|
||||
User user = userService.getById(userId);
|
||||
UserInfo userInfo = userInfoService.getByUserId(userId);
|
||||
CurrentUserFullInfoVo result = new CurrentUserFullInfoVo();
|
||||
BeanConvertUtil.copyProperties(userInfo,result);
|
||||
BeanConvertUtil.copyProperties(user,result);
|
||||
UserInfoAudit avatarAudit = userInfoAuditService.getByUserIdAndType(userId, UserInfoAuditTypeEnum.AVATAR);
|
||||
AvatarMinAuditDTO avatarAuditInfo = new AvatarMinAuditDTO();
|
||||
avatarAuditInfo.setAvatar(user.getAvatar());
|
||||
avatarAuditInfo.setAuditStatus(AuditEnum.NO.getCode());
|
||||
if(avatarAudit != null){
|
||||
avatarAuditInfo.setAvatar(avatarAudit.getAuditContent());
|
||||
avatarAuditInfo.setAuditStatus(avatarAudit.getAuditStatus());
|
||||
}
|
||||
result.setAvatarAudit(avatarAuditInfo);
|
||||
|
||||
UserInfoAudit remarkAudit = userInfoAuditService.getByUserIdAndType(userId, UserInfoAuditTypeEnum.REMARK);
|
||||
RemarkMinAuditDTO remarkAuditInfo = new RemarkMinAuditDTO();
|
||||
remarkAuditInfo.setRemark(user.getAvatar());
|
||||
remarkAuditInfo.setAuditStatus(AuditEnum.NO.getCode());
|
||||
if(remarkAudit != null){
|
||||
remarkAuditInfo.setAuditRemark(remarkAudit.getAuditContent());
|
||||
remarkAuditInfo.setAuditStatus(remarkAudit.getAuditStatus());
|
||||
}
|
||||
result.setRemarkAudit(remarkAuditInfo);
|
||||
|
||||
List<UserPictures> userPictures = userPicturesService.listByUserId(user.getId());
|
||||
result.setUserPicturesList(BeanConvertUtil.convertListTo(userPictures, UserPicturesDTO::new));
|
||||
return result;
|
||||
}
|
||||
public CurrentUserInfoVo currentBaseInfo() {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
User user = userService.getById(userId);
|
||||
CurrentUserInfoVo vo = new CurrentUserInfoVo();
|
||||
vo.setUserId(user.getId());
|
||||
vo.setUsercode(user.getUsercode());
|
||||
vo.setType(user.getType());
|
||||
vo.setNickname(user.getNickname());
|
||||
vo.setMobile(user.getMobile());
|
||||
vo.setAvatar(user.getAvatar());
|
||||
vo.setGender(user.getGender());
|
||||
vo.setBirthday(user.getBirthday());
|
||||
vo.setAge(AgeUtil.getAge(user.getBirthday()));
|
||||
vo.setResidenceCity(user.getResidenceCity());
|
||||
vo.setStatus(user.getStatus());
|
||||
vo.setFinishBaseStatus(user.getFinishBaseStatus());
|
||||
vo.setImToken(user.getImToken());
|
||||
List<UserPictures> userPictures = userPicturesService.listByUserId(user.getId());
|
||||
vo.setUserPicturesList(BeanConvertUtil.convertListTo(userPictures, UserPicturesDTO::new));
|
||||
return vo;
|
||||
}
|
||||
|
||||
public void updateBaseInfo(UpdateBaseInfoReq req) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
User updateUser = BeanConvertUtil.convertTo(req, User::new);
|
||||
updateUser.setId(userId);
|
||||
userService.updateById(updateUser);
|
||||
UserInfo updateUserInfo = BeanConvertUtil.convertTo(req, UserInfo::new);
|
||||
UserInfo userInfo = userInfoService.getByUserId(userId);
|
||||
updateUserInfo.setId(userInfo.getId());
|
||||
userInfoService.updateById(updateUserInfo);
|
||||
// 检查finishStatus
|
||||
boolean finishBaseStatus = true;
|
||||
User user = userService.getById(userId);
|
||||
if(user.getForPersonals() == null || user.getGender() == 0
|
||||
|| user.getBirthday() == null || user.getHeight() == null
|
||||
|| user.getWeight() == null || user.getResidence() == null
|
||||
|| user.getAddress() == null || user.getEducation() == null
|
||||
|| user.getMarriage() == null || user.getProfession() == null
|
||||
|| user.getAnnualIncome() == null || user.getUsercode() == null){
|
||||
finishBaseStatus = false;
|
||||
}
|
||||
userInfo = userInfoService.getById(userInfo.getId());
|
||||
if(userInfo.getCarStatus() == null || userInfo.getHousingStatus() == null){
|
||||
finishBaseStatus = false;
|
||||
}
|
||||
if(finishBaseStatus){
|
||||
userService.update(Wrappers.lambdaUpdate(User.class)
|
||||
.eq(User::getId,user.getId())
|
||||
.set(User::getFinishBaseStatus, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
public void updateRemark(String remark){
|
||||
Long userId = LoginHelper.getUserId();
|
||||
User user = userService.getById(userId);
|
||||
RLock lock = redissonClient.getLock(LockKey.getUserInfoAuditLock(userId));
|
||||
try {
|
||||
if(lock.isLocked()){
|
||||
log.warn("点击太快了,等一等,dealInviteId");
|
||||
return;
|
||||
}
|
||||
lock.lock(5,TimeUnit.SECONDS);
|
||||
UserInfoAudit audit = userInfoAuditService.getByUserIdAndType(userId, UserInfoAuditTypeEnum.REMARK);
|
||||
if(audit == null){
|
||||
audit = new UserInfoAudit();
|
||||
audit.setUserId(userId);
|
||||
audit.setUsercode(user.getUsercode());
|
||||
audit.setInfoType(UserInfoAuditTypeEnum.REMARK.getCode());
|
||||
audit.setAuditContent(remark);
|
||||
audit.setAuditStatus(AuditEnum.AUDITING.getCode());
|
||||
userInfoAuditService.save(audit);
|
||||
}else{
|
||||
userInfoAuditService.update(Wrappers.lambdaUpdate(UserInfoAudit.class)
|
||||
.set(UserInfoAudit::getAuditContent, remark)
|
||||
.eq(UserInfoAudit::getId, audit.getId()));
|
||||
}
|
||||
} finally {
|
||||
lock.unlockAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAvatar(String avatar){
|
||||
Long userId = LoginHelper.getUserId();
|
||||
User user = userService.getById(userId);
|
||||
RLock lock = redissonClient.getLock(LockKey.getUserInfoAuditLock(userId));
|
||||
try {
|
||||
if(lock.isLocked()){
|
||||
log.warn("点击太快了,等一等,dealInviteId");
|
||||
return;
|
||||
}
|
||||
lock.lock(5,TimeUnit.SECONDS);
|
||||
UserInfoAudit audit = userInfoAuditService.getByUserIdAndType(userId, UserInfoAuditTypeEnum.AVATAR);
|
||||
if(audit == null){
|
||||
audit = new UserInfoAudit();
|
||||
audit.setUserId(userId);
|
||||
audit.setUsercode(user.getUsercode());
|
||||
audit.setInfoType(UserInfoAuditTypeEnum.AVATAR.getCode());
|
||||
audit.setAuditContent(avatar);
|
||||
audit.setAuditStatus(AuditEnum.AUDITING.getCode());
|
||||
userInfoAuditService.save(audit);
|
||||
}else{
|
||||
userInfoAuditService.update(Wrappers.lambdaUpdate(UserInfoAudit.class)
|
||||
.set(UserInfoAudit::getAuditContent, avatar)
|
||||
.eq(UserInfoAudit::getId, audit.getId()));
|
||||
}
|
||||
} finally {
|
||||
lock.unlockAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateInfo(UpdateUserFullInfoReq req) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
User updateUser = BeanConvertUtil.convertTo(req, User::new);
|
||||
updateUser.setId(userId);
|
||||
userService.updateById(updateUser);
|
||||
UserInfo updateUserInfo = BeanConvertUtil.convertTo(req, UserInfo::new);
|
||||
UserInfo userInfo = userInfoService.getByUserId(userId);
|
||||
updateUserInfo.setId(userInfo.getId());
|
||||
userInfoService.updateById(updateUserInfo);
|
||||
}
|
||||
|
||||
public UserAuthInfoVo currentAuthInfo() {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
UserAuth userAuth = userAuthService.getByUserId(userId);
|
||||
return BeanConvertUtil.convertTo(userAuth, UserAuthInfoVo::new);
|
||||
}
|
||||
|
||||
public void updateInfoAuth(UpdateUserAuthInfoReq req) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
User user = userService.getById(userId);
|
||||
if(BooleanUtils.isTrue(req.getPushCarAuth())){ // 车辆认证
|
||||
if(req.getCarPic() == null){
|
||||
throw new ServiceException("请上传车辆认证照片");
|
||||
}
|
||||
boolean update = userAuthService.update(Wrappers.lambdaUpdate(UserAuth.class)
|
||||
.eq(UserAuth::getUserId, userId)
|
||||
.in(UserAuth::getCarAuth, AuditEnum.NO.getCode(), AuditEnum.FAIL.getCode())
|
||||
.set(UserAuth::getCarAuth, AuditEnum.AUDITING.getCode()));
|
||||
if(!update){
|
||||
throw new ServiceException("车辆认证正在审核中,请勿重复提交");
|
||||
}
|
||||
userAuthAuditService.saveAuthAudit(user,UserAuthTypeEnum.CAR,req.getCarPic());
|
||||
}
|
||||
if(BooleanUtils.isTrue(req.getPushHouseAuth())){ // 房子认证
|
||||
if(req.getHousePic() == null){
|
||||
throw new ServiceException("请上传房产认证照片");
|
||||
}
|
||||
boolean update = userAuthService.update(Wrappers.lambdaUpdate(UserAuth.class)
|
||||
.eq(UserAuth::getUserId, userId)
|
||||
.in(UserAuth::getHouseAuth, AuditEnum.NO.getCode(), AuditEnum.FAIL.getCode())
|
||||
.set(UserAuth::getHouseAuth, AuditEnum.AUDITING.getCode()));
|
||||
if(!update){
|
||||
throw new ServiceException("房产认证正在审核中,请勿重复提交");
|
||||
}
|
||||
userAuthAuditService.saveAuthAudit(user,UserAuthTypeEnum.HOUSE,req.getHousePic());
|
||||
}
|
||||
if(BooleanUtils.isTrue(req.getPushEducationAuth())){ // 学历认证
|
||||
if(req.getEducationPic() == null){
|
||||
throw new ServiceException("请上传最高学历认证照片");
|
||||
}
|
||||
boolean update = userAuthService.update(Wrappers.lambdaUpdate(UserAuth.class)
|
||||
.eq(UserAuth::getUserId, userId)
|
||||
.in(UserAuth::getEducationAuth, AuditEnum.NO.getCode(), AuditEnum.FAIL.getCode())
|
||||
.set(UserAuth::getEducationAuth, AuditEnum.AUDITING.getCode()));
|
||||
if(!update){
|
||||
throw new ServiceException("房产认证正在审核中,请勿重复提交");
|
||||
}
|
||||
userAuthAuditService.saveAuthAudit(user,UserAuthTypeEnum.EDUCATION,req.getEducationPic());
|
||||
}
|
||||
if(BooleanUtils.isTrue(req.getPushMarriageAuth())){ // 婚况认证
|
||||
if(req.getMarriagePic() == null){
|
||||
throw new ServiceException("请上传婚况认证照片");
|
||||
}
|
||||
boolean update = userAuthService.update(Wrappers.lambdaUpdate(UserAuth.class)
|
||||
.eq(UserAuth::getUserId, userId)
|
||||
.in(UserAuth::getMarriageAuth, AuditEnum.NO.getCode(), AuditEnum.FAIL.getCode())
|
||||
.set(UserAuth::getMarriageAuth, AuditEnum.AUDITING.getCode()));
|
||||
if(!update){
|
||||
throw new ServiceException("房产认证正在审核中,请勿重复提交");
|
||||
}
|
||||
userAuthAuditService.saveAuthAudit(user,UserAuthTypeEnum.MARRIAGE,req.getMarriagePic());
|
||||
}
|
||||
if(BooleanUtils.isTrue(req.getPushJobAuthBoo())){ // 工作认证
|
||||
if(req.getJobAuthType() == null){
|
||||
throw new ServiceException("请选择工作认证方式");
|
||||
}
|
||||
if(req.getJobPic() == null){
|
||||
throw new ServiceException("请上传工作认证照片");
|
||||
}
|
||||
boolean update = userAuthService.update(Wrappers.lambdaUpdate(UserAuth.class)
|
||||
.eq(UserAuth::getUserId, userId)
|
||||
.in(UserAuth::getJobAuth, AuditEnum.NO.getCode(), AuditEnum.FAIL.getCode())
|
||||
.set(UserAuth::getJobAuth, AuditEnum.AUDITING.getCode()));
|
||||
if(!update){
|
||||
throw new ServiceException("房产认证正在审核中,请勿重复提交");
|
||||
}
|
||||
String authRemark = "工作认证";
|
||||
userAuthAuditService.saveAuthAudit(user,UserAuthTypeEnum.JOB,req.getJobPic(),authRemark);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void addUserPicture(AddPicturesReq req) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
User user = userService.getById(userId);
|
||||
UserPictures userPictures = new UserPictures();
|
||||
userPictures.setUserId(user.getId());
|
||||
userPictures.setUsercode(user.getUsercode());
|
||||
userPictures.setPicture(req.getPicture());
|
||||
userPictures.setAuditStatus(AuditEnum.AUDITING.getCode());
|
||||
userPicturesService.save(userPictures);
|
||||
}
|
||||
|
||||
public void removeUserPictures(List<Long> ids) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
userPicturesService.remove(Wrappers.lambdaQuery(UserPictures.class)
|
||||
.eq(UserPictures::getUserId,userId)
|
||||
.in(UserPictures::getId, ids));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user