|
|
@ -40,8 +40,30 @@ export default class Index { |
|
|
|
return h.view("views/about.pug", data) |
|
|
|
} |
|
|
|
|
|
|
|
@route("/color/del") |
|
|
|
@method("POST") |
|
|
|
@auth() |
|
|
|
async color_del(request: Req, h: Res) { |
|
|
|
const { id } = request.payload as any |
|
|
|
if (!id) { |
|
|
|
request.yar.flash("error", "未提供id") |
|
|
|
return h.redirect("/color") |
|
|
|
} |
|
|
|
try { |
|
|
|
const ColorModel = request.getModel("color") |
|
|
|
await ColorModel.destroy({ where: { id} }) |
|
|
|
request.yar.flash("success", "删除成功") |
|
|
|
} catch (error) { |
|
|
|
loggerSite.error(error) |
|
|
|
request.yar.flash("error", "删除失败") |
|
|
|
} |
|
|
|
|
|
|
|
return h.redirect("/color") |
|
|
|
} |
|
|
|
|
|
|
|
@route("/color") |
|
|
|
@method("POST") |
|
|
|
@auth() |
|
|
|
async color_post(request: Req, h: Res) { |
|
|
|
const { name, value, desctibe } = request.payload as any |
|
|
|
|
|
|
|