|
|
@@ -21,6 +21,7 @@ interface Request {
|
|
|
}[];
|
|
|
}
|
|
|
|
|
|
+// 插入数据
|
|
|
export async function POST(req: any) {
|
|
|
try {
|
|
|
// 从连接池中获取连接
|
|
|
@@ -50,13 +51,15 @@ export async function POST(req: any) {
|
|
|
|
|
|
// 释放连接回连接池
|
|
|
connection.release()
|
|
|
- return NextResponse.json({ message: 'ok', data: (rows as any).length }, { status: 200 })
|
|
|
- } catch (error) {
|
|
|
- console.error('Error:', error)
|
|
|
- return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 })
|
|
|
+
|
|
|
+ return NextResponse.json({ message: 'success', data: {} }, { status: 200 })
|
|
|
+ } catch (e) {
|
|
|
+ console.error('Error:', e)
|
|
|
+ return NextResponse.json({ message: 'error' }, { status: 500 })
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 查询数据
|
|
|
export async function GET() {
|
|
|
try {
|
|
|
// 从连接池中获取连接
|
|
|
@@ -64,14 +67,14 @@ export async function GET() {
|
|
|
|
|
|
// 执行 MySQL 查询
|
|
|
const [rows, fields] = await connection.query('SELECT he.id,he.dialog_name,de.id did,de.dialog_id,de.type,de.content,de.create_time ' +
|
|
|
- 'FROM dialog he left join dialog_detail de on he.id = de.dialog_id order by he.create_time desc, he.id , de.create_time, type desc')
|
|
|
+ 'FROM dialog he left join dialog_detail de on he.id = de.dialog_id order by he.create_time desc, he.id , de.create_time, type desc')
|
|
|
|
|
|
// 释放连接回连接池
|
|
|
connection.release()
|
|
|
|
|
|
- return NextResponse.json({ data: rows }, { status: 200 })
|
|
|
- } catch (error) {
|
|
|
- console.error('Error:', error)
|
|
|
- return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 })
|
|
|
+ return NextResponse.json({ message: 'success', data: rows }, { status: 200 })
|
|
|
+ } catch (e) {
|
|
|
+ console.error('Error:', e)
|
|
|
+ return NextResponse.json({ message: 'error' }, { status: 500 })
|
|
|
}
|
|
|
}
|