import { createCrudRoutes } from '@d8d/shared-crud';
import { OpenAPIHono } from '@hono/zod-openapi';
import { GoodsCategory } from '../entities/goods-category.entity.js';
import { GoodsCategorySchema, CreateGoodsCategoryDto, UpdateGoodsCategoryDto } from '../schemas/goods-category.schema.js';
import { authMiddleware } from '@d8d/auth-module';

// 创建基础CRUD路由
export const adminGoodsCategoriesRoutes = createCrudRoutes({
  entity: GoodsCategory,
  createSchema: CreateGoodsCategoryDto,
  updateSchema: UpdateGoodsCategoryDto,
  getSchema: GoodsCategorySchema,
  listSchema: GoodsCategorySchema,
  searchFields: ['name'],
  relations: ['imageFile.uploadUser'],
  middleware: [authMiddleware],
  userTracking: {
    createdByField: 'createdBy',
    updatedByField: 'updatedBy'
  }
});