erp-platform/ui/src/services/menu.service.ts

80 lines
1.8 KiB
TypeScript
Raw Normal View History

2025-06-26 13:58:53 +00:00
import { PagedAndSortedResultRequestDto, PagedResultDto } from '@/proxy/abp'
import { MenuDto } from '@/proxy/menus/models'
2025-05-06 06:45:49 +00:00
import apiService, { Config } from '@/services/api.service'
export class MenuService {
apiName = 'Default'
2025-08-11 06:34:44 +00:00
update = (id: string, input: MenuDto) =>
apiService.fetchData<MenuDto, MenuDto>(
{
method: 'PUT',
url: `/api/app/menu/${id}`,
data: input,
},
2025-08-11 06:34:44 +00:00
{ apiName: this.apiName },
)
2025-05-06 06:45:49 +00:00
2025-08-11 06:34:44 +00:00
create = (input: MenuDto) =>
apiService.fetchData<MenuDto, MenuDto>(
{
method: 'POST',
url: '/api/app/menu',
data: input,
},
2025-08-11 06:34:44 +00:00
{ apiName: this.apiName },
)
2025-05-06 06:45:49 +00:00
2025-08-11 06:34:44 +00:00
delete = (id: string) =>
apiService.fetchData<void>(
{
method: 'DELETE',
url: `/api/app/menu/${id}`,
},
2025-08-11 06:34:44 +00:00
{ apiName: this.apiName },
)
2025-08-11 06:34:44 +00:00
get = (id: string) =>
apiService.fetchData<MenuDto>(
{
method: 'GET',
url: `/api/app/menu/${id}`,
},
2025-08-11 06:34:44 +00:00
{ apiName: this.apiName },
)
2025-05-06 06:45:49 +00:00
2025-08-11 06:34:44 +00:00
getList = (input: PagedAndSortedResultRequestDto) =>
2025-05-06 06:45:49 +00:00
apiService.fetchData<PagedResultDto<MenuDto>, PagedAndSortedResultRequestDto>(
{
method: 'GET',
url: '/api/app/menu',
params: {
sorting: input.sorting,
skipCount: input.skipCount,
maxResultCount: input.maxResultCount,
},
},
2025-08-11 06:34:44 +00:00
{ apiName: this.apiName },
2025-05-06 06:45:49 +00:00
)
2025-08-11 06:34:44 +00:00
updateAll = (inputs: MenuDto[]) =>
apiService.fetchData<void, MenuDto[]>(
{
method: 'PUT',
url: '/api/app/menu/all',
data: inputs,
},
2025-08-11 06:34:44 +00:00
{ apiName: this.apiName },
)
2025-05-06 06:45:49 +00:00
}
export const getMenus = async (skipCount = 0, maxResultCount = 1000, sorting = 'order') => {
const menuService = new MenuService()
return await menuService.getList({
sorting,
skipCount,
maxResultCount,
})
}