48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import { PagedResultDto } from '@/proxy'
|
|
import apiService from './api.service'
|
|
import { QuestionDto } from '@/types/coordinator'
|
|
|
|
class QuestionService {
|
|
async getQuestions(): Promise<PagedResultDto<QuestionDto>> {
|
|
const response = await apiService.fetchData<PagedResultDto<QuestionDto>>({
|
|
url: '/api/app/question',
|
|
method: 'GET',
|
|
})
|
|
return response.data
|
|
}
|
|
|
|
async getQuestion(id: string): Promise<QuestionDto> {
|
|
const response = await apiService.fetchData<QuestionDto>({
|
|
url: `/api/app/question/${id}`,
|
|
method: 'GET',
|
|
})
|
|
return response.data
|
|
}
|
|
|
|
async updateQuestion(id: string, input: QuestionDto) {
|
|
const response = await apiService.fetchData<QuestionDto>({
|
|
url: `/api/app/question/${id}`,
|
|
method: 'PUT',
|
|
data: input as any,
|
|
})
|
|
return response.data
|
|
}
|
|
|
|
async createQuestion(input: QuestionDto) {
|
|
const response = await apiService.fetchData<QuestionDto>({
|
|
method: 'POST',
|
|
url: '/api/app/question',
|
|
data: input as any,
|
|
})
|
|
return response.data
|
|
}
|
|
|
|
async deleteQuestion(id: string) {
|
|
await apiService.fetchData<void>({
|
|
method: 'DELETE',
|
|
url: `/api/app/question/${id}`,
|
|
})
|
|
}
|
|
}
|
|
|
|
export const questionService = new QuestionService()
|