phongdt:page video
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { utils } from "~/utils/utilities";
|
||||
import Base from "./base";
|
||||
import { H3Event } from "h3";
|
||||
|
||||
export const listPaging = async(event: H3Event) => {
|
||||
try {
|
||||
const { apiUrl } = useRuntimeConfig().public
|
||||
const { siteId, page, fetch } = getQuery(event)
|
||||
|
||||
const { items, total }: any = await $fetch(`${apiUrl}/cms/event/condition/paging:${page}-${fetch}`, {
|
||||
method: 'POST',
|
||||
body: {siteIds: [siteId]}
|
||||
})
|
||||
return {items, total}
|
||||
} catch (error) {
|
||||
handleError(error);
|
||||
}
|
||||
}
|
||||
|
||||
export const fetchByCode = async(event: H3Event) => {
|
||||
try {
|
||||
const { apiUrl } = useRuntimeConfig().public
|
||||
const { eventCode }: any = getQuery(event)
|
||||
const { item }: any = await $fetch(`${apiUrl}/cms/event/code:${eventCode}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Site: 1
|
||||
}
|
||||
})
|
||||
return item
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
}
|
||||
}
|
||||
|
||||
export const fetchById = async(event: H3Event) => {
|
||||
try {
|
||||
const { apiUrl } = useRuntimeConfig().public
|
||||
const { eventId }: any = getQuery(event)
|
||||
const { item }: any = await $fetch(`${apiUrl}/cms/event/${eventId}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Site: 1
|
||||
}
|
||||
})
|
||||
return item
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { utils } from "~/utils/utilities";
|
||||
import { Author } from "./author";
|
||||
import Base from "./base";
|
||||
import { H3Event } from "h3";
|
||||
|
||||
export const get = async(event: H3Event) => {
|
||||
try {
|
||||
const { apiUrl } = useRuntimeConfig().public
|
||||
const { code } = getQuery(event)
|
||||
|
||||
const { items }: any = await $fetch(`${apiUrl}/cms/tag/code:${code}`, {
|
||||
headers: {
|
||||
site: 1
|
||||
}
|
||||
})
|
||||
return items
|
||||
} catch(error) {
|
||||
handleError(error);
|
||||
}
|
||||
}
|
||||
|
||||
export const fetchById = async(event: H3Event) => {
|
||||
try {
|
||||
const { apiUrl } = useRuntimeConfig().public
|
||||
const { tagId }: any = getQuery(event)
|
||||
const { item }: any = await $fetch(`${apiUrl}/cms/tag/${tagId}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Site: 1
|
||||
}
|
||||
})
|
||||
return item
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import { utils } from "~/utils/utilities";
|
||||
import { Author } from "./author";
|
||||
import Base from "./base";
|
||||
import { ref } from "vue"
|
||||
import { H3Event } from "h3";
|
||||
|
||||
export const listPaging = async (event: H3Event) => {
|
||||
try {
|
||||
const { apiUrl } = useRuntimeConfig().public
|
||||
const { categoryId, page, limit, sort } = getQuery(event)
|
||||
const query = ref({})
|
||||
if(categoryId) {
|
||||
query.value = { categoryId }
|
||||
}
|
||||
|
||||
const { items, total }: any = await $fetch(`${apiUrl}/cms/topic/condition/paging:${page}-${limit}/sorting:${sort}`,{
|
||||
method: 'POST',
|
||||
headers: {site: 1},
|
||||
body:{ ...query.value }
|
||||
})
|
||||
|
||||
return { items, total };
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
}
|
||||
}
|
||||
|
||||
export const fetchByCode = async(event: H3Event) => {
|
||||
try {
|
||||
const { apiUrl } = useRuntimeConfig().public
|
||||
const { topicCode }: any = getQuery(event)
|
||||
const { item }: any = await $fetch(`${apiUrl}/cms/topic/code:${topicCode}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
site: 1
|
||||
}
|
||||
})
|
||||
|
||||
return item
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
}
|
||||
}
|
||||
|
||||
export const fetchById = async(event: H3Event) => {
|
||||
try {
|
||||
const { apiUrl } = useRuntimeConfig().public
|
||||
const { topicId }: any = getQuery(event)
|
||||
const { item }: any = await $fetch(`${apiUrl}/cms/topic/${topicId}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
site: 1
|
||||
}
|
||||
})
|
||||
|
||||
return item
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user