@simitgroup/simpleapp-generator 2.0.0-n-alpha → 2.0.0-o-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 +4 -0
- package/package.json +1 -1
- package/templates/nest/src/main.ts._eta +1 -1
- package/templates/nest/src/simple-app/_core/features/document-no-format/document-no-format.service.ts.eta +29 -0
- package/templates/nest/src/simple-app/_core/framework/base/simple-app.service.ts.eta +11 -10
- package/templates/nuxt/components/select/SelectTemplate.vue._eta +1 -1
package/ReleaseNote.md
CHANGED
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ async function bootstrap() {
|
|
|
27
27
|
|
|
28
28
|
const config = new DocumentBuilder()
|
|
29
29
|
.setTitle(process.env.PROJECT_NAME)
|
|
30
|
-
.addServer(process.env.
|
|
30
|
+
.addServer(process.env.APP_SWAGGER_SERVER_URL)
|
|
31
31
|
.setDescription(`${process.env.PROJECT_DESCRIPTION} (generator: ${generatorVersion})`)
|
|
32
32
|
.setVersion(process.env.PROJECT_VERSION)
|
|
33
33
|
.addApiKey(
|
|
@@ -186,4 +186,33 @@ export class SimpleAppDocumentNoFormatService {
|
|
|
186
186
|
Object.assign(filter, isolationFilter);
|
|
187
187
|
return await this.docformat.find<DocumentNoFormat>(filter, null, { session: appUser.getDBSession() });
|
|
188
188
|
}
|
|
189
|
+
|
|
190
|
+
async requestMultipleNumbers(appUser: UserContext, doctype: string, quantity:number, id: string = '') {
|
|
191
|
+
doctype = doctype.toUpperCase();
|
|
192
|
+
const documentNumbers: string[] = []
|
|
193
|
+
const filter = { docNoType: doctype, active: true };
|
|
194
|
+
if (id) {
|
|
195
|
+
filter['_id'] = id;
|
|
196
|
+
}
|
|
197
|
+
//
|
|
198
|
+
Object.assign(filter, appUser.getBranchFilter());
|
|
199
|
+
const result = await this.docformat.find(filter).session(appUser.getDBSession());
|
|
200
|
+
if (result && result.length > 0) {
|
|
201
|
+
const d: DocumentNoFormat = result[0];
|
|
202
|
+
const recordId = d._id;
|
|
203
|
+
|
|
204
|
+
for(let i=0;i<quantity;i++){
|
|
205
|
+
d.nextNumber++
|
|
206
|
+
const newdocno = SimpleAppDocumentNoFormatService.previewDocNo(d);
|
|
207
|
+
documentNumbers.push(newdocno)
|
|
208
|
+
|
|
209
|
+
}
|
|
210
|
+
const updatedata = { nextNumber: d.nextNumber+1 } as DocumentNoFormat;
|
|
211
|
+
const updateresult = await this.docformat.findByIdAndUpdate(recordId, updatedata).session(appUser.getDBSession());
|
|
212
|
+
|
|
213
|
+
return documentNumbers
|
|
214
|
+
} else {
|
|
215
|
+
throw new BadRequestException(`No active document number found for ${doctype}. Please update in Settings > Document Numbering Format`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
189
218
|
}
|
|
@@ -16,15 +16,13 @@ import addFormats from 'ajv-formats';
|
|
|
16
16
|
import { FilterQuery, Model, PipelineStage, mongo } from 'mongoose';
|
|
17
17
|
// import { CloudApiService } from 'src/cloudapi/cloudapi.service';
|
|
18
18
|
import { foreignkeys } from '../../features/foreign-key/foreignkeys.dict';
|
|
19
|
-
import { CustomException } from '../custom-exception';
|
|
20
19
|
|
|
21
20
|
import { camelToKebab } from 'src/simple-app/_core/utils/string-utils';
|
|
22
21
|
import { SimpleAppDocumentNoFormatService } from '../../features/document-no-format/document-no-format.service';
|
|
22
|
+
import { SimpleAppLogService } from '../../features/log/log.service';
|
|
23
23
|
import { UserContext } from '../../features/user-context/user.context';
|
|
24
24
|
import { RunWebhookService } from '../../features/webhook/run-webhook.service';
|
|
25
|
-
import {
|
|
26
|
-
import { SimpleAppLogService } from '../../features/log/log.service';
|
|
27
|
-
import { ProcessErrorException } from 'src/simple-app/features/exception/process-error.exception';
|
|
25
|
+
import { DeleteResultType, IsolationType, MoreProjectionType, PatchManyRequest, SchemaFields, TextSearchBody, UniqueKeyExistResponse } from '../schemas';
|
|
28
26
|
|
|
29
27
|
@Injectable()
|
|
30
28
|
export class SimpleAppService<T extends SchemaFields> {
|
|
@@ -108,7 +106,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
108
106
|
public isReadOnly(): boolean {
|
|
109
107
|
return false;
|
|
110
108
|
}
|
|
111
|
-
reCalculateValue(data: T) {}
|
|
109
|
+
reCalculateValue(data: T) { }
|
|
112
110
|
getIsolationFilter = (appuser: UserContext) => {
|
|
113
111
|
let isolationFilter = {};
|
|
114
112
|
switch (this.isolationtype) {
|
|
@@ -483,6 +481,10 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
483
481
|
try {
|
|
484
482
|
const result = await this.doc.insertMany(datas, { session: dbsession });
|
|
485
483
|
await this.addManyAuditEvents(appuser, this.documentName, 'createMany', datas);
|
|
484
|
+
for (const data of datas) {
|
|
485
|
+
appuser.addInsertedRecordId(this.documentName, data._id);
|
|
486
|
+
}
|
|
487
|
+
|
|
486
488
|
return result;
|
|
487
489
|
} catch (e) {
|
|
488
490
|
throw e;
|
|
@@ -902,7 +904,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
902
904
|
|
|
903
905
|
//patch not suitable trigger afterupdate
|
|
904
906
|
// if (this.hooks.beforeUpdate) await this.hooks.beforeUpdate(appuser, id, existingdata, data);
|
|
905
|
-
await this.runEvent(appuser, this.setHookName('beforePatch'), { id: id, patchData: data,prevData:existingdata }, false);
|
|
907
|
+
await this.runEvent(appuser, this.setHookName('beforePatch'), { id: id, patchData: data, prevData: existingdata }, false);
|
|
906
908
|
const dbsession = appuser.getDBSession();
|
|
907
909
|
if (dbsession && !dbsession.inTransaction()) {
|
|
908
910
|
dbsession.startTransaction({ readPreference: 'primary' });
|
|
@@ -935,7 +937,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
935
937
|
await this.addAuditEvent(appuser, this.documentName, id, 'patch', data);
|
|
936
938
|
}
|
|
937
939
|
appuser.addUpdatedRecordId(this.documentName, data._id);
|
|
938
|
-
await this.runEvent(appuser, this.setHookName('afterPatch'), { id: id, patchData: data, prevData:existingdata }, false);
|
|
940
|
+
await this.runEvent(appuser, this.setHookName('afterPatch'), { id: id, patchData: data, prevData: existingdata }, false);
|
|
939
941
|
return result; //await this.findById(appuser, id);
|
|
940
942
|
} catch (err) {
|
|
941
943
|
this.logger.error(err.message, 'findIdThenPath error');
|
|
@@ -1090,13 +1092,12 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
1090
1092
|
* @param {any} data The data
|
|
1091
1093
|
* @return {Promise} { description_of_the_return_value }
|
|
1092
1094
|
*/
|
|
1093
|
-
async runEvent(appuser: UserContext, eventName: string, payloads: any, enforce: boolean = true) {
|
|
1095
|
+
async runEvent(appuser: UserContext, eventName: string, payloads: any, enforce: boolean = true) {
|
|
1094
1096
|
try {
|
|
1095
1097
|
if (enforce && !this.eventEmitter.hasListeners(eventName)) {
|
|
1096
1098
|
throw new InternalServerErrorException(`${eventName} seems no listener`);
|
|
1097
1099
|
} else if (this.eventEmitter.hasListeners(eventName)) {
|
|
1098
|
-
|
|
1099
|
-
console.log("run eventName",eventName)
|
|
1100
|
+
console.log('run eventName', eventName);
|
|
1100
1101
|
const res = await this.eventEmitter.emitAsync(eventName, appuser, payloads);
|
|
1101
1102
|
|
|
1102
1103
|
if (!res) {
|