提交正式官网
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { requireAuth } from '~/server/utils/auth'
|
||||
import { execute } from '~/server/utils/mysql'
|
||||
import { fail, ok } from '~/server/utils/response'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const auth = requireAuth(event)
|
||||
if (!auth) {
|
||||
setResponseStatus(event, 401)
|
||||
return fail('未授权,请先登录', 401)
|
||||
}
|
||||
|
||||
const id = getRouterParam(event, 'id')
|
||||
if (!id) return fail('ID不能为空')
|
||||
|
||||
if (event.method === 'PATCH') {
|
||||
const body = await readBody<{ status?: string }>(event)
|
||||
if (body.status !== 'read' && body.status !== 'unread') {
|
||||
return fail('状态无效')
|
||||
}
|
||||
await execute('UPDATE partner_submissions SET status = ? WHERE id = ?', [body.status, id])
|
||||
return ok(null, '更新成功')
|
||||
}
|
||||
|
||||
setResponseStatus(event, 405)
|
||||
return fail('Method Not Allowed', 405)
|
||||
})
|
||||
Reference in New Issue
Block a user