init project portal web
This commit is contained in:
59
lib/price-plan/model/price-plan-model.ts
Normal file
59
lib/price-plan/model/price-plan-model.ts
Normal file
@ -0,0 +1,59 @@
|
||||
interface Props {
|
||||
id: string
|
||||
name: string
|
||||
type: string
|
||||
code: string
|
||||
validPeriod: string
|
||||
}
|
||||
|
||||
export default class PricePlanModel {
|
||||
private id: string
|
||||
private name: string
|
||||
private type: string
|
||||
private code: string
|
||||
private validPeriod: string
|
||||
|
||||
constructor({ id, name, type, code, validPeriod }: Props) {
|
||||
this.id = id
|
||||
this.name = name
|
||||
this.type = type
|
||||
this.code = code
|
||||
this.validPeriod = validPeriod
|
||||
}
|
||||
|
||||
getId() { return this.id}
|
||||
getName() { return this.name }
|
||||
getType() { return this.type }
|
||||
getCode() { return this.code }
|
||||
getValidPeriod() { return this.validPeriod }
|
||||
|
||||
static fromJSON(data: any): PricePlanModel[] {
|
||||
return data.data.content.map((item: {
|
||||
id: string
|
||||
pricePlanName: string,
|
||||
pricePlanType: string,
|
||||
pricePlanCode: string,
|
||||
validPeriod: string,
|
||||
}) => {
|
||||
return new PricePlanModel({
|
||||
id: item.id,
|
||||
name: item.pricePlanName,
|
||||
type: item.pricePlanType,
|
||||
code: item.pricePlanCode,
|
||||
validPeriod: item.validPeriod,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
static toJsonList = (list: PricePlanModel[]): Props[] => {
|
||||
return list.map((item: PricePlanModel) => {
|
||||
return {
|
||||
id: item.getId(),
|
||||
name: item.getName(),
|
||||
type: item.getType(),
|
||||
code: item.getCode(),
|
||||
validPeriod: item.getValidPeriod(),
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user