authorityManage.js 1.89 KB

import { getParams } from './util'
import {
  api,
  getAction,
  deleteAction,
  putAction
} from './manageApi'
/** 角色管理开始 */
// 获取角色列表 by categoryId
export const getRolesById = categoryId => {
  const conditionGroup = {
    conditions: [
      {
        property: 'category',
        value: categoryId,
        operator: 'EQ'
      }
    ],
    queryRelation: 'AND'
  }
  const params = getParams(conditionGroup)
  return getAction(api.roles, params)
}
/** 角色管理结束 */
/** 授权管理开始 */
// 获取权限列表
export const getAuthorityListAction = (productId, subsystemCode) => {
  const conditionGroup = {
    conditions: [
      {
        property: 'productId',
        value: productId,
        operator: 'EQ'
      },
      {
        property: 'code',
        value: subsystemCode + '_MENU',
        operator: 'EQ'
      }
    ],
    queryRelation: 'AND'
  }
  const params = getParams(conditionGroup)
  return getAction(api.resourceCategory, params)
}

/**
 * 获取角色的权限 id  operationCodes resourceCategoryCode
 * id 授权id
 * operationCodes 操作符集合
 * resourceCategoryCode 菜单默认MENU
 */
export const getRoleAuthorityList = (
  id,
  operationCodes,
  resourceCategoryCode
) => {
  return getAction(`${api.rolePermissions}/${id}`, {
    operationCodes: operationCodes,
    resourceCategoryCode: resourceCategoryCode
  })
}
// 角色授权
export const roleAuthority = (id, permissionDtos) => {
  return putAction(`${api.rolePermissions}/${id}`, permissionDtos)
}



// 获取父级菜单
export const getParentMenuListAction = (id) => {
  let conditionGroup = {}
  if (id && id !== '') {
    conditionGroup = {
      conditions: [
        {
          property: 'productId',
          value: id,
          operator: 'EQ'
        }
      ],
      queryRelation: 'AND'
    }
  }
  const params = getParams(conditionGroup)
  return getAction(api.menus, params)
}