mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-16 22:13:47 +08:00
增加系统设置表
This commit is contained in:
@@ -12,9 +12,45 @@ async function handle(
|
||||
// console.log('----', pathname, searchParams, params.path)
|
||||
if (method === "GET" && !params.path) {
|
||||
const all_setting = await prisma.setting.findMany();
|
||||
console.log("all_setting,", all_setting);
|
||||
// console.log("all_setting,", all_setting);
|
||||
return NextResponse.json({ result: all_setting });
|
||||
}
|
||||
if (method === "POST" && !params.path) {
|
||||
try {
|
||||
const setting_instance = await prisma.setting.create({
|
||||
data: await req.json(),
|
||||
});
|
||||
// console.log('-------', setting_instance)
|
||||
return NextResponse.json({ result: setting_instance });
|
||||
} catch (e) {
|
||||
console.log("[insert setting] error,", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (method === "PUT" && params.path) {
|
||||
try {
|
||||
const setting_key = params.path[0];
|
||||
const setting_instance = await prisma.setting.update({
|
||||
where: {
|
||||
key: setting_key,
|
||||
},
|
||||
data: await req.json(),
|
||||
});
|
||||
return NextResponse.json({ result: setting_instance });
|
||||
} catch {}
|
||||
}
|
||||
|
||||
if (method === "DELETE" && params.path) {
|
||||
try {
|
||||
const setting_key = params.path[0];
|
||||
const setting_instance = await prisma.setting.delete({
|
||||
where: {
|
||||
key: setting_key,
|
||||
},
|
||||
});
|
||||
return NextResponse.json({ result: setting_instance });
|
||||
} catch {}
|
||||
}
|
||||
|
||||
return NextResponse.json({ error: "当前方法不支持" }, { status: 405 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user