fix funny nickName

main
wangqing 7 months ago
parent 9cf043ace8
commit 5b55d45601

@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletRequest;
import api.Result; import api.Result;
import api.StatusCode; import api.StatusCode;
import com.luoo.user.util.NickNameUtil2;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
@ -200,7 +201,8 @@ public class UserInfoService {
if (null == userInfo) { if (null == userInfo) {
userInfo = loginUserInfo; userInfo = loginUserInfo;
userInfo.setId(String.valueOf(idWorker.nextId())); userInfo.setId(String.valueOf(idWorker.nextId()));
userInfo.setNickName("雀乐-" + NickNameUtil.getRandomNickName()); // userInfo.setNickName("雀乐-" + NickNameUtil.getRandomNickName());
userInfo.setNickName(NickNameUtil2.generateRandomString());
Date curDate = new Date(); Date curDate = new Date();
userInfo.setJoinTime(curDate); userInfo.setJoinTime(curDate);
userInfo.setLastLoginTime(curDate); userInfo.setLastLoginTime(curDate);
@ -231,7 +233,8 @@ public class UserInfoService {
// return "未注册"; // return "未注册";
userInfo = loginUserInfo; userInfo = loginUserInfo;
userInfo.setId(String.valueOf(idWorker.nextId())); userInfo.setId(String.valueOf(idWorker.nextId()));
userInfo.setNickName("雀乐-" + NickNameUtil.getRandomNickName()); userInfo.setNickName(NickNameUtil2.generateRandomString());
// userInfo.setNickName("雀乐-" + NickNameUtil.getRandomNickName());
Date curDate = new Date(); Date curDate = new Date();
userInfo.setJoinTime(curDate); userInfo.setJoinTime(curDate);
userInfo.setLastLoginTime(curDate); userInfo.setLastLoginTime(curDate);
@ -301,7 +304,8 @@ public class UserInfoService {
if (null == userInfo) { if (null == userInfo) {
userInfo = loginUserInfo; userInfo = loginUserInfo;
userInfo.setId(String.valueOf(idWorker.nextId())); userInfo.setId(String.valueOf(idWorker.nextId()));
userInfo.setNickName("雀乐-" + NickNameUtil.getRandomNickName()); userInfo.setNickName(NickNameUtil2.generateRandomString());
// userInfo.setNickName("雀乐-" + NickNameUtil.getRandomNickName());
Date curDate = new Date(); Date curDate = new Date();
userInfo.setJoinTime(curDate); userInfo.setJoinTime(curDate);
userInfo.setLastLoginTime(curDate); userInfo.setLastLoginTime(curDate);

File diff suppressed because one or more lines are too long

@ -0,0 +1,18 @@
package com.luoo.user.util;
import java.util.stream.IntStream;
import org.junit.Test;
public class NickNameUtil2Test {
@Test
public void test() {
int total = 10000000;
System.out.println("total: " + total);
IntStream.range(0, total).parallel().mapToObj(j -> NickNameUtil2.generateRandomString()).limit(10)
.forEach(System.out::println);
long distinctNickName = IntStream.range(0, total).parallel().mapToObj(j -> NickNameUtil2.generateRandomString())
.distinct().count();
System.out.println("length: " + 9 + " distinctCount: " + distinctNickName);
}
}
Loading…
Cancel
Save