lrj
1 天以前 7ad9c3c93f0cc103347ae2e2429e0122fb512e24
web/src/api/role.ts
@@ -111,8 +111,8 @@
  // 获取所有角色
  async getRoles(): Promise<Role[]> {
    try {
      const data = await graphqlRequest(ROLE_QUERIES.GET_ROLES)
      return data?.roles || []
      const result = await graphqlRequest(ROLE_QUERIES.GET_ROLES)
      return result?.data?.roles || []
    } catch (error: any) {
      throw new Error(error.message || '获取角色列表失败')
    }
@@ -121,8 +121,8 @@
  // 获取激活状态的角色
  async getActiveRoles(): Promise<Role[]> {
    try {
      const data = await graphqlRequest(ROLE_QUERIES.GET_ACTIVE_ROLES)
      return data?.activeRoles || []
      const result = await graphqlRequest(ROLE_QUERIES.GET_ACTIVE_ROLES)
      return result?.data?.activeRoles || []
    } catch (error: any) {
      throw new Error(error.message || '获取激活角色列表失败')
    }
@@ -131,8 +131,8 @@
  // 根据ID获取角色
   async getRoleById(id: string): Promise<Role | null> {
     try {
       const data = await graphqlRequest(ROLE_QUERIES.GET_ROLE, { id })
       return data?.role || null
       const result = await graphqlRequest(ROLE_QUERIES.GET_ROLE, { id })
       return result?.data?.role || null
     } catch (error: any) {
       throw new Error(error.message || '获取角色详情失败')
     }
@@ -141,8 +141,8 @@
  // 根据代码获取角色
  async getRoleByCode(code: string): Promise<Role | null> {
    try {
      const data = await graphqlRequest(ROLE_QUERIES.GET_ROLE_BY_CODE, { code })
      return data?.roleByCode || null
      const result = await graphqlRequest(ROLE_QUERIES.GET_ROLE_BY_CODE, { code })
      return result?.data?.roleByCode || null
    } catch (error: any) {
      throw new Error(error.message || '获取角色详情失败')
    }
@@ -151,8 +151,8 @@
  // 根据状态获取角色
  async getRolesByState(state: number): Promise<Role[]> {
    try {
      const data = await graphqlRequest(ROLE_QUERIES.GET_ROLES_BY_STATE, { state })
      return data?.rolesByState || []
      const result = await graphqlRequest(ROLE_QUERIES.GET_ROLES_BY_STATE, { state })
      return result?.data?.rolesByState || []
    } catch (error: any) {
      throw new Error(error.message || '获取角色列表失败')
    }
@@ -161,8 +161,8 @@
  // 根据名称搜索角色
  async searchRolesByName(name: string): Promise<Role[]> {
    try {
      const data = await graphqlRequest(ROLE_QUERIES.SEARCH_ROLES_BY_NAME, { name })
      return data?.searchRolesByName || []
      const result = await graphqlRequest(ROLE_QUERIES.SEARCH_ROLES_BY_NAME, { name })
      return result?.data?.searchRolesByName || []
    } catch (error: any) {
      throw new Error(error.message || '搜索角色失败')
    }