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

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