-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpocData.template
77 lines (72 loc) · 2.19 KB
/
pocData.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{% if entity.name == "Persona" %}
const direccion = require("./Direccion");
const telefono = require("./Telefono");
{% endif %}
/**
* Clase destinada a la gestion de datos referente {{entity.name|capitalize}}
*/
class {{entity.name|capitalize}} {
/**
* Constructor de la clase
*/
constructor ( {% for property in entity.properties %}{{property.name}}{% if not loop.last %}, {% endif %}{% endfor %} ){
this.db = [];
{% for property in entity.properties %}
this.{{property.name}} = {{property.name}};
{% endfor %}
}
{% for property in entity.properties %}
/**
* Funcion que obtiene {{property.name}} de {{entity.name|capitalize}}
*/
get{{property.name|capitalize}} () {
return this.{{property.name}};
}
{% endfor %}
{% for property in entity.properties %}
/**
* Funcion que establece {{property.name}} de {{entity.name|capitalize}}
*/
set{{property.name|capitalize}} (precio) {
this.{{property.name}} = {{property.name}};
}
{% endfor %}
/**
* Funcion que inserta una nueva {{entity.name|capitalize}} en la base de datos
*/
insertar{{entity.name|capitalize}} ({{entity.name|lower}}) {
let valores = `{% for property in entity.properties -%}
${ {{entity.name|lower}}.get{{property.name|capitalize}}() }{% if not loop.last %}, {% endif %}
{%- endfor %}`;
let r = this.db.push(valores);
if (r) {
console.log( "{{entity.name|upper}}_INSERTADA" );
} else {
console.log( "ERROR_{{entity.name|upper}}_INSERTADA" );
}
}
}
{% if entity.name == "Persona" %}
const persona1 = new Persona(
"hola",
"mundo",
direccion,
13,
telefono,
"305222@"
);
{% endif %}
{% if entity.name == "Telefono" %}
const telefono1 = new Telefono("+57", "305222");
{% endif %}
{% if entity.name == "Direccion" %}
const direccion1 = new Direccion("calle 4", "bogota", "colombia");
{% endif %}
{{entity.name|lower}}1.insertar{{entity.name|capitalize}}({{entity.name|lower}}1);
{% if entity.name == "Telefono" %}
exports.telefono1 = new Telefono("+57", "305222");
{% endif %}
console.log({{entity.name|lower}}1);
{% if entity.name == "Direccion" %}
exports.direccion1 = new Direccion("calle 4", "bogota", "colombia");
{% endif %}