|
|
@@ -6,7 +6,13 @@ import { AuthContext } from '../types/context';
|
|
|
import { ObjectLiteral } from 'typeorm';
|
|
|
import { AppDataSource } from '../data-source';
|
|
|
|
|
|
-export function createCrudRoutes<T extends ObjectLiteral>(options: CrudOptions<T>) {
|
|
|
+export function createCrudRoutes<
|
|
|
+ T extends ObjectLiteral,
|
|
|
+ CreateSchema extends z.ZodSchema = z.ZodSchema,
|
|
|
+ UpdateSchema extends z.ZodSchema = z.ZodSchema,
|
|
|
+ GetSchema extends z.ZodSchema = z.ZodSchema,
|
|
|
+ ListSchema extends z.ZodSchema = z.ZodSchema
|
|
|
+>(options: CrudOptions<T, CreateSchema, UpdateSchema, GetSchema, ListSchema>) {
|
|
|
const { entity, createSchema, updateSchema, getSchema, listSchema, searchFields, middleware = [] } = options;
|
|
|
|
|
|
// 创建CRUD服务实例
|