import { createCrudRoutes } from '@d8d/shared-crud';
import { authMiddleware } from '@d8d/auth-module';
import { DisabledPerson } from '../entities/disabled-person.entity';
import { DisabledPersonSchema, CreateDisabledPersonSchema, UpdateDisabledPersonSchema } from '../schemas/disabled-person.schema';

export const disabledPersonCrudRoutes = createCrudRoutes({
  entity: DisabledPerson,
  createSchema: CreateDisabledPersonSchema,
  updateSchema: UpdateDisabledPersonSchema,
  getSchema: DisabledPersonSchema,
  listSchema: DisabledPersonSchema,
  searchFields: ['name', 'idCard', 'address'],
  relations: ['bankCards', 'photos', 'remarks', 'visits'],
  middleware: [authMiddleware],
  readOnly: true, // 设置为只读，因为创建、更新、删除操作通过自定义路由处理
  userTracking: {
    createdByField: 'createdBy',
    updatedByField: 'updatedBy'
  }
});