新增订单推荐人和邀请码功能,优化支付流程中的订单插入逻辑,确保订单记录准确。更新小程序支付请求,支持传递邀请码以便于分销归属和对账。同时,调整数据库结构以支持新字段,提升系统的稳定性和用户体验。
This commit is contained in:
@@ -88,8 +88,22 @@ export async function PUT(req: NextRequest) {
|
||||
)
|
||||
}
|
||||
|
||||
// TODO: 根据ID找到文件并更新
|
||||
|
||||
// id 格式: category/filename(无 .md)
|
||||
const filePath = path.join(BOOK_DIR, `${id}.md`)
|
||||
if (!fs.existsSync(filePath)) {
|
||||
return NextResponse.json(
|
||||
{ error: '章节文件不存在' },
|
||||
{ status: 404 }
|
||||
)
|
||||
}
|
||||
const markdownContent = matter.stringify(content ?? '', {
|
||||
title: title ?? id.split('/').pop(),
|
||||
date: new Date().toISOString(),
|
||||
tags: tags || [],
|
||||
draft: false
|
||||
})
|
||||
fs.writeFileSync(filePath, markdownContent, 'utf-8')
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: '章节更新成功'
|
||||
@@ -117,8 +131,15 @@ export async function DELETE(req: NextRequest) {
|
||||
)
|
||||
}
|
||||
|
||||
// TODO: 根据ID删除文件
|
||||
|
||||
const filePath = path.join(BOOK_DIR, `${id}.md`)
|
||||
if (!fs.existsSync(filePath)) {
|
||||
return NextResponse.json(
|
||||
{ error: '章节文件不存在' },
|
||||
{ status: 404 }
|
||||
)
|
||||
}
|
||||
fs.unlinkSync(filePath)
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: '章节删除成功'
|
||||
|
||||
Reference in New Issue
Block a user