bill-fontend/src/api/role.ts
2024-01-17 07:46:08 +08:00

62 lines
1.3 KiB
TypeScript

import axios from 'axios';
import { ListParams, queryList } from '@/api/list';
export interface RoleCreateRecord {
id: number | undefined;
name: string;
dataScope: string;
permissionIds: (number | undefined)[];
remark: string;
}
export interface ListRecord {
username: string;
phone: string;
email: string;
enable: string;
nickname: string;
avater: string;
address: string;
}
export interface RoleRecord extends RoleCreateRecord {
permissions?: [];
}
export interface RoleListRecord extends RoleRecord {
name: string;
}
export function create(data: RoleCreateRecord) {
return axios.post(`/api/role`, data);
}
// 更新用户
export function update(data: RoleRecord) {
return axios.patch(`/api/rest/user/${data.id}`, data);
}
export function getDetail(id: number) {
return axios.get<RoleRecord>(`/api/role/${id}`);
}
// 删除用户
export function remove(id: string) {
return axios.delete(`/api/rest/role/${id}`);
}
// 模糊查询用户列表
export function queryRoles(params?: ListParams<Partial<RoleRecord>>) {
return queryList<RoleRecord>(`/api/rest/user/query`, params);
}
// 添加用户
export function addUser(params: ListRecord) {
return axios.post('/api/rest/user/register', params);
}
// 是否启用
export function enabled(id: string) {
return axios.patch(`/api/rest/user/${id}/toggle`);
}