@simitgroup/simpleapp-generator 2.0.0-u-alpha → 2.0.0-w-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/package.json +1 -1
- package/templates/basic/miniApi/resource.controller.ts.eta +14 -0
- package/templates/basic/miniApi/resource.service.ts.eta +6 -0
- package/templates/basic/nest/controller.ts.eta +70 -76
- package/templates/basic/nuxt/pages.form.vue.eta +2 -2
- package/templates/basic/nuxt/pages.landing.vue.eta +2 -2
- package/templates/miniApi/src/constants/api-scopes.ts.eta +18 -0
- package/templates/nest/src/main.ts._eta +14 -19
- package/templates/nest/src/simple-app/_core/features/user-context/user.context.ts.eta +1 -4
- package/templates/nest/src/simple-app/_core/framework/base/simple-app.controller.ts.eta +12 -2
- package/templates/nest/src/simple-app/_core/framework/base/simple-app.service.ts.eta +3 -4
- package/templates/nuxt/components/simpleApp/SimpleAppFormToolBar.vue._eta +1 -1
- package/templates/nuxt/server/api/[xorg]/[...].ts._eta +76 -121
- package/templates/nest/src/simple-app/features/print/api/.gitignore.eta +0 -4
- package/templates/nest/src/simple-app/features/print/api/.npmignore.eta +0 -1
- package/templates/nest/src/simple-app/features/print/api/.openapi-generator/FILES.eta +0 -8
- package/templates/nest/src/simple-app/features/print/api/.openapi-generator/VERSION.eta +0 -1
- package/templates/nest/src/simple-app/features/print/api/.openapi-generator-ignore.eta +0 -23
- package/templates/nest/src/simple-app/features/print/api/api.ts.eta +0 -223
- package/templates/nest/src/simple-app/features/print/api/base.ts.eta +0 -86
- package/templates/nest/src/simple-app/features/print/api/common.ts.eta +0 -150
- package/templates/nest/src/simple-app/features/print/api/configuration.ts.eta +0 -110
- package/templates/nest/src/simple-app/features/print/api/git_push.sh.eta +0 -57
- package/templates/nest/src/simple-app/features/print/api/index.ts.eta +0 -18
- package/templates/nest/src/simple-app/features/print/api/openapitools.json.eta +0 -7
- package/templates/nest/src/simple-app/features/print/print.module.ts.eta +0 -15
- package/templates/nest/src/simple-app/features/print/print.service.ts.eta +0 -41
package/ReleaseNote.md
CHANGED
package/package.json
CHANGED
|
@@ -120,6 +120,20 @@ export class <%= pascalName %>Controller {
|
|
|
120
120
|
) {
|
|
121
121
|
return await this.<%= serviceVariable %>.patch(headers, id, resourceDto);
|
|
122
122
|
}
|
|
123
|
+
<% } else if(action === 'patchMany') { %>
|
|
124
|
+
@Patch('patchMany')
|
|
125
|
+
@ApiOperation({ operationId: 'patchMany' })
|
|
126
|
+
@ApiBody({ type: SimtrainSchema.PatchManyRequestDto, required: true })
|
|
127
|
+
@ApiResponse({ status: 200, description: 'Success', type: SimtrainSchema.UpdateManyResponseDto })
|
|
128
|
+
@ApiResponse({ status: 400, description: 'Bad Request' })
|
|
129
|
+
@ApiResponse({ status: 404, description: 'Not Found' })
|
|
130
|
+
@ApiResponse({ status: 500, description: 'Internal Error' })
|
|
131
|
+
async patchMany(
|
|
132
|
+
@Headers() headers: ApiHeader,
|
|
133
|
+
@Body() resourceDto: any,
|
|
134
|
+
) {
|
|
135
|
+
return await this.<%= serviceVariable %>.patchMany(headers, resourceDto);
|
|
136
|
+
}
|
|
123
137
|
<% } else if(action === 'delete') { %>
|
|
124
138
|
@Delete(':id')
|
|
125
139
|
@ApiOperation({ operationId: 'delete' })
|
|
@@ -86,6 +86,12 @@ export class <%= pascalName %>Service {
|
|
|
86
86
|
const resp = await api.runPatch(id, resourceDto);
|
|
87
87
|
return resp.data;
|
|
88
88
|
}
|
|
89
|
+
<% } else if(action === 'patchMany') { %>
|
|
90
|
+
async patchMany(headers: ApiHeader, resourceDto: any) {
|
|
91
|
+
const api = this.getApi(headers);
|
|
92
|
+
const resp = await api.runPatchMany(resourceDto);
|
|
93
|
+
return resp.data;
|
|
94
|
+
}
|
|
89
95
|
<% } else if(action === 'delete') { %>
|
|
90
96
|
async delete(headers: ApiHeader, id: string) {
|
|
91
97
|
const api = this.getApi(headers);
|
|
@@ -81,52 +81,6 @@ export class <%= it.typename %>Controller extends SimpleAppController<
|
|
|
81
81
|
async runDefault(@AppUser() appuser: UserContext) {
|
|
82
82
|
return await this.service.runDefault(appuser)
|
|
83
83
|
}
|
|
84
|
-
//autocomplete shall above :id
|
|
85
|
-
@Post('/autocomplete')
|
|
86
|
-
<%if(superadmindoctype.includes(it.doctype)){%>
|
|
87
|
-
@Roles(Role.SuperAdmin,Role.<%= `${it.typename}_search`%>)
|
|
88
|
-
<%}else{%>
|
|
89
|
-
@Roles(Role.SuperAdmin,Role.SuperUser,Role.User)
|
|
90
|
-
<%}%>
|
|
91
|
-
@ApiResponse({
|
|
92
|
-
status: 200,
|
|
93
|
-
description: 'Found',
|
|
94
|
-
type: schemas.<%= it.typename %>AutoComplete,
|
|
95
|
-
isArray: true,
|
|
96
|
-
})
|
|
97
|
-
@ApiResponse({ status: 500, description: 'Internal error' })
|
|
98
|
-
@ApiQuery({ name: 'keyword', type:String})
|
|
99
|
-
@ApiBody({ description: 'Data', type: ()=>Object})
|
|
100
|
-
@ApiOperation({ operationId: 'autoComplete',description:"retrieve array of {_id, code, name}" })
|
|
101
|
-
<%~ drawMiniAppScope('autoComplete') %>
|
|
102
|
-
async autoComplete(@AppUser() appuser: UserContext,
|
|
103
|
-
@Query('keyword') keyword:string,
|
|
104
|
-
@Body() data: schemas.<%=it.typename%>,
|
|
105
|
-
) {
|
|
106
|
-
return this._autocomplete(appuser, keyword,data);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
@Post()
|
|
112
|
-
<%if(superadmindoctype.includes(it.doctype)){%>
|
|
113
|
-
@Roles(Role.SuperAdmin,Role.<%= `${it.typename}_create`%>)
|
|
114
|
-
<%}else{%>
|
|
115
|
-
@Roles(Role.SuperAdmin,Role.SuperUser,Role.<%= `${it.typename}_create`%>)
|
|
116
|
-
<%}%>
|
|
117
|
-
@ApiResponse({
|
|
118
|
-
status: 201,
|
|
119
|
-
description: 'success',
|
|
120
|
-
type: schemas.<%= it.typename%>
|
|
121
|
-
})
|
|
122
|
-
@ApiResponse({ status: 400, description: 'bad request' })
|
|
123
|
-
@ApiResponse({ status: 500, description: 'internal error' })
|
|
124
|
-
@ApiBody({ description: 'Data',type:schemas.<%= it.typename%> })
|
|
125
|
-
@ApiOperation({ operationId: 'runCreate' })
|
|
126
|
-
<%~ drawMiniAppScope('create') %>
|
|
127
|
-
async create(@AppUser() appuser: UserContext,@Body() data: schemas.<%= it.typename%>) {
|
|
128
|
-
return await this._create(appuser,data)
|
|
129
|
-
}
|
|
130
84
|
|
|
131
85
|
@Post('/search')
|
|
132
86
|
@HttpCode(200)
|
|
@@ -149,7 +103,6 @@ export class <%= it.typename %>Controller extends SimpleAppController<
|
|
|
149
103
|
return await this._search(appuser,data)
|
|
150
104
|
}
|
|
151
105
|
|
|
152
|
-
|
|
153
106
|
<% if(simpleappconfig.search !==undefined){%>
|
|
154
107
|
@Post('/fulltextsearch')
|
|
155
108
|
@HttpCode(200)
|
|
@@ -171,33 +124,6 @@ export class <%= it.typename %>Controller extends SimpleAppController<
|
|
|
171
124
|
}
|
|
172
125
|
<%}%>
|
|
173
126
|
|
|
174
|
-
|
|
175
|
-
@Patch('bulk-patch')
|
|
176
|
-
@ApiResponse({ status: 200, description: 'success',})
|
|
177
|
-
@Roles(Role.SuperAdmin, Role.SuperUser, Role.<%= it.typename%>_update)
|
|
178
|
-
@ApiResponse({ status: 404, description: 'Document not found' })
|
|
179
|
-
@ApiResponse({ status: 500, description: 'Internal error' })
|
|
180
|
-
@ApiBody({ description: 'Data', type: schemas.PatchManyRequest<schemas.<%= it.typename%>> })
|
|
181
|
-
@ApiOperation({ operationId: 'runPatchMany' })
|
|
182
|
-
<%~ drawMiniAppScope('patch-many') %>
|
|
183
|
-
async patchMany(@AppUser() appuser: UserContext, @Param('id') id: string, @Body() patchManyData: schemas.PatchManyRequest<schemas.<%= it.typename%>>) {
|
|
184
|
-
return await this._patchMany(appuser, id, patchManyData);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
/***************************** start status control api definitions *****************************************/
|
|
189
|
-
<%for(let s=0; s<it.docStatusSettings.length; s++){ %>
|
|
190
|
-
<%let statusconf = it.docStatusSettings[s]%>
|
|
191
|
-
<%let statusname = statusconf['status']%>
|
|
192
|
-
@Post(':id/set-<%=statusname%>')
|
|
193
|
-
@ApiBody({ description: 'Document data', type: Object })
|
|
194
|
-
@Roles(Role.SuperAdmin,Role.<%= `${it.typename}_${statusname}`%>)
|
|
195
|
-
async setStatus<%=capitalizeFirstLetter(statusname)%>(@AppUser() appuser: UserContext,@Param('id') id: string, @Body() data:any,){
|
|
196
|
-
return await this.service.setDocumentStatus(appuser,id,data,'<%=statusname%>',)
|
|
197
|
-
}
|
|
198
|
-
<%}%>
|
|
199
|
-
/***************************** end status control api definitions *****************************************/
|
|
200
|
-
|
|
201
127
|
@Get(':id')
|
|
202
128
|
<%if(superadmindoctype.includes(it.doctype)){%>
|
|
203
129
|
@Roles(Role.SuperAdmin,Role.<%= `${it.typename}_search`%>)
|
|
@@ -221,8 +147,52 @@ export class <%= it.typename %>Controller extends SimpleAppController<
|
|
|
221
147
|
return data
|
|
222
148
|
}
|
|
223
149
|
}
|
|
224
|
-
|
|
225
150
|
|
|
151
|
+
//autocomplete shall above :id
|
|
152
|
+
@Post('/autocomplete')
|
|
153
|
+
<%if(superadmindoctype.includes(it.doctype)){%>
|
|
154
|
+
@Roles(Role.SuperAdmin,Role.<%= `${it.typename}_search`%>)
|
|
155
|
+
<%}else{%>
|
|
156
|
+
@Roles(Role.SuperAdmin,Role.SuperUser,Role.User)
|
|
157
|
+
<%}%>
|
|
158
|
+
@ApiResponse({
|
|
159
|
+
status: 200,
|
|
160
|
+
description: 'Found',
|
|
161
|
+
type: schemas.<%= it.typename %>AutoComplete,
|
|
162
|
+
isArray: true,
|
|
163
|
+
})
|
|
164
|
+
@ApiResponse({ status: 500, description: 'Internal error' })
|
|
165
|
+
@ApiQuery({ name: 'keyword', type:String})
|
|
166
|
+
@ApiBody({ description: 'Data', type: ()=>Object})
|
|
167
|
+
@ApiOperation({ operationId: 'autoComplete',description:"retrieve array of {_id, code, name}" })
|
|
168
|
+
<%~ drawMiniAppScope('autoComplete') %>
|
|
169
|
+
async autoComplete(@AppUser() appuser: UserContext,
|
|
170
|
+
@Query('keyword') keyword:string,
|
|
171
|
+
@Body() data: schemas.<%=it.typename%>,
|
|
172
|
+
) {
|
|
173
|
+
return this._autocomplete(appuser, keyword,data);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
@Post()
|
|
177
|
+
<%if(superadmindoctype.includes(it.doctype)){%>
|
|
178
|
+
@Roles(Role.SuperAdmin,Role.<%= `${it.typename}_create`%>)
|
|
179
|
+
<%}else{%>
|
|
180
|
+
@Roles(Role.SuperAdmin,Role.SuperUser,Role.<%= `${it.typename}_create`%>)
|
|
181
|
+
<%}%>
|
|
182
|
+
@ApiResponse({
|
|
183
|
+
status: 201,
|
|
184
|
+
description: 'success',
|
|
185
|
+
type: schemas.<%= it.typename%>
|
|
186
|
+
})
|
|
187
|
+
@ApiResponse({ status: 400, description: 'bad request' })
|
|
188
|
+
@ApiResponse({ status: 500, description: 'internal error' })
|
|
189
|
+
@ApiBody({ description: 'Data',type:schemas.<%= it.typename%> })
|
|
190
|
+
@ApiOperation({ operationId: 'runCreate' })
|
|
191
|
+
<%~ drawMiniAppScope('create') %>
|
|
192
|
+
async create(@AppUser() appuser: UserContext,@Body() data: schemas.<%= it.typename%>) {
|
|
193
|
+
return await this._create(appuser,data)
|
|
194
|
+
}
|
|
195
|
+
|
|
226
196
|
@Put(':id')
|
|
227
197
|
@ApiResponse({
|
|
228
198
|
status: 200,
|
|
@@ -241,6 +211,7 @@ export class <%= it.typename %>Controller extends SimpleAppController<
|
|
|
241
211
|
async update(@AppUser() appuser: UserContext,@Param('id') id: string, @Body() data: schemas.<%= it.typename%>) {
|
|
242
212
|
return await this._update(appuser,id, data) ;
|
|
243
213
|
}
|
|
214
|
+
|
|
244
215
|
@Patch(':id')
|
|
245
216
|
@ApiResponse({
|
|
246
217
|
status: 200,
|
|
@@ -260,6 +231,18 @@ export class <%= it.typename %>Controller extends SimpleAppController<
|
|
|
260
231
|
return await this._patch(appuser,id, data) ;
|
|
261
232
|
}
|
|
262
233
|
|
|
234
|
+
@Patch('bulk-patch')
|
|
235
|
+
@ApiResponse({ status: 200, description: 'success', type: schemas.UpdateManyResponse})
|
|
236
|
+
@Roles(Role.SuperAdmin, Role.SuperUser, Role.<%= it.typename%>_update)
|
|
237
|
+
@ApiResponse({ status: 404, description: 'Document not found' })
|
|
238
|
+
@ApiResponse({ status: 500, description: 'Internal error' })
|
|
239
|
+
@ApiBody({ description: 'Data', type: schemas.PatchManyRequest<schemas.<%= it.typename%>> })
|
|
240
|
+
@ApiOperation({ operationId: 'runPatchMany' })
|
|
241
|
+
<%~ drawMiniAppScope('patch-many') %>
|
|
242
|
+
async patchMany(@AppUser() appuser: UserContext, @Body() patchManyData: schemas.PatchManyRequest<schemas.<%= it.typename%>>) {
|
|
243
|
+
return await this._patchMany(appuser, patchManyData);
|
|
244
|
+
}
|
|
245
|
+
|
|
263
246
|
@Delete(':id')
|
|
264
247
|
<%if(superadmindoctype.includes(it.doctype)){%>
|
|
265
248
|
@Roles(Role.SuperAdmin,Role.<%= `${it.typename}_delete`%>)
|
|
@@ -279,6 +262,17 @@ export class <%= it.typename %>Controller extends SimpleAppController<
|
|
|
279
262
|
return this._delete(appuser,id);
|
|
280
263
|
}
|
|
281
264
|
|
|
282
|
-
|
|
265
|
+
/***************************** start status control api definitions *****************************************/
|
|
266
|
+
<%for(let s=0; s<it.docStatusSettings.length; s++){ %>
|
|
267
|
+
<%let statusconf = it.docStatusSettings[s]%>
|
|
268
|
+
<%let statusname = statusconf['status']%>
|
|
269
|
+
@Post(':id/set-<%=statusname%>')
|
|
270
|
+
@ApiBody({ description: 'Document data', type: Object })
|
|
271
|
+
@Roles(Role.SuperAdmin,Role.<%= `${it.typename}_${statusname}`%>)
|
|
272
|
+
async setStatus<%=capitalizeFirstLetter(statusname)%>(@AppUser() appuser: UserContext,@Param('id') id: string, @Body() data:any,){
|
|
273
|
+
return await this.service.setDocumentStatus(appuser,id,data,'<%=statusname%>',)
|
|
274
|
+
}
|
|
275
|
+
<%}%>
|
|
276
|
+
/***************************** end status control api definitions *****************************************/
|
|
283
277
|
|
|
284
278
|
}
|
|
@@ -146,10 +146,10 @@
|
|
|
146
146
|
*/
|
|
147
147
|
import { SimpleAppInputType,FormCrudEvent } from "~/types";
|
|
148
148
|
import { <%= it.typename %> } from "~/simpleapp/generate/types";
|
|
149
|
-
import { <%= it.
|
|
149
|
+
import { <%= capitalizeFirstLetter(it.name) %>Doc} from "~/simpleapp/docs/<%= capitalizeFirstLetter(it.name) %>Doc"
|
|
150
150
|
|
|
151
151
|
|
|
152
|
-
const props = defineProps<{ _id?: string, doc?: <%= it.
|
|
152
|
+
const props = defineProps<{ _id?: string, doc?: <%= capitalizeFirstLetter(it.name) %>Doc , paras?:<%= it.typename %>}>();
|
|
153
153
|
const doc = props.doc ?? useNuxtApp().$<%= capitalizeFirstLetter(it.name) %>Doc()
|
|
154
154
|
const data = doc.getReactiveData();
|
|
155
155
|
const emits = defineEmits(["after"]);
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
import { <%= it.typename %> } from '~/simpleapp/generate/openapi';
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
const {$<%= it.
|
|
23
|
-
const doc = $<%= it.
|
|
22
|
+
const {$<%= capitalizeFirstLetter(it.name) %>Doc,$listen } = useNuxtApp();
|
|
23
|
+
const doc = $<%= capitalizeFirstLetter(it.name) %>Doc()
|
|
24
24
|
const docdata = doc.getReactiveData();
|
|
25
25
|
type <%= it.typename %>Key = keyof <%= it.typename %>
|
|
26
26
|
|
|
@@ -46,6 +46,11 @@
|
|
|
46
46
|
description = `Update specific fields of an existing ${resourceTitleName} record.`;
|
|
47
47
|
break;
|
|
48
48
|
|
|
49
|
+
case 'patchMany':
|
|
50
|
+
method = 'patch';
|
|
51
|
+
description = `Update specific fields of existing ${resourceTitleName} records.`;
|
|
52
|
+
break;
|
|
53
|
+
|
|
49
54
|
case 'delete':
|
|
50
55
|
method = 'delete';
|
|
51
56
|
description = `Delete an existing ${resourceTitleName} record.`;
|
|
@@ -89,6 +94,19 @@ const scopes = {
|
|
|
89
94
|
<%= resourceName %>: <%~ JSON.stringify(availableApis) %>,
|
|
90
95
|
<% } %>
|
|
91
96
|
<% }); %>
|
|
97
|
+
|
|
98
|
+
// --- Custom ---
|
|
99
|
+
|
|
100
|
+
onlinePayment: {
|
|
101
|
+
requestOnlinePayment: {
|
|
102
|
+
method: "post",
|
|
103
|
+
description: "Make online payment request",
|
|
104
|
+
},
|
|
105
|
+
checkStatus: {
|
|
106
|
+
method: "get",
|
|
107
|
+
description: "Check online payment status",
|
|
108
|
+
},
|
|
109
|
+
},
|
|
92
110
|
};
|
|
93
111
|
|
|
94
112
|
export default scopes;
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was automatically generated by simpleapp generator. It is changable.
|
|
3
|
-
* --remove-this-line-to-prevent-override--
|
|
4
|
-
* last change 2023-10-28
|
|
5
|
-
* Author: Ks Tan
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { NestFactory } from '@nestjs/core';
|
|
9
|
-
import { AppModule } from './app.module';
|
|
10
|
-
import { SimpleAppExceptionFilter } from './simple-app/_core/framework/exception-filter';
|
|
11
|
-
import { HttpAdapterHost } from '@nestjs/core';
|
|
12
|
-
import {generatorVersion} from 'src/simple-app/_core/framework/generator-version'
|
|
13
|
-
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
|
14
|
-
import { writeFileSync } from 'fs';
|
|
15
1
|
import { LogLevel } from '@nestjs/common';
|
|
2
|
+
import { HttpAdapterHost, NestFactory } from '@nestjs/core';
|
|
3
|
+
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
|
4
|
+
import { writeFileSync } from 'fs';
|
|
5
|
+
import { generatorVersion } from 'src/simple-app/_core/framework/generator-version';
|
|
6
|
+
import { AppModule } from './app.module';
|
|
16
7
|
const yaml = require('yaml');
|
|
17
8
|
|
|
18
9
|
async function bootstrap() {
|
|
@@ -21,15 +12,19 @@ async function bootstrap() {
|
|
|
21
12
|
logger: logs,
|
|
22
13
|
});
|
|
23
14
|
|
|
15
|
+
// Handle shutdown signals for docker / kubernetes
|
|
16
|
+
app.enableShutdownHooks();
|
|
17
|
+
|
|
24
18
|
// app.enableCors();
|
|
25
19
|
const httpAdapter = app.get(HttpAdapterHost);
|
|
26
20
|
// app.useGlobalFilters(new SimpleAppExceptionFilter(httpAdapter));
|
|
27
21
|
|
|
28
22
|
const config = new DocumentBuilder()
|
|
29
|
-
.setTitle(
|
|
23
|
+
.setTitle('simtrain-eco backend api')
|
|
30
24
|
.addServer(process.env.APP_SWAGGER_SERVER_URL)
|
|
31
|
-
.setDescription(
|
|
32
|
-
.setVersion(
|
|
25
|
+
.setDescription(`Internal use only (generator: ${generatorVersion})`)
|
|
26
|
+
.setVersion('2.0')
|
|
27
|
+
|
|
33
28
|
.addApiKey(
|
|
34
29
|
{
|
|
35
30
|
in: 'header',
|
|
@@ -54,7 +49,7 @@ async function bootstrap() {
|
|
|
54
49
|
.addApiKey(
|
|
55
50
|
{
|
|
56
51
|
in: 'header',
|
|
57
|
-
name: 'x-
|
|
52
|
+
name: 'x-apikey',
|
|
58
53
|
type: 'apiKey',
|
|
59
54
|
description: 'optional only use for specal case',
|
|
60
55
|
},
|
|
@@ -63,7 +58,7 @@ async function bootstrap() {
|
|
|
63
58
|
.addApiKey(
|
|
64
59
|
{
|
|
65
60
|
in: 'header',
|
|
66
|
-
name: 'x-
|
|
61
|
+
name: 'x-apisecret',
|
|
67
62
|
type: 'apiKey',
|
|
68
63
|
description: 'optional only use for specal case',
|
|
69
64
|
},
|
|
@@ -1150,10 +1150,7 @@ export class UserContext extends UserContextInfo {
|
|
|
1150
1150
|
return data;
|
|
1151
1151
|
}
|
|
1152
1152
|
|
|
1153
|
-
|
|
1154
|
-
return this.groups.includes(Role.Executive) && this.groups.length == 1;
|
|
1155
|
-
};
|
|
1156
|
-
|
|
1153
|
+
|
|
1157
1154
|
offsetDate(date: string): string {
|
|
1158
1155
|
const timestamp = new Date(date).getTime();
|
|
1159
1156
|
const offsets = this.getOffsetMinute() * 60000;
|
|
@@ -8,7 +8,10 @@ import { Controller, Get, Put, Post, Delete, Body, Param, Type } from '@nestjs/c
|
|
|
8
8
|
// import { ApiTags, ApiBody, ApiResponse, ApiOperation } from '@nestjs/swagger';
|
|
9
9
|
import { UserContext } from '../../features/user-context/user.context';
|
|
10
10
|
import { SearchBody, TextSearchBody,PatchManyRequest } from '../schemas';
|
|
11
|
+
import { UpdateWriteOpResult } from 'mongoose';
|
|
12
|
+
|
|
11
13
|
const doctype = 'person'.toUpperCase();
|
|
14
|
+
|
|
12
15
|
type ServiceType = {
|
|
13
16
|
list: Function;
|
|
14
17
|
search: Function;
|
|
@@ -22,6 +25,7 @@ type ServiceType = {
|
|
|
22
25
|
setData: Function;
|
|
23
26
|
getAutoComplete: Function;
|
|
24
27
|
fullTextSearch: Function;
|
|
28
|
+
patchMany: Function;
|
|
25
29
|
};
|
|
26
30
|
|
|
27
31
|
// @ApiTags(doctype)
|
|
@@ -38,15 +42,19 @@ export class SimpleAppController<TService extends ServiceType, TApiSchema> {
|
|
|
38
42
|
async _list(appuser: UserContext) {
|
|
39
43
|
return this.service.list(appuser);
|
|
40
44
|
}
|
|
45
|
+
|
|
41
46
|
async _fulltextsearch(appuser: UserContext, body: TextSearchBody) {
|
|
42
47
|
return this.service.fullTextSearch(appuser, body);
|
|
43
48
|
}
|
|
49
|
+
|
|
44
50
|
async _search(appuser: UserContext, searchObject: SearchBody) {
|
|
45
51
|
return this.service.search(appuser, searchObject['filter'], searchObject['fields'], searchObject['sorts'], searchObject['lookup']);
|
|
46
52
|
}
|
|
53
|
+
|
|
47
54
|
async _autocomplete(appuser: UserContext, keyword: string, data?: TApiSchema) {
|
|
48
55
|
return this.service.getAutoComplete(appuser, keyword, data);
|
|
49
56
|
}
|
|
57
|
+
|
|
50
58
|
async _findOne(appuser: UserContext, id: string) {
|
|
51
59
|
const result = (await this.service.findById(appuser, id)) as TApiSchema;
|
|
52
60
|
|
|
@@ -65,6 +73,7 @@ export class SimpleAppController<TService extends ServiceType, TApiSchema> {
|
|
|
65
73
|
Object.assign(newdata, data); //
|
|
66
74
|
return this.service.findIdThenUpdate(appuser, id, newdata) as TApiSchema;
|
|
67
75
|
}
|
|
76
|
+
|
|
68
77
|
async _patch(appuser: UserContext, id: string, data: TApiSchema) {
|
|
69
78
|
const newdata: TApiSchema = {} as TApiSchema; //= { ...data };
|
|
70
79
|
Object.assign(newdata, data); //
|
|
@@ -74,8 +83,9 @@ export class SimpleAppController<TService extends ServiceType, TApiSchema> {
|
|
|
74
83
|
async _delete(appuser: UserContext, id: string) {
|
|
75
84
|
return this.service.findIdThenDelete(appuser, id);
|
|
76
85
|
}
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
|
|
87
|
+
async _patchMany(appuser: UserContext, patchManyData: PatchManyRequest<TApiSchema>) {
|
|
88
|
+
return this.service.findIdThenPatch(appuser, patchManyData);
|
|
79
89
|
}
|
|
80
90
|
|
|
81
91
|
async _deleteMany(appuser: UserContext, data: SearchBody) {
|
|
@@ -1324,11 +1324,10 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
1324
1324
|
}
|
|
1325
1325
|
|
|
1326
1326
|
const subPipeline: PipelineStage.Lookup['$lookup']['pipeline'] = [];
|
|
1327
|
-
const foreignField = `${this.documentName}._id`;
|
|
1328
1327
|
|
|
1329
1328
|
subPipeline.push({
|
|
1330
1329
|
$match: {
|
|
1331
|
-
$expr: { $eq: [`$${foreignField}`, '$$
|
|
1330
|
+
$expr: { $eq: [`$${relationOption.foreignField}`, '$$localValue'] },
|
|
1332
1331
|
},
|
|
1333
1332
|
...relationOption.filter,
|
|
1334
1333
|
});
|
|
@@ -1351,9 +1350,9 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
1351
1350
|
|
|
1352
1351
|
pipeline.push({
|
|
1353
1352
|
$lookup: {
|
|
1354
|
-
from: relationName,
|
|
1353
|
+
from: relationName.toLowerCase(),
|
|
1355
1354
|
as: `_${relationName}`,
|
|
1356
|
-
let: {
|
|
1355
|
+
let: { localValue: `$${relationOption.localField}` },
|
|
1357
1356
|
pipeline: subPipeline,
|
|
1358
1357
|
},
|
|
1359
1358
|
});
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
<div v-if="menu.label && menu.type == 'crud'">
|
|
49
49
|
<ButtonAction
|
|
50
50
|
v-if="menu.action == 'print'"
|
|
51
|
-
:disabled="!canPerform(doc.getDocName(true), '
|
|
51
|
+
:disabled="!canPerform(doc.getDocName(true), 'print')"
|
|
52
52
|
@click="emitEvent(menu, $event)"
|
|
53
53
|
:action-name="menu.action"
|
|
54
54
|
>{{ menu.label }}</ButtonAction
|