48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import { H3Event } from 'h3';
|
|
import Base from './base'
|
|
|
|
export type PollSetting = {
|
|
participantType?: number; // Loại thành phần tham gia
|
|
resultPublication?: number; // Nguyên tắc công bố kết quả
|
|
}
|
|
|
|
export type Poll = {
|
|
id?: number; // Mã định danh
|
|
siteId?: number; // Mã hệ thống
|
|
title?: string; // Tiêu đề
|
|
code?: string; // Nhận diện
|
|
keywords?: string; // Từ khóa
|
|
thumbnail?: string; // Ảnh nhỏ
|
|
description?: string; // Mô tả
|
|
startTime?: string; // Bắt đầu (string)
|
|
endTime?: string; // Kết thúc (string)
|
|
type?: number; // Phân loại
|
|
settings?: PollSetting; // Thiết lập: PollSettings (Json)
|
|
features?: string; // Đặc trưng: Featured (nổi bật)
|
|
taxonomy?: string; // Phân nhóm
|
|
isPublished?: boolean; // Đã xuất bản
|
|
publishedBy?: number; // Xuất bản bởi
|
|
publishedOn?: string; // Xuất bản vào lúc (string)
|
|
expiresOn?: string; // Đã hết hạn vào lúc (string)
|
|
order?: number; // Thứ tự sắp xếp
|
|
status?: number; // Trạng thái
|
|
}
|
|
|
|
export const fetchById = async (event: H3Event) => {
|
|
try {
|
|
const { apiUrl } = useRuntimeConfig().public
|
|
const { pollId}: any = getQuery(event)
|
|
const query = getQuery(event)
|
|
const { item }: Poll | any = await $fetch(`${apiUrl}/cms/poll/${pollId}`, {
|
|
method: 'GET',
|
|
headers: {
|
|
site: getSite(query.site).toString()
|
|
}
|
|
})
|
|
|
|
return item
|
|
|
|
} catch (error) {
|
|
handleError(error);
|
|
}
|
|
} |