import { createCrudRoutes } from '../../utils/generic-crud.routes';
import { Advertisement } from '../../modules/advertisements/advertisement.entity';
import { AdvertisementSchema, CreateAdvertisementDto, UpdateAdvertisementDto } from '../../modules/advertisements/advertisement.schema';
import { authMiddleware } from '../../middleware/auth.middleware';

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'
  }
});

export default advertisementRoutes;