Pārlūkot izejas kodu

20220810 更新了权限-

lifuquan 2 gadi atpakaļ
vecāks
revīzija
76e0f0ebc7

+ 4 - 0
src/main/java/com/nokia/dao/UserDao.java

@@ -99,4 +99,8 @@ public interface UserDao extends BaseMapper<User> {
         Integer hasLoginName(String loginName);
 
         List<User> getByRoleIds(List<Integer> roleIds, List<Integer> cityIds);
+
+        @Insert("INSERT INTO sqmdb_rpt.acl_user (login_name, user_name, phone, email, city_id, area_id, province_id, org) "
+                        + " VALUES(#{loginName}, #{userName}, #{phone}, #{email}, #{cityId}, #{areaId}, #{provinceId}, #{org})")
+        int insert(User user);
 }

+ 54 - 8
src/test/java/com/nokia/service/UserServiceTest.java

@@ -4,11 +4,16 @@ import java.io.BufferedReader;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
+import java.util.Arrays;
+
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.data.redis.core.RedisTemplate;
 
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.nokia.dao.UserDao;
+import com.nokia.dao.UserRoleCityDao;
 import com.nokia.pojo.User;
 import com.nokia.pojo.UserRoleCity;
 
@@ -17,6 +22,10 @@ public class UserServiceTest {
 
     @Autowired
     private UserService userService;
+    @Autowired
+    private UserDao userDao;
+    @Autowired
+    private UserRoleCityDao userRoleCityDao;
 
     @Autowired
     private RedisTemplate<String, Object> redisTemplate;
@@ -25,10 +34,10 @@ public class UserServiceTest {
     void testRedisTemplate() {
         Object value = redisTemplate.opsForValue().get("test_token_hengshui");
         System.out.println(value);
-        Boolean delete = redisTemplate.delete("test_token_hengshui");
-        System.out.println(delete);
-        value = redisTemplate.opsForValue().get("test_token_hengshui");
-        System.out.println(value);
+        // Boolean delete = redisTemplate.delete("test_token_hengshui");
+        // System.out.println(delete);
+        // value = redisTemplate.opsForValue().get("test_token_hengshui");
+        // System.out.println(value);
     }
 
     @Test
@@ -40,15 +49,52 @@ public class UserServiceTest {
     @Test
     void testAddUserRoleCity() throws FileNotFoundException, IOException {
         try (BufferedReader reader = new BufferedReader(
-                new FileReader("D:\\code\\acl_tousu_all\\acl_tousu\\ignored\\abc.txt"))) {
+                new FileReader("D:\\code\\acl_tousu_all\\acl_tousu\\ignored\\user_role_city.txt"))) {
             String line = null;
             while ((line = reader.readLine()) != null) {
                 String[] strs = line.split("\t");
                 UserRoleCity userRoleCity = new UserRoleCity();
                 userRoleCity.setUserId(Integer.parseInt(strs[0]));
-                userRoleCity.setRoleId(Integer.parseInt(strs[1]));
-                userRoleCity.setCityId(Integer.parseInt(strs[2]));
-                userService.addUserRoleCity(userRoleCity);
+                userRoleCity.setCityId(Integer.parseInt(strs[1]));
+                userRoleCity.setRoleId(Integer.parseInt(strs[2]));
+                UserRoleCity selectOne = userRoleCityDao.selectOne(Wrappers.query(userRoleCity));
+                if (selectOne != null) {
+                    System.out.println("=======================================" + selectOne);
+                    // return;
+                } else {
+                    userService.addUserRoleCity(userRoleCity);
+                }
+                // userService.addUserRoleCity(userRoleCity);
+            }
+        }
+    }
+
+    @Test
+    void testAddUser() throws FileNotFoundException, IOException {
+        try (BufferedReader reader = new BufferedReader(
+                new FileReader("D:\\code\\acl_tousu_all\\acl_tousu\\ignored\\user.txt"))) {
+            String line = null;
+            while ((line = reader.readLine()) != null) {
+                System.out.println(line);
+                String[] strs = line.split(",");
+                System.out.println(Arrays.toString(strs));
+                User user = new User();
+                user.setLoginName(strs[0]);
+                user.setUserName(strs[1]);
+                user.setPhone(strs[2]);
+                user.setEmail(strs[3]);
+                user.setCityId(Integer.parseInt(strs[4]));
+                Integer areaId = null;
+                try {
+                    areaId = Integer.parseInt(strs[5]);
+                } catch (Exception e) {
+
+                }
+                user.setAreaId(areaId);
+                user.setProvinceId(Integer.parseInt(strs[6]));
+                user.setOrg(strs[7]);
+                System.out.println(user);
+                userDao.insert(user);
             }
         }
     }