Browse Source

角色保存修改

liaoyitao 2 months ago
parent
commit
4f478aef71

+ 8 - 4
src/main/java/com/lqkj/link/module/authority/repository/RoleInfoRepository.java

@@ -96,10 +96,8 @@ public interface RoleInfoRepository extends JpaRepository<RoleInfo, Integer> {
96 96
 
97 97
     @Modifying
98 98
     @Query(nativeQuery = true,
99
-        value = "with t1 as (delete from role_authority where role_id = :roleId and authority_id not in :authorityIds)" +
100
-                "insert into role_authority(role_id, authority_id) " +
101
-                "select :roleId, authority_id from authority_info where authority_id in :authorityIds " +
102
-                "on conflict (role_id, authority_id) do nothing "
99
+        value = "insert into role_authority(role_id, authority_id) " +
100
+                "select :roleId, authority_id from authority_info where authority_id in :authorityIds "
103 101
     )
104 102
     void updateRoleAuthority(@Param("roleId") Integer roleId,
105 103
                              @Param("authorityIds") List<Integer> authorityIds);
@@ -131,4 +129,10 @@ public interface RoleInfoRepository extends JpaRepository<RoleInfo, Integer> {
131 129
         value = "select string_agg(role_name, ',') from role_info where role_id in :hasUserRoleIds"
132 130
     )
133 131
     String findHasUserRoleNames(@Param("hasUserRoleIds") List<Integer> hasUserRoleIds);
132
+
133
+    @Modifying
134
+    @Query(nativeQuery = true,
135
+        value = "delete from role_authority where role_id = :roleId"
136
+    )
137
+    void deleteByRoleId(@Param("roleId") Integer roleId);
134 138
 }

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

@@ -69,6 +69,7 @@ public class RoleInfoService {
69 69
             roleInfoRepository.save(oldRole);
70 70
         }
71 71
 
72
+        roleInfoRepository.deleteByRoleId(roleInfo.getRoleId());
72 73
         roleInfoRepository.updateRoleAuthority(roleInfo.getRoleId(), authorityIds);
73 74
         return null;
74 75
     }

+ 1 - 1
src/main/java/com/lqkj/link/module/zone/repository/MaterialInfoRepository.java

@@ -44,7 +44,7 @@ public interface MaterialInfoRepository extends JpaRepository<MaterialInfo, Inte
44 44
                     "(:materialName = '' or material_name like concat('%', :materialName, '%')) " +
45 45
                     "and (:materialType is null or material_type = :materialType) " +
46 46
                     "and (:userId is null or user_id = :userId) " +
47
-                    "order by update_time"
47
+                    "order by update_time desc"
48 48
     )
49 49
     Page<MaterialInfo> pageQuery(@Param("materialName") String materialName,
50 50
                                  @Param("materialType") Integer materialType,