authorityManage.js 2.15 KB
/*
 * @Author: yangwei
 * @Date: 2023-02-24 15:12:45
 * @LastEditors: yangwei
 * @LastEditTime: 2023-03-14 10:45:11
 * @FilePath: \bdcjg-web\src\api\authorityManage.js
 * @Description: 
 * 
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. 
 */

import { getParams } from './util'
import {
  api,
  getAction,
  deleteAction,
  putAction
} from './manageApi'
/** 角色管理开始 */
// 获取角色列表 by categoryId
export const getRolesById = categoryIdList => {
  const conditionGroup = {
    conditions: [
      {
        property: 'category',
        value: categoryIdList,
        operator: 'IN'
      }
    ],
    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)
}