Browse Source

Add role repository

pull/1224/head
Hironsan 3 years ago
parent
commit
9d16e988e9
2 changed files with 26 additions and 0 deletions
  1. 16
      frontend/repositories/role/api.ts
  2. 10
      frontend/repositories/role/interface.ts

16
frontend/repositories/role/api.ts

@ -0,0 +1,16 @@
import ApiService from '@/services/api.service'
import { RoleItem } from '@/models/role'
import { RoleItemListRepository, RoleItemResponse } from './interface'
export class FromApiRoleItemListRepository implements RoleItemListRepository {
constructor(
private readonly request = ApiService
) {}
async list(): Promise<RoleItem[]> {
const url = `/roles`
const response = await this.request.get(url)
const responseItems: RoleItemResponse[] = response.data
return responseItems.map(item => RoleItem.valueOf(item))
}
}

10
frontend/repositories/role/interface.ts

@ -0,0 +1,10 @@
import { RoleItem } from '@/models/role'
export interface RoleItemResponse {
id: number,
name: string
}
export interface RoleItemListRepository {
list(): Promise<RoleItem[]>
}
Loading…
Cancel
Save