實作題目管理與資料庫整合
This commit is contained in:
19
app/api/questions/creative/route.ts
Normal file
19
app/api/questions/creative/route.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { NextResponse } from "next/server"
|
||||
import { getAllCreativeQuestions } from "@/lib/database/models/creative_question"
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const questions = await getAllCreativeQuestions()
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
data: questions
|
||||
})
|
||||
} catch (error) {
|
||||
console.error("獲取創意題目失敗:", error)
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "獲取創意題目失敗" },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
}
|
19
app/api/questions/logic/route.ts
Normal file
19
app/api/questions/logic/route.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { NextResponse } from "next/server"
|
||||
import { getAllLogicQuestions } from "@/lib/database/models/logic_question"
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const questions = await getAllLogicQuestions()
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
data: questions
|
||||
})
|
||||
} catch (error) {
|
||||
console.error("獲取邏輯題目失敗:", error)
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "獲取邏輯題目失敗" },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user