thainv-dev: tạo lại cấu trúc folder và làm UI
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user