@bmstravel/nvp-plop-templates 0.2.63 → 0.2.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -20,6 +20,7 @@ export interface I{{pascalCase name}} {
|
|
|
20
20
|
// END addition here
|
|
21
21
|
{{#if hasId}}
|
|
22
22
|
status: STATUS
|
|
23
|
+
creator?: string
|
|
23
24
|
createdBy?: any
|
|
24
25
|
updatedBy?: any
|
|
25
26
|
deleteBy?: any
|
|
@@ -57,6 +58,10 @@ const {{pascalCase name}}Model: ISequelizeModel<I{{pascalCase name}}> = {
|
|
|
57
58
|
values: Object.values(STATUS),
|
|
58
59
|
defaultValue: STATUS.ACTIVE,
|
|
59
60
|
},
|
|
61
|
+
creator: {
|
|
62
|
+
type: DataTypes.STRING,
|
|
63
|
+
allowNull: true,
|
|
64
|
+
},
|
|
60
65
|
createdBy: {
|
|
61
66
|
type: DataTypes.STRING(15),
|
|
62
67
|
allowNull: true,
|
|
@@ -77,15 +82,30 @@ const {{pascalCase name}}Model: ISequelizeModel<I{{pascalCase name}}> = {
|
|
|
77
82
|
createdAt: {
|
|
78
83
|
type: DataTypes.BIGINT,
|
|
79
84
|
allowNull: false,
|
|
80
|
-
|
|
81
|
-
return
|
|
82
|
-
},
|
|
85
|
+
defaultValue: function () {
|
|
86
|
+
return new Date().getTime()
|
|
87
|
+
},
|
|
88
|
+
set(value: any) {
|
|
89
|
+
// const curVal = this.getDataValue("createdAt")
|
|
90
|
+
if (value == null || typeof value == "undefined") {
|
|
91
|
+
this.setDataValue("createdAt", new Date().getTime())
|
|
92
|
+
} else {
|
|
93
|
+
this.setDataValue("createdAt", value)
|
|
94
|
+
}
|
|
95
|
+
},
|
|
83
96
|
},
|
|
84
97
|
updatedAt: {
|
|
85
98
|
type: DataTypes.BIGINT,
|
|
86
99
|
allowNull: false,
|
|
87
100
|
defaultValue: function () {
|
|
88
|
-
return
|
|
101
|
+
return new Date().getTime()
|
|
102
|
+
},
|
|
103
|
+
set(value: any) {
|
|
104
|
+
if (value == null || typeof value == "undefined") {
|
|
105
|
+
this.setDataValue("updatedAt", new Date().getTime())
|
|
106
|
+
} else {
|
|
107
|
+
this.setDataValue("updatedAt", value)
|
|
108
|
+
}
|
|
89
109
|
},
|
|
90
110
|
},
|
|
91
111
|
deletedAt: { type: DataTypes.BIGINT },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import moleculer, { Errors } from "moleculer";
|
|
4
|
-
import { Service, Action, Method, ActionService, MethodService, HookService, EventService } from "@bmstravel/nvp-decorator";
|
|
4
|
+
import { Service, Action, Method, Event, ActionService, MethodService, HookService, EventService } from "@bmstravel/nvp-decorator";
|
|
5
5
|
import { VERSION, Config, VISIBILITY } from "@src/common";
|
|
6
6
|
|
|
7
7
|
const serviceName = "{{camelCase serviceName}}"
|
|
@@ -97,6 +97,44 @@ export default class {{pascalCase serviceName}}Service extends moleculer.Service
|
|
|
97
97
|
}
|
|
98
98
|
{{/if}}
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Event called to one of instance of service when started
|
|
102
|
+
* is being call by broker.emit(...)
|
|
103
|
+
* @param _payload
|
|
104
|
+
* @param _sender
|
|
105
|
+
* @param _name
|
|
106
|
+
* @param _ctx
|
|
107
|
+
* @returns void
|
|
108
|
+
*/
|
|
109
|
+
@Event({})
|
|
110
|
+
async "$service.bootstap"(_payload: Record<string, any>, _sender: string, _name: string, _ctx: moleculer.Context) {
|
|
111
|
+
/* const $this: IBaseService = this as any
|
|
112
|
+
try {
|
|
113
|
+
// implements here
|
|
114
|
+
} catch (err) {
|
|
115
|
+
$this.logger.error(`🔥 ~ $service.bootstap:`, err)
|
|
116
|
+
} */
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Event called to each instance of service when started
|
|
121
|
+
* is being call by broker.broadcastLocal(...)
|
|
122
|
+
* @param _payload
|
|
123
|
+
* @param _sender
|
|
124
|
+
* @param _name
|
|
125
|
+
* @param _ctx
|
|
126
|
+
* @returns void
|
|
127
|
+
*/
|
|
128
|
+
@Event({})
|
|
129
|
+
async "$broker.started"(_payload: Record<string, any>, _sender: string, _name: string, _ctx: moleculer.Context) {
|
|
130
|
+
/* const $this: IBaseService = this as any
|
|
131
|
+
try {
|
|
132
|
+
// implements here
|
|
133
|
+
} catch (err) {
|
|
134
|
+
$this.logger.error(`🔥 ~ $service.bootstap:`, err)
|
|
135
|
+
} */
|
|
136
|
+
}
|
|
137
|
+
|
|
100
138
|
public created() {
|
|
101
139
|
// Fired when created
|
|
102
140
|
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
{{#if hasSeedDb}}
|
|
10
10
|
Method,
|
|
11
11
|
{{/if}}
|
|
12
|
+
Event,
|
|
12
13
|
Service,
|
|
13
14
|
ActionService,
|
|
14
15
|
MethodService,
|
|
@@ -168,6 +169,44 @@ export default class {{pascalCase serviceName}}Service extends MoleculerDBServic
|
|
|
168
169
|
}
|
|
169
170
|
{{/if}}
|
|
170
171
|
|
|
172
|
+
/**
|
|
173
|
+
* Event called to one of instance of service when started
|
|
174
|
+
* is being call by broker.emit(...)
|
|
175
|
+
* @param _payload
|
|
176
|
+
* @param _sender
|
|
177
|
+
* @param _name
|
|
178
|
+
* @param _ctx
|
|
179
|
+
* @returns void
|
|
180
|
+
*/
|
|
181
|
+
@Event({})
|
|
182
|
+
async "$service.bootstap"(_payload: Record<string, any>, _sender: string, _name: string, _ctx: moleculer.Context) {
|
|
183
|
+
/* const $this: IBaseService = this as any
|
|
184
|
+
try {
|
|
185
|
+
// implements here
|
|
186
|
+
} catch (err) {
|
|
187
|
+
$this.logger.error(`🔥 ~ $service.bootstap:`, err)
|
|
188
|
+
} */
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Event called to each instance of service when started
|
|
193
|
+
* is being call by broker.broadcastLocal(...)
|
|
194
|
+
* @param _payload
|
|
195
|
+
* @param _sender
|
|
196
|
+
* @param _name
|
|
197
|
+
* @param _ctx
|
|
198
|
+
* @returns void
|
|
199
|
+
*/
|
|
200
|
+
@Event({})
|
|
201
|
+
async "$broker.started"(_payload: Record<string, any>, _sender: string, _name: string, _ctx: moleculer.Context) {
|
|
202
|
+
/* const $this: IBaseService = this as any
|
|
203
|
+
try {
|
|
204
|
+
// implements here
|
|
205
|
+
} catch (err) {
|
|
206
|
+
$this.logger.error(`🔥 ~ $service.bootstap:`, err)
|
|
207
|
+
} */
|
|
208
|
+
}
|
|
209
|
+
|
|
171
210
|
public created() {
|
|
172
211
|
// Fired when created
|
|
173
212
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bmstravel/nvp-plop-templates",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.65",
|
|
4
4
|
"description": "🏆 Using for plop templates",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
"phongnv86 <phongnguyenvan86@gmail.com>",
|
|
16
16
|
"phongnv86 <phongnv@media-one.vn>"
|
|
17
17
|
],
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "c01878afc3b49fe4d74de8665708ae673ba811de"
|
|
19
19
|
}
|