Browse Source

处理添加自定义角色出错的bug

hejq 8 years ago
parent
commit
b8a6025fc3

+ 8 - 0
src/main/java/com/uas/platform/b2b/dao/RoleDao.java

@@ -71,4 +71,12 @@ public interface RoleDao extends JpaRepository<Role, Long> {
 	@Query(value = "select * from sec$roles r where r.role_desc = :description and r.isdefault = 1 and r.role_enuu is null and rownum <= 1",nativeQuery = true)
     Role findDefaultRoleByDesc(@Param("description")String desc);
 
+	/**
+	 * 查询角色表的INDEX值
+	 *
+	 * @param enUU
+	 * @return
+	 */
+	@Query(value = "select nvl(max(role_index), 0) from sec$roles where role_enuu = :enUU", nativeQuery = true)
+	Long findIndexByEnUU(@Param("enUU") Long enUU);
 }

+ 1 - 0
src/main/java/com/uas/platform/b2b/service/impl/RoleServiceImpl.java

@@ -71,6 +71,7 @@ public class RoleServiceImpl implements RoleService {
 			role.setEnUU(enUU);
 			role.setIsdefault(Constant.NO);
 			role.setIssys(Constant.NO);
+			role.setIndex(roleDao.findIndexByEnUU(enUU) + 1);
 		}
 		return roleDao.save(role);
 	}