Ai config
This commit is contained in:
@@ -26,7 +26,7 @@ async function getCategoryById(ctx) {
|
||||
}
|
||||
|
||||
async function createCategory(ctx) {
|
||||
const { name, icon, sortOrder = 0 } = ctx.request.body
|
||||
const { name, icon, color, sortOrder = 0 } = ctx.request.body
|
||||
|
||||
if (!name) {
|
||||
ctx.body = {
|
||||
@@ -37,20 +37,20 @@ async function createCategory(ctx) {
|
||||
}
|
||||
|
||||
const result = await query(
|
||||
'INSERT INTO categories (name, icon, sort_order) VALUES (?, ?, ?)',
|
||||
[name, icon || '', parseInt(sortOrder)]
|
||||
'INSERT INTO categories (name, icon, color, sort_order) VALUES (?, ?, ?, ?)',
|
||||
[name, icon || '', color || '#1890ff', parseInt(sortOrder)]
|
||||
)
|
||||
|
||||
ctx.body = {
|
||||
code: 200,
|
||||
message: '添加成功',
|
||||
data: { id: result.insertId, name, icon, sort_order: sortOrder }
|
||||
data: { id: result.insertId, name, icon, color, sort_order: sortOrder }
|
||||
}
|
||||
}
|
||||
|
||||
async function updateCategory(ctx) {
|
||||
const categoryId = parseInt(ctx.params.id)
|
||||
const { name, icon, sortOrder, isShow } = ctx.request.body
|
||||
const { name, icon, color, sortOrder, isShow } = ctx.request.body
|
||||
|
||||
if (!name) {
|
||||
ctx.body = {
|
||||
@@ -61,8 +61,8 @@ async function updateCategory(ctx) {
|
||||
}
|
||||
|
||||
const result = await query(
|
||||
'UPDATE categories SET name = ?, icon = ?, sort_order = ?, is_show = ? WHERE id = ?',
|
||||
[name, icon || '', parseInt(sortOrder) || 0, parseInt(isShow) || 1, categoryId]
|
||||
'UPDATE categories SET name = ?, icon = ?, color = ?, sort_order = ?, is_show = ? WHERE id = ?',
|
||||
[name, icon || '', color || '#1890ff', parseInt(sortOrder) || 0, parseInt(isShow) || 1, categoryId]
|
||||
)
|
||||
|
||||
if (result.affectedRows > 0) {
|
||||
|
||||
Reference in New Issue
Block a user