[用户明细]-用户明细查询增加筛选条件

This commit is contained in:
liaozetao
2024-06-19 14:14:43 +08:00
parent e1364dfc81
commit f78275366a
16 changed files with 555 additions and 603 deletions

View File

@@ -41,21 +41,21 @@ public enum LoginTypeEnum {
/**
* 谷歌登录
*/
GOOGLE((byte)8),
GOOGLE((byte) 8),
/**
* line登录
*/
LINE((byte)9),
LINE((byte) 9),
/**
* facebook登录
*/
FACEBOOK((byte)10),
FACEBOOK((byte) 10),
;
private byte value;
private final byte value;
LoginTypeEnum(byte value) {
this.value = value;

View File

@@ -80,19 +80,18 @@ public class AccountManageService {
protected Gson gson = new Gson();
public Account getOrGenAccountByPhone(String phone,String phoneAreaCode, String smsCode, DeviceInfo deviceInfo, String ipAddress)
public Account getOrGenAccountByPhone(String phone, String phoneAreaCode, String smsCode, DeviceInfo deviceInfo, String ipAddress)
throws Exception {
log.info("getOrGenAccountByPhone phone:{},smsCode:{},phoneAreaCode{}",phone,smsCode,phoneAreaCode);
log.info("getOrGenAccountByPhone phone:{},smsCode:{},phoneAreaCode{}", phone, smsCode, phoneAreaCode);
final String lockVal = jedisLockService.lock(RedisKey.lock_register_by_phone.getKey(phone));
try {
if (BlankUtil.isBlank(lockVal)){
if (BlankUtil.isBlank(lockVal)) {
throw new ServiceException(BusiStatus.REQUEST_FAST);
}
Account account = accountService.getAccountByPhone(phone);
if (account == null) {
account = saveSignUpByPhone(phone,null, deviceInfo,ipAddress,phoneAreaCode);
account = saveSignUpByPhone(phone, null, deviceInfo, ipAddress, phoneAreaCode);
} else {
//account = fillDeviceInfo(account, deviceInfo);
String state = account.getState();
if ("2".equals(state)) {
throw new CustomOAuth2Exception(CustomOAuth2Exception.INVALID_USER,
@@ -111,15 +110,15 @@ public class AccountManageService {
public Account getOrGenAccountByOpenid(String openid, Byte type, DeviceInfo deviceInfo, String ipAddress, String unionId) throws Exception {
log.info("getOrGenAccountByOpenid openId:{},type:{},unionId:{}",openid,type,unionId);
log.info("getOrGenAccountByOpenid openId:{},type:{},unionId:{}", openid, type, unionId);
final String locKey = RedisKey.lock_register_by_openid.getKey(openid, unionId, String.valueOf(type));
final String lockVal = jedisLockService.lock(locKey, 10 * 1000);
try {
if (BlankUtil.isBlank(lockVal)){
if (BlankUtil.isBlank(lockVal)) {
throw new ServiceException(BusiStatus.REQUEST_FAST);
}
Account account = accountService.getAccountByThird(type, unionId,
LoginTypeEnum.GOOGLE.getValue() == type? deviceInfo.getApp(): null);
LoginTypeEnum.GOOGLE.getValue() == type ? deviceInfo.getApp() : null);
if (account == null) {
checkRegisterLimit(deviceInfo.getDeviceId(), ipAddress);
@@ -177,27 +176,27 @@ public class AccountManageService {
}
}
private void checkRegisterLimit(String deviceId, String ipAddress){
if (!StringUtils.hasText(deviceId)){
private void checkRegisterLimit(String deviceId, String ipAddress) {
if (!StringUtils.hasText(deviceId)) {
throw new CustomOAuth2Exception(CustomOAuth2Exception.SIGN_IP_TO_OFTEN, BusiStatus.DEVICE_ERROR.getReasonPhrase());
}
RepeatedDeviceIpRegisterLimitConfig repeatedConfig = getRepeatedDeviceIpLimitConfig();
if (repeatedConfig.isOpen()){
if (repeatedConfig.isOpen()) {
int repeatedDeviceNum = accountService.lambdaQuery().eq(Account::getDeviceId, deviceId).count();
if (repeatedDeviceNum >= repeatedConfig.getRepeatedDeviceNumLimit()){
if (repeatedDeviceNum >= repeatedConfig.getRepeatedDeviceNumLimit()) {
throw new CustomOAuth2Exception(CustomOAuth2Exception.SIGN_IP_TO_OFTEN, BusiStatus.REGISTER_FREQUENT.getReasonPhrase());
}
int repeatedIpNum = accountService.lambdaQuery().eq(Account::getRegisterIp, ipAddress).count();
if (repeatedIpNum >= repeatedConfig.getRepeatedIpNumLimit()){
if (repeatedIpNum >= repeatedConfig.getRepeatedIpNumLimit()) {
throw new CustomOAuth2Exception(CustomOAuth2Exception.SIGN_IP_TO_OFTEN, BusiStatus.REGISTER_FREQUENT.getReasonPhrase());
}
}
//当日单个ip注册数
DayIpMaxRegisterLimitConfig config = getIpMaxLimitConfig();
if (config.getOpen()){
if (config.getOpen()) {
int count = accountService.getRegisterIpCountByOneDay(ipAddress);
if (count >= config.getMax()) {
throw new CustomOAuth2Exception(CustomOAuth2Exception.SIGN_IP_TO_OFTEN, BusiStatus.REGISTER_FREQUENT.getReasonPhrase());
@@ -217,8 +216,8 @@ public class AccountManageService {
* @return
*/
public Account saveSignUpByPhone(String phone, String password, DeviceInfo deviceInfo,
String ipAddress,String phoneAreaCode) throws Exception {
return saveSignUpByPhone(phone, password, deviceInfo, null, null, ipAddress,phoneAreaCode);
String ipAddress, String phoneAreaCode) throws Exception {
return saveSignUpByPhone(phone, password, deviceInfo, null, null, ipAddress, phoneAreaCode);
}
@@ -230,14 +229,14 @@ public class AccountManageService {
* @return
*/
public Account saveSignUpByPhone(String phone, String password, DeviceInfo deviceInfo, String prefillInviteCode, Long prefillInviteUid,
String ipAddress,String phoneAreaCode) throws Exception {
String ipAddress, String phoneAreaCode) throws Exception {
checkRegisterLimit(deviceInfo.getDeviceId(), ipAddress);
Date date = new Date();
Account account = new Account();
account.setPhone(phone);
account.setPhoneAreaCode(phoneAreaCode);
if(!StringUtils.isEmpty(password)){
if (!StringUtils.isEmpty(password)) {
account.setPassword(encryptPassword(password));
}
account.setNeteaseToken(UUIDUtil.get());
@@ -307,7 +306,7 @@ public class AccountManageService {
throw new ServiceException(BusiStatus.USER_NOT_EXISTED);
}
phone = account.getPhone();
if (!CommonUtil.checkPhoneFormat(account.getPhoneAreaCode(),account.getPhone())) {
if (!CommonUtil.checkPhoneFormat(account.getPhoneAreaCode(), account.getPhone())) {
throw new ServiceException(BusiStatus.ACCOUNT_NOT_BIND_PHONE);
}
}
@@ -318,19 +317,19 @@ public class AccountManageService {
}
Account account = accountService.getAccountByPhone(phone);
if (null == account || (uid != null && !account.getUid().equals(uid)) ) {
if (null == account || (uid != null && !account.getUid().equals(uid))) {
throw new ServiceException(BusiStatus.PHONE_BIND_ERROR);
}
uid = account.getUid();
//检验验证码
if (!accountService.verifySmsCodeByCache(phone, resetCode, uid)){
if (!accountService.verifySmsCodeByCache(phone, resetCode, uid)) {
throw new ServiceException(BusiStatus.INVALID_IDENTIFYING_CODE);
}
accountService.resetAccountPwd(account.getUid(), password);
//成功后删除验证码缓存
accountService.delSmsCodeCache(phone,account.getUid());
accountService.delSmsCodeCache(phone, account.getUid());
//accountService.delNickPasswordCache(account.getErbanNo());
// 删除用户信息缓存
jedisService.hdel(RedisKey.user.getKey(), account.getUid().toString());
@@ -346,7 +345,7 @@ public class AccountManageService {
String oldPwd = account.getPassword();
password = encryptPassword(password);
if (!StringUtils.hasText(password) || !password.equals(oldPwd)){
if (!StringUtils.hasText(password) || !password.equals(oldPwd)) {
throw new ServiceException(BusiStatus.OLD_PASSWORD_ERROR);
}
@@ -355,7 +354,7 @@ public class AccountManageService {
//记录最近30天内绑定手机号
jedisService.setex(RedisKey.modify_pwd_sign.getKey(String.valueOf(account.getUid())),
30 * 24 * 60 *60, String.valueOf(new Date().getTime()));
30 * 24 * 60 * 60, String.valueOf(new Date().getTime()));
}
/**
@@ -371,7 +370,7 @@ public class AccountManageService {
}
Boolean result = accountService.updateAccountPwd(account.getUid(), password);
if (!result){
if (!result) {
throw new ServiceException(BusiStatus.INVALID_REQUEST);
}
@@ -413,17 +412,17 @@ public class AccountManageService {
throw exception;
}
private DayIpMaxRegisterLimitConfig getIpMaxLimitConfig(){
private DayIpMaxRegisterLimitConfig getIpMaxLimitConfig() {
String config = sysConfService.getSysConfValueById(Constant.SysConfId.IP_MAX_REGISTER_LIMIT_CONFIG);
if (!StringUtils.hasText(config)){
if (!StringUtils.hasText(config)) {
throw new ServiceException(BusiStatus.ALREADY_NOTEXISTS_CONFIG);
}
return gson.fromJson(config, DayIpMaxRegisterLimitConfig.class);
}
private RepeatedDeviceIpRegisterLimitConfig getRepeatedDeviceIpLimitConfig(){
private RepeatedDeviceIpRegisterLimitConfig getRepeatedDeviceIpLimitConfig() {
String config = sysConfService.getSysConfValueById(Constant.SysConfId.REPEATED_DEVICE_IP_REGISTER_LIMIT_CONFIG);
if (!StringUtils.hasText(config)){
if (!StringUtils.hasText(config)) {
throw new ServiceException(BusiStatus.ALREADY_NOTEXISTS_CONFIG);
}
return gson.fromJson(config, RepeatedDeviceIpRegisterLimitConfig.class);