thainv-dev: tạo lại cấu trúc folder và làm UI
This commit is contained in:
@@ -24,20 +24,22 @@ export type Category = {
|
||||
status: number;
|
||||
} & Base;
|
||||
|
||||
export type CategoryTree = Category & {
|
||||
children?: Category[]
|
||||
}
|
||||
|
||||
export const list = async () => {
|
||||
console.log('vào category service')
|
||||
try {
|
||||
const { site, apiUrl } = useRuntimeConfig().public;
|
||||
|
||||
const {items}:any = await $fetch(`${apiUrl}/cms/category/site`, {
|
||||
const { items }: CategoryTree[] | any = await $fetch(`${apiUrl}/cms/category/tree/site:1`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
site: site,
|
||||
site: 1,
|
||||
},
|
||||
});
|
||||
|
||||
return items;
|
||||
return { items } ;
|
||||
} catch (error) {
|
||||
handleError(error);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
import { H3Event } from 'h3';
|
||||
import Base from './base'
|
||||
|
||||
export type PollOption = {
|
||||
id?: number; // Mã định danh
|
||||
siteId?: number; // Mã hệ thống
|
||||
pollId?: number; // Mã bình chọn
|
||||
title?: string; // Tiêu đề
|
||||
thumbnail?: string; // Ảnh đại diện
|
||||
description?: string; // Mô tả
|
||||
type?: number; // Phân loại
|
||||
order?: number; // Sắp xếp
|
||||
status?: number; // Trạng thái
|
||||
responsesCount?: number //số lượng response của option
|
||||
}
|
||||
|
||||
export const fetchByPollId = async (event: H3Event) => {
|
||||
try {
|
||||
|
||||
const { apiUrl } = useRuntimeConfig().public
|
||||
const { pollId}: any = getQuery(event)
|
||||
const { items }: any = await $fetch(`${apiUrl}/cms/poll-option/poll:${pollId}`, {
|
||||
const { pollId }: any = getQuery(event)
|
||||
const { items }: PollOption[] | any = await $fetch(`${apiUrl}/cms/poll-option/poll:${pollId}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
site: 1
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
import { H3Event } from 'h3';
|
||||
import Base from './base'
|
||||
|
||||
export type PollResponse = {
|
||||
id?: number; // Mã định danh
|
||||
siteId?: number; // Mã hệ thống
|
||||
pollId?: number; // Mã bình chọn
|
||||
optionId?: number; // Mã tùy chọn
|
||||
responderId?: number; // Mã người phản hồi
|
||||
responderInfo?: string; // Thông tin người phản hồi
|
||||
status?: number; // Trạng thái
|
||||
}
|
||||
|
||||
export const create = async (event: H3Event) => {
|
||||
export const create = async (event: H3Event) => {
|
||||
try {
|
||||
const { apiUrl } = useRuntimeConfig().public
|
||||
const payload = await readBody<any>(event)
|
||||
@@ -11,14 +20,31 @@ import Base from './base'
|
||||
headers: {
|
||||
site: 1
|
||||
},
|
||||
body: {
|
||||
payload
|
||||
}
|
||||
body: payload
|
||||
})
|
||||
|
||||
console.log(payload, 'payload')
|
||||
return item
|
||||
|
||||
} catch (error) {
|
||||
handleError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const fetchByPollId = async (event: H3Event) => {
|
||||
try {
|
||||
|
||||
const { apiUrl } = useRuntimeConfig().public
|
||||
const { pollId }: any = getQuery(event)
|
||||
const { items }: PollResponse[] | any = await $fetch(`${apiUrl}/cms/poll-response/poll:${pollId}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
site: 1
|
||||
}
|
||||
})
|
||||
|
||||
return items
|
||||
|
||||
} catch (error) {
|
||||
handleError(error);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,11 @@
|
||||
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
|
||||
@@ -12,7 +17,7 @@ export type Poll = {
|
||||
startTime?: string; // Bắt đầu (string)
|
||||
endTime?: string; // Kết thúc (string)
|
||||
type?: number; // Phân loại
|
||||
settings?: object; // Thiết lập: PollSettings (Json)
|
||||
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
|
||||
@@ -25,10 +30,9 @@ export type Poll = {
|
||||
|
||||
export const fetchById = async (event: H3Event) => {
|
||||
try {
|
||||
|
||||
const { apiUrl } = useRuntimeConfig().public
|
||||
const { pollId}: any = getQuery(event)
|
||||
const { item }: any = await $fetch(`${apiUrl}/cms/poll/${pollId}`, {
|
||||
const { item }: Poll | any = await $fetch(`${apiUrl}/cms/poll/${pollId}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
site: 1
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import { H3Event } from 'h3';
|
||||
export type QuizSetting = {
|
||||
participantType?: number; // Loại thành phần tham gia
|
||||
resultPublication?: number; // Nguyên tắc công bố kết quả
|
||||
}
|
||||
|
||||
export type Quiz = {
|
||||
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
|
||||
endTime?: string; // Kết thúc
|
||||
type?: number; // Phân loại
|
||||
settings?: object; // Thiết lập
|
||||
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
|
||||
expiresOn?: string; // Đã hết hạn vào lúc
|
||||
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 { quizId }: any = getQuery(event)
|
||||
const { item }: Quiz | any = await $fetch(`${apiUrl}/cms/quiz/${quizId}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
site: 1
|
||||
}
|
||||
})
|
||||
|
||||
return item
|
||||
|
||||
} catch (error) {
|
||||
handleError(error);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user