Browse Source

Merge branch 'test' of jishutao/kede-server into prod

liliang4869 7 years ago
parent
commit
91ab7b2dde

+ 13 - 0
src/main/java/com/goafanti/admin/controller/AdminApiController.java

@@ -3123,4 +3123,17 @@ public class AdminApiController extends CertifyApiController {
 		}
 		return res;
 	}
+	
+	
+
+	/**
+	 * 锁定密码未更改的用户
+	 */
+	@RequestMapping(value = "/lockAdmin", method = RequestMethod.POST)
+	public Result updateLockAdmin() {
+		Result res = new Result();
+		res.setData(adminService.updateLockAdmin());
+		return res;
+	}
+	
 }

+ 2 - 0
src/main/java/com/goafanti/admin/service/AdminService.java

@@ -64,4 +64,6 @@ public interface AdminService {
 	List<Admin> listAdminByName(String name);
 
 	List<AdminListBo> selectDepartmentStaff(String departmentId,String name);
+
+	int updateLockAdmin();
 }

+ 73 - 0
src/main/java/com/goafanti/admin/service/impl/AdminServiceImpl.java

@@ -1,10 +1,13 @@
 package com.goafanti.admin.service.impl;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 
+import javax.annotation.Resource;
+
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -17,10 +20,13 @@ 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;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.customer.bo.LockingReleaseBo;
 
 @Service
 public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements AdminService {
@@ -30,6 +36,8 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 	private UserRoleMapper		userRoleMapper;
 	@Autowired
 	private AdminLocationMapper	adminLocationMapper;
+	@Resource(name = "passwordUtil")
+	private PasswordUtil					passwordUtil;
 	@Override
 	public List<Admin> selectAllAdmin() {
 		return adminMapper.selectAllAdmin();
@@ -230,6 +238,71 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 		return adminMapper.selectDepartmentStaff( departmentId,  name);
 	}
 
+	@Override
+	public int updateLockAdmin() {
+		int count=0;
+		List<Admin> list=adminMapper.selectAllAdmin();//获取所有用户
+		List<List<Admin>>aList=groupList(list);//拆分成多个
+		String lockIds = "";
+		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);
+				lockIds = "";
+					Thread.sleep(1000);
+				} catch (InterruptedException e) {
+					LoggerUtils.error(getClass(), "未修改管理员锁定失败", e);
+				}
+			}
+		}
+		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 += toIndex) {
+            if (i + toIndex > 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);
+	}*/
+
 	
 
 }

+ 2 - 0
src/main/java/com/goafanti/common/dao/AdminMapper.java

@@ -171,6 +171,8 @@ public interface AdminMapper {
 
 	List<Admin> selectAllAdmin();
 
+	int updateLockIds(@Param("lockIds")String lockIds);
+
 	
 
 }

+ 4 - 1
src/main/java/com/goafanti/common/mapper/AdminMapper.xml

@@ -512,6 +512,7 @@
     select 
     <include refid="Base_Column_List" />
     from admin 
+    where status !='锁定' 
   </select>
   
   <select id="selectByMobile" parameterType="java.lang.String" resultMap="BaseResultMap">
@@ -946,6 +947,8 @@
 	left join `role` c on b.rid=c.id
 	where c.role_name  = #{name,jdbcType=VARCHAR}
   </select>
-  
+   <update id="updateLockIds" parameterType="java.lang.String">
+  	update admin set status = '锁定' where id in (${lockIds})
+  </update>
   
 </mapper>

+ 2 - 2
src/main/resources/props/config_local.properties

@@ -1,7 +1,7 @@
 #Driver
 jdbc.driverClassName=com.mysql.jdbc.Driver
 #\u6570\u636e\u5e93\u94fe\u63a5\uff0c
-jdbc.url=jdbc:mysql://192.168.1.102:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+jdbc.url=jdbc:mysql://192.168.0.17:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 #\u5e10\u53f7
 jdbc.username=dev
 #\u5bc6\u7801
@@ -40,7 +40,7 @@ jdbc.filters=stat
 
 logging.level.com.goafanti=DEBUG
 
-jedis.host=127.0.0.1
+jedis.host=192.168.0.17
 jedis.port=6379
 jedis.timeout=5000
 jedis.password=aft123456

+ 1 - 1
src/main/resources/props/config_test.properties

@@ -1,7 +1,7 @@
 #Driver
 jdbc.driverClassName=com.mysql.jdbc.Driver
 #\u6570\u636e\u5e93\u94fe\u63a5\uff0c
-jdbc.url=jdbc:mysql://127.0.0.1:3306/aft20180522?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+jdbc.url=jdbc:mysql://127.0.0.1:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 #\u5e10\u53f7
 jdbc.username=root
 #\u5bc6\u7801