@ -1,5 +1,6 @@
package com.dongjian.datacenter.admin.service.impl ;
package com.dongjian.datacenter.admin.service.impl ;
import com.dongjian.datacenter.admin.common.Constants ;
import com.github.pagehelper.PageHelper ;
import com.github.pagehelper.PageHelper ;
import com.dongjian.datacenter.admin.common.exception.MsgCodeException ;
import com.dongjian.datacenter.admin.common.exception.MsgCodeException ;
import com.dongjian.datacenter.admin.common.language.msg.MsgLanguageChange ;
import com.dongjian.datacenter.admin.common.language.msg.MsgLanguageChange ;
@ -30,6 +31,7 @@ import com.dongjian.datacenter.admin.util.async.OptAsync;
import com.dongjian.datacenter.admin.util.redis.RedisUtil ;
import com.dongjian.datacenter.admin.util.redis.RedisUtil ;
import com.dongjian.datacenter.admin.vo.user.UserPageDTO ;
import com.dongjian.datacenter.admin.vo.user.UserPageDTO ;
import java.io.Serializable ;
import java.text.MessageFormat ;
import java.text.MessageFormat ;
import java.util.Arrays ;
import java.util.Arrays ;
import java.util.List ;
import java.util.List ;
@ -44,7 +46,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory ;
import org.slf4j.LoggerFactory ;
import org.springframework.beans.BeanUtils ;
import org.springframework.beans.BeanUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Qualifier ;
import org.springframework.beans.factory.annotation.Value ;
import org.springframework.beans.factory.annotation.Value ;
import org.springframework.data.redis.core.RedisTemplate ;
import org.springframework.stereotype.Service ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import org.springframework.transaction.annotation.Transactional ;
import org.springframework.transaction.interceptor.TransactionAspectSupport ;
import org.springframework.transaction.interceptor.TransactionAspectSupport ;
@ -57,6 +61,9 @@ public class UserServiceImpl implements UserService {
//同时含大写字母、小写字母、数字和特殊字符且长度大于8
//同时含大写字母、小写字母、数字和特殊字符且长度大于8
private static final String pwdPattern = "^(?=.*\\d)(?=.*[a-zA-Z])(?=.*[~!@#$%^&*])[\\da-zA-Z~!@#$%^&*]{12,}$" ;
private static final String pwdPattern = "^(?=.*\\d)(?=.*[a-zA-Z])(?=.*[~!@#$%^&*])[\\da-zA-Z~!@#$%^&*]{12,}$" ;
@Autowired
@Qualifier ( "redisTemplateForBusiness" )
private RedisTemplate < String , Serializable > redisTemplateForBusiness ;
@Value ( "${web.login.url}" )
@Value ( "${web.login.url}" )
private String webLoginUrl ;
private String webLoginUrl ;
@ -421,4 +428,31 @@ public class UserServiceImpl implements UserService {
}
}
}
}
@Override
public SimpleDataResponse batchUnlock ( ResetPassword userInfo , Long companyId , Long userId , Integer languageType ) {
if ( StringUtils . isBlank ( userInfo . getUserIds ( ) ) ) {
return SimpleDataResponse . success ( ) ;
}
try {
List < Long > idList = Arrays . asList ( userInfo . getUserIds ( ) . split ( "," ) ) . stream ( ) . map ( s - > Long . parseLong ( s . trim ( ) ) ) . collect ( Collectors . toList ( ) ) ;
for ( Long targetUserId : idList ) {
String lockKey = String . format ( Constants . LOGIN_LOCK , targetUserId ) ;
String failKey = String . format ( Constants . LOGIN_FAIL , targetUserId ) ;
redisTemplateForBusiness . delete ( lockKey ) ;
redisTemplateForBusiness . delete ( failKey ) ;
String businessLockKey = String . format ( Constants . BUSINESS_LOGIN_LOCK , targetUserId ) ;
String businessFailKey = String . format ( Constants . BUSINESS_LOGIN_FAIL , targetUserId ) ;
redisTemplateForBusiness . delete ( businessLockKey ) ;
redisTemplateForBusiness . delete ( businessFailKey ) ;
}
return SimpleDataResponse . success ( ) ;
} catch ( Exception e ) {
logger . error ( "batchUnlock error" , e ) ;
return new SimpleDataResponse ( ResponseCode . SERVER_ERROR , "server error" ) ;
}
}
}
}