@simitgroup/simpleapp-generator 1.0.32 → 1.0.35
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.
- package/.vscode/settings.json +3 -0
- package/README.md +185 -16
- package/buildinschemas copy/autoincreament.autoinc.jsonschema.json +39 -0
- package/buildinschemas copy/branch.branch.jsonschema.json +41 -0
- package/buildinschemas copy/docnoformat.docno.jsonschema.json +41 -0
- package/buildinschemas copy/organization.org.jsonschema.json +50 -0
- package/buildinschemas copy/permission.perm.jsonschema.json +23 -0
- package/buildinschemas copy/permission.perm.jsonschema.try.json +25 -0
- package/buildinschemas copy/tenant.tenant.jsonschema.json +21 -0
- package/buildinschemas copy/tenant.tenant.jsonschema.try.json +27 -0
- package/buildinschemas copy/user.user.jsonschema.json +31 -0
- package/dist/buildinschemas/autoincreament.d.ts +3 -0
- package/dist/buildinschemas/autoincreament.d.ts.map +1 -0
- package/dist/buildinschemas/autoincreament.js +36 -0
- package/dist/buildinschemas/autoincreament.js.map +1 -0
- package/dist/buildinschemas/branch.d.ts +3 -0
- package/dist/buildinschemas/branch.d.ts.map +1 -0
- package/dist/buildinschemas/branch.js +41 -0
- package/dist/buildinschemas/branch.js.map +1 -0
- package/dist/buildinschemas/docnoformat.d.ts +3 -0
- package/dist/buildinschemas/docnoformat.d.ts.map +1 -0
- package/dist/buildinschemas/docnoformat.js +60 -0
- package/dist/buildinschemas/docnoformat.js.map +1 -0
- package/dist/buildinschemas/index.d.ts +8 -0
- package/dist/buildinschemas/index.d.ts.map +1 -0
- package/dist/buildinschemas/index.js +18 -0
- package/dist/buildinschemas/index.js.map +1 -0
- package/dist/buildinschemas/organization.d.ts +3 -0
- package/dist/buildinschemas/organization.d.ts.map +1 -0
- package/dist/buildinschemas/organization.js +34 -0
- package/dist/buildinschemas/organization.js.map +1 -0
- package/dist/buildinschemas/permission.d.ts +3 -0
- package/dist/buildinschemas/permission.d.ts.map +1 -0
- package/dist/buildinschemas/permission.js +34 -0
- package/dist/buildinschemas/permission.js.map +1 -0
- package/dist/buildinschemas/tenant.d.ts +3 -0
- package/dist/buildinschemas/tenant.d.ts.map +1 -0
- package/dist/buildinschemas/tenant.js +41 -0
- package/dist/buildinschemas/tenant.js.map +1 -0
- package/dist/buildinschemas/user.d.ts +3 -0
- package/dist/buildinschemas/user.d.ts.map +1 -0
- package/dist/buildinschemas/user.js +31 -0
- package/dist/buildinschemas/user.js.map +1 -0
- package/dist/constant.d.ts +4 -0
- package/dist/constant.d.ts.map +1 -0
- package/dist/constant.js +2 -1
- package/dist/constant.js.map +1 -1
- package/dist/framework.d.ts +10 -0
- package/dist/framework.d.ts.map +1 -0
- package/dist/framework.js +120 -68
- package/dist/framework.js.map +1 -1
- package/dist/generate-allow-changebackend.js +305 -0
- package/dist/generate-allow-changebackend.js.map +1 -0
- package/dist/generate.d.ts +2 -0
- package/dist/generate.d.ts.map +1 -0
- package/dist/generate.js +310 -230
- package/dist/generate.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +84 -20
- package/dist/index.js.map +1 -1
- package/dist/libs.d.ts +2 -0
- package/dist/libs.d.ts.map +1 -0
- package/dist/processors/groupsbuilder.js +2 -0
- package/dist/processors/groupsbuilder.js.map +1 -0
- package/dist/processors/jsonschemabuilder.d.ts +4 -0
- package/dist/processors/jsonschemabuilder.d.ts.map +1 -0
- package/dist/processors/jsonschemabuilder.js +146 -172
- package/dist/processors/jsonschemabuilder.js.map +1 -1
- package/dist/schematype/baseschema.js +25 -0
- package/dist/schematype/baseschema.js.map +1 -0
- package/dist/schematype/default.js +2 -0
- package/dist/schematype/default.js.map +1 -0
- package/dist/schematype/index.js +12 -0
- package/dist/schematype/index.js.map +1 -0
- package/dist/schematype/primarymasterdata.js +38 -0
- package/dist/schematype/primarymasterdata.js.map +1 -0
- package/dist/schematype/simple.js +24 -0
- package/dist/schematype/simple.js.map +1 -0
- package/dist/schematype/simplemasterdata.js +31 -0
- package/dist/schematype/simplemasterdata.js.map +1 -0
- package/dist/schematype/transaction.js +74 -0
- package/dist/schematype/transaction.js.map +1 -0
- package/dist/storage.d.ts +3 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +2 -2
- package/dist/storage.js.map +1 -1
- package/dist/type.d.ts +164 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +16 -1
- package/dist/type.js.map +1 -1
- package/dist/validation.d.ts +1 -0
- package/dist/validation.d.ts.map +1 -0
- package/documentation/designconcept.bpmn +349 -0
- package/documentation/documentation.png +0 -0
- package/documentation/infra.drawio +141 -0
- package/documentation/infra.png +0 -0
- package/documentation/management.drawio +57 -0
- package/documentation/stack.drawio +106 -0
- package/package.json +3 -1
- package/src/buildinschemas/autoincreament.ts +34 -0
- package/src/buildinschemas/branch.ts +39 -0
- package/src/buildinschemas/docnoformat.ts +58 -0
- package/src/buildinschemas/index.ts +7 -0
- package/src/buildinschemas/organization.ts +31 -0
- package/src/buildinschemas/permission.ts +31 -0
- package/src/buildinschemas/tenant.ts +38 -0
- package/src/buildinschemas/user.ts +28 -0
- package/src/constant.ts +2 -1
- package/src/framework.ts +126 -67
- package/src/generate.ts +327 -266
- package/src/generate.ts.backup +339 -0
- package/src/index.ts +93 -18
- package/src/processors/jsonschemabuilder.ts +199 -226
- package/src/processors/jsonschemabuilder.ts-old +383 -0
- package/src/storage.ts +1 -1
- package/src/type.ts +94 -27
- package/templates/basic/nest/controller.ts.eta +255 -0
- package/templates/basic/nest/default.ts.eta +42 -0
- package/templates/basic/{model.eta → nest/model.ts.eta} +18 -5
- package/templates/basic/nest/processor.ts.eta +129 -0
- package/templates/basic/nest/service.ts.eta +64 -0
- package/templates/basic/{type.eta → nest/type.ts.eta} +3 -3
- package/templates/basic/nuxt/default.ts.eta +42 -0
- package/templates/basic/{pageindex.vue.eta → nuxt/pages.crud.vue.eta} +85 -22
- package/templates/basic/nuxt/simpleapp.doc.ts.eta +11 -0
- package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +212 -0
- package/templates/nest/.env.eta +31 -0
- package/templates/nest/.gitignore.eta +40 -0
- package/templates/nest/src/app.controller.ts.eta +19 -0
- package/templates/nest/src/app.module.ts.eta +77 -0
- package/templates/nest/src/app.service.ts.eta +9 -0
- package/templates/nest/src/main.ts.eta +58 -0
- package/templates/nest/src/simpleapp/generate/apischemas/index.ts.eta +16 -0
- package/templates/nest/src/simpleapp/generate/commons/decorators/appuser.decorator.ts.eta +8 -0
- package/templates/nest/src/simpleapp/generate/commons/dicts/foreignkeys.ts.eta +1 -0
- package/templates/nest/src/simpleapp/generate/commons/docnogenerator.service.ts.eta +101 -0
- package/templates/nest/src/simpleapp/generate/commons/exceptions/SimpleAppExceptionFilter.ts.eta +39 -0
- package/templates/nest/src/simpleapp/generate/commons/interceptors/response.interceptor.ts.eta +38 -0
- package/templates/nest/src/simpleapp/generate/commons/middlewares/tenant.middleware.ts.eta +88 -0
- package/templates/nest/{Workflow.eta → src/simpleapp/generate/commons/providers/workflow.provider.ts.etax} +20 -14
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.decorator.ts.eta +6 -0
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.enum.ts.eta +28 -0
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.group.ts.eta +10 -0
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.guard.ts.eta +34 -0
- package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +391 -0
- package/templates/nest/src/simpleapp/generate/controllers/simpleapp.controller.ts.eta +71 -0
- package/templates/nest/src/simpleapp/generate/models/perm.model.ts.eta +53 -0
- package/templates/nest/src/simpleapp/generate/models/tenant.model.ts.eta +45 -0
- package/templates/nest/src/simpleapp/generate/models/user.model.ts.eta +57 -0
- package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +624 -0
- package/templates/nest/src/simpleapp/generate/types/index.ts.eta +19 -0
- package/templates/nest/src/simpleapp/profile/profile.apischema.ts.eta +74 -0
- package/templates/nest/src/simpleapp/profile/profile.controller.ts.eta +110 -0
- package/templates/nest/src/simpleapp/profile/profile.service.ts.eta +195 -0
- package/templates/nest/src/simpleapp/profile/profile.types.ts.eta +18 -0
- package/templates/nest/src/simpleapp/services/autoinc.service.ts.eta +89 -0
- package/templates/nest/src/simpleapp/services/branch.service.ts.eta +66 -0
- package/templates/nest/src/simpleapp/services/docno.service.ts.eta +93 -0
- package/templates/nest/src/simpleapp/services/org.service.ts.eta +67 -0
- package/templates/nest/src/simpleapp/services/perm.service.ts.eta +102 -0
- package/templates/nest/src/simpleapp/services/tenant.service.ts.eta +69 -0
- package/templates/nest/src/simpleapp/services/user.service.ts.eta +66 -0
- package/templates/nest/src/simpleapp/simpleapp.module.ts.eta +43 -0
- package/templates/nuxt/.env.eta +21 -0
- package/templates/nuxt/.gitignore.eta +28 -0
- package/templates/nuxt/app.vue.eta +5 -2
- package/templates/nuxt/assets/css/tailwind.css.eta +35 -0
- package/templates/nuxt/components/CrudNestedDoc.vue.eta +164 -0
- package/templates/nuxt/components/CrudSimple.vue.eta +179 -0
- package/templates/nuxt/{components.debugdocdata.vue.eta → components/DebugDocumentData.vue.eta} +4 -1
- package/templates/nuxt/{components.eventmonitor.vue.eta → components/EventMonitor.vue.eta} +27 -27
- package/templates/nuxt/components/Invitation.vue.eta +50 -0
- package/templates/nuxt/components/Menus.vue.eta +58 -0
- package/templates/nuxt/components/PermissionInfo.vue.eta +92 -0
- package/templates/nuxt/components/SimpleAppAutocomplete.vue.eta +131 -0
- package/templates/nuxt/components/SimpleAppAutocompletemulti.vue.eta +73 -0
- package/templates/nuxt/components/SimpleAppCalendar.vue.eta +55 -0
- package/templates/nuxt/components/SimpleAppCheckbox.vue.eta +29 -0
- package/templates/nuxt/components/SimpleAppChip.vue.eta +28 -0
- package/templates/nuxt/components/SimpleAppColor.vue.eta +41 -0
- package/templates/nuxt/components/SimpleAppDatatable.vue.eta +20 -0
- package/templates/nuxt/components/SimpleAppDocumentNo.vue.eta +90 -0
- package/templates/nuxt/components/SimpleAppDynamicInput.vue.eta +29 -0
- package/templates/nuxt/components/SimpleAppEditor.vue.eta +31 -0
- package/templates/nuxt/components/SimpleAppForm.vue.eta +131 -0
- package/templates/nuxt/components/SimpleAppInputTable.vue.eta +104 -0
- package/templates/nuxt/components/SimpleAppList.vue.eta +38 -0
- package/templates/nuxt/components/SimpleAppListmulti.vue.eta +41 -0
- package/templates/nuxt/components/SimpleAppNumber.vue.eta +32 -0
- package/templates/nuxt/components/SimpleAppPassword.vue.eta +41 -0
- package/templates/nuxt/components/SimpleAppRadio.vue.eta +42 -0
- package/templates/nuxt/components/SimpleAppRating.vue.eta +41 -0
- package/templates/nuxt/components/SimpleAppSelect.vue.eta +38 -0
- package/templates/nuxt/components/SimpleAppSelectmulti.vue.eta +39 -0
- package/templates/nuxt/components/SimpleAppSlider.vue.eta +42 -0
- package/templates/nuxt/components/SimpleAppSwitch.vue.eta +30 -0
- package/templates/nuxt/components/SimpleAppText.vue.eta +50 -0
- package/templates/nuxt/components/SimpleAppTextarea.vue.eta +30 -0
- package/templates/nuxt/components/SimpleAppValue.vue.eta +86 -0
- package/templates/nuxt/components/SimpleFieldContainer.vue.eta +102 -0
- package/templates/nuxt/components/XorgPicker.vue.eta +66 -0
- package/templates/nuxt/components/helper.ts.eta +90 -0
- package/templates/nuxt/components/type.ts.eta +32 -0
- package/templates/nuxt/composables/docformat.generate.ts.eta +5 -0
- package/templates/nuxt/{composables.getautocomplete.ts.eta → composables/getAutocomplete.generate.ts.eta} +4 -5
- package/templates/nuxt/{composables.getmenus.ts.eta → composables/getMenus.generate.ts.eta} +22 -7
- package/templates/nuxt/composables/getOpenApi.generate.ts.eta +6 -0
- package/templates/nuxt/composables/getTenant.generate.ts.eta +4 -0
- package/templates/nuxt/composables/getUserStore.generate.ts.eta +22 -0
- package/templates/nuxt/composables/logout.generate.ts.eta +22 -0
- package/templates/nuxt/composables/roles.generate.ts.eta +48 -0
- package/templates/nuxt/composables/stringHelper.generate.ts.eta +5 -0
- package/templates/nuxt/{layouts.default.vue.eta → layouts/default.vue.eta} +2 -0
- package/templates/nuxt/middleware/10.acl.global.ts.eta +38 -0
- package/templates/nuxt/nuxt.config.ts.eta +12 -2
- package/templates/nuxt/pages/[xorg]/branch/index.vue.eta +102 -0
- package/templates/nuxt/pages/[xorg]/docnoformat/[id].vue.eta +17 -0
- package/templates/nuxt/pages/[xorg]/docnoformat/index.vue.eta +269 -0
- package/templates/nuxt/pages/[xorg]/index.vue.eta +36 -0
- package/templates/nuxt/pages/[xorg]/organization/index.vue.eta +148 -0
- package/templates/nuxt/pages/[xorg]/permission/index.vue.eta +280 -0
- package/templates/nuxt/pages/[xorg]/tenant/index.vue.eta +93 -0
- package/templates/nuxt/pages/[xorg]/user/index.vue.eta +468 -0
- package/templates/nuxt/pages/index.vue.eta +191 -0
- package/templates/nuxt/pages/login.vue.eta +21 -0
- package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +53 -0
- package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +155 -0
- package/templates/nuxt/plugins/50.simpleapp-client.ts.eta +23 -0
- package/templates/nuxt/{server.api.ts.eta → server/api/[xorg]/[...].ts.eta} +5 -2
- package/templates/nuxt/server/api/auth/[...].ts.eta +68 -0
- package/templates/nuxt/{server.api.auth.logout.ts.eta → server/api/auth/logout.ts.eta} +1 -3
- package/templates/nuxt/server/api/profile/[...].ts.eta +150 -0
- package/templates/nuxt/server/api/profile/index.ts.eta +103 -0
- package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +187 -0
- package/templates/nuxt/simpleapp/generate/commons/documents.ts.eta +6 -0
- package/templates/nuxt/simpleapp/generate/commons/events.ts.eta +5 -0
- package/templates/nuxt/simpleapp/generate/commons/groups.ts.eta +11 -0
- package/templates/nuxt/simpleapp/generate/commons/roles.ts.eta +21 -0
- package/templates/nuxt/types/index.ts.eta +65 -0
- package/templates/project/README.md +11 -0
- package/templates/project/build.sh.eta +17 -0
- package/templates/project/config.json.eta +2 -0
- package/templates/project/generate.ts.eta +10 -0
- package/templates/project/schemas/category.ts.eta +26 -0
- package/templates/project/schemas/index.ts.eta +5 -0
- package/templates/project/schemas/product.ts.eta +59 -0
- package/templates/project/shares/hello.ts.eta +1 -0
- package/templates/project/shares/index.ts.eta +2 -0
- package/tsconfig.json +9 -2
- package/tsconfig.tsbuildinfo +1 -0
- package/definations/category.cat.jsonschema.json +0 -55
- package/definations/level.lvl.jsonschema.json +0 -48
- package/definations/product.prd.jsonschema.json +0 -46
- package/templates/basic/controller.eta +0 -152
- package/templates/basic/module.eta +0 -22
- package/templates/basic/service.eta +0 -62
- package/templates/basic/simpleappclient.eta +0 -120
- package/templates/nest/SimpleAppController.eta +0 -69
- package/templates/nest/SimpleAppService.eta +0 -366
- package/templates/nest/TenantMiddleware.eta +0 -34
- package/templates/nest/UserProvider.eta +0 -127
- package/templates/nest/app.controller.eta +0 -12
- package/templates/nest/app.module.eta +0 -64
- package/templates/nest/app.service.eta +0 -8
- package/templates/nest/inputvalidation-exception.eta +0 -6
- package/templates/nest/nest.env.eta +0 -28
- package/templates/nest/nest.main.eta +0 -31
- package/templates/nuxt/components.crudsimple.vue.eta +0 -124
- package/templates/nuxt/components.menus.vue.eta +0 -35
- package/templates/nuxt/env.eta +0 -17
- package/templates/nuxt/pages.[xorg].index.vue.eta +0 -20
- package/templates/nuxt/pages.index.vue.eta +0 -72
- package/templates/nuxt/pages.login.vue.eta +0 -20
- package/templates/nuxt/plugins.simpleapp.ts.eta +0 -88
- package/templates/nuxt/server.api.auth[...].ts.eta +0 -233
- package/templates/nuxt/tailwind.css.eta +0 -49
- /package/templates/basic/{apischema.eta → nest/apischema.ts.eta} +0 -0
- /package/templates/basic/{jsonschema.eta → nest/jsonschema.ts.eta} +0 -0
- /package/templates/basic/{pageindexwithid.vue.eta → nuxt/pages.[id].vue.eta} +0 -0
- /package/templates/nest/{oauth2-redirect.eta → public_html/oauth2-redirect.html.eta} +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
import {ProfileUserInvites,ProfileUserBranch} from './profile.types'
|
|
3
|
+
export class RegTenantApiSchema {
|
|
4
|
+
@ApiProperty({
|
|
5
|
+
type: 'string',
|
|
6
|
+
required: true,
|
|
7
|
+
examples: ['my company 1'],
|
|
8
|
+
default: '',
|
|
9
|
+
})
|
|
10
|
+
tenantName: string;
|
|
11
|
+
}
|
|
12
|
+
export class MyProfileApiSchemaBranches{
|
|
13
|
+
@ApiProperty({type: 'string'})
|
|
14
|
+
_id: '1231231';
|
|
15
|
+
@ApiProperty({type: 'number'})
|
|
16
|
+
tenantId: 2;
|
|
17
|
+
@ApiProperty({type: 'number'})
|
|
18
|
+
orgId: 1;
|
|
19
|
+
@ApiProperty({type: 'number'})
|
|
20
|
+
branchId: 1;
|
|
21
|
+
@ApiProperty({type: 'string'})
|
|
22
|
+
group: 'cashier';
|
|
23
|
+
@ApiProperty({type: 'string'})
|
|
24
|
+
xOrg: 'Mi0xLTE';
|
|
25
|
+
}
|
|
26
|
+
export class MyProfileApiSchemaInvites{
|
|
27
|
+
@ApiProperty({type: 'string'})
|
|
28
|
+
_id: string;
|
|
29
|
+
@ApiProperty({type: 'string'})
|
|
30
|
+
email: string;
|
|
31
|
+
@ApiProperty({type: 'string'})
|
|
32
|
+
created: string;
|
|
33
|
+
permission: any[];
|
|
34
|
+
// @ApiProperty({type: 'string'})
|
|
35
|
+
// _id: '6527e3eff96dd5156e267bab';
|
|
36
|
+
// @ApiProperty({type: 'number'})
|
|
37
|
+
// tenantId: 2;
|
|
38
|
+
// @ApiProperty({type: 'number'})
|
|
39
|
+
// orgId: 1;
|
|
40
|
+
// @ApiProperty({type: 'number'})
|
|
41
|
+
// branchId: 1;
|
|
42
|
+
// @ApiProperty({type: 'string'})
|
|
43
|
+
// group: 'cashier';
|
|
44
|
+
// @ApiProperty({type: 'string'})
|
|
45
|
+
// xOrg: 'Mi0xLTE';
|
|
46
|
+
}
|
|
47
|
+
export class MyProfileApiSchema {
|
|
48
|
+
@ApiProperty({type: 'string'})
|
|
49
|
+
_id: string;
|
|
50
|
+
@ApiProperty({type: 'number'})
|
|
51
|
+
tenantId: number;
|
|
52
|
+
@ApiProperty({type: 'number'})
|
|
53
|
+
'orgId': number;
|
|
54
|
+
@ApiProperty({type: 'number'})
|
|
55
|
+
'branchId': number;
|
|
56
|
+
@ApiProperty({type: 'string'})
|
|
57
|
+
'email': string;
|
|
58
|
+
@ApiProperty({type: 'number'})
|
|
59
|
+
'uid': string;
|
|
60
|
+
@ApiProperty({type: 'number'})
|
|
61
|
+
'fullName': string;
|
|
62
|
+
@ApiProperty({type: 'number'})
|
|
63
|
+
'group': string;
|
|
64
|
+
@ApiProperty({type: ['string']})
|
|
65
|
+
'roles': string[];
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@ApiProperty({type: [MyProfileApiSchemaBranches]})
|
|
69
|
+
'branches': ProfileUserBranch[]
|
|
70
|
+
@ApiProperty({type: [MyProfileApiSchemaInvites]})
|
|
71
|
+
'invites': ProfileUserInvites[];
|
|
72
|
+
@ApiProperty({type: 'string'})
|
|
73
|
+
'time': string;
|
|
74
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Controller,
|
|
3
|
+
Get,
|
|
4
|
+
Put,
|
|
5
|
+
Post,
|
|
6
|
+
Patch,
|
|
7
|
+
Delete,
|
|
8
|
+
Body,
|
|
9
|
+
Query,
|
|
10
|
+
Param,
|
|
11
|
+
Type,
|
|
12
|
+
Res,
|
|
13
|
+
HttpStatus,
|
|
14
|
+
Inject,
|
|
15
|
+
Injectable,
|
|
16
|
+
Scope,
|
|
17
|
+
Req,
|
|
18
|
+
HttpException,
|
|
19
|
+
Request,
|
|
20
|
+
Logger,
|
|
21
|
+
} from '@nestjs/common';
|
|
22
|
+
import { Roles } from '../generate/commons/roles/roles.decorator';
|
|
23
|
+
import { Role } from '../generate/commons/roles/roles.enum';
|
|
24
|
+
import { ApiTags, ApiBody, ApiResponse, ApiOperation } from '@nestjs/swagger';
|
|
25
|
+
import { UserContext } from '../generate/commons/user.context';
|
|
26
|
+
import { ProfileService } from './profile.service';
|
|
27
|
+
import { AppUser } from '../generate/commons/decorators/appuser.decorator';
|
|
28
|
+
import { RegTenant } from './profile.types';
|
|
29
|
+
import { RegTenantApiSchema, MyProfileApiSchema } from './profile.apischema';
|
|
30
|
+
@ApiTags('PROFILE')
|
|
31
|
+
@Controller('/profile')
|
|
32
|
+
export class ProfileController {
|
|
33
|
+
protected logger = new Logger();
|
|
34
|
+
constructor(private profileservice: ProfileService) {
|
|
35
|
+
//console.log("init Profile Controller ")
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@Get()
|
|
39
|
+
@Roles(Role.Everyone, Role.User)
|
|
40
|
+
@ApiOperation({
|
|
41
|
+
operationId: 'getProfile',
|
|
42
|
+
description: 'Get current user profile',
|
|
43
|
+
})
|
|
44
|
+
@ApiResponse({
|
|
45
|
+
status: 200,
|
|
46
|
+
type: () => MyProfileApiSchema,
|
|
47
|
+
description: 'Success',
|
|
48
|
+
})
|
|
49
|
+
@ApiResponse({ status: 401, type: Object, description: 'Undefine profile' })
|
|
50
|
+
async getProfile(@AppUser() appuser: UserContext) {
|
|
51
|
+
this.logger.debug(
|
|
52
|
+
`access getProfile API by ${appuser.getUid()},(${appuser.getId()})`,
|
|
53
|
+
);
|
|
54
|
+
const result = await this.profileservice.getProfile(appuser);
|
|
55
|
+
this.logger.debug('getProfile result is:');
|
|
56
|
+
this.logger.debug(result);
|
|
57
|
+
if (result) {
|
|
58
|
+
return result;
|
|
59
|
+
} else {
|
|
60
|
+
throw new HttpException('Forbidden', HttpStatus.FORBIDDEN);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@Post('/tenant')
|
|
66
|
+
@Roles(Role.Everyone)
|
|
67
|
+
@ApiBody({ description: 'create tenant name', type: RegTenantApiSchema })
|
|
68
|
+
@ApiOperation({
|
|
69
|
+
operationId: 'createTenant',
|
|
70
|
+
description: 'create new tenant',
|
|
71
|
+
})
|
|
72
|
+
@ApiResponse({ status: 201, type: Object, description: 'Success' })
|
|
73
|
+
async createTenant(
|
|
74
|
+
@AppUser() appuser: UserContext,
|
|
75
|
+
@Body('tenantName') tenantName: string,
|
|
76
|
+
) {
|
|
77
|
+
const result = await this.profileservice.createTenant(appuser, tenantName);
|
|
78
|
+
if (result) {
|
|
79
|
+
return result;
|
|
80
|
+
} else {
|
|
81
|
+
throw new HttpException('Forbidden', HttpStatus.FORBIDDEN);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@Post('/invitation/:id/:decision')
|
|
86
|
+
@Roles(Role.Everyone)
|
|
87
|
+
@ApiOperation({
|
|
88
|
+
operationId: 'decideInvitation',
|
|
89
|
+
description: 'accept or reject invitation to tenant',
|
|
90
|
+
})
|
|
91
|
+
@ApiResponse({ status: 201, type: Object, description: 'Success' })
|
|
92
|
+
async decideInvitation(
|
|
93
|
+
@AppUser() appuser: UserContext,
|
|
94
|
+
@Param('id') id: string,
|
|
95
|
+
@Param('decision') decision: string,
|
|
96
|
+
) {
|
|
97
|
+
const result = await this.profileservice.decideInvitation(
|
|
98
|
+
appuser,
|
|
99
|
+
id,
|
|
100
|
+
decision,
|
|
101
|
+
);
|
|
102
|
+
if (result) {
|
|
103
|
+
console.log('result', result);
|
|
104
|
+
return result;
|
|
105
|
+
} else {
|
|
106
|
+
console.log('throw error');
|
|
107
|
+
throw new HttpException('Forbidden', HttpStatus.FORBIDDEN);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { UserService, User } from './../services/user.service';
|
|
2
|
+
import {
|
|
3
|
+
Injectable,
|
|
4
|
+
Scope,
|
|
5
|
+
Inject,
|
|
6
|
+
Logger,
|
|
7
|
+
BadRequestException,
|
|
8
|
+
InternalServerErrorException,
|
|
9
|
+
} from '@nestjs/common';
|
|
10
|
+
import { UserContext } from '../generate/commons/user.context';
|
|
11
|
+
import { RegTenant } from './profile.types';
|
|
12
|
+
import * as mongoose from 'mongoose';
|
|
13
|
+
import { InjectConnection } from '@nestjs/mongoose';
|
|
14
|
+
import { TenantService, Tenant } from '../services/tenant.service';
|
|
15
|
+
import { OrganizationService, Organization } from '../services/org.service';
|
|
16
|
+
import { BranchService, Branch } from '../services/branch.service';
|
|
17
|
+
import { PermissionService, Permission } from './../services/perm.service';
|
|
18
|
+
|
|
19
|
+
const Base64URL = require('@darkwolf/base64url');
|
|
20
|
+
@Injectable()
|
|
21
|
+
export class ProfileService {
|
|
22
|
+
protected logger = new Logger();
|
|
23
|
+
constructor(
|
|
24
|
+
private usersvc: UserService,
|
|
25
|
+
private tenantsvc: TenantService,
|
|
26
|
+
private orgsvc: OrganizationService,
|
|
27
|
+
private branchsvc: BranchService,
|
|
28
|
+
private permsvc: PermissionService,
|
|
29
|
+
) {}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* get user profile for current tenant
|
|
33
|
+
* tenantId=0, if profile not exists will auto create one
|
|
34
|
+
* tenantId>0, if profile not exists will reject
|
|
35
|
+
* @param appuser
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
async getProfile(appuser: UserContext) {
|
|
39
|
+
const accessTenantId = appuser.getTenantId();
|
|
40
|
+
this.logger.verbose(
|
|
41
|
+
`get userprofile for ${appuser.getUid()} for tenantId ${accessTenantId}`,
|
|
42
|
+
'getProfile',
|
|
43
|
+
);
|
|
44
|
+
const userinfo = await appuser.getUserInfo();
|
|
45
|
+
|
|
46
|
+
if (userinfo._id == '') {
|
|
47
|
+
this.logger.warn('unknown _id for ', appuser.getUid());
|
|
48
|
+
|
|
49
|
+
let newprofile;
|
|
50
|
+
if (accessTenantId == 0) {
|
|
51
|
+
newprofile = await this.createUserProfile(appuser);
|
|
52
|
+
newprofile['time'] = new Date().toISOString();
|
|
53
|
+
return newprofile;
|
|
54
|
+
} else {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
userinfo['time'] = new Date().toISOString();
|
|
59
|
+
return userinfo;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async createUserProfile(appuser: UserContext) {
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
const data: User = {
|
|
67
|
+
uid: appuser.getUid(),
|
|
68
|
+
fullname: appuser.getFullname(),
|
|
69
|
+
email: appuser.getEmail(),
|
|
70
|
+
active: true,
|
|
71
|
+
doctype: 'user',
|
|
72
|
+
} as User;
|
|
73
|
+
|
|
74
|
+
const createresult = await this.usersvc.create(appuser, data);
|
|
75
|
+
const userinfo = await appuser.getUserInfo();
|
|
76
|
+
userinfo._id = createresult._id;
|
|
77
|
+
return userinfo;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async createTenant(appuser: UserContext, tenantName: string) {
|
|
81
|
+
// try{
|
|
82
|
+
appuser.getDBSession().startTransaction()
|
|
83
|
+
const tenantdata: Tenant = {
|
|
84
|
+
tenantId: 1,
|
|
85
|
+
tenantName: tenantName,
|
|
86
|
+
active: true,
|
|
87
|
+
owner: {
|
|
88
|
+
_id: appuser.getId(),
|
|
89
|
+
label: appuser.getFullname(),
|
|
90
|
+
uid: appuser.getUid(),
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
this.logger.log(tenantdata, 'createTenant data');
|
|
94
|
+
const tenantResult = await this.tenantsvc.create(appuser, tenantdata);
|
|
95
|
+
if (!tenantResult) {
|
|
96
|
+
throw new BadRequestException('Create tenant failed');
|
|
97
|
+
}
|
|
98
|
+
this.logger.log(tenantResult, 'createTenant result');
|
|
99
|
+
const tenantId = tenantResult.tenantId;
|
|
100
|
+
|
|
101
|
+
// return tenantResult
|
|
102
|
+
const orgdata: Organization = {
|
|
103
|
+
tenantId: tenantResult.tenantId,
|
|
104
|
+
orgName: tenantName,
|
|
105
|
+
active: true,
|
|
106
|
+
orgCode: 'HQ',
|
|
107
|
+
orgId: 1,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
this.logger.log(orgdata, 'createOrg data');
|
|
111
|
+
const orgResult = await this.orgsvc.create(appuser, orgdata);
|
|
112
|
+
if (!orgResult) {
|
|
113
|
+
throw new BadRequestException('Create Org failed');
|
|
114
|
+
}
|
|
115
|
+
const orgRecordId = orgResult._id.toString();
|
|
116
|
+
this.logger.log(orgResult, 'createOrg result');
|
|
117
|
+
|
|
118
|
+
const branchdata: Branch = {
|
|
119
|
+
branchId: 1,
|
|
120
|
+
branchCode: 'HQ',
|
|
121
|
+
branchName: tenantName,
|
|
122
|
+
active: true,
|
|
123
|
+
orgId: orgResult.orgId,
|
|
124
|
+
tenantId: tenantResult.tenantId,
|
|
125
|
+
organization: { _id: orgRecordId, label: tenantName },
|
|
126
|
+
};
|
|
127
|
+
this.logger.log(branchdata, 'createbranch data');
|
|
128
|
+
|
|
129
|
+
const branchResult = await this.branchsvc.create(appuser, branchdata);
|
|
130
|
+
if (!branchResult) {
|
|
131
|
+
throw new BadRequestException('Create Branch failed');
|
|
132
|
+
}
|
|
133
|
+
const branchRecordId = branchResult._id.toString();
|
|
134
|
+
this.logger.log(branchResult, 'createbranch result');
|
|
135
|
+
|
|
136
|
+
const userdata: User = {
|
|
137
|
+
tenantId: tenantResult.tenantId,
|
|
138
|
+
orgId: orgResult.orgId,
|
|
139
|
+
branchId: branchResult.branchId,
|
|
140
|
+
uid: appuser.getUid(),
|
|
141
|
+
fullname: appuser.getFullname(),
|
|
142
|
+
email: appuser.getEmail(),
|
|
143
|
+
active: true,
|
|
144
|
+
};
|
|
145
|
+
this.logger.log(userdata, 'createtenant user data');
|
|
146
|
+
const userResult = await this.usersvc.create(appuser, userdata);
|
|
147
|
+
// if(true ){
|
|
148
|
+
if (!userResult) {
|
|
149
|
+
throw new BadRequestException('Create User failed');
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
this.logger.log(userResult, 'createtenant user result');
|
|
153
|
+
const userRecordId = userResult._id.toString();
|
|
154
|
+
|
|
155
|
+
const permdata: Permission = {
|
|
156
|
+
tenantId: tenantResult.tenantId,
|
|
157
|
+
orgId: orgResult.orgId,
|
|
158
|
+
branchId: branchResult.branchId,
|
|
159
|
+
uid: appuser.getUid(),
|
|
160
|
+
group: 'admin',
|
|
161
|
+
};
|
|
162
|
+
this.logger.log(permdata, 'create Permission data');
|
|
163
|
+
const permResult = await this.permsvc.create(appuser, permdata);
|
|
164
|
+
if (!permResult) {
|
|
165
|
+
throw new BadRequestException('Create permResult failed');
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
this.logger.log(permResult, 'create Permission result');
|
|
169
|
+
|
|
170
|
+
const xorg: string = Base64URL.encodeText(
|
|
171
|
+
`${tenantResult.tenantId}-${orgResult.orgId}-${branchResult.branchId}`,
|
|
172
|
+
);
|
|
173
|
+
const finalresult = {
|
|
174
|
+
xOrg: xorg,
|
|
175
|
+
tenantId: tenantResult.tenantId,
|
|
176
|
+
orgId: orgResult.orgId,
|
|
177
|
+
branchId: branchResult.branchId,
|
|
178
|
+
};
|
|
179
|
+
return finalresult;
|
|
180
|
+
// }catch(e){
|
|
181
|
+
// this.logger.error("Couldn't generate tenant or subsequence records")
|
|
182
|
+
// throw new InternalServerErrorException(e)
|
|
183
|
+
// }
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* accept or reject invitation
|
|
188
|
+
* @param appuser
|
|
189
|
+
* @param id
|
|
190
|
+
* @param decision
|
|
191
|
+
*/
|
|
192
|
+
async decideInvitation(appuser: UserContext, id: string, decision: string) {
|
|
193
|
+
return await appuser.decideInvitation(id, decision);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type RegTenant = {
|
|
2
|
+
tenantName: string;
|
|
3
|
+
};
|
|
4
|
+
export type ProfileUserBranch = {
|
|
5
|
+
_id: string
|
|
6
|
+
branch: any
|
|
7
|
+
group: string
|
|
8
|
+
xOrg: string
|
|
9
|
+
};
|
|
10
|
+
export type ProfileUserInvites = {
|
|
11
|
+
_id: string;
|
|
12
|
+
email: string;
|
|
13
|
+
fullName: string;
|
|
14
|
+
tenantId: string;
|
|
15
|
+
tenantName: string;
|
|
16
|
+
created: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator.
|
|
3
|
+
* It will not override by generator
|
|
4
|
+
* last change 2023-09-23
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
7
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
8
|
+
import { Model } from 'mongoose';
|
|
9
|
+
import { Injectable } from '@nestjs/common';
|
|
10
|
+
import { AutoincreamentProcessor } from '../generate/processors/autoinc.processor';
|
|
11
|
+
import { DocNumberFormatGenerator } from '../generate/commons/docnogenerator.service';
|
|
12
|
+
import { Autoincreament } from '../generate/types/autoinc.type';
|
|
13
|
+
import { UserContext } from '../generate/commons/user.context';
|
|
14
|
+
export { Autoincreament } from '../generate/types/autoinc.type';
|
|
15
|
+
|
|
16
|
+
@Injectable()
|
|
17
|
+
export class AutoincreamentService extends AutoincreamentProcessor {
|
|
18
|
+
constructor(
|
|
19
|
+
@InjectModel('Autoincreament') mydoc: Model<Autoincreament>,
|
|
20
|
+
docnogenerator: DocNumberFormatGenerator,
|
|
21
|
+
) {
|
|
22
|
+
super(mydoc,docnogenerator);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// hook = async (appuser:UserContext,type: string, data?: any) => {
|
|
26
|
+
// switch(type){
|
|
27
|
+
// case 'init':
|
|
28
|
+
// break;
|
|
29
|
+
// case 'beforeSearch':
|
|
30
|
+
// break;
|
|
31
|
+
// case 'afterSearch':
|
|
32
|
+
// break;
|
|
33
|
+
// case 'beforeValidation':
|
|
34
|
+
// break;
|
|
35
|
+
// case 'afterValidation':
|
|
36
|
+
// break;
|
|
37
|
+
// case 'beforeCreate':
|
|
38
|
+
// break;
|
|
39
|
+
// case 'afterCreate':
|
|
40
|
+
// break;
|
|
41
|
+
// case 'beforeUpdate':
|
|
42
|
+
// break;
|
|
43
|
+
// case 'afterUpdate':
|
|
44
|
+
// break;
|
|
45
|
+
// case 'beforeDelete':
|
|
46
|
+
// break;
|
|
47
|
+
// case 'afterDelete':
|
|
48
|
+
// break;
|
|
49
|
+
// case 'beforeFetchRecord':
|
|
50
|
+
// break;
|
|
51
|
+
// case 'afterFetchRecord':
|
|
52
|
+
// break;
|
|
53
|
+
// default:
|
|
54
|
+
// break;
|
|
55
|
+
// }
|
|
56
|
+
// return true;
|
|
57
|
+
// };
|
|
58
|
+
|
|
59
|
+
async generateNextNo(
|
|
60
|
+
appuser: UserContext,
|
|
61
|
+
collection: string,
|
|
62
|
+
field: string,
|
|
63
|
+
) {
|
|
64
|
+
const res = await this.search(appuser, {
|
|
65
|
+
collectionName: collection,
|
|
66
|
+
fieldName: field,
|
|
67
|
+
});
|
|
68
|
+
// console.log(res)
|
|
69
|
+
let data;
|
|
70
|
+
if (res.length > 0) {
|
|
71
|
+
// console.log("FOUND RESULT------")
|
|
72
|
+
const tmp = res[0];
|
|
73
|
+
const nextno = tmp.nextno;
|
|
74
|
+
data = { collectionName: collection, fieldName: field, nextno: nextno };
|
|
75
|
+
this.findIdThenUpdate(appuser, tmp._id, {
|
|
76
|
+
collectionName: collection,
|
|
77
|
+
fieldName: field,
|
|
78
|
+
nextno: tmp.nextno + 1,
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
// console.log("CREATE ROW------")
|
|
82
|
+
this.data = { collectionName: collection, fieldName: field, nextno: 2 };
|
|
83
|
+
const createResult = await this.create(appuser, this.data);
|
|
84
|
+
data = { _id:crypto.randomUUID(), collectionName: collection, fieldName: field, nextno: 1 };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return data;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator.
|
|
3
|
+
* It will not override by generator
|
|
4
|
+
* last change 2023-09-23
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
7
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
8
|
+
import { Model } from 'mongoose';
|
|
9
|
+
import { Injectable } from '@nestjs/common';
|
|
10
|
+
import { BranchProcessor } from '../generate/processors/branch.processor';
|
|
11
|
+
import { Branch } from '../generate/types/branch.type';
|
|
12
|
+
export { Branch } from '../generate/types/branch.type';
|
|
13
|
+
import { AutoincreamentService } from './autoinc.service';
|
|
14
|
+
import { UserContext } from '../generate/commons/user.context';
|
|
15
|
+
import { DocNumberFormatGenerator } from '../generate/commons/docnogenerator.service';
|
|
16
|
+
@Injectable()
|
|
17
|
+
export class BranchService extends BranchProcessor {
|
|
18
|
+
protected strictIsolation = false;
|
|
19
|
+
constructor(
|
|
20
|
+
@InjectModel('Branch') mydoc: Model<Branch>,
|
|
21
|
+
private increament: AutoincreamentService,
|
|
22
|
+
docnogenerator: DocNumberFormatGenerator,
|
|
23
|
+
) {
|
|
24
|
+
super(mydoc,docnogenerator);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
hook = async (appuser: UserContext, type: string, data?: any) => {
|
|
28
|
+
switch (type) {
|
|
29
|
+
// case 'init':
|
|
30
|
+
// break;
|
|
31
|
+
// case 'beforeSearch':
|
|
32
|
+
// break;
|
|
33
|
+
// case 'afterSearch':
|
|
34
|
+
// break;
|
|
35
|
+
// case 'beforeValidation':
|
|
36
|
+
// break;
|
|
37
|
+
// case 'afterValidation':
|
|
38
|
+
// break;
|
|
39
|
+
case 'beforeCreate':
|
|
40
|
+
const searchresult = await this.increament.generateNextNo(
|
|
41
|
+
appuser,
|
|
42
|
+
'branch',
|
|
43
|
+
'branchId',
|
|
44
|
+
);
|
|
45
|
+
data.branchId = searchresult.nextno;
|
|
46
|
+
break;
|
|
47
|
+
// case 'afterCreate':
|
|
48
|
+
// break;
|
|
49
|
+
// case 'beforeUpdate':
|
|
50
|
+
// break;
|
|
51
|
+
// case 'afterUpdate':
|
|
52
|
+
// break;
|
|
53
|
+
// case 'beforeDelete':
|
|
54
|
+
// break;
|
|
55
|
+
// case 'afterDelete':
|
|
56
|
+
// break;
|
|
57
|
+
// case 'beforeFetchRecord':
|
|
58
|
+
// break;
|
|
59
|
+
// case 'afterFetchRecord':
|
|
60
|
+
// break;
|
|
61
|
+
// default:
|
|
62
|
+
// break;
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { BadRequestException } from '@nestjs/common';
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by simpleapp generator.
|
|
4
|
+
* It will not override by generator
|
|
5
|
+
* last change 2023-09-23
|
|
6
|
+
* Author: Ks Tan
|
|
7
|
+
*/
|
|
8
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
9
|
+
import { Model } from 'mongoose';
|
|
10
|
+
import { Injectable, InternalServerErrorException } from '@nestjs/common';
|
|
11
|
+
import { DocnoformatProcessor } from '../generate/processors/docno.processor';
|
|
12
|
+
import { Docnoformat } from '../generate/types/docno.type';
|
|
13
|
+
import { UserContext } from '../generate/commons/user.context';
|
|
14
|
+
import * as moment from 'moment';
|
|
15
|
+
import { DocNumberFormatGenerator } from '../generate/commons/docnogenerator.service';
|
|
16
|
+
export { Docnoformat } from '../generate/types/docno.type';
|
|
17
|
+
|
|
18
|
+
@Injectable()
|
|
19
|
+
export class DocnoformatService extends DocnoformatProcessor {
|
|
20
|
+
constructor(
|
|
21
|
+
@InjectModel('Docnoformat') mydoc: Model<Docnoformat>,
|
|
22
|
+
docnogenerator: DocNumberFormatGenerator,
|
|
23
|
+
) {
|
|
24
|
+
super(mydoc,docnogenerator);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// hook = async (type: string, data?: any) => {
|
|
28
|
+
// switch(type){
|
|
29
|
+
// case 'init':
|
|
30
|
+
// break;
|
|
31
|
+
// case 'beforeSearch':
|
|
32
|
+
// break;
|
|
33
|
+
// case 'afterSearch':
|
|
34
|
+
// break;
|
|
35
|
+
// case 'beforeValidation':
|
|
36
|
+
// break;
|
|
37
|
+
// case 'afterValidation':
|
|
38
|
+
// break;
|
|
39
|
+
// case 'beforeCreate':
|
|
40
|
+
// break;
|
|
41
|
+
// case 'afterCreate':
|
|
42
|
+
// break;
|
|
43
|
+
// case 'beforeUpdate':
|
|
44
|
+
// break;
|
|
45
|
+
// case 'afterUpdate':
|
|
46
|
+
// break;
|
|
47
|
+
// case 'beforeDelete':
|
|
48
|
+
// break;
|
|
49
|
+
// case 'afterDelete':
|
|
50
|
+
// break;
|
|
51
|
+
// case 'beforeFetchRecord':
|
|
52
|
+
// break;
|
|
53
|
+
// case 'afterFetchRecord':
|
|
54
|
+
// break;
|
|
55
|
+
// default:
|
|
56
|
+
// break;
|
|
57
|
+
// }
|
|
58
|
+
// return true;
|
|
59
|
+
// };
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* list document number format and prepare sample of docformat
|
|
63
|
+
* @param appuser
|
|
64
|
+
* @param doctype
|
|
65
|
+
* @returns
|
|
66
|
+
*/
|
|
67
|
+
async listDocFormats(appuser: UserContext, doctype: string) {
|
|
68
|
+
doctype = doctype.toUpperCase();
|
|
69
|
+
const searchresult = await this.search(
|
|
70
|
+
appuser,
|
|
71
|
+
{ docNoType: doctype },
|
|
72
|
+
{ default: 'desc' },
|
|
73
|
+
);
|
|
74
|
+
console.log(searchresult);
|
|
75
|
+
let data: any = [];
|
|
76
|
+
for (let i = 0; i < searchresult.length; i++) {
|
|
77
|
+
const s = searchresult[i];
|
|
78
|
+
if (s.active && s.docNoPattern) {
|
|
79
|
+
data.push({
|
|
80
|
+
_id: s._id,
|
|
81
|
+
docNoFormatNo: s.docNoFormatNo,
|
|
82
|
+
docNoFormatName: s.docNoFormatName,
|
|
83
|
+
docNoPattern: s.docNoPattern,
|
|
84
|
+
isMonthly: s.isMonthly,
|
|
85
|
+
nextNumber: s.nextNumber,
|
|
86
|
+
default: s.default,
|
|
87
|
+
sample: DocNumberFormatGenerator.previewDocNo(s),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return data;
|
|
92
|
+
}
|
|
93
|
+
}
|