You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

21 lines
768 B

import { delCache } from "#server/utils/context";
import { z } from "zod";
import { validate } from "#server/utils/validation";
import { createCategory } from "../../service/category";
const createSchema = z.object({
name: z.string().min(1, "名称不能为空").max(100, "名称不能超过 100 字"),
parentId: z.string().nullable().optional(),
sortOrder: z.number().int().optional(),
defaultCardType: z.enum(['text', 'image', 'image-text', 'project', 'digest']).nullable().optional(),
});
export default defineWrappedResponseHandler(async (event) => {
const body = await readBody(event);
const data = validate(createSchema, body);
const category = await createCategory(data);
await delCache("categories:tree");
return R.success(category);
});