pg-mvc-service 2.0.36 → 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.
|
@@ -127,7 +127,10 @@ class AwsS3Client {
|
|
|
127
127
|
ContentType: type
|
|
128
128
|
});
|
|
129
129
|
yield this.client.send(command);
|
|
130
|
-
return
|
|
130
|
+
return {
|
|
131
|
+
url: `${this.UrlPrefix}/${key}`,
|
|
132
|
+
fileName: fileName
|
|
133
|
+
};
|
|
131
134
|
});
|
|
132
135
|
}
|
|
133
136
|
uploadFromUrl(path, fileName, url) {
|
|
@@ -150,7 +153,10 @@ class AwsS3Client {
|
|
|
150
153
|
});
|
|
151
154
|
yield this.client.send(command);
|
|
152
155
|
// アップロードされたファイルのURLを返す
|
|
153
|
-
return
|
|
156
|
+
return {
|
|
157
|
+
url: this.url(path, fileName),
|
|
158
|
+
fileName: fileName
|
|
159
|
+
};
|
|
154
160
|
}
|
|
155
161
|
catch (error) {
|
|
156
162
|
if (axios_1.default.isAxiosError(error)) {
|
package/dist/models/TableDoc.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
@@ -3,6 +3,11 @@ import { Base64Client } from './Base64Client';
|
|
|
3
3
|
import { UnprocessableException } from '../exceptions/Exception';
|
|
4
4
|
import axios from 'axios';
|
|
5
5
|
|
|
6
|
+
type IUploadResponse = {
|
|
7
|
+
url: string;
|
|
8
|
+
fileName: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
export class AwsS3Client {
|
|
7
12
|
private client: S3Client;
|
|
8
13
|
|
|
@@ -96,7 +101,7 @@ export class AwsS3Client {
|
|
|
96
101
|
await this.client.send(command);
|
|
97
102
|
}
|
|
98
103
|
|
|
99
|
-
public async uploadBase64Data(path: string, fileName: string, base64Data: string) : Promise<
|
|
104
|
+
public async uploadBase64Data(path: string, fileName: string, base64Data: string) : Promise<IUploadResponse> {
|
|
100
105
|
const base64Client = new Base64Client();
|
|
101
106
|
|
|
102
107
|
const type = base64Client.getMimeType(base64Data);
|
|
@@ -120,10 +125,13 @@ export class AwsS3Client {
|
|
|
120
125
|
});
|
|
121
126
|
await this.client.send(command);
|
|
122
127
|
|
|
123
|
-
return
|
|
128
|
+
return {
|
|
129
|
+
url: `${this.UrlPrefix}/${key}`,
|
|
130
|
+
fileName: fileName
|
|
131
|
+
}
|
|
124
132
|
}
|
|
125
133
|
|
|
126
|
-
public async uploadFromUrl(path: string, fileName: string, url: string): Promise<
|
|
134
|
+
public async uploadFromUrl(path: string, fileName: string, url: string): Promise<IUploadResponse> {
|
|
127
135
|
try {
|
|
128
136
|
// URLからデータを取得
|
|
129
137
|
const response = await axios.get(url, {
|
|
@@ -146,8 +154,10 @@ export class AwsS3Client {
|
|
|
146
154
|
await this.client.send(command);
|
|
147
155
|
|
|
148
156
|
// アップロードされたファイルのURLを返す
|
|
149
|
-
return
|
|
150
|
-
|
|
157
|
+
return {
|
|
158
|
+
url: this.url(path, fileName),
|
|
159
|
+
fileName: fileName
|
|
160
|
+
}
|
|
151
161
|
} catch (error) {
|
|
152
162
|
if (axios.isAxiosError(error)) {
|
|
153
163
|
if (error.response) {
|
package/src/models/TableDoc.ts
CHANGED
|
@@ -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>
|
package/src/models/TableModel.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
554
|
+
this.throwUnprocessableException("301", this.errorMessages.find.replace('{pks}', (whereQuery.vars ?? []).join(',')));
|
|
545
555
|
}
|
|
546
556
|
}
|
|
547
557
|
|