2026-02-24 20:44:16 +00:00
|
|
|
|
import { PagedAndSortedResultRequestDto, PagedResultDto } from '@/proxy/abp'
|
|
|
|
|
|
import { MenuDto } from '@/proxy/menus/models'
|
2026-07-07 19:14:26 +00:00
|
|
|
|
import apiService from '@/services/api.service'
|
|
|
|
|
|
|
2026-08-31 14:17:50 +00:00
|
|
|
|
export type ModuleLookupDto = {
|
2026-07-07 19:14:26 +00:00
|
|
|
|
key: string
|
|
|
|
|
|
name: string
|
|
|
|
|
|
group?: string
|
|
|
|
|
|
}
|
2026-02-24 20:44:16 +00:00
|
|
|
|
|
|
|
|
|
|
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 },
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-08-18 08:00:53 +00:00
|
|
|
|
/** Menüyü tüm alanlarıyla günceller; görünen adın EN/TR dil metinlerini de yazar. */
|
|
|
|
|
|
updateWithLanguageKeyText = (id: string, input: MenuDto) =>
|
|
|
|
|
|
apiService.fetchData<MenuDto, MenuDto>(
|
|
|
|
|
|
{
|
|
|
|
|
|
method: 'PUT',
|
|
|
|
|
|
url: `/api/app/menu/${id}/with-language-key-text`,
|
|
|
|
|
|
data: input,
|
|
|
|
|
|
},
|
|
|
|
|
|
{ apiName: this.apiName },
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-02-28 21:37:34 +00:00
|
|
|
|
createWithLanguageKeyText = (input: MenuDto) =>
|
|
|
|
|
|
apiService.fetchData<MenuDto, MenuDto>(
|
|
|
|
|
|
{
|
|
|
|
|
|
method: 'POST',
|
|
|
|
|
|
url: '/api/app/menu/with-language-key-text',
|
|
|
|
|
|
data: input,
|
|
|
|
|
|
},
|
|
|
|
|
|
{ apiName: this.apiName },
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-02-24 20:44:16 +00:00
|
|
|
|
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,
|
2026-02-28 21:37:34 +00:00
|
|
|
|
maxResultCount: input.maxResultCount,
|
2026-02-24 20:44:16 +00:00
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
{ apiName: this.apiName },
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
updateAll = (inputs: MenuDto[]) =>
|
|
|
|
|
|
apiService.fetchData<void, MenuDto[]>(
|
|
|
|
|
|
{
|
|
|
|
|
|
method: 'PUT',
|
|
|
|
|
|
url: '/api/app/menu/all',
|
|
|
|
|
|
data: inputs,
|
|
|
|
|
|
},
|
|
|
|
|
|
{ apiName: this.apiName },
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
getListMainMenu = () =>
|
|
|
|
|
|
apiService.fetchData<MenuDto[]>(
|
|
|
|
|
|
{
|
|
|
|
|
|
method: 'GET',
|
|
|
|
|
|
url: `/api/app/menu/main-menu`,
|
|
|
|
|
|
},
|
|
|
|
|
|
{ apiName: this.apiName },
|
|
|
|
|
|
)
|
2026-07-07 19:14:26 +00:00
|
|
|
|
|
2026-08-31 14:17:50 +00:00
|
|
|
|
getModules = () =>
|
|
|
|
|
|
apiService.fetchData<ModuleLookupDto[]>(
|
2026-07-07 19:14:26 +00:00
|
|
|
|
{
|
|
|
|
|
|
method: 'GET',
|
2026-08-31 14:17:50 +00:00
|
|
|
|
url: '/api/app/menu/modules',
|
2026-07-07 19:14:26 +00:00
|
|
|
|
},
|
|
|
|
|
|
{ apiName: this.apiName },
|
|
|
|
|
|
)
|
2026-02-24 20:44:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const getMenus = async (skipCount = 0, maxResultCount = 1000, sorting = 'order') => {
|
|
|
|
|
|
const menuService = new MenuService()
|
|
|
|
|
|
|
2026-02-28 21:37:34 +00:00
|
|
|
|
return await menuService.getList({
|
|
|
|
|
|
sorting,
|
|
|
|
|
|
skipCount,
|
|
|
|
|
|
maxResultCount,
|
|
|
|
|
|
})
|
2026-02-24 20:44:16 +00:00
|
|
|
|
}
|
2026-07-07 19:14:26 +00:00
|
|
|
|
|
2026-08-31 14:17:50 +00:00
|
|
|
|
export const getModules = async () => {
|
2026-07-07 19:14:26 +00:00
|
|
|
|
const menuService = new MenuService()
|
|
|
|
|
|
|
2026-08-31 14:17:50 +00:00
|
|
|
|
return await menuService.getModules()
|
2026-07-07 19:14:26 +00:00
|
|
|
|
}
|