27 lines
727 B
TypeScript
27 lines
727 B
TypeScript
|
import { protocol } from "../../entity/protocol";
|
||
|
import { ProtocolViewModel } from "../../viewmodel/admin/protocol.models";
|
||
|
|
||
|
export default abstract class ProtocolFactory {
|
||
|
/**
|
||
|
* @description map record to protocol
|
||
|
* @param {protocol} record
|
||
|
* @returns {ProtocolViewModel}
|
||
|
*/
|
||
|
public static mapToSingle(record: protocol): ProtocolViewModel {
|
||
|
return {
|
||
|
id: record.id,
|
||
|
title: record.title,
|
||
|
date: record.date,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @description map records to protocol
|
||
|
* @param {Array<protocol>} records
|
||
|
* @returns {Array<ProtocolViewModel>}
|
||
|
*/
|
||
|
public static mapToBase(records: Array<protocol>): Array<ProtocolViewModel> {
|
||
|
return records.map((r) => this.mapToSingle(r));
|
||
|
}
|
||
|
}
|