@bmstravel/nvp-plop-templates 0.0.2 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- import { IBaseAction, IBaseAdapter, I{{pascalCase serviceName}}Service, UsersAuthMeta } from "@src/types";
1
+ import { IBaseAction, IBaseAdapter, I{{pascalCase serviceName}}Service, UserAuthMeta } from "@src/types";
2
2
  import { Context } from "moleculer";
3
3
  import { VISIBILITY, ERR_SYSTEM } from "@src/common";
4
4
  import { MoleculerRegularError } from "@src/errors";
@@ -89,7 +89,7 @@ const {{pascalCase actionName}}Action: IBaseAction = {
89
89
  {{/eq}}
90
90
  params: {
91
91
  },
92
- async handler(ctx: Context<{{pascalCase actionName}}Params, UsersAuthMeta>) {
92
+ async handler(ctx: Context<{{pascalCase actionName}}Params, UserAuthMeta>) {
93
93
  const $this: I{{pascalCase serviceName}}Service = this;
94
94
  const $adapter: IBaseAdapter = $this.adapter;
95
95
  const i18next = ctx.broker.i18next
@@ -4,18 +4,29 @@ import dayjs from "dayjs";
4
4
  import { generateUuid } from '@bmstravel/nvp-utils'
5
5
  {{/eq}}
6
6
  import { ISequelizeModel } from '@src/types'
7
+ import { STATUS } from "@src/common"
7
8
 
8
9
  export interface I{{pascalCase name}} {
9
10
  {{#if hasId}}
11
+ {{#eq dataTypeId "integer"}}
10
12
  id: number;
13
+ {{/eq}}
14
+ {{#eq dataTypeId "uuid"}}
15
+ id: string;
16
+ {{/eq}}
11
17
  {{/if}}
12
18
  // BEGIN addition here
13
19
 
14
20
  // END addition here
15
21
  {{#if hasId}}
22
+ status: STATUS
23
+ createdBy?: any
24
+ updatedBy?: any
25
+ deleteBy?: any
26
+ isDelete?: boolean
16
27
  createdAt: number;
17
28
  updatedAt: number;
18
- deletedAt: number;
29
+ deletedAt?: number;
19
30
  {{/if}}
20
31
  }
21
32
 
@@ -30,7 +41,9 @@ const {{pascalCase name}}Model: ISequelizeModel<I{{pascalCase name}}> = {
30
41
  {{/eq}}
31
42
  {{#eq dataTypeId "uuid"}}
32
43
  type: DataTypes.STRING,
33
- defaultValue: generateUuid({ _prefix: '{{truncate (camelCase name) 3}}' }),
44
+ defaultValue: function () {
45
+ return generateUuid({ _prefix: '{{truncate (camelCase name) 4}}', length: 19, replaceDash: true })
46
+ },,
34
47
  {{/eq}}
35
48
  primaryKey: true,
36
49
  },
@@ -39,6 +52,28 @@ const {{pascalCase name}}Model: ISequelizeModel<I{{pascalCase name}}> = {
39
52
 
40
53
  // END addition here
41
54
  {{#if hasCrudDate}}
55
+ status: {
56
+ type: DataTypes.STRING(20),
57
+ values: Object.values(STATUS),
58
+ defaultValue: STATUS.ACTIVE,
59
+ },
60
+ createdBy: {
61
+ type: DataTypes.STRING(15),
62
+ allowNull: true,
63
+ },
64
+ updatedBy: {
65
+ type: DataTypes.STRING(15),
66
+ allowNull: true,
67
+ },
68
+ deleteBy: {
69
+ type: DataTypes.STRING(15),
70
+ allowNull: true,
71
+ },
72
+ isDelete: {
73
+ type: DataTypes.BOOLEAN,
74
+ allowNull: true,
75
+ defaultValue: false,
76
+ },
42
77
  createdAt: {
43
78
  type: DataTypes.BIGINT,
44
79
  allowNull: false,
@@ -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-mixins";
4
+ import { Service, Action, Method, 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}}"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bmstravel/nvp-plop-templates",
3
- "version": "0.0.2",
3
+ "version": "0.0.5",
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": "42201e64954f884fef901d6d10e4bb90fbf46ab5"
18
+ "gitHead": "f4953836288d23d681cc842bf8b6bf4ee7b3760e"
19
19
  }