@simitgroup/simpleapp-generator 2.0.0-d-alpha → 2.0.0-f-alpha
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/ReleaseNote.md +10 -0
- package/dist/buildinschemas/index.d.ts +2 -0
- package/dist/buildinschemas/index.d.ts.map +1 -1
- package/dist/buildinschemas/index.js +5 -3
- package/dist/buildinschemas/index.js.map +1 -1
- package/dist/buildinschemas/webhook.js +1 -1
- package/dist/generate.js +1 -1
- package/dist/generate.js.map +1 -1
- package/dist/processors/jsonschemabuilder.d.ts.map +1 -1
- package/dist/processors/jsonschemabuilder.js +3 -0
- package/dist/processors/jsonschemabuilder.js.map +1 -1
- package/package.json +1 -1
- package/src/buildinschemas/index.ts +2 -2
- package/src/buildinschemas/{webhook.ts.backup → webhook.ts} +1 -1
- package/src/generate.ts +1 -1
- package/src/processors/jsonschemabuilder.ts +4 -2
- package/templates/basic/nest/jsonschema.ts.eta +3 -1
- package/templates/basic/nest/module.ts.eta +2 -2
- package/templates/basic/nest/service.ts.eta +2 -2
- package/templates/nest/src/simple-app/.core/features/document-no-format/document-no-format.module.ts.eta +15 -7
- package/templates/nest/src/simple-app/.core/features/document-no-format/document-no-format.schema.ts.eta +41 -42
- package/templates/nest/src/simple-app/.core/features/document-no-format/document-no-format.service.ts.eta +11 -11
- package/templates/nest/src/simple-app/.core/features/log/log.controller.ts.eta +42 -0
- package/templates/nest/src/simple-app/.core/features/log/log.module.ts.eta +11 -8
- package/templates/nest/src/simple-app/.core/features/log/log.service.ts.eta +42 -12
- package/templates/nest/src/simple-app/.core/features/log/schemas/document-event.schema.ts.eta +23 -1
- package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager-policy.service.ts.eta +13 -6
- package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager.service.ts.eta +5 -2
- package/templates/nest/src/simple-app/.core/features/policy/policy.service.ts.eta +6 -5
- package/templates/nest/src/simple-app/.core/features/profile/profile.controller.ts.eta +29 -16
- package/templates/nest/src/simple-app/.core/features/profile/profile.module.ts.eta +7 -6
- package/templates/nest/src/simple-app/.core/features/profile/profile.schema.ts.eta +8 -8
- package/templates/nest/src/simple-app/.core/features/profile/profile.service.ts.eta +9 -1
- package/templates/nest/src/simple-app/.core/features/queue/queue-base/queue-base.consumer.ts.eta +1 -1
- package/templates/nest/src/simple-app/.core/features/simple-app-core-features.module.ts.eta +3 -3
- package/templates/nest/src/simple-app/.core/features/user-context/user.context.ts.eta +11 -0
- package/templates/nest/src/simple-app/.core/features/webhook/schemas/webhook.schema.ts.eta +36 -36
- package/templates/nest/src/simple-app/.core/framework/base/simple-app.service.ts.eta +3 -3
- package/templates/nest/src/simple-app/.core/framework/json-schemas.dict.ts.eta +11 -0
- package/templates/nest/src/simple-app/mini-apps/mini-apps.module.ts._eta +14 -0
- package/templates/nest/src/simple-app/simple-app.module.ts.eta +5 -1
- package/templates/nuxt/components/form/FormDocnoformat.vue._eta +78 -17
- package/templates/nuxt/components/image/ImageAvatar.vue._eta +40 -32
- package/templates/nuxt/components/image/ImageToBase64Uploader.vue.eta +1 -2
- package/templates/nuxt/components/renderer/RendererDocHistories.vue._eta +90 -50
- package/templates/nuxt/composables/docformat.generate.ts.eta +2 -2
- package/templates/nuxt/pages/profile.vue._eta +2 -7
- package/templates/nuxt/plugins/19.simpleapp-mini-app-store.ts.eta +2 -2
- package/templates/nuxt/types/events.ts.eta +1 -0
- package/templates/nuxt/types/others.ts.eta +8 -0
- /package/src/buildinschemas/{documentnoformat.ts.backup → documentnoformat.ts} +0 -0
|
@@ -7,7 +7,7 @@ import { Injectable, InternalServerErrorException, BadRequestException } from '@
|
|
|
7
7
|
import { alldocuments } from './document.dict';
|
|
8
8
|
import dayjs from 'dayjs';
|
|
9
9
|
|
|
10
|
-
export class
|
|
10
|
+
export class SimpleAppDocumentNoFormatService {
|
|
11
11
|
constructor(@InjectModel('DocumentNoFormat') private docformat: Model<DocumentNoFormat>) {}
|
|
12
12
|
|
|
13
13
|
async runListDocFormats(appUser: UserContext, doctype: string) {
|
|
@@ -33,7 +33,7 @@ export class DocumentNoFormatService {
|
|
|
33
33
|
docNoPattern: s.docNoPattern,
|
|
34
34
|
nextNumber: s.nextNumber,
|
|
35
35
|
default: s.default,
|
|
36
|
-
sample:
|
|
36
|
+
sample: SimpleAppDocumentNoFormatService.previewDocNo(s),
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -66,7 +66,7 @@ export class DocumentNoFormatService {
|
|
|
66
66
|
if (result && result.length > 0) {
|
|
67
67
|
const d: DocumentNoFormat = result[0];
|
|
68
68
|
const recordId = d._id;
|
|
69
|
-
const newdocno =
|
|
69
|
+
const newdocno = SimpleAppDocumentNoFormatService.previewDocNo(d);
|
|
70
70
|
const newnextnumber = d.nextNumber + 1;
|
|
71
71
|
const updatedata = { nextNumber: newnextnumber } as DocumentNoFormat;
|
|
72
72
|
const updateresult = await this.docformat.findByIdAndUpdate(recordId, updatedata).session(appUser.getDBSession());
|
|
@@ -177,13 +177,13 @@ export class DocumentNoFormatService {
|
|
|
177
177
|
}
|
|
178
178
|
};
|
|
179
179
|
|
|
180
|
-
async search
|
|
181
|
-
const isolationFilter:FilterQuery<DocumentNoFormat> = {
|
|
182
|
-
tenantId:appUser.tenantId,
|
|
183
|
-
orgId:appUser.orgId,
|
|
184
|
-
branchId:appUser.branchId,
|
|
185
|
-
}
|
|
186
|
-
Object.assign(filter,isolationFilter)
|
|
187
|
-
return await this.docformat.find<DocumentNoFormat>(filter,null,{session:appUser.getDBSession()})
|
|
180
|
+
async search(appUser, filter: FilterQuery<DocumentNoFormat>) {
|
|
181
|
+
const isolationFilter: FilterQuery<DocumentNoFormat> = {
|
|
182
|
+
tenantId: appUser.tenantId,
|
|
183
|
+
orgId: appUser.orgId,
|
|
184
|
+
branchId: appUser.branchId,
|
|
185
|
+
};
|
|
186
|
+
Object.assign(filter, isolationFilter);
|
|
187
|
+
return await this.docformat.find<DocumentNoFormat>(filter, null, { session: appUser.getDBSession() });
|
|
188
188
|
}
|
|
189
189
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. It is changable.
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* Author: Ks Tan
|
|
5
|
+
*/
|
|
6
|
+
import { Controller, Get, Put, Post, Patch, Delete, Body, Query, Param, Type, Res, HttpStatus, Inject, Injectable, Scope, Req, HttpException, Request, Logger } from '@nestjs/common';
|
|
7
|
+
import { Roles } from '../auth/role-guard/roles.decorator';
|
|
8
|
+
import { Role } from '../auth/role-guard/roles.enum';
|
|
9
|
+
import { ApiTags, ApiBody, ApiResponse, ApiOperation } from '@nestjs/swagger';
|
|
10
|
+
import { UserContext } from '../user-context/user.context';
|
|
11
|
+
import { SimpleAppLogService } from './log.service';
|
|
12
|
+
import { AppUser } from '../user-context/appUser.decorator';
|
|
13
|
+
import { DocumentEventListItem } from './schemas';
|
|
14
|
+
@ApiTags('LOG')
|
|
15
|
+
@Controller('/log')
|
|
16
|
+
export class SimpleAppLogController {
|
|
17
|
+
protected logger = new Logger();
|
|
18
|
+
constructor(private logSvc: SimpleAppLogService) {
|
|
19
|
+
//console.log("init Profile Controller ")
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Get('search/:docName/:id')
|
|
23
|
+
@Roles(Role.User)
|
|
24
|
+
@ApiOperation({
|
|
25
|
+
operationId: 'searchDocumentEvent',
|
|
26
|
+
description: 'Search Document Event',
|
|
27
|
+
})
|
|
28
|
+
@ApiResponse({
|
|
29
|
+
status: 200,
|
|
30
|
+
type: [DocumentEventListItem],
|
|
31
|
+
description: 'Success',
|
|
32
|
+
})
|
|
33
|
+
// @ApiResponse({ status: 401, type: Object, description: 'Expired' })
|
|
34
|
+
async searchDocumentEvent(@AppUser() appUser: UserContext, @Param('docName') docName: string, @Param('id') id: string) {
|
|
35
|
+
const result = await this.logSvc.searchDocumentEvent(appUser, docName, id);
|
|
36
|
+
if (result) {
|
|
37
|
+
return result;
|
|
38
|
+
} else {
|
|
39
|
+
throw new HttpException('Forbidden', HttpStatus.FORBIDDEN);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -6,15 +6,18 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { Module } from '@nestjs/common';
|
|
8
8
|
import { MongooseModule } from '@nestjs/mongoose';
|
|
9
|
-
import { ApiEventMongoSchema,DocumentEventMongoSchema } from './schemas';
|
|
10
|
-
import {SimpleAppLogService} from './log.service'
|
|
9
|
+
import { ApiEventMongoSchema, DocumentEventMongoSchema } from './schemas';
|
|
10
|
+
import { SimpleAppLogService } from './log.service';
|
|
11
|
+
import {SimpleAppLogController} from './log.controller'
|
|
11
12
|
@Module({
|
|
12
|
-
imports: [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
imports: [
|
|
14
|
+
MongooseModule.forFeature([
|
|
15
|
+
{ name: 'ApiEvent', schema: ApiEventMongoSchema },
|
|
16
|
+
{ name: 'DocumentEvent', schema: DocumentEventMongoSchema },
|
|
17
|
+
]),
|
|
18
|
+
],
|
|
19
|
+
controllers: [SimpleAppLogController],
|
|
17
20
|
providers: [SimpleAppLogService],
|
|
18
|
-
exports: [MongooseModule,SimpleAppLogService],
|
|
21
|
+
exports: [MongooseModule, SimpleAppLogService],
|
|
19
22
|
})
|
|
20
23
|
export class SimpleAppLogModule {}
|
|
@@ -17,6 +17,36 @@ export class SimpleAppLogService {
|
|
|
17
17
|
// addEvent(data: any) {
|
|
18
18
|
// console.log('Add event into db:', data);
|
|
19
19
|
// }
|
|
20
|
+
//
|
|
21
|
+
async searchDocumentEvent(appUser: UserContext, documentName: string, id: string) {
|
|
22
|
+
const data = await this.doc.aggregate([
|
|
23
|
+
{ $match: { documentName: documentName, documentId: id } },
|
|
24
|
+
{
|
|
25
|
+
$lookup: {
|
|
26
|
+
from: 'user',
|
|
27
|
+
as: 'user',
|
|
28
|
+
localField: 'createdBy',
|
|
29
|
+
foreignField: 'uid',
|
|
30
|
+
pipeline: [{$match:{tenantId:appUser.getTenantId()}},{ $project: { fullName: 1 } }],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{ $unwind: '$user' },
|
|
34
|
+
{
|
|
35
|
+
$project: {
|
|
36
|
+
_id: 1,
|
|
37
|
+
fullName: '$user.fullName',
|
|
38
|
+
eventType:1,
|
|
39
|
+
createdBy: 1,
|
|
40
|
+
created: 1,
|
|
41
|
+
eventData: 1
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{$sort:{created:1}}
|
|
45
|
+
]);
|
|
46
|
+
// find({documentName:documentName,documentId:id},null,{session:appUser.getDBSession()})
|
|
47
|
+
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
20
50
|
async addEvent(appUser: UserContext, documentName: string, id: string, eventType: string, data: any) {
|
|
21
51
|
const eventdata: DocumentEvent = {
|
|
22
52
|
_id: crypto.randomUUID(),
|
|
@@ -24,13 +54,13 @@ export class SimpleAppLogService {
|
|
|
24
54
|
documentId: id,
|
|
25
55
|
eventType: eventType,
|
|
26
56
|
eventData: data,
|
|
27
|
-
created:'',
|
|
28
|
-
createdBy:'',
|
|
57
|
+
created: '',
|
|
58
|
+
createdBy: '',
|
|
29
59
|
updated: '',
|
|
30
|
-
updatedBy:'',
|
|
31
|
-
tenantId:0,
|
|
32
|
-
orgId:0,
|
|
33
|
-
branchId:0,
|
|
60
|
+
updatedBy: '',
|
|
61
|
+
tenantId: 0,
|
|
62
|
+
orgId: 0,
|
|
63
|
+
branchId: 0,
|
|
34
64
|
};
|
|
35
65
|
Object.assign(eventdata, appUser.getCreateFilter());
|
|
36
66
|
// console.log('add event', documentName, id, eventType);
|
|
@@ -51,13 +81,13 @@ export class SimpleAppLogService {
|
|
|
51
81
|
documentId: data.id,
|
|
52
82
|
eventType: eventType,
|
|
53
83
|
eventData: data,
|
|
54
|
-
created:'',
|
|
55
|
-
createdBy:'',
|
|
84
|
+
created: '',
|
|
85
|
+
createdBy: '',
|
|
56
86
|
updated: '',
|
|
57
|
-
updatedBy:'',
|
|
58
|
-
tenantId:0,
|
|
59
|
-
orgId:0,
|
|
60
|
-
branchId:0,
|
|
87
|
+
updatedBy: '',
|
|
88
|
+
tenantId: 0,
|
|
89
|
+
orgId: 0,
|
|
90
|
+
branchId: 0,
|
|
61
91
|
};
|
|
62
92
|
Object.assign(eventdata, appUser.getCreateFilter());
|
|
63
93
|
alldata.push(eventdata);
|
package/templates/nest/src/simple-app/.core/features/log/schemas/document-event.schema.ts.eta
CHANGED
|
@@ -3,6 +3,28 @@ import { Field, ObjectType, ID } from '@nestjs/graphql';
|
|
|
3
3
|
import GraphQLJSON, { GraphQLJSONObject } from 'graphql-type-json';
|
|
4
4
|
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
5
5
|
|
|
6
|
+
@ObjectType()
|
|
7
|
+
export class DocumentEventListItem {
|
|
8
|
+
@Field()
|
|
9
|
+
@ApiProperty({ type: 'string', required: false, format: 'uuid', default: '' })
|
|
10
|
+
_id: string;
|
|
11
|
+
@Field()
|
|
12
|
+
@ApiProperty({ type: 'string', required: false, format: 'uuid', default: '' })
|
|
13
|
+
eventType: string;
|
|
14
|
+
@Field()
|
|
15
|
+
@ApiProperty({ type: 'string', required: false, format: 'uuid', default: '' })
|
|
16
|
+
created: string;
|
|
17
|
+
@Field()
|
|
18
|
+
@ApiProperty({ type: 'string', required: false, format: 'uuid', default: '' })
|
|
19
|
+
createdBy: string;
|
|
20
|
+
@Field()
|
|
21
|
+
@ApiProperty({ type: 'string', required: false, format: 'uuid', default: '' })
|
|
22
|
+
fullName: string;
|
|
23
|
+
@Field(()=>GraphQLJSON)
|
|
24
|
+
@ApiProperty({ type: ()=>Object, required: false, format: 'uuid', default: '' })
|
|
25
|
+
eventData: any;
|
|
26
|
+
}
|
|
27
|
+
|
|
6
28
|
@ObjectType()
|
|
7
29
|
@Schema()
|
|
8
30
|
export class DocumentEvent {
|
|
@@ -50,7 +72,7 @@ export class DocumentEvent {
|
|
|
50
72
|
@Field()
|
|
51
73
|
@ApiProperty({ type: 'string', required: false, example: ['create', 'delete'], default: '' })
|
|
52
74
|
eventType: string;
|
|
53
|
-
@Prop({type: ()=>Object})
|
|
75
|
+
@Prop({ type: () => Object })
|
|
54
76
|
@Field(() => GraphQLJSON)
|
|
55
77
|
@ApiProperty({ type: () => Object, required: false, default: {} })
|
|
56
78
|
eventData: Object;
|
|
@@ -5,7 +5,7 @@ import { PolicyService } from 'src/simple-app/.core/features/policy/policy.servi
|
|
|
5
5
|
import { Role } from 'src/simple-app/.core/features/auth/role-guard/roles.enum';
|
|
6
6
|
import { UserContext } from 'src/simple-app/.core/features/user-context/user.context';
|
|
7
7
|
import { MiniApp } from '../dto';
|
|
8
|
-
|
|
8
|
+
import * as plans from 'src/simple-app/features/subscription/license/plans'
|
|
9
9
|
@Injectable()
|
|
10
10
|
export class MiniAppManagerPolicyService {
|
|
11
11
|
readonly _RELEASED_STATUSES = [MiniAppStatusEnum.PUBLISHED];
|
|
@@ -30,11 +30,18 @@ export class MiniAppManagerPolicyService {
|
|
|
30
30
|
|
|
31
31
|
hasRequiredPlan(appUser: UserContext, miniApp: MiniApp) {
|
|
32
32
|
const currentPlan = appUser.tenantInfo.package;
|
|
33
|
-
const requiredPlans = miniApp.access.requiredPlans ?? [];
|
|
34
|
-
|
|
35
|
-
if
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
// const requiredPlans = miniApp.access.requiredPlans ?? [];
|
|
34
|
+
|
|
35
|
+
if(plans[currentPlan]){
|
|
36
|
+
const plansetting = plans[currentPlan]()
|
|
37
|
+
return plansetting?.features?.advance?.features?.miniApp ?? false
|
|
38
|
+
|
|
39
|
+
}else{
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
// if (_.isEmpty(requiredPlans)) return true;
|
|
43
|
+
|
|
44
|
+
// return requiredPlans.includes(currentPlan);
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
isMiniAppRealeased(status: MiniAppStatusEnum) {
|
|
@@ -9,7 +9,7 @@ import { MiniAppInstallationService } from 'src/simple-app/.core/resources/mini-
|
|
|
9
9
|
import _ from 'lodash';
|
|
10
10
|
import { MiniAppManagerPolicyService } from './mini-app-manager-policy.service';
|
|
11
11
|
import { MiniAppError } from './mini-app-manager.error';
|
|
12
|
-
|
|
12
|
+
import * as plans from 'src/simple-app/features/subscription/license/plans'
|
|
13
13
|
@Injectable()
|
|
14
14
|
export class MiniAppManagerService {
|
|
15
15
|
constructor(
|
|
@@ -82,7 +82,7 @@ export class MiniAppManagerService {
|
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
const permissions = this.getMiniAppActionAccess(appUser);
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
const installedMiniApps = miniAppInstallations.map((installation) => {
|
|
87
87
|
const miniApp = miniApps.find((miniApp) => miniApp._id === installation.miniApp._id);
|
|
88
88
|
if (!miniApp) {
|
|
@@ -176,6 +176,9 @@ export class MiniAppManagerService {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
private getMiniAppActionAccess(appUser: UserContext) {
|
|
179
|
+
const currentPlan = appUser.tenantInfo.package;
|
|
180
|
+
const planSetting = plans[currentPlan]()
|
|
181
|
+
|
|
179
182
|
return {
|
|
180
183
|
hasMiniAppFeature: this.policyService.hasFeature(appUser),
|
|
181
184
|
canInstall: this.policyService.canInstall(appUser),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { Role } from 'src/simple-app/.core/features/auth/role-guard/roles.enum';
|
|
3
3
|
import { UserContext } from 'src/simple-app/.core/features/user-context/user.context';
|
|
4
|
-
|
|
4
|
+
import * as plans from 'src/simple-app/features/subscription/license/plans'
|
|
5
5
|
@Injectable()
|
|
6
6
|
export class PolicyService {
|
|
7
7
|
private readonly _HIGH_PRIVILEGE_ROLES = [Role.SuperAdmin, Role.SuperUser, Role.TenantOwner];
|
|
@@ -27,11 +27,12 @@ export class PolicyService {
|
|
|
27
27
|
* - plans/pro.ts
|
|
28
28
|
* - plans/enterprise.ts
|
|
29
29
|
*/
|
|
30
|
-
hasFeature(appUser: UserContext, feature: keyof typeof this._FEATURES): boolean {
|
|
31
|
-
const appPackage = appUser.tenantInfo.package
|
|
30
|
+
hasFeature(appUser: UserContext, feature: keyof typeof this._FEATURES): boolean {
|
|
31
|
+
const appPackage = appUser.tenantInfo.package;
|
|
32
32
|
const allowedPlans = this._FEATURES[feature];
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const planSetting = plans[appPackage]();
|
|
34
|
+
const allowed = planSetting.features?.advance?.features[feature] ?? false;
|
|
35
|
+
return allowed
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
can(appUser: UserContext, role: Role) {
|
|
@@ -9,8 +9,8 @@ import { Role } from '../auth/role-guard/roles.enum';
|
|
|
9
9
|
import { ApiTags, ApiBody, ApiResponse, ApiOperation } from '@nestjs/swagger';
|
|
10
10
|
import { UserContext } from '../user-context/user.context';
|
|
11
11
|
import { ProfileService } from './profile.service';
|
|
12
|
-
import { AppUser } from '../user-context/
|
|
13
|
-
import { UserContextInfo, TenantPermission, RegTenant } from './profile.schema';
|
|
12
|
+
import { AppUser } from '../user-context/appUser.decorator';
|
|
13
|
+
import { UserContextInfo, TenantPermission, RegTenant, KeyValue } from './profile.schema';
|
|
14
14
|
@ApiTags('PROFILE')
|
|
15
15
|
@Controller('/profile')
|
|
16
16
|
export class ProfileController {
|
|
@@ -31,9 +31,9 @@ export class ProfileController {
|
|
|
31
31
|
description: 'Success',
|
|
32
32
|
})
|
|
33
33
|
@ApiResponse({ status: 401, type: Object, description: 'Undefine profile' })
|
|
34
|
-
async getProfile(@AppUser()
|
|
35
|
-
this.logger.debug(`access getProfile API by ${
|
|
36
|
-
const result = await this.profileservice.getProfile(
|
|
34
|
+
async getProfile(@AppUser() appUser: UserContext) {
|
|
35
|
+
this.logger.debug(`access getProfile API by ${appUser.getUid()},(${appUser.getId()})`);
|
|
36
|
+
const result = await this.profileservice.getProfile(appUser);
|
|
37
37
|
this.logger.debug('getProfile result is:');
|
|
38
38
|
this.logger.debug(result);
|
|
39
39
|
if (result) {
|
|
@@ -55,8 +55,8 @@ export class ProfileController {
|
|
|
55
55
|
description: 'Success',
|
|
56
56
|
})
|
|
57
57
|
@ApiResponse({ status: 401, type: Object, description: 'Expired' })
|
|
58
|
-
async getSession(@AppUser()
|
|
59
|
-
const result = await this.profileservice.getSession(
|
|
58
|
+
async getSession(@AppUser() appUser: UserContext) {
|
|
59
|
+
const result = await this.profileservice.getSession(appUser);
|
|
60
60
|
if (result) {
|
|
61
61
|
return result;
|
|
62
62
|
} else {
|
|
@@ -76,9 +76,9 @@ export class ProfileController {
|
|
|
76
76
|
description: 'Success',
|
|
77
77
|
})
|
|
78
78
|
@ApiResponse({ status: 401, type: Object, description: 'Undefine profile' })
|
|
79
|
-
async getAllTenants(@AppUser()
|
|
80
|
-
this.logger.debug(`access getAllTenants API by ${
|
|
81
|
-
const result = await this.profileservice.getAllTenants(
|
|
79
|
+
async getAllTenants(@AppUser() appUser: UserContext) {
|
|
80
|
+
this.logger.debug(`access getAllTenants API by ${appUser.getUid()},(${appUser.getId()})`);
|
|
81
|
+
const result = await this.profileservice.getAllTenants(appUser);
|
|
82
82
|
this.logger.debug('getProfile result is:');
|
|
83
83
|
this.logger.debug(result);
|
|
84
84
|
if (result) {
|
|
@@ -88,6 +88,19 @@ export class ProfileController {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
@Post('photo')
|
|
92
|
+
@Roles(Role.Everyone)
|
|
93
|
+
@ApiBody({ description: 'base64 photo', type: KeyValue })
|
|
94
|
+
@ApiOperation({
|
|
95
|
+
operationId: 'uploadPhoto',
|
|
96
|
+
description: 'Upload avatar image with base64',
|
|
97
|
+
})
|
|
98
|
+
@ApiResponse({ status: 201, type: String, description: 'Success' })
|
|
99
|
+
async uploadImage(@AppUser() appUser: UserContext, @Body() data: KeyValue) {
|
|
100
|
+
const result = await this.profileservice.uploadPhoto(appUser, data);
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
|
|
91
104
|
@Post('/tenant')
|
|
92
105
|
@Roles(Role.Everyone)
|
|
93
106
|
@ApiBody({ description: 'create tenant name', type: RegTenant })
|
|
@@ -97,13 +110,13 @@ export class ProfileController {
|
|
|
97
110
|
})
|
|
98
111
|
@ApiResponse({ status: 201, type: Object, description: 'Success' })
|
|
99
112
|
async createTenant(
|
|
100
|
-
@AppUser()
|
|
113
|
+
@AppUser() appUser: UserContext,
|
|
101
114
|
@Body('tenantName') tenantName: string,
|
|
102
115
|
@Body('timeZone') timeZone: string,
|
|
103
116
|
@Body('utcOffset') utcOffset: number,
|
|
104
117
|
@Body('businessType') businessType: string,
|
|
105
118
|
) {
|
|
106
|
-
const result = await this.profileservice.createTenant(
|
|
119
|
+
const result = await this.profileservice.createTenant(appUser, tenantName, timeZone, utcOffset, businessType);
|
|
107
120
|
if (result) {
|
|
108
121
|
return result;
|
|
109
122
|
} else {
|
|
@@ -118,8 +131,8 @@ export class ProfileController {
|
|
|
118
131
|
description: 'accept or reject invitation to tenant',
|
|
119
132
|
})
|
|
120
133
|
@ApiResponse({ status: 201, type: Object, description: 'Success' })
|
|
121
|
-
async decideInvitation(@AppUser()
|
|
122
|
-
const result = await this.profileservice.decideInvitation(
|
|
134
|
+
async decideInvitation(@AppUser() appUser: UserContext, @Param('id') id: string, @Param('decision') decision: string) {
|
|
135
|
+
const result = await this.profileservice.decideInvitation(appUser, id, decision);
|
|
123
136
|
if (result) {
|
|
124
137
|
return result;
|
|
125
138
|
} else {
|
|
@@ -133,8 +146,8 @@ export class ProfileController {
|
|
|
133
146
|
description: 'complete specific tour guide',
|
|
134
147
|
})
|
|
135
148
|
@ApiResponse({ status: 201, type: Object, description: 'Success' })
|
|
136
|
-
async runTourComplete(@AppUser()
|
|
137
|
-
const result = await this.profileservice.runTourComplete(
|
|
149
|
+
async runTourComplete(@AppUser() appUser: UserContext, @Param('guidename') guidename: string) {
|
|
150
|
+
const result = await this.profileservice.runTourComplete(appUser, guidename);
|
|
138
151
|
if (result) {
|
|
139
152
|
return result;
|
|
140
153
|
} else {
|
|
@@ -8,13 +8,14 @@ import { Module } from '@nestjs/common';
|
|
|
8
8
|
import { MongooseModule } from '@nestjs/mongoose';
|
|
9
9
|
import { ProfileService } from './profile.service';
|
|
10
10
|
import { ProfileController } from './profile.controller';
|
|
11
|
-
import {UserModule} from '../../resources/user/user.module'
|
|
12
|
-
import {PermissionModule} from '../../resources/permission/permission.module'
|
|
13
|
-
import {TenantModule} from '../../resources/tenant/tenant.module'
|
|
14
|
-
import {BranchModule} from '../../resources/branch/branch.module'
|
|
15
|
-
import {OrganizationModule} from '../../resources/organization/organization.module'
|
|
11
|
+
import { UserModule } from '../../resources/user/user.module';
|
|
12
|
+
import { PermissionModule } from '../../resources/permission/permission.module';
|
|
13
|
+
import { TenantModule } from '../../resources/tenant/tenant.module';
|
|
14
|
+
import { BranchModule } from '../../resources/branch/branch.module';
|
|
15
|
+
import { OrganizationModule } from '../../resources/organization/organization.module';
|
|
16
|
+
import { PhotoModule } from 'src/simple-app/features/upload-file/photo/photo.module';
|
|
16
17
|
@Module({
|
|
17
|
-
imports: [UserModule,PermissionModule,TenantModule,OrganizationModule,BranchModule],
|
|
18
|
+
imports: [UserModule, PermissionModule, TenantModule, OrganizationModule, BranchModule, PhotoModule],
|
|
18
19
|
controllers: [ProfileController],
|
|
19
20
|
providers: [ProfileService],
|
|
20
21
|
exports: [ProfileService],
|
|
@@ -5,7 +5,7 @@ import { Permission } from 'src/simple-app/.core/resources/permission/permission
|
|
|
5
5
|
import { Role } from '../auth/role-guard/roles.enum';
|
|
6
6
|
import { Organization } from '../../resources/organization/organization.schema';
|
|
7
7
|
import { Tenant } from '../../resources/tenant/tenant.schema';
|
|
8
|
-
|
|
8
|
+
export {KeyValue} from '../../framework/schemas';
|
|
9
9
|
export class UserContextInfo {
|
|
10
10
|
@ApiProperty({ type: String })
|
|
11
11
|
_id: string;
|
|
@@ -59,13 +59,13 @@ export class UserContextInfo {
|
|
|
59
59
|
@ApiProperty({ type: () => [ProfileUserBranch], description: 'List of branch the user can access in current tenant' })
|
|
60
60
|
branches: ProfileUserBranch[];
|
|
61
61
|
|
|
62
|
-
@ApiProperty({ type: ()=>Tenant, description: 'List of task, or authority of the user can do' })
|
|
63
|
-
tenantInfo:Tenant;
|
|
64
|
-
@ApiProperty({ type: ()=>Organization, description: 'List of task, or authority of the user can do' })
|
|
65
|
-
orgInfo:Organization;
|
|
66
|
-
@ApiProperty({ type: ()=>Branch, description: 'List of task, or authority of the user can do' })
|
|
67
|
-
branchInfo:Branch;
|
|
68
|
-
|
|
62
|
+
@ApiProperty({ type: () => Tenant, description: 'List of task, or authority of the user can do' })
|
|
63
|
+
tenantInfo: Tenant;
|
|
64
|
+
@ApiProperty({ type: () => Organization, description: 'List of task, or authority of the user can do' })
|
|
65
|
+
orgInfo: Organization;
|
|
66
|
+
@ApiProperty({ type: () => Branch, description: 'List of task, or authority of the user can do' })
|
|
67
|
+
branchInfo: Branch;
|
|
68
|
+
|
|
69
69
|
@ApiProperty({ type: () => Object, description: 'Store all the rest of useful fields regarding user or branch' })
|
|
70
70
|
moreProps?: Record<string, any>;
|
|
71
71
|
}
|
|
@@ -21,9 +21,10 @@ import { Tenant } from '../../resources/tenant/tenant.schema';
|
|
|
21
21
|
import { Organization } from '../../resources/organization/organization.schema';
|
|
22
22
|
import { Branch } from '../../resources/branch/branch.schema';
|
|
23
23
|
import { User } from '../../resources/user/user.schema';
|
|
24
|
-
import { Permission } from '../../resources/permission/permission.schema'
|
|
24
|
+
import { KeyValue, Permission } from '../../resources/permission/permission.schema';
|
|
25
25
|
|
|
26
26
|
import { UserContextInfo } from './profile.schema';
|
|
27
|
+
import { PhotoService } from 'src/simple-app/features/upload-file/photo/photo.service';
|
|
27
28
|
const Base64URL = require('@darkwolf/base64url');
|
|
28
29
|
@Injectable()
|
|
29
30
|
export class ProfileService {
|
|
@@ -34,6 +35,7 @@ export class ProfileService {
|
|
|
34
35
|
private orgsvc: OrganizationService,
|
|
35
36
|
private branchsvc: BranchService,
|
|
36
37
|
private permsvc: PermissionService,
|
|
38
|
+
private uploadImageSvc: PhotoService,
|
|
37
39
|
) {}
|
|
38
40
|
|
|
39
41
|
/**
|
|
@@ -265,4 +267,10 @@ export class ProfileService {
|
|
|
265
267
|
|
|
266
268
|
return 'ok';
|
|
267
269
|
}
|
|
270
|
+
|
|
271
|
+
async uploadPhoto(appuser, data: KeyValue) {
|
|
272
|
+
const fileName = `user/${appuser.getUid()}`;
|
|
273
|
+
await this.uploadImageSvc.sendBase64Image(data.value, fileName, 0);
|
|
274
|
+
return 'ok';
|
|
275
|
+
}
|
|
268
276
|
}
|
package/templates/nest/src/simple-app/.core/features/queue/queue-base/queue-base.consumer.ts.eta
CHANGED
|
@@ -35,7 +35,7 @@ export abstract class BaseQueueConsumer extends WorkerHost {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
async process(job: Job) {
|
|
38
|
-
console.log("process job", job.data)
|
|
38
|
+
// console.log("process job", job.data)
|
|
39
39
|
const { userContext, payload } = job.data
|
|
40
40
|
|
|
41
41
|
const appUser = this.createUserContext(userContext.user);
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { Module } from '@nestjs/common';
|
|
8
8
|
|
|
9
9
|
import { SimpleAppAuthModule } from './auth/auth.module';
|
|
10
|
-
import {
|
|
10
|
+
import { SimpleAppDocumentNoFormatModule } from './document-no-format/document-no-format.module';
|
|
11
11
|
import { SimpleAppForeignKeyModule } from './foreign-key/foreign-key.module';
|
|
12
12
|
import { SimpleAppLogModule } from './log/log.module';
|
|
13
13
|
import { MaintenanceModule } from './maintenance/maintenance.module';
|
|
@@ -22,7 +22,7 @@ import { AutoIncreamentModule } from './auto-increament/auto-increament.module';
|
|
|
22
22
|
imports: [
|
|
23
23
|
AutoIncreamentModule,
|
|
24
24
|
SimpleAppAuthModule,
|
|
25
|
-
|
|
25
|
+
SimpleAppDocumentNoFormatModule,
|
|
26
26
|
SimpleAppForeignKeyModule,
|
|
27
27
|
SimpleAppLogModule,
|
|
28
28
|
MaintenanceModule,
|
|
@@ -37,7 +37,7 @@ import { AutoIncreamentModule } from './auto-increament/auto-increament.module';
|
|
|
37
37
|
exports: [
|
|
38
38
|
AutoIncreamentModule,
|
|
39
39
|
SimpleAppAuthModule,
|
|
40
|
-
|
|
40
|
+
SimpleAppDocumentNoFormatModule,
|
|
41
41
|
SimpleAppForeignKeyModule,
|
|
42
42
|
SimpleAppLogModule,
|
|
43
43
|
MaintenanceModule,
|
|
@@ -1000,6 +1000,17 @@ export class UserContext extends UserContextInfo {
|
|
|
1000
1000
|
return miniAppInstallation;
|
|
1001
1001
|
}
|
|
1002
1002
|
|
|
1003
|
+
async findInstalledMiniAppCode(miniAppCode: string) {
|
|
1004
|
+
const miniAppInstallation = await this.miniAppInstallationModel.findOne({
|
|
1005
|
+
'miniApp.code': miniAppCode,
|
|
1006
|
+
isActive: true,
|
|
1007
|
+
tenantId: this.tenantId,
|
|
1008
|
+
orgId: this.orgId,
|
|
1009
|
+
branchId: this.branchId,
|
|
1010
|
+
});
|
|
1011
|
+
return miniAppInstallation.miniApp;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1003
1014
|
async setUserProfileFromDB() {
|
|
1004
1015
|
// const userProfile = await this.obtainProfileFromDB();
|
|
1005
1016
|
// if (userProfile) {
|