79 lines
1.8 KiB
TypeScript
79 lines
1.8 KiB
TypeScript
import { PagedAndSortedResultRequestDto, PagedResultDto } from '@/proxy/abp'
|
|
import { MenuDto } from '@/proxy/menus/models'
|
|
import apiService, { Config } from '@/services/api.service'
|
|
|
|
export class MenuService {
|
|
apiName = 'Default'
|
|
|
|
update = (id: string, input: MenuDto) =>
|
|
apiService.fetchData<MenuDto, MenuDto>(
|
|
{
|
|
method: 'PUT',
|
|
url: `/api/app/menu/${id}`,
|
|
data: input,
|
|
},
|
|
{ apiName: this.apiName },
|
|
)
|
|
|
|
create = (input: MenuDto) =>
|
|
apiService.fetchData<MenuDto, MenuDto>(
|
|
{
|
|
method: 'POST',
|
|
url: '/api/app/menu',
|
|
data: input,
|
|
},
|
|
{ apiName: this.apiName },
|
|
)
|
|
|
|
delete = (id: string) =>
|
|
apiService.fetchData<void>(
|
|
{
|
|
method: 'DELETE',
|
|
url: `/api/app/menu/${id}`,
|
|
},
|
|
{ apiName: this.apiName },
|
|
)
|
|
|
|
get = (id: string) =>
|
|
apiService.fetchData<MenuDto>(
|
|
{
|
|
method: 'GET',
|
|
url: `/api/app/menu/${id}`,
|
|
},
|
|
{ apiName: this.apiName },
|
|
)
|
|
|
|
getList = (input: PagedAndSortedResultRequestDto) =>
|
|
apiService.fetchData<PagedResultDto<MenuDto>, PagedAndSortedResultRequestDto>(
|
|
{
|
|
method: 'GET',
|
|
url: '/api/app/menu',
|
|
params: {
|
|
sorting: input.sorting,
|
|
skipCount: input.skipCount,
|
|
maxResultCount: input.maxResultCount,
|
|
},
|
|
},
|
|
{ apiName: this.apiName },
|
|
)
|
|
|
|
updateAll = (inputs: MenuDto[]) =>
|
|
apiService.fetchData<void, MenuDto[]>(
|
|
{
|
|
method: 'PUT',
|
|
url: '/api/app/menu/all',
|
|
data: inputs,
|
|
},
|
|
{ apiName: this.apiName },
|
|
)
|
|
}
|
|
|
|
export const getMenus = async (skipCount = 0, maxResultCount = 1000, sorting = 'order') => {
|
|
const menuService = new MenuService()
|
|
|
|
return await menuService.getList({
|
|
sorting,
|
|
skipCount,
|
|
maxResultCount,
|
|
})
|
|
}
|