/*
 * @Author: zc
 * @description 系统管理-角色管理
 */
import request from '@/utils/request';
/**
 * @description 获取角色列表
 * @param {object} params
 * @return {*}
 */
export const getRoleListPaged = (params: object) => {
	return request({
		url: '/api/v1/Role/paged',
		method: 'get',
		params: params,
	});
};
/**
 * @description 新增角色
 * @param {object} params
 * @return {*}
 */
export const addRole = (params: object) => {
	return request({
		url: '/api/v1/Role',
		method: 'post',
		data: params,
	});
};
/**
 * @description 更新角色
 * @param {object} params
 * @return {*}
 */
export const updateRole = (params: object) => {
	return request({
		url: '/api/v1/Role',
		method: 'put',
		data: params,
	});
};
/**
 * @description 删除角色
 * @param {string} roleId 角色ID
 * @return {*}
 */
export const delRole = (roleId: string) => {
	return request({
		url: `/api/v1/Role/${roleId}`,
		method: 'delete',
	});
};
/**
 * @description 获取角色权限
 * @return {*}
 * @param {object} params
 */
export const getRolePower = (params?: object) => {
	return request({
		url: `/api/v1/Role/getauthority`,
		method: 'get',
		params,
	});
};
/**
 * @description 分配角色
 * @param {object} data
 * @return {*}
 */
export const setRolePower = (data: object) => {
	return request({
		url: `/api/v1/Role/allocationauthority`,
		method: 'post',
		data,
	});
};
/**
 * @description 根据id批量查询用户
 * @param {object} data  ids
 * @return {*}
 */
export const getUserListByIds = (data: any) => {
	return request({
		url: `/api/v1/User/range`,
		method: 'post',
		data
	});
};
/**
 * @description 获取数据表
 * @return {*}
 */
export const dataAuthList = () => {
	return request({
		url: `/api/v1/Role/tables`,
		method: 'get',
	});
};
/**
 * @description 新增数据权限
 * @param {object} data
 * @return {*}
 */
export const addDataAuth = (data: object) => {
	return request({
		url: `/api/v1/Role/accesslevel`,
		method: 'post',
		data,
	});
};
/**
 * @description 修改数据权限
 * @param {object} data
 * @return {*}
 */
export const editDataAuth = (data: object) => {
	return request({
		url: `/api/v1/Role/accesslevel`,
		method: 'put',
		data,
	});
};
/**
 * @description 删除数据权限
 * @param {string} id
 * @return {*}
 */
export const deleteDataAuth = (id: string) => {
	return request({
		url: `/api/v1/Role/accesslevel/${id}`,
		method: 'delete',
	});
};
/**
 * @description 获取角色所有数据权限设置
 * @param {string | any[]} roleId
 * @return {*}
 */
export const getDataAuthorityByRole = (roleId: string | any[]) => {
	return request({
		url: `/api/v1/Role/${roleId}/accesslevels`,
		method: 'get',
	});
};
/**
 * @description 获取角色所有数据权限基础数据
 * @return {*}
 */
export const baseData = () => {
	return request({
		url: `/api/v1/Role/base-data`,
		method: 'get',
	});
};

/**
 * @description 基础数据
 * @param {object} params
 * @return {*}
 */
export const getRoleBaseData = (params?: object) => {
	return request({
		url: `/api/v1/Role/role/basedata`,
		method: 'get',
		params,
	});
};