Blame view

Yi.Vben5.Vue3/playground/src/api/system/role.ts 1.08 KB
515fceeb   “wangming”   框架初始化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  import type { Recordable } from '@vben/types';
  
  import { requestClient } from '#/api/request';
  
  export namespace SystemRoleApi {
    export interface SystemRole {
      [key: string]: any;
      id: string;
      name: string;
      permissions: string[];
      remark?: string;
      status: 0 | 1;
    }
  }
  
  /**
   * 获取角色列表数据
   */
  async function getRoleList(params: Recordable<any>) {
    return requestClient.get<Array<SystemRoleApi.SystemRole>>(
      '/system/role/list',
      { params },
    );
  }
  
  /**
   * 创建角色
   * @param data 角色数据
   */
  async function createRole(data: Omit<SystemRoleApi.SystemRole, 'id'>) {
    return requestClient.post('/system/role', data);
  }
  
  /**
   * 更新角色
   *
   * @param id 角色 ID
   * @param data 角色数据
   */
  async function updateRole(
    id: string,
    data: Omit<SystemRoleApi.SystemRole, 'id'>,
  ) {
    return requestClient.put(`/system/role/${id}`, data);
  }
  
  /**
   * 删除角色
   * @param id 角色 ID
   */
  async function deleteRole(id: string) {
    return requestClient.delete(`/system/role/${id}`);
  }
  
  export { createRole, deleteRole, getRoleList, updateRole };