|
|
@@ -20,6 +20,7 @@ import com.goafanti.common.dao.AdminLocationMapper;
|
|
|
import com.goafanti.common.dao.AdminMapper;
|
|
|
import com.goafanti.common.dao.UserRoleMapper;
|
|
|
import com.goafanti.common.model.Admin;
|
|
|
+import com.goafanti.common.utils.LoggerUtils;
|
|
|
import com.goafanti.common.utils.PasswordUtil;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
import com.goafanti.core.mybatis.BaseMybatisDao;
|
|
|
@@ -239,19 +240,67 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
|
|
|
|
|
|
@Override
|
|
|
public int updateLockAdmin() {
|
|
|
- List<Admin> list=adminMapper.selectAllAdmin();
|
|
|
+ int count=0;
|
|
|
+ List<Admin> list=adminMapper.selectAllAdmin();//获取所有用户
|
|
|
+ List<List<Admin>>aList=groupList(list);//拆分成多个
|
|
|
String lockIds = "";
|
|
|
- for (Admin a : list) {
|
|
|
- String pwd=a.getPassword();
|
|
|
- a.setPassword("123456");
|
|
|
- String pwd2=passwordUtil.getEncryptPwd(a);
|
|
|
- if (pwd.equals(pwd2)) {
|
|
|
- lockIds += a.getId() + ",";
|
|
|
+ for(List<Admin> al:aList){
|
|
|
+ for (Admin a : al) {
|
|
|
+ String pwd=a.getPassword();
|
|
|
+ a.setPassword("123456");
|
|
|
+ String pwd2=passwordUtil.getEncryptPwd(a);
|
|
|
+ if (pwd.equals(pwd2)) {
|
|
|
+ lockIds += a.getId() + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(lockIds.length()>0){
|
|
|
+ try {
|
|
|
+ lockIds = "'" + lockIds.substring(0,lockIds.length()-1).replace(",", "','") + "'";
|
|
|
+ count+= adminMapper.updateLockIds(lockIds);
|
|
|
+ Thread.sleep(1000);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ LoggerUtils.error(getClass(), "未修改管理员锁定失败", e);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- if(lockIds.length()>0)lockIds = "'" + lockIds.substring(0,lockIds.length()-1).replace(",", "','") + "'";
|
|
|
- return adminMapper.updateLockIds(lockIds);
|
|
|
+ return count;
|
|
|
}
|
|
|
+
|
|
|
+ /*
|
|
|
+ * List分割
|
|
|
+ */
|
|
|
+ public List<List<Admin>> groupList(List<Admin> list) {
|
|
|
+ List<List<Admin>> listGroup = new ArrayList<List<Admin>>();
|
|
|
+ int listSize = list.size();
|
|
|
+ //子集合的长度
|
|
|
+ int toIndex = 100;
|
|
|
+ for (int i = 0; i < list.size(); i += 100) {
|
|
|
+ if (i + 100 > listSize) {
|
|
|
+ toIndex = listSize - i;
|
|
|
+ }
|
|
|
+ List<Admin> newList = list.subList(i, i + toIndex);
|
|
|
+ listGroup.add(newList);
|
|
|
+ }
|
|
|
+ return listGroup;
|
|
|
+ }
|
|
|
+ /* public static void main(String[] args) {
|
|
|
+ List<String> list=new ArrayList<>();
|
|
|
+ for (int i = 1; i < 888; i++) {
|
|
|
+ list.add(String.valueOf(i));
|
|
|
+ }
|
|
|
+ List<List<String>> listGroup = new ArrayList<List<String>>();
|
|
|
+ int listSize = list.size();
|
|
|
+ //子集合的长度
|
|
|
+ int toIndex = 100;
|
|
|
+ for (int i = 0; i < list.size(); i += 100) {
|
|
|
+ if (i + 100 > listSize) {
|
|
|
+ toIndex = listSize - i;
|
|
|
+ }
|
|
|
+ List<String> newList = list.subList(i, i + toIndex);
|
|
|
+ listGroup.add(newList);
|
|
|
+ }
|
|
|
+ System.out.println(listGroup);
|
|
|
+ }*/
|
|
|
|
|
|
|
|
|
|