feat(worker-platform): 分类标识改为系统自动生成并在前端UI隐藏
This commit is contained in:
@@ -33,6 +33,66 @@ export async function listAllWorkCategories(): Promise<WorkCategoryRow[]> {
|
||||
return result.rows
|
||||
}
|
||||
|
||||
export async function createWorkCategory(input: {
|
||||
categoryKey: string
|
||||
name: string
|
||||
parentId?: number | null
|
||||
iconUrl?: string | null
|
||||
sortOrder: number
|
||||
status: string
|
||||
now: string
|
||||
}): Promise<WorkCategoryRow | null> {
|
||||
const result = await query<WorkCategoryRow>(
|
||||
`
|
||||
INSERT INTO work_categories (category_key, name, parent_id, icon_url, sort_order, status, created_at, updated_at)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
RETURNING *
|
||||
`,
|
||||
[
|
||||
input.categoryKey,
|
||||
input.name,
|
||||
input.parentId ?? null,
|
||||
input.iconUrl ?? null,
|
||||
input.sortOrder,
|
||||
input.status,
|
||||
input.now,
|
||||
input.now,
|
||||
],
|
||||
)
|
||||
return result.rows[0] || null
|
||||
}
|
||||
|
||||
export async function updateWorkCategoryById(
|
||||
id: number,
|
||||
input: {
|
||||
name: string
|
||||
parentId?: number | null
|
||||
iconUrl?: string | null
|
||||
sortOrder: number
|
||||
status: string
|
||||
now: string
|
||||
},
|
||||
): Promise<WorkCategoryRow | null> {
|
||||
const result = await query<WorkCategoryRow>(
|
||||
`
|
||||
UPDATE work_categories
|
||||
SET name = $1, parent_id = $2, icon_url = $3, sort_order = $4, status = $5, updated_at = $6
|
||||
WHERE id = $7
|
||||
RETURNING *
|
||||
`,
|
||||
[
|
||||
input.name,
|
||||
input.parentId ?? null,
|
||||
input.iconUrl ?? null,
|
||||
input.sortOrder,
|
||||
input.status,
|
||||
input.now,
|
||||
id,
|
||||
],
|
||||
)
|
||||
return result.rows[0] || null
|
||||
}
|
||||
|
||||
export async function upsertWorkCategory(input: {
|
||||
categoryKey: string
|
||||
name: string
|
||||
|
||||
Reference in New Issue
Block a user