release: 1.1 根据邀请码获取用户部分信息

release-2024-04-25
huangyw 1 month ago
parent dc05223d61
commit 46e7cf56f8

@ -38,6 +38,7 @@ public class ErrorConstants {
public final static String USER_ALREADY_EXISTS_ARTIST = "用户已发起过音乐人审核"; public final static String USER_ALREADY_EXISTS_ARTIST = "用户已发起过音乐人审核";
public final static String USER_STATUS_ERROR = "用户状态错误"; public final static String USER_STATUS_ERROR = "用户状态错误";
public final static String USER_NAME_ALREADY_EXISTS = "用户名已存在"; public final static String USER_NAME_ALREADY_EXISTS = "用户名已存在";
public final static String USER_INVITE_CODE_NOT_EXIST = "邀请码不存在";
// 会员部分 // 会员部分
public static final String MEMBERSHIP_CODE_NOT_EXISTS = "会员码不存在"; public static final String MEMBERSHIP_CODE_NOT_EXISTS = "会员码不存在";

@ -18,8 +18,10 @@ import com.luoo.user.pojo.*;
import com.luoo.user.service.*; import com.luoo.user.service.*;
import com.luoo.user.util.EmojiConverterUtil; import com.luoo.user.util.EmojiConverterUtil;
import com.luoo.user.util.IpUtil; import com.luoo.user.util.IpUtil;
import com.luoo.user.vo.userinfo.UserInfoForInviteVO;
import com.luoo.user.vo.userinfo.UserinfoShippingAddressAppVO; import com.luoo.user.vo.userinfo.UserinfoShippingAddressAppVO;
import constants.Constants; import constants.Constants;
import constants.ErrorConstants;
import constants.TaskPointIdConstants; import constants.TaskPointIdConstants;
import controller.BaseController; import controller.BaseController;
import dto.UserLoginDto; import dto.UserLoginDto;
@ -132,6 +134,17 @@ public class MyController extends BaseController {
return Result.success(userRespDTO); return Result.success(userRespDTO);
} }
@ApiOperation(value = "1.1 根据邀请码获取用户部分信息", notes = "无认证")
@GetMapping("/userInfo/invite")
public Result<UserInfoForInviteVO> getUserInfoForInvite(String inviteCode) {
UserInfo userInfoByInvitationCode = userInfoService.getUserInfoByInvitationCode(inviteCode);
if(userInfoByInvitationCode != null) {
return Result.success(new UserInfoForInviteVO(userInfoByInvitationCode.getNickName(), userInfoByInvitationCode.getAvatar(), inviteCode));
} else {
return Result.failed(ErrorConstants.USER_INVITE_CODE_NOT_EXIST);
}
}
@ApiOperation(value = "2.更新个人信息", notes = "游客无法编辑个人信息") @ApiOperation(value = "2.更新个人信息", notes = "游客无法编辑个人信息")
@PutMapping("/userInfo") @PutMapping("/userInfo")
@GlobalInterceptor(checkAppUserLogin = true) @GlobalInterceptor(checkAppUserLogin = true)

@ -82,10 +82,10 @@ public class UserInfoService {
private final UserPointLogDao userPointLogDao; private final UserPointLogDao userPointLogDao;
public UserInfoService(UserInfoDao userInfoDao, IdWorker idWorker, RedisTemplate redisTemplate, public UserInfoService(UserInfoDao userInfoDao, IdWorker idWorker, RedisTemplate redisTemplate,
RabbitTemplate rabbitTemplate, BCryptPasswordEncoder encoder, HttpServletRequest request, RabbitTemplate rabbitTemplate, BCryptPasswordEncoder encoder, HttpServletRequest request,
JwtUtil jwtUtil, UserRealNameDao userRealNameDao, UserBankDao userBankDao, JwtUtil jwtUtil, UserRealNameDao userRealNameDao, UserBankDao userBankDao,
WithdrawDao withdrawDao, UserPointLogService userPointLogService, WithdrawDao withdrawDao, UserPointLogService userPointLogService,
UserPointLogDao userPointLogDao) { UserPointLogDao userPointLogDao) {
this.userInfoDao = userInfoDao; this.userInfoDao = userInfoDao;
this.idWorker = idWorker; this.idWorker = idWorker;
this.redisTemplate = redisTemplate; this.redisTemplate = redisTemplate;
@ -233,8 +233,8 @@ public class UserInfoService {
* *
* *
* @param loginUserInfo * @param loginUserInfo
* @param loginReq * @param loginReq
* @return token * @return token
*/ */
public String loginOrRegisterWithInvite(UserInfo loginUserInfo, LoginReq loginReq) { public String loginOrRegisterWithInvite(UserInfo loginUserInfo, LoginReq loginReq) {
UserInfo userInfo = userInfoDao.findByMobile(loginUserInfo.getMobile()); UserInfo userInfo = userInfoDao.findByMobile(loginUserInfo.getMobile());
@ -269,7 +269,7 @@ public class UserInfoService {
userInfoDao.save(userInfo); userInfoDao.save(userInfo);
String token = Constants.TOKEN_PREFIX String token = Constants.TOKEN_PREFIX
+ jwtUtil.createJWT(userInfo.getId(), userInfo.getNickName(), Constants.TOKEN_ROLE_APP_USER, userInfo.getAvatar()); + jwtUtil.createJWT(userInfo.getId(), userInfo.getNickName(), Constants.TOKEN_ROLE_APP_USER, userInfo.getAvatar());
if(isNewUser) { if (isNewUser) {
// 只有新用户会获得积分 // 只有新用户会获得积分
userPointLogService.addByTaskNew(TaskPointIdConstants.NEW_USER_WELCOME_AWARD, token); userPointLogService.addByTaskNew(TaskPointIdConstants.NEW_USER_WELCOME_AWARD, token);
} }
@ -279,7 +279,7 @@ public class UserInfoService {
/** /**
* *
* *
* @param userInfo * @param userInfo
* @param invitationCode * @param invitationCode
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -343,7 +343,7 @@ public class UserInfoService {
String token = Constants.TOKEN_PREFIX String token = Constants.TOKEN_PREFIX
+ jwtUtil.createJWT(userInfo.getId(), userInfo.getNickName(), Constants.TOKEN_ROLE_APP_USER, userInfo.getAvatar()); + jwtUtil.createJWT(userInfo.getId(), userInfo.getNickName(), Constants.TOKEN_ROLE_APP_USER, userInfo.getAvatar());
if(isNewUser) { if (isNewUser) {
// 只有新用户会获得积分 // 只有新用户会获得积分
userPointLogService.addByTaskNew(TaskPointIdConstants.NEW_USER_WELCOME_AWARD, token); userPointLogService.addByTaskNew(TaskPointIdConstants.NEW_USER_WELCOME_AWARD, token);
} }
@ -383,7 +383,7 @@ public class UserInfoService {
userInfoDao.save(userInfo); userInfoDao.save(userInfo);
String token = Constants.TOKEN_PREFIX String token = Constants.TOKEN_PREFIX
+ jwtUtil.createJWT(userInfo.getId(), userInfo.getNickName(), Constants.TOKEN_ROLE_APP_USER, userInfo.getAvatar()); + jwtUtil.createJWT(userInfo.getId(), userInfo.getNickName(), Constants.TOKEN_ROLE_APP_USER, userInfo.getAvatar());
if(isNewUser) { if (isNewUser) {
// 只有新用户会获得积分 // 只有新用户会获得积分
userPointLogService.addByTaskNew(TaskPointIdConstants.NEW_USER_WELCOME_AWARD, token); userPointLogService.addByTaskNew(TaskPointIdConstants.NEW_USER_WELCOME_AWARD, token);
} }
@ -469,7 +469,7 @@ public class UserInfoService {
userInfoDao.save(userInfo); userInfoDao.save(userInfo);
String token = Constants.TOKEN_PREFIX String token = Constants.TOKEN_PREFIX
+ jwtUtil.createJWT(userInfo.getId(), userInfo.getNickName(), Constants.TOKEN_ROLE_APP_USER, userInfo.getAvatar()); + jwtUtil.createJWT(userInfo.getId(), userInfo.getNickName(), Constants.TOKEN_ROLE_APP_USER, userInfo.getAvatar());
if(isNewUser) { if (isNewUser) {
// 只有新用户会获得积分 // 只有新用户会获得积分
userPointLogService.addByTaskNew(TaskPointIdConstants.NEW_USER_WELCOME_AWARD, token); userPointLogService.addByTaskNew(TaskPointIdConstants.NEW_USER_WELCOME_AWARD, token);
} }
@ -804,9 +804,9 @@ public class UserInfoService {
/** /**
* *
* *
* @param token token * @param token token
* @param page * @param page
* @param size * @param size
* @return * @return
*/ */
public PageResult<Withdraw> withdrawPageResult(String token, Integer page, Integer size) { public PageResult<Withdraw> withdrawPageResult(String token, Integer page, Integer size) {
@ -820,7 +820,7 @@ public class UserInfoService {
long totalElements = withdrawPage.getTotalElements(); long totalElements = withdrawPage.getTotalElements();
List<Withdraw> content = withdrawPage.getContent(); List<Withdraw> content = withdrawPage.getContent();
for (Withdraw withdraw : content) { for (Withdraw withdraw : content) {
if(withdraw.getState() != null) { if (withdraw.getState() != null) {
withdraw.setStateStr(Objects.requireNonNull(WithdrawStateEnum.getByCode(withdraw.getState())).getDesc()); withdraw.setStateStr(Objects.requireNonNull(WithdrawStateEnum.getByCode(withdraw.getState())).getDesc());
} }
} }
@ -843,21 +843,21 @@ public class UserInfoService {
/** /**
* *
* *
* @param userId id * @param userId id
* @param token uuid * @param token uuid
* @param type 1- 2- * @param type 1- 2-
* @return token * @return token
*/ */
public void scan(String userId, String token, Integer type) throws Exception { public void scan(String userId, String token, Integer type) throws Exception {
Object o = redisTemplate.opsForValue().get(token); Object o = redisTemplate.opsForValue().get(token);
if (o == null) { if (o == null) {
throw new BizException("二维码失效!"); throw new BizException("二维码失效!");
} }
if(!String.valueOf(o).equals("0") && !String.valueOf(o).equals("1")) { if (!String.valueOf(o).equals("0") && !String.valueOf(o).equals("1")) {
throw new BizException("登录认证已完成"); throw new BizException("登录认证已完成");
} }
if(type == 1) { if (type == 1) {
// 扫码 // 扫码
redisTemplate.opsForValue().set(token, 1, 60, TimeUnit.SECONDS); redisTemplate.opsForValue().set(token, 1, 60, TimeUnit.SECONDS);
} else { } else {
@ -884,7 +884,7 @@ public class UserInfoService {
public String createInvitationCode(String token) { public String createInvitationCode(String token) {
UserLoginDto user = jwtUtil.getUserLoginDto(token); UserLoginDto user = jwtUtil.getUserLoginDto(token);
UserInfo byId = userInfoDao.getById(user.getUserId()); UserInfo byId = userInfoDao.getById(user.getUserId());
if(StringUtils.isNotBlank(byId.getInvitationCode())) { if (StringUtils.isNotBlank(byId.getInvitationCode())) {
return byId.getInvitationCode(); return byId.getInvitationCode();
} }
@ -907,4 +907,14 @@ public class UserInfoService {
public List<UserInfo> getExpireVipList() { public List<UserInfo> getExpireVipList() {
return userInfoDao.getExpireVipList(); return userInfoDao.getExpireVipList();
} }
/**
*
*
* @param invitationCode
* @return
*/
public UserInfo getUserInfoByInvitationCode(String invitationCode) {
return userInfoDao.findByInvitationCode(invitationCode);
}
} }

@ -0,0 +1,31 @@
package com.luoo.user.vo.userinfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @program: luoo_parent
* @description: h5
* @author: yawei.huang
* @create: 2024-10-10 08:14
**/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserInfoForInviteVO implements Serializable {
private static final long serialVersionUID = -3383281434773850094L;
@ApiModelProperty(value = "用户昵称")
private String nickName;
@ApiModelProperty(value = "用户头像")
private String avatar;
@ApiModelProperty(value = "邀请码")
private String inviteCode;
}
Loading…
Cancel
Save