46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
|
|
import { H3Event } from 'h3';
|
||
|
|
export type SurveySetting = {
|
||
|
|
participantType?: number; // Loại thành phần tham gia
|
||
|
|
resultPublication?: number; // Nguyên tắc công bố kết quả
|
||
|
|
}
|
||
|
|
|
||
|
|
export type Survey = {
|
||
|
|
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, assuming date is handled as ISO string
|
||
|
|
endTime?: string; // Kết thúc, assuming date is handled as ISO string
|
||
|
|
type?: number; // Phân loại
|
||
|
|
settings?: SurveySetting; // Thiết lập, as a JSON string
|
||
|
|
features?: string; // Đặc trưng
|
||
|
|
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, assuming date is handled as ISO string
|
||
|
|
expiresOn?: string; // Đã hết hạn vào lúc, assuming date is handled as ISO 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 { surveyId }: any = getQuery(event)
|
||
|
|
const { item }: Survey | any = await $fetch(`${apiUrl}/cms/survey/${surveyId}`, {
|
||
|
|
method: 'GET',
|
||
|
|
headers: {
|
||
|
|
site: 1
|
||
|
|
}
|
||
|
|
})
|
||
|
|
|
||
|
|
return item
|
||
|
|
|
||
|
|
} catch (error) {
|
||
|
|
handleError(error);
|
||
|
|
}
|
||
|
|
}
|