import { createCrudRoutes } from '@d8d/shared-crud';
import { authMiddleware } from '@d8d/auth-module';
import { Company } from '../entities/company.entity';
import { CompanySchema, CreateCompanySchema, UpdateCompanySchema } from '../schemas/company.schema';

export const companyCrudRoutes = createCrudRoutes({
  entity: Company,
  createSchema: CreateCompanySchema,
  updateSchema: UpdateCompanySchema,
  getSchema: CompanySchema,
  listSchema: CompanySchema,
  searchFields: ['companyName', 'contactPerson', 'contactPhone'],
  middleware: [authMiddleware],
  readOnly: true, // 设置为只读，因为创建、更新、删除操作通过自定义路由处理
  userTracking: {
    createdByField: 'createdBy',
    updatedByField: 'updatedBy'
  }
});