Browse Source

1.修改第一次添加用户报错的bug

hellohaidie 5 months ago
parent
commit
9ba5b0cfa0

+ 7 - 0
src/main/java/com/lqkj/link/module/authority/repository/UserInfoRepository.java

@@ -38,6 +38,13 @@ public interface UserInfoRepository extends JpaRepository<UserInfo, Integer> {
38
     @Transactional
38
     @Transactional
39
     @Modifying
39
     @Modifying
40
     @Query(nativeQuery = true,
40
     @Query(nativeQuery = true,
41
+        value = "select setval('user_info_user_id_seq', 3)"
42
+    )
43
+    void initUserIdSeq();
44
+
45
+    @Transactional
46
+    @Modifying
47
+    @Query(nativeQuery = true,
41
         value = "insert into user_role values (1, 1)"
48
         value = "insert into user_role values (1, 1)"
42
     )
49
     )
43
     void initSuperAdminRole();
50
     void initSuperAdminRole();

+ 1 - 0
src/main/java/com/lqkj/link/module/authority/service/UserInfoService.java

@@ -32,6 +32,7 @@ public class UserInfoService {
32
     public void initSuperUser() {
32
     public void initSuperUser() {
33
         if (!userInfoRepository.existsById(1)) {
33
         if (!userInfoRepository.existsById(1)) {
34
             userInfoRepository.initSuperAdmin();
34
             userInfoRepository.initSuperAdmin();
35
+            userInfoRepository.initUserIdSeq();
35
             userInfoRepository.initSuperAdminRole();
36
             userInfoRepository.initSuperAdminRole();
36
         }
37
         }
37
     }
38
     }