import { createCrudRoutes } from '@/server/utils/generic-crud.routes';
import { Template } from '@/server/modules/templates/template.entity';
import { TemplateSchema, CreateTemplateDto, UpdateTemplateDto } from '@/server/modules/templates/template.schema';
import { authMiddleware } from '@/server/middleware/auth.middleware';

const templateRoutes = createCrudRoutes({
  entity: Template,
  createSchema: CreateTemplateDto,
  updateSchema: UpdateTemplateDto,
  getSchema: TemplateSchema,
  listSchema: TemplateSchema,
  searchFields: ['title', 'description', 'category'],
  relations: ['file.uploadUser'],
  middleware: [authMiddleware] // 需要登录才能管理模板
});

export default templateRoutes;