1.add more attribute for user profile

main
hechanggeng 11 months ago
parent e28b432720
commit e8b51b82f9

@ -117,6 +117,7 @@ public class UserController {
// 得到缓存中的验证码
String checkcodeRedis = (String) redisTemplate.opsForValue().get("checkcode_"+user.getMobile());
if (checkcodeRedis.isEmpty()){
//单独定义一个请重新获取验证码的code? 2024.01.12 by he,changgeng
return new Result(false,StatusCode.ERROR,"请先获取手机验证码");
}
if (!checkcodeRedis.equals(code)) {

@ -0,0 +1,14 @@
package com.luoo.user.enumerate;
public enum Gender {
Male("0"), Female("1");
private String code;
private Gender(String code) {
this.code = code;
}
public String getCode() {
return code;
}
}

@ -15,6 +15,7 @@ import entity.Result;
import entity.StatusCode;
import io.jsonwebtoken.Claims;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.amqp.rabbit.core.RabbitMessagingTemplate;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.BeanUtils;
@ -32,6 +33,7 @@ import util.IdWorker;
import com.apifan.common.random.RandomSource;
import com.luoo.user.dao.UserDao;
import com.luoo.user.enumerate.Gender;
import com.luoo.user.pojo.User;
import com.luoo.user.vo.UserVO;
@ -259,8 +261,10 @@ public class UserService {
user=new User();
user.setId(String.valueOf(idWorker.nextId()));
user.setMobile(mobile);
user.setNickname(RandomSource.personInfoSource().randomChineseNickName(8));
user.setNickname("雀乐"+getRandomNickName());
user.setSex(Gender.Male.getCode());
user.setAvatar("default");
user.setPersonality("无签名");
userDao.save(user);
}
@ -279,10 +283,20 @@ public class UserService {
public UserVO touristLogin() {
UserVO userVO=new UserVO();
userVO.setId(String.valueOf(idWorker.nextId()));
userVO.setNickname(RandomSource.personInfoSource().randomChineseNickName(8));
userVO.setNickname("游客"+getRandomNickName());
userVO.setSex(Gender.Male.getCode());
userVO.setAvatar("default");
userVO.setPersonality("无签名");
String token = jwtUtil.createJWT(userVO.getId(),"tourist","tourist");
userVO.setToken(token);
return userVO;
}
private String getRandomNickName() {
String rawNickName=RandomSource.personInfoSource().randomChineseNickName(3);
if(rawNickName.length()>3) {
return rawNickName.substring(0, 3);
}
return rawNickName;
}
}

@ -8,10 +8,14 @@ import lombok.Data;
public class UserVO {
@ApiModelProperty(value = "ID")
private String id;//ID
@ApiModelProperty(value = "昵称",notes="初次登录,随机生成")
@ApiModelProperty(value = "昵称首次注册登录登录用户随机为“雀乐XXX”游客为“游客XXX”",example="雀乐XXX")
private String nickname;//昵称
@ApiModelProperty(value = "头像",notes="初次登录,默认头像")
@ApiModelProperty(value = "性别0为男1 为女首次注册登录默认为0",example="0")
private String sex;//性别
@ApiModelProperty(value = "头像,首次注册登录,默认头像",example="default")
private String avatar;//头像
@ApiModelProperty(value = "个性签名,首次注册登录,默认为“无签名”",example="无签名")
private String personality;//个性
@ApiModelProperty(value = "TOKEN")
private String token;
}

@ -0,0 +1,28 @@
package com.luoo.user.service;
import static org.junit.Assert.*;
import org.junit.Test;
import com.apifan.common.random.RandomSource;
public class UserServiceTest {
@Test
public void testRandomNickName() {
for(int i=0;i<100;i++) {
String nickName=getRandomNickName();
assertTrue(nickName.length()<=3);
}
}
private String getRandomNickName() {
String rawNickName=RandomSource.personInfoSource().randomChineseNickName(3);
if(rawNickName.length()>3) {
return rawNickName.substring(0, 3);
}
return rawNickName;
}
}
Loading…
Cancel
Save