Files
NSG_PORTAL_V2/server/models/category.ts
T
nguyen van thai 795cd47e41 thainv-dev: Fix
2024-07-17 10:35:35 +07:00

47 lines
1.0 KiB
TypeScript

import Base from "./base";
import {H3Event} from "h3";
export type Category = {
id: number;
siteId: number;
parentId?: number;
title: string;
code: string;
description?: string;
thumbnail?: string;
keyword?: string;
taxonomy?: string;
type: number;
layout?: number;
template?: string;
feature?: string;
settings?: string;
order?: number;
isPublished?: boolean;
publishType?: number;
publishedBy?: string;
publishedOn?: string;
status: number;
} & Base;
export type CategoryTree = Category & {
children?: Category[]
}
export const list = async (event : H3Event) => {
try {
const { site, apiUrl } = useRuntimeConfig().public;
const query = getQuery(event)
const siteId = getSite(query.site).toString()
const { items }: CategoryTree[] | any = await $fetch(`${apiUrl}/cms/category/tree/site:${siteId}`, {
method: "GET",
headers: new Headers({
site: siteId,
}),
});
return { items } ;
} catch (error) {
handleError(error);
}
};