Просмотр исходного кода

查询用户角色的方法更新

hejq 7 лет назад
Родитель
Сommit
95bcfcc0f0
1 измененных файлов с 20 добавлено и 32 удалено
  1. 20 32
      src/main/java/com/uas/platform/b2b/dao/RoleDao.java

+ 20 - 32
src/main/java/com/uas/platform/b2b/dao/RoleDao.java

@@ -11,57 +11,45 @@ import java.util.List;
 @Repository
 public interface RoleDao extends JpaRepository<Role, Long> {
 
-	@Query("from Role r where r.enUU = :enUU order by id")
-	public List<Role> findByEnUU(@Param("enUU") long enUU);
-
 	/**
-	 * 按角色描述查找角色
-	 * 
-	 * @param enUU
-	 * @param desc
+	 * 查询企业角色
+	 *
+	 * @param enUU 企业UU
 	 * @return
 	 */
-	public List<Role> findByEnUUAndDesc(Long enUU, String desc);
+	@Query("from Role r where r.enUU = :enUU order by id")
+	List<Role> findByEnUU(@Param("enUU") long enUU);
 
 	/**
-	 * 角色个数
+	 * 按角色描述查找角色
 	 * 
-	 * @param enUU
+	 * @param enUU 企业UU
+	 * @param desc 角色描述
 	 * @return
 	 */
-	@Query("select count(r) from Role r where r.enUU = :enUU")
-	public int getCountByEnUU(@Param("enUU") long enUU);
+	List<Role> findByEnUUAndDesc(Long enUU, String desc);
 
 	/**
-	 * 按角色描述查找角色个数
-	 * 
-	 * @param enUU
-	 * @param desc
+	 * 查询企业默认角色
+	 *
+	 * @param enUU 企业UU
+	 * @param yes 是否默认
 	 * @return
 	 */
-	@Query("select count(r) from Role r where r.enUU = :enUU and r.desc = :desc")
-	public int getCountByEnUUAndDesc(@Param("enUU") long enUU, @Param("desc") String desc);
-
-    List<Role> findByEnUUAndIssys(Long vendUU, short yes);
+    List<Role> findByEnUUAndIssys(Long enUU, short yes);
 
 	/**
 	 * 查询当前用户在当前企业的角色是否是管理员或者销售经理<br>
 	 *
 	 * 分配客户需要
 	 *
-	 * @param enuu
-	 * @param useruu
+	 * @param enUU 企业UU
+	 * @param userUU 用户UU
+	 * @param roles 角色
 	 * @return
 	 */
-    @Query(value = "select count(1) from sec$roles r left join sec$userrole u on r.role_id = u.role_id where r.role_enuu = :enuu and u.user_uu = :useruu and (r.role_name = 'ROLE_ADMIN' or r.role_name = 'ROLE_SALEMANAGER')",nativeQuery = true)
-    Double findByEnuuAndUseruu(@Param("enuu") Long enuu, @Param("useruu") Long useruu);
-
-	@Query(value = "select count(1) from sec$roles r left join sec$userrole u on r.role_id = u.role_id where r.role_enuu = :enuu and u.user_uu = :useruu and r.role_name = 'ROLE_ADMIN'",nativeQuery = true)
-	Double findByEnuuAndUserUU(@Param("enuu") Long enuu, @Param("useruu") Long useruu);
-
-	@Query(value = "select count(1) from sec$roles r left join sec$userrole u on r.role_id = u.role_id where r.role_enuu = :enuu and u.user_uu = :useruu and r.role_name = 'ROLE_USER'",nativeQuery = true)
-	Double findByEnuuAndUserUu(@Param("enuu") Long enuu, @Param("useruu") Long useruu);
-
+	@Query(value = "select count(1) from sec$roles r left join sec$userrole u on r.role_id = u.role_id where r.role_enuu = :enUU and u.user_uu = :userUU and r.role_name IN (:roles)", nativeQuery = true)
+	Double findByEnUUAndUserUU(@Param("enUU") Long enUU, @Param("userUU") Long userUU, @Param("roles") List<String> roles);
 
 	/**
 	 * 根据角色名称查找默认角色的默认值
@@ -69,7 +57,7 @@ public interface RoleDao extends JpaRepository<Role, Long> {
 	 * @return
 	 */
 	@Query(value = "select * from sec$roles r where r.role_desc = :description and r.isdefault = 1 and r.role_enuu is null limit 1", nativeQuery = true)
-    Role findDefaultRoleByDesc(@Param("description")String desc);
+    Role findDefaultRoleByDesc(@Param("description") String desc);
 
 	/**
 	 * 查询角色表的INDEX值