/**
 * 数据权限-API
 */
import http from "@/http/http";
import { Idparams, ResultInterface } from "../base/BaseDataModel";
import { DataPermissionDto, DataPermissionParam, RoleDataPermissionDto, RoleDataPermissionParam, UserDataPermissionDto, UserDataPermissionParam } from "./dataPermissionModel";

enum Api {
    dataPermissionList = '/api/dataPermission/list',
    add = '/api/dataPermission/add',
    edit = '/api/dataPermission/edit',
    delete = '/api/dataPermission',
    userDataPermission = '/api/userDataPermission/list',
    userDataPermissionSave ='/api/userDataPermission/save',
    userDataPermissionDelete = '/api/userDataPermission',
    roleDataPermission = '/api/roleDataPermission/list',
    roleDataPermissionSave = '/api/roleDataPermission/save',
    roleDataPermissionDelete = '/api/roleDataPermission',
}

/**
 * 数据权限查询列表
 * @param parms 
 * @returns 
 */
export const api_getDataPermissionList = async (parms: DataPermissionParam) => {
    return await http.get<ResultInterface<DataPermissionDto>>(Api.dataPermissionList, parms)
}


/**
 * 新增数据权限
 * @param parms 
 * @returns 
 */
export const api_addDataPermission = async (parms: Pick<DataPermissionDto, "id">) => {
    return await http.post(Api.add, parms)
}


/**
 * 编辑数据权限
 * @param parms 
 * @returns 
 */
export const api_editDataPermission = async (parms: DataPermissionDto) => {
    return await http.post(Api.edit, parms)
}

/**
 * 删除数据权限
 * @param parms 
 * @returns 
 */
export const api_deleteDataPermission = async (parms: Idparams) => {
    return await http.delete(Api.delete, parms)
}

/**
 * 用户数据权限列表
 * @param parms 
 * @returns 
 */
export const api_getUserDataPermission = async (parms: UserDataPermissionParam) => {
    return await http.get<UserDataPermissionDto[]>(Api.userDataPermission, parms)
}

/**
 * 用户数据权限编辑
 * @param parms 
 * @returns 
 */
export const api_userDataPermissionSave = async (parms: UserDataPermissionDto[]) => {
    return await http.post(Api.userDataPermissionSave, parms)
}

/**
 * 用户数据权限删除
 * @param parms 
 * @returns 
 */
export const api_userDataPermissionDelete = async (parms: Idparams) => {
    return await http.delete(Api.userDataPermissionDelete, parms)
}

/**
 * 角色数据权限列表
 * @param parms 
 * @returns 
 */
export const api_getRoleDataPermission = async (parms: RoleDataPermissionParam) => {
    return await http.get<RoleDataPermissionDto[]>(Api.roleDataPermission, parms)
}

/**
 * 角色数据权限编辑
 * @param parms 
 * @returns 
 */
export const api_roleDataPermissionSave = async (parms: RoleDataPermissionDto[]) => {
    return await http.post(Api.roleDataPermissionSave, parms)
}

/**
 * 角色数据权限删除
 * @param parms 
 * @returns 
 */
export const api_roleDataPermissionDelete = async (parms: Idparams) => {
    return await http.delete(Api.roleDataPermissionDelete, parms)
}