Ai config

This commit is contained in:
董海洋
2026-05-26 13:37:55 +08:00
parent 55452a2d21
commit 0c7ed3498d
42 changed files with 1264 additions and 767 deletions
+7 -7
View File
@@ -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) {