import { createCrudRoutes } from '@d8d/shared-crud';
import { authMiddleware } from '@d8d/auth-module-mt';
import { SupplierMt } from '../entities/supplier.mt.entity';
import { UserSupplierSchema, CreateUserSupplierDto, UpdateUserSupplierDto } from '../schemas/user-supplier.mt.schema';

export const userSupplierRoutes = createCrudRoutes({
  entity: SupplierMt,
  createSchema: CreateUserSupplierDto,
  updateSchema: UpdateUserSupplierDto,
  getSchema: UserSupplierSchema,
  listSchema: UserSupplierSchema,
  searchFields: ['name', 'username', 'realname'],
  middleware: [authMiddleware],
  userTracking: {
    createdByField: 'createdBy',
    updatedByField: 'updatedBy'
  },
  dataPermission: {
    enabled: true,
    userIdField: 'createdBy'
  },
  tenantOptions: {
    enabled: true,
    tenantIdField: 'tenantId'
  }
});