优化随机用户名生成
This commit is contained in:
parent
f0f37d1659
commit
a31f0f3d19
@ -39,6 +39,12 @@ public class Constant {
|
|||||||
public static final String ORDER_DESC_READCOUNT = "read_count desc";
|
public static final String ORDER_DESC_READCOUNT = "read_count desc";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 终端
|
||||||
|
*/
|
||||||
|
public static final String H5 = "H5";
|
||||||
|
public static final String WXAPP = "WXAPP";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户是否禁用
|
* 用户是否禁用
|
||||||
|
@ -173,7 +173,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
|
|||||||
appUser.setMobile(form.getMobile());
|
appUser.setMobile(form.getMobile());
|
||||||
appUser.setGender(0);
|
appUser.setGender(0);
|
||||||
appUser.setAvatar(Constant.DEAULT_HEAD);
|
appUser.setAvatar(Constant.DEAULT_HEAD);
|
||||||
appUser.setUsername(generateRandomName("H5"));
|
appUser.setUsername(generateRandomName(Constant.H5));
|
||||||
appUser.setCreateTime(DateUtil.nowDateTime());
|
appUser.setCreateTime(DateUtil.nowDateTime());
|
||||||
appUser.setUpdateTime(DateUtil.nowDateTime());
|
appUser.setUpdateTime(DateUtil.nowDateTime());
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
@ -336,7 +336,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
|
|||||||
AppUserEntity appUser = new AppUserEntity();
|
AppUserEntity appUser = new AppUserEntity();
|
||||||
appUser.setGender(0);
|
appUser.setGender(0);
|
||||||
appUser.setAvatar(Constant.DEAULT_HEAD);
|
appUser.setAvatar(Constant.DEAULT_HEAD);
|
||||||
appUser.setUsername(generateRandomName("WX"));
|
appUser.setUsername(generateRandomName(Constant.WXAPP));
|
||||||
appUser.setCreateTime(DateUtil.nowDateTime());
|
appUser.setCreateTime(DateUtil.nowDateTime());
|
||||||
appUser.setUpdateTime(DateUtil.nowDateTime());
|
appUser.setUpdateTime(DateUtil.nowDateTime());
|
||||||
appUser.setOpenid(openId);
|
appUser.setOpenid(openId);
|
||||||
@ -420,11 +420,17 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
|
|||||||
return (String) json.get("openid");
|
return (String) json.get("openid");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成随机用户名
|
||||||
|
* @param type 终端类型
|
||||||
|
* @return 随机用户名
|
||||||
|
*/
|
||||||
private String generateRandomName(String type){
|
private String generateRandomName(String type){
|
||||||
String name = "";
|
String name = "";
|
||||||
if(type.equals("H5")){
|
if(type.equals(Constant.H5)){
|
||||||
name = "LF_" + RandomUtil.randomNumbers(8);
|
name = "LF_" + RandomUtil.randomNumbers(8);
|
||||||
}else if(type.equals("WX")){
|
}else if(type.equals(Constant.WXAPP)){
|
||||||
name = "LF_wx" + RandomUtil.randomNumbers(8);
|
name = "LF_wx" + RandomUtil.randomNumbers(8);
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user