import { createCrudRoutes } from '@d8d/shared-crud';
import { authMiddleware } from '@d8d/auth-module';
import { Advertisement } from '../entities/advertisement.entity';
import { AdvertisementSchema, CreateAdvertisementDto, UpdateAdvertisementDto } from '../schemas/advertisement.schema';

export const advertisementRoutes = createCrudRoutes({
  entity: Advertisement,
  createSchema: CreateAdvertisementDto,
  updateSchema: UpdateAdvertisementDto,
  getSchema: AdvertisementSchema,
  listSchema: AdvertisementSchema,
  searchFields: ['title', 'code'],
  relations: ['imageFile', 'advertisementType'],
  middleware: [authMiddleware],
  userTracking: {
    createdByField: 'createdBy',
    updatedByField: 'updatedBy'
  }
});