Instruction file imported from GabFrank/frc-sistemas-integrados-angular (
.cursor/rules/entidades.mdc). Copyright stays with the author.
Crear nueva entidad
Example: export class PedidoItemSucursal { id: number; pedidoItem: PedidoItem; sucursal: Sucursal; sucursalEntrega: Sucursal; cantidadPorUnidad: number; cantidadPorUnidadRecibida: number; creadoEn: Date; usuario: Usuario;
toInput(): PedidoItemSucursalInput {
let input = new PedidoItemSucursalInput();
input.id = this?.id,
input.pedidoItemId = this?.pedidoItem?.id;
input.sucursalId = this?.sucursal?.id;
input.sucursalEntregaId = this?.sucursalEntrega?.id;
input.cantidadPorUnidad = this?.cantidadPorUnidad;
input.cantidadPorUnidadRecibida = this?.cantidadPorUnidadRecibida;
input.usuarioId = this?.usuario?.id;
return input;
}
}
export class PedidoItemSucursalInput { id?: number; pedidoItemId?: number; sucursalId?: number; sucursalEntregaId?: number; cantidadPorUnidad?: number; cantidadPorUnidadRecibida?: number; usuarioId?: number; }
- this is an example of a entity class, we always create in one model.ts
- in a model.ts file we create the entity, the entityInput and the method toInput() as we have in the example
- on toInput method, always use ? before reference any propertie to avoid null data problem
- the file name will be: .model.ts
- always follow the example before generating the file