记得上下班打卡 | git大法好,push需谨慎

Commit 73993cc0 authored by 张国柄's avatar 张国柄

adam:+昵称生成规则(昵称库随机取);

parent 11aa2ea9
......@@ -18,7 +18,7 @@ public class AdamRedisConst {
public static final String INFO_TAGS_MUSIC = INFO.concat("tags:music");
public static final String INFO_USER = INFO.concat("user:");
public static final String INFO_USER_MEMBER = INFO_USER.concat("member:");
public static final String INFO_USER_MEMBER = INFO.concat("umember:");
public static final String INFO_REAL_NAME = INFO.concat("real_name:");
public static final String INFO_THIRD_PARTY = INFO.concat("third_party:");
public static final String INFO_ENTERS = INFO.concat("enters:");
......@@ -32,6 +32,8 @@ public class AdamRedisConst {
public static final String INFO_MEMBER_AGREEMENT = INFO.concat("member:agreement");
public static final String INFO_MEMBER_CODE = INFO.concat("member:code:");
public static final String INFO_LIBRARY_NKNAME = INFO.concat("library:nkname");
public static final String BLACK_LIST = ADAM.concat("blacklist:");
public static final String BLK_LIST_MEMBER_UID = BLACK_LIST.concat("member:uid");
......
......@@ -4,6 +4,7 @@ import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.SensitizeUtil;
import com.liquidnet.service.adam.constant.AdamRedisConst;
import com.liquidnet.service.adam.dto.vo.*;
import com.liquidnet.service.adam.util.NknameUtil;
import com.liquidnet.service.kylin.constant.KylinRedisConst;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinPerformanceVo;
import lombok.extern.slf4j.Slf4j;
......@@ -17,6 +18,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
......@@ -30,11 +32,25 @@ public class AdamRdmService {
@Autowired
RedisUtil redisUtil;
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Switch config */
public Integer getSwitch(String rk) {
Integer i = (Integer) redisUtil.get(rk);
return null == i ? 1 : i;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Loader meta-fil */
public List<String> getNknameList() {
ArrayList<String> list = (ArrayList<String>) redisUtil.get(AdamRedisConst.INFO_LIBRARY_NKNAME);
if (CollectionUtils.isEmpty(list)) {
list = NknameUtil.readForStringList();
if (!CollectionUtils.isEmpty(list)) redisUtil.set(AdamRedisConst.INFO_LIBRARY_NKNAME, list);
}
return list;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | <Mobile, SMS CODE> */
public boolean setSmsCodeByMobile(String mobile, String smsCode) {
......
......@@ -22,6 +22,7 @@ import com.mongodb.client.model.ReturnDocument;
import com.mongodb.client.result.DeleteResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
import org.bson.Document;
import org.springframework.beans.BeanUtils;
......@@ -81,7 +82,8 @@ public class AdamUserServiceImpl implements IAdamUserService {
userInfoVo = AdamUserInfoVo.getNew();
userInfoVo.setUid(IDGenerator.nextSnowId() + "");
userInfoVo.setMobile(mobile);
userInfoVo.setNickname("Now_".concat(RandomStringUtils.randomAlphanumeric(3)).concat(mobile.substring(6)));
List<String> nknameList = adamRdmService.getNknameList();
userInfoVo.setNickname("宇航员".concat(nknameList.get(RandomUtils.nextInt(0, nknameList.size()))));
userInfoVo.setIsComplete(0);
userInfoVo.setState(1);
userInfoVo.setQrCode("lN".concat(userInfoVo.getUid()).concat(RandomStringUtils.randomAlphanumeric(5).toUpperCase()));
......
package com.liquidnet.service.adam.util;
import com.liquidnet.commons.lang.util.CollectionUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
public class NknameUtil {
private static final Logger log = LoggerFactory.getLogger(NknameUtil.class);
public static ArrayList<String> readForStringList() {
ArrayList<String> nknameList = CollectionUtil.arrayListString();
InputStream inputStream = null;
InputStreamReader inputStreamReader = null;
BufferedReader bufferedReader = null;
try {
inputStream = NknameUtil.class.getClassLoader().getResourceAsStream("META-FIL/library_nickname.csv");
inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
bufferedReader = new BufferedReader(inputStreamReader);
String line;
while ((line = bufferedReader.readLine()) != null) {
int l = StringUtils.length(line);
if (l == 0) {
break;
}
if (l > 11) {
line = line.substring(0, 11);
}
nknameList.add(line);
}
} catch (IOException e) {
log.error("Read CSV[library_nickname.csv] failure.", e);
} finally {
try {
if (null != bufferedReader) bufferedReader.close();
if (null != inputStreamReader) inputStreamReader.close();
if (null != inputStream) inputStream.close();
} catch (IOException e) {
log.error("Close stream failure.", e);
}
}
return nknameList;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment