feat: add domain models
This commit is contained in:
3
src/app/models/Chain.ts
Normal file
3
src/app/models/Chain.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export class Chain {
|
||||
constructor(public name: string | null, public image: string | null, public id?: number) {}
|
||||
}
|
||||
5
src/app/models/Establishment.ts
Normal file
5
src/app/models/Establishment.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { Chain } from './Chain';
|
||||
|
||||
export class Establishment {
|
||||
constructor(public chain: Chain, public address = '', public id?: number) {}
|
||||
}
|
||||
8
src/app/models/Product.ts
Normal file
8
src/app/models/Product.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export class Product {
|
||||
constructor(
|
||||
public barcode: string,
|
||||
public name = '',
|
||||
public image: string | null = null,
|
||||
public id?: number
|
||||
) {}
|
||||
}
|
||||
14
src/app/models/ProductEstablisment.ts
Normal file
14
src/app/models/ProductEstablisment.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Establishment } from './Establishment';
|
||||
import { Product } from './Product';
|
||||
|
||||
export class ProductEstablishment {
|
||||
id?: number;
|
||||
establishment: Establishment;
|
||||
product: Product;
|
||||
|
||||
constructor(product: Product, establishment: Establishment, id?: number) {
|
||||
this.id = id;
|
||||
this.establishment = establishment;
|
||||
this.product = product;
|
||||
}
|
||||
}
|
||||
24
src/app/models/Purchase.ts
Normal file
24
src/app/models/Purchase.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Establishment } from './Establishment';
|
||||
import { Product } from './Product';
|
||||
|
||||
export class Purchase {
|
||||
#price: number;
|
||||
constructor(
|
||||
public establishment: Establishment,
|
||||
public product: Product,
|
||||
price = 0,
|
||||
public quantity = 1,
|
||||
public date = Date.now(),
|
||||
public id?: number
|
||||
) {
|
||||
this.#price = price * 100;
|
||||
}
|
||||
|
||||
get price() {
|
||||
return this.#price / 100;
|
||||
}
|
||||
|
||||
set price(price: number) {
|
||||
this.#price = price * 100;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user