pg-mvc-service 2.0.37 → 2.0.38

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.
@@ -217,7 +217,7 @@ td:nth-child(11) {
217
217
  html += `
218
218
  <div class="table-wrapper">
219
219
  <div class="table-title-wrapper">
220
- <div class="table-title-left">${model.TableName} ${model.TableDescription !== '' ? ` : ${model.TableDescription}` : ''}</div>
220
+ <div class="table-title-left">${model.Id !== "" ? `[${model.Id}] ` : ""}${model.TableName} ${model.TableDescription !== '' ? ` : ${model.TableDescription}` : ''}</div>
221
221
  <button class="table-title-right" onclick="${createFuncName}()">Copy Create Query</button>
222
222
  </div>
223
223
  <div class="comment-wrapper">${model.Comment.replace('\n', '<br>')}</div>
@@ -22,6 +22,7 @@ const ExpressionClient_1 = __importDefault(require("./ExpressionClient"));
22
22
  const UpdateExpression_1 = __importDefault(require("./SqlUtils/UpdateExpression"));
23
23
  const MessageUtil_1 = __importDefault(require("./Utils/MessageUtil"));
24
24
  class TableModel {
25
+ get Id() { return this.id; }
25
26
  get DbName() { return this.dbName; }
26
27
  get TableName() {
27
28
  if (this.tableName === "") {
@@ -98,6 +99,7 @@ class TableModel {
98
99
  return this.client;
99
100
  }
100
101
  constructor(client, tableAlias) {
102
+ this.id = "";
101
103
  this.dbName = "default";
102
104
  this.tableName = "";
103
105
  this.tableDescription = "";
@@ -344,7 +346,13 @@ class TableModel {
344
346
  if (message.includes("{length}") && (column.type === 'string' || column.type === 'string[]')) {
345
347
  message = message.replace('{length}', ((_a = column.length) !== null && _a !== void 0 ? _a : '未設定').toString());
346
348
  }
347
- throw new Exception_1.UnprocessableException(code, message);
349
+ this.throwUnprocessableException(code, message);
350
+ }
351
+ throwDbCoflictException(code, message) {
352
+ throw new Exception_1.DbConflictException(`${this.id}-${code}`, message);
353
+ }
354
+ throwUnprocessableException(code, message) {
355
+ throw new Exception_1.UnprocessableException(`${this.id}-${code}`, message);
348
356
  }
349
357
  validateOptions(options, isInsert, pkOrId) {
350
358
  return __awaiter(this, void 0, void 0, function* () {
@@ -406,14 +414,14 @@ class TableModel {
406
414
  // 一部の値がnullの場合はエラー
407
415
  if (refValues.some(value => value === null || value === undefined)) {
408
416
  const name = ref.columns.map(col => { var _a; return (_a = this.getColumn(col.target).alias) !== null && _a !== void 0 ? _a : this.getColumn(col.target).columnName; }).join(',');
409
- throw new Exception_1.UnprocessableException("006", this.errorMessages.null.replace('{name}', name));
417
+ this.throwUnprocessableException("006", this.errorMessages.null.replace('{name}', name));
410
418
  }
411
419
  let refIndex = 1;
412
420
  const sql = `SELECT COUNT(*) as count FROM ${ref.table} WHERE ${ref.columns.map(col => `${col.ref} = $${refIndex++}`).join(" AND ")}`;
413
421
  const datas = yield this.clientQuery(sql, refValues);
414
422
  if (datas.rows[0].count == "0") {
415
423
  const name = ref.columns.map(col => { var _a; return (_a = this.getColumn(col.target).alias) !== null && _a !== void 0 ? _a : this.getColumn(col.target).columnName; }).join(',');
416
- throw new Exception_1.DbConflictException("007", this.errorMessages.fk.replace('{name}', name));
424
+ this.throwDbCoflictException("007", this.errorMessages.fk.replace('{name}', name));
417
425
  }
418
426
  }
419
427
  }
@@ -452,7 +460,7 @@ class TableModel {
452
460
  const sql = updateSetQuery.expression + ' WHERE ' + whereQuery.expression;
453
461
  const data = yield this.executeQuery(sql, whereQuery.vars);
454
462
  if (data.rowCount !== 1) {
455
- throw new Exception_1.UnprocessableException("201", this.errorMessages.find.replace('{pks}', ((_a = whereQuery.vars) !== null && _a !== void 0 ? _a : []).join(',')));
463
+ this.throwUnprocessableException("201", this.errorMessages.find.replace('{pks}', ((_a = whereQuery.vars) !== null && _a !== void 0 ? _a : []).join(',')));
456
464
  }
457
465
  });
458
466
  }
@@ -470,7 +478,7 @@ class TableModel {
470
478
  const sql = `DELETE FROM ${this.TableName} WHERE ${whereQuery.expression}`;
471
479
  const data = yield this.executeQuery(sql, whereQuery.vars);
472
480
  if (data.rowCount !== 1) {
473
- throw new Exception_1.UnprocessableException("301", this.errorMessages.find.replace('{pks}', ((_a = whereQuery.vars) !== null && _a !== void 0 ? _a : []).join(',')));
481
+ this.throwUnprocessableException("301", this.errorMessages.find.replace('{pks}', ((_a = whereQuery.vars) !== null && _a !== void 0 ? _a : []).join(',')));
474
482
  }
475
483
  });
476
484
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-mvc-service",
3
- "version": "2.0.37",
3
+ "version": "2.0.38",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/n-daira/npm-pack_mvc-service#readme",
6
6
  "bugs": {
@@ -219,7 +219,7 @@ td:nth-child(11) {
219
219
  html += `
220
220
  <div class="table-wrapper">
221
221
  <div class="table-title-wrapper">
222
- <div class="table-title-left">${model.TableName} ${model.TableDescription !== '' ? ` : ${model.TableDescription}` : ''}</div>
222
+ <div class="table-title-left">${model.Id !== "" ? `[${model.Id}] ` : ""}${model.TableName} ${model.TableDescription !== '' ? ` : ${model.TableDescription}` : ''}</div>
223
223
  <button class="table-title-right" onclick="${createFuncName}()">Copy Create Query</button>
224
224
  </div>
225
225
  <div class="comment-wrapper">${model.Comment.replace('\n', '<br>')}</div>
@@ -11,6 +11,8 @@ import MessageUtil, { TOptionErrorMessage } from './Utils/MessageUtil';
11
11
 
12
12
  export class TableModel {
13
13
 
14
+ protected readonly id: string = "";
15
+ get Id(): string { return this.id; }
14
16
  protected readonly dbName: string = "default";
15
17
  get DbName(): string { return this.dbName; }
16
18
  protected readonly tableName: string = "";
@@ -406,7 +408,15 @@ export class TableModel {
406
408
  message = message.replace('{length}', (column.length ?? '未設定').toString());
407
409
  }
408
410
 
409
- throw new UnprocessableException(code, message);
411
+ this.throwUnprocessableException(code, message);
412
+ }
413
+
414
+ protected throwDbCoflictException(code: string, message: string): never {
415
+ throw new DbConflictException(`${this.id}-${code}`, message);
416
+ }
417
+
418
+ protected throwUnprocessableException(code: string, message: string): never {
419
+ throw new UnprocessableException(`${this.id}-${code}`, message);
410
420
  }
411
421
 
412
422
  protected async validateOptions(options: {[key: string]: any}, isInsert: boolean, pkOrId?: string | number | boolean | {[key: string]: any}): Promise<void> {
@@ -476,7 +486,7 @@ export class TableModel {
476
486
  // 一部の値がnullの場合はエラー
477
487
  if (refValues.some(value => value === null || value === undefined)) {
478
488
  const name = ref.columns.map(col => this.getColumn(col.target).alias ?? this.getColumn(col.target).columnName).join(',');
479
- throw new UnprocessableException("006", this.errorMessages.null.replace('{name}', name));
489
+ this.throwUnprocessableException("006", this.errorMessages.null.replace('{name}', name));
480
490
  }
481
491
 
482
492
  let refIndex = 1;
@@ -484,7 +494,7 @@ export class TableModel {
484
494
  const datas = await this.clientQuery(sql, refValues);
485
495
  if (datas.rows[0].count == "0") {
486
496
  const name = ref.columns.map(col => this.getColumn(col.target).alias ?? this.getColumn(col.target).columnName).join(',');
487
- throw new DbConflictException("007", this.errorMessages.fk.replace('{name}', name));
497
+ this.throwDbCoflictException("007", this.errorMessages.fk.replace('{name}', name))
488
498
  }
489
499
  }
490
500
  }
@@ -525,7 +535,7 @@ export class TableModel {
525
535
  const sql = updateSetQuery.expression + ' WHERE ' + whereQuery.expression;
526
536
  const data = await this.executeQuery(sql, whereQuery.vars);
527
537
  if (data.rowCount !== 1) {
528
- throw new UnprocessableException("201", this.errorMessages.find.replace('{pks}', (whereQuery.vars ?? []).join(',')));
538
+ this.throwUnprocessableException("201", this.errorMessages.find.replace('{pks}', (whereQuery.vars ?? []).join(',')));
529
539
  }
530
540
  }
531
541
 
@@ -541,7 +551,7 @@ export class TableModel {
541
551
  const sql = `DELETE FROM ${this.TableName} WHERE ${whereQuery.expression}`;
542
552
  const data = await this.executeQuery(sql, whereQuery.vars);
543
553
  if (data.rowCount !== 1) {
544
- throw new UnprocessableException("301", this.errorMessages.find.replace('{pks}', (whereQuery.vars ?? []).join(',')));
554
+ this.throwUnprocessableException("301", this.errorMessages.find.replace('{pks}', (whereQuery.vars ?? []).join(',')));
545
555
  }
546
556
  }
547
557