baja-lite 1.2.0 → 1.2.2
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/code.js +3 -3
- package/package.json +3 -3
- package/sql.d.ts +4 -2
- package/sql.js +70 -72
- package/test-mysql.js +71 -98
package/code.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import path from 'path';
|
|
3
2
|
import fs from 'fs';
|
|
4
|
-
import { start } from 'repl';
|
|
5
|
-
import { createPool } from 'mysql2/promise';
|
|
6
3
|
import mustache from 'mustache';
|
|
4
|
+
import { createPool } from 'mysql2/promise';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { start } from 'repl';
|
|
7
7
|
import { mkdir } from 'shelljs';
|
|
8
8
|
const lxMap = {
|
|
9
9
|
tinyint: "number",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "baja-lite",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "some util for self",
|
|
5
5
|
"homepage": "https://github.com/void-soul/util-man",
|
|
6
6
|
"repository": {
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"@types/pg-pool": "2.0.6",
|
|
62
62
|
"@types/shelljs": "0.8.15",
|
|
63
63
|
"@types/sqlstring": "2.3.2",
|
|
64
|
-
"@typescript-eslint/eslint-plugin": "8.26.
|
|
65
|
-
"@typescript-eslint/parser": "8.26.
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "8.26.1",
|
|
65
|
+
"@typescript-eslint/parser": "8.26.1",
|
|
66
66
|
"better-sqlite3": "11.8.1",
|
|
67
67
|
"ioredis": "5.6.0",
|
|
68
68
|
"mongodb": "6.14.2",
|
package/sql.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { ExtensionCodec } from "@msgpack/msgpack";
|
|
1
2
|
import { XML } from './convert-xml.js';
|
|
2
|
-
import { ArrayList } from './list.js';
|
|
3
3
|
import { EnumMap } from './enum.js';
|
|
4
|
-
import {
|
|
4
|
+
import { ArrayList } from './list.js';
|
|
5
5
|
export declare const extensionCodec: ExtensionCodec<undefined>;
|
|
6
6
|
declare const _daoDBName: unique symbol;
|
|
7
7
|
declare const _tableName: unique symbol;
|
|
@@ -1418,6 +1418,8 @@ export declare class SqlService<T extends object> {
|
|
|
1418
1418
|
*/
|
|
1419
1419
|
private _createTable;
|
|
1420
1420
|
private _matchSqlid;
|
|
1421
|
+
private _setParam;
|
|
1422
|
+
private _generSql;
|
|
1421
1423
|
}
|
|
1422
1424
|
declare class StreamQuery<T extends object> {
|
|
1423
1425
|
private _prefix;
|
package/sql.js
CHANGED
|
@@ -9,21 +9,21 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
};
|
|
10
10
|
var _b, _c, _d, _e;
|
|
11
11
|
var _f, _g, _h, _j;
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
12
|
+
import { decode, DecodeError, encode, ExtensionCodec } from "@msgpack/msgpack";
|
|
13
|
+
import HTML from 'html-parse-stringify';
|
|
14
14
|
import * as ite from 'iterare';
|
|
15
|
-
import
|
|
15
|
+
import LGet from 'lodash.get';
|
|
16
|
+
import mustache from 'mustache';
|
|
16
17
|
import pino from 'pino';
|
|
18
|
+
import { formatDialect, mysql, postgresql, sqlite } from 'sql-formatter';
|
|
19
|
+
import tslib from 'tslib';
|
|
20
|
+
import { convert } from './convert-xml.js';
|
|
21
|
+
import { Throw } from './error.js';
|
|
17
22
|
import { excuteSplit, ExcuteSplitMode, sleep } from './fn.js';
|
|
23
|
+
import { ArrayList } from './list.js';
|
|
18
24
|
import { add, calc, ten2Any } from './math.js';
|
|
19
|
-
import mustache from 'mustache';
|
|
20
25
|
import { C2P, C2P2, P2C } from './object.js';
|
|
21
|
-
import {
|
|
22
|
-
import HTML from 'html-parse-stringify';
|
|
23
|
-
import { convert } from './convert-xml.js';
|
|
24
|
-
import { ArrayList } from './list.js';
|
|
25
|
-
import LGet from 'lodash.get';
|
|
26
|
-
import { encode, decode, ExtensionCodec, DecodeError } from "@msgpack/msgpack";
|
|
26
|
+
import { emptyString } from './string.js';
|
|
27
27
|
const iterate = ite.iterate;
|
|
28
28
|
BigInt.prototype.toJSON = function () { return this.toString(); };
|
|
29
29
|
const BIGINT_EXT_TYPE = 0;
|
|
@@ -271,7 +271,7 @@ class MysqlConnection {
|
|
|
271
271
|
}
|
|
272
272
|
;
|
|
273
273
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
274
|
-
logger.trace(sql
|
|
274
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
275
275
|
}
|
|
276
276
|
return new Promise(async (resolve, reject) => {
|
|
277
277
|
try {
|
|
@@ -304,7 +304,7 @@ class MysqlConnection {
|
|
|
304
304
|
}
|
|
305
305
|
;
|
|
306
306
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
307
|
-
logger.trace(sql
|
|
307
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
308
308
|
}
|
|
309
309
|
return new Promise(async (resolve, reject) => {
|
|
310
310
|
try {
|
|
@@ -340,7 +340,7 @@ class MysqlConnection {
|
|
|
340
340
|
}
|
|
341
341
|
;
|
|
342
342
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
343
|
-
logger.trace(sql
|
|
343
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
344
344
|
}
|
|
345
345
|
return new Promise(async (resolve, reject) => {
|
|
346
346
|
try {
|
|
@@ -374,7 +374,7 @@ class MysqlConnection {
|
|
|
374
374
|
}
|
|
375
375
|
;
|
|
376
376
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
377
|
-
logger.trace(sql
|
|
377
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
378
378
|
}
|
|
379
379
|
return new Promise(async (resolve, reject) => {
|
|
380
380
|
try {
|
|
@@ -408,7 +408,7 @@ class MysqlConnection {
|
|
|
408
408
|
}
|
|
409
409
|
;
|
|
410
410
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
411
|
-
logger.trace(sql
|
|
411
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
412
412
|
}
|
|
413
413
|
return new Promise(async (resolve, reject) => {
|
|
414
414
|
try {
|
|
@@ -550,7 +550,7 @@ class PostgresqlConnection {
|
|
|
550
550
|
}
|
|
551
551
|
;
|
|
552
552
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
553
|
-
logger.trace(sql
|
|
553
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
554
554
|
}
|
|
555
555
|
return new Promise(async (resolve, reject) => {
|
|
556
556
|
try {
|
|
@@ -587,7 +587,7 @@ class PostgresqlConnection {
|
|
|
587
587
|
}
|
|
588
588
|
;
|
|
589
589
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
590
|
-
logger.trace(sql
|
|
590
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
591
591
|
}
|
|
592
592
|
return new Promise(async (resolve, reject) => {
|
|
593
593
|
try {
|
|
@@ -627,7 +627,7 @@ class PostgresqlConnection {
|
|
|
627
627
|
}
|
|
628
628
|
;
|
|
629
629
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
630
|
-
logger.trace(sql
|
|
630
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
631
631
|
}
|
|
632
632
|
return new Promise(async (resolve, reject) => {
|
|
633
633
|
try {
|
|
@@ -665,7 +665,7 @@ class PostgresqlConnection {
|
|
|
665
665
|
}
|
|
666
666
|
;
|
|
667
667
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
668
|
-
logger.trace(sql
|
|
668
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
669
669
|
}
|
|
670
670
|
return new Promise(async (resolve, reject) => {
|
|
671
671
|
try {
|
|
@@ -703,7 +703,7 @@ class PostgresqlConnection {
|
|
|
703
703
|
}
|
|
704
704
|
;
|
|
705
705
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
706
|
-
logger.trace(sql
|
|
706
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
707
707
|
}
|
|
708
708
|
return new Promise(async (resolve, reject) => {
|
|
709
709
|
try {
|
|
@@ -850,7 +850,7 @@ class SqliteConnection {
|
|
|
850
850
|
}
|
|
851
851
|
;
|
|
852
852
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
853
|
-
logger.trace(sql
|
|
853
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
854
854
|
}
|
|
855
855
|
const result = this[_daoConnection].prepare(sql).run(params ?? {});
|
|
856
856
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
@@ -881,7 +881,7 @@ class SqliteConnection {
|
|
|
881
881
|
}
|
|
882
882
|
;
|
|
883
883
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
884
|
-
logger.trace(sql
|
|
884
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
885
885
|
}
|
|
886
886
|
return this[_daoConnection].prepare(sql).pluck().get(params ?? {});
|
|
887
887
|
}
|
|
@@ -906,7 +906,7 @@ class SqliteConnection {
|
|
|
906
906
|
}
|
|
907
907
|
;
|
|
908
908
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
909
|
-
logger.trace(sql
|
|
909
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
910
910
|
}
|
|
911
911
|
return this[_daoConnection].prepare(sql).get(params ?? {});
|
|
912
912
|
}
|
|
@@ -932,7 +932,7 @@ class SqliteConnection {
|
|
|
932
932
|
}
|
|
933
933
|
;
|
|
934
934
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
935
|
-
logger.trace(sql
|
|
935
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
936
936
|
}
|
|
937
937
|
return this[_daoConnection].prepare(sql).raw().all(params ?? {});
|
|
938
938
|
}
|
|
@@ -958,7 +958,7 @@ class SqliteConnection {
|
|
|
958
958
|
}
|
|
959
959
|
;
|
|
960
960
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
961
|
-
logger.trace(sql
|
|
961
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
962
962
|
}
|
|
963
963
|
return this[_daoConnection].prepare(sql).all(params ?? {});
|
|
964
964
|
}
|
|
@@ -1055,7 +1055,7 @@ export class SqliteRemoteConnection {
|
|
|
1055
1055
|
}
|
|
1056
1056
|
;
|
|
1057
1057
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
1058
|
-
logger.trace(sql
|
|
1058
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
1059
1059
|
}
|
|
1060
1060
|
return new Promise(async (resolve, reject) => {
|
|
1061
1061
|
try {
|
|
@@ -1085,7 +1085,7 @@ export class SqliteRemoteConnection {
|
|
|
1085
1085
|
}
|
|
1086
1086
|
;
|
|
1087
1087
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
1088
|
-
logger.trace(sql
|
|
1088
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
1089
1089
|
}
|
|
1090
1090
|
return new Promise(async (resolve, reject) => {
|
|
1091
1091
|
try {
|
|
@@ -1115,7 +1115,7 @@ export class SqliteRemoteConnection {
|
|
|
1115
1115
|
}
|
|
1116
1116
|
;
|
|
1117
1117
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
1118
|
-
logger.trace(sql
|
|
1118
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
1119
1119
|
}
|
|
1120
1120
|
return new Promise(async (resolve, reject) => {
|
|
1121
1121
|
try {
|
|
@@ -1145,7 +1145,7 @@ export class SqliteRemoteConnection {
|
|
|
1145
1145
|
}
|
|
1146
1146
|
;
|
|
1147
1147
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
1148
|
-
logger.trace(sql
|
|
1148
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
1149
1149
|
}
|
|
1150
1150
|
return new Promise(async (resolve, reject) => {
|
|
1151
1151
|
try {
|
|
@@ -1175,7 +1175,7 @@ export class SqliteRemoteConnection {
|
|
|
1175
1175
|
}
|
|
1176
1176
|
;
|
|
1177
1177
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
1178
|
-
logger.trace(sql
|
|
1178
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
1179
1179
|
}
|
|
1180
1180
|
return new Promise(async (resolve, reject) => {
|
|
1181
1181
|
try {
|
|
@@ -2607,6 +2607,8 @@ export class SqlService {
|
|
|
2607
2607
|
option.mode ?? (option.mode = InsertMode.Insert);
|
|
2608
2608
|
const isArray = option.data instanceof Array;
|
|
2609
2609
|
const datas = option.data instanceof Array ? option.data : [option.data];
|
|
2610
|
+
if (datas.length === 0)
|
|
2611
|
+
return 0n;
|
|
2610
2612
|
if (option.sync === SyncMode.Sync) {
|
|
2611
2613
|
const fn = () => {
|
|
2612
2614
|
const result = excuteSplit(ExcuteSplitMode.SyncTrust, datas, _data => {
|
|
@@ -2713,6 +2715,8 @@ export class SqlService {
|
|
|
2713
2715
|
update(option) {
|
|
2714
2716
|
Throw.if(!this[_ids] || this[_ids].length === 0, 'not found id');
|
|
2715
2717
|
const datas = option.data instanceof Array ? option.data : [option.data];
|
|
2718
|
+
if (datas.length === 0)
|
|
2719
|
+
return 0;
|
|
2716
2720
|
if (option.sync === SyncMode.Sync) {
|
|
2717
2721
|
const fn = () => {
|
|
2718
2722
|
const result = excuteSplit(ExcuteSplitMode.SyncTrust, datas, _data => {
|
|
@@ -2774,6 +2778,9 @@ export class SqlService {
|
|
|
2774
2778
|
option.where = ids.map(i => ({ [idName]: i }));
|
|
2775
2779
|
}
|
|
2776
2780
|
const wheres = option.where instanceof Array ? option.where : [option.where];
|
|
2781
|
+
if (wheres.length === 0) {
|
|
2782
|
+
return 0;
|
|
2783
|
+
}
|
|
2777
2784
|
const sqls = [];
|
|
2778
2785
|
if (option.mode === DeleteMode.Common) {
|
|
2779
2786
|
const params = new Array();
|
|
@@ -3057,27 +3064,7 @@ export class SqlService {
|
|
|
3057
3064
|
}
|
|
3058
3065
|
const _params = Object.assign({}, option.context, option.params);
|
|
3059
3066
|
option.sql ?? (option.sql = globalThis[_sqlCache].load(this._matchSqlid(option.sqlId), { ctx: option.context, isCount: option.isCount, ..._params }));
|
|
3060
|
-
const params =
|
|
3061
|
-
const sql = formatDialect(option.sql?.replace(/\:([A-Za-z0-9._]+)/g, (txt, key) => {
|
|
3062
|
-
let V = LGet(_params, key);
|
|
3063
|
-
if (V !== undefined) {
|
|
3064
|
-
params.push(V);
|
|
3065
|
-
return '?';
|
|
3066
|
-
}
|
|
3067
|
-
const _key = C2P(key);
|
|
3068
|
-
V = LGet(_params, _key);
|
|
3069
|
-
if (V !== undefined) {
|
|
3070
|
-
params.push(V);
|
|
3071
|
-
return '?';
|
|
3072
|
-
}
|
|
3073
|
-
const __key = P2C(key);
|
|
3074
|
-
V = LGet(_params, __key);
|
|
3075
|
-
if (V !== undefined) {
|
|
3076
|
-
params.push(V);
|
|
3077
|
-
return '?';
|
|
3078
|
-
}
|
|
3079
|
-
return txt;
|
|
3080
|
-
}), { dialect: formatDialects[option.dbType] });
|
|
3067
|
+
const { sql, params } = this._generSql(option.dbType, option.sql, _params);
|
|
3081
3068
|
if (option.sync === SyncMode.Sync) {
|
|
3082
3069
|
const result = option.conn.query(SyncMode.Sync, sql, params);
|
|
3083
3070
|
return this._select(option.selectResult, result, option.defValue, option.errorMsg, option.hump, option.mapper, option.mapperIfUndefined);
|
|
@@ -3098,27 +3085,7 @@ export class SqlService {
|
|
|
3098
3085
|
Throw.if(!option.sqlId && !option.sql, 'not found sql!');
|
|
3099
3086
|
const _params = Object.assign({}, option.context, option.params);
|
|
3100
3087
|
option.sql ?? (option.sql = globalThis[_sqlCache].load(this._matchSqlid(option.sqlId), { ctx: option.context, ..._params }));
|
|
3101
|
-
const params =
|
|
3102
|
-
const sql = formatDialect(option.sql?.replace(/\:(\w+)/g, (txt, key) => {
|
|
3103
|
-
let V = LGet(_params, key);
|
|
3104
|
-
if (V !== undefined) {
|
|
3105
|
-
params.push(V);
|
|
3106
|
-
return '?';
|
|
3107
|
-
}
|
|
3108
|
-
const _key = C2P(key);
|
|
3109
|
-
V = LGet(_params, _key);
|
|
3110
|
-
if (V !== undefined) {
|
|
3111
|
-
params.push(V);
|
|
3112
|
-
return '?';
|
|
3113
|
-
}
|
|
3114
|
-
const __key = P2C(key);
|
|
3115
|
-
V = LGet(_params, __key);
|
|
3116
|
-
if (V !== undefined) {
|
|
3117
|
-
params.push(V);
|
|
3118
|
-
return '?';
|
|
3119
|
-
}
|
|
3120
|
-
return txt;
|
|
3121
|
-
}), { dialect: formatDialects[option.dbType] });
|
|
3088
|
+
const { sql, params } = this._generSql(option.dbType, option.sql, _params);
|
|
3122
3089
|
if (option.sync === SyncMode.Sync) {
|
|
3123
3090
|
const result = option.conn.execute(SyncMode.Sync, sql, params);
|
|
3124
3091
|
return result.affectedRows;
|
|
@@ -3542,6 +3509,37 @@ export class SqlService {
|
|
|
3542
3509
|
else
|
|
3543
3510
|
return [`${this[_tableName]}.${sqlid}`, `${this[_className]}.${sqlid}`, `${this[_ClassName]}.${sqlid}`, `${this[_vueName]}.${sqlid}`];
|
|
3544
3511
|
}
|
|
3512
|
+
_setParam(v, ps) {
|
|
3513
|
+
if (v instanceof Array) {
|
|
3514
|
+
ps.push(...v);
|
|
3515
|
+
return v.map(i => '?').join(',');
|
|
3516
|
+
}
|
|
3517
|
+
else {
|
|
3518
|
+
ps.push(v);
|
|
3519
|
+
return '?';
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
_generSql(dbType, _sql, _params) {
|
|
3523
|
+
const params = [];
|
|
3524
|
+
const sql = formatDialect(_sql?.replace(/\:(\w+)/g, (txt, key) => {
|
|
3525
|
+
let V = LGet(_params, key);
|
|
3526
|
+
if (V !== undefined) {
|
|
3527
|
+
return this._setParam(V, params);
|
|
3528
|
+
}
|
|
3529
|
+
const _key = C2P(key);
|
|
3530
|
+
V = LGet(_params, _key);
|
|
3531
|
+
if (V !== undefined) {
|
|
3532
|
+
return this._setParam(V, params);
|
|
3533
|
+
}
|
|
3534
|
+
const __key = P2C(key);
|
|
3535
|
+
V = LGet(_params, __key);
|
|
3536
|
+
if (V !== undefined) {
|
|
3537
|
+
return this._setParam(V, params);
|
|
3538
|
+
}
|
|
3539
|
+
return txt;
|
|
3540
|
+
}), { dialect: formatDialects[dbType] });
|
|
3541
|
+
return { params, sql };
|
|
3542
|
+
}
|
|
3545
3543
|
}
|
|
3546
3544
|
__decorate([
|
|
3547
3545
|
P(),
|
package/test-mysql.js
CHANGED
|
@@ -9,127 +9,100 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
};
|
|
10
10
|
import 'reflect-metadata';
|
|
11
11
|
import { Boot } from './boot.js';
|
|
12
|
-
import {
|
|
13
|
-
class
|
|
12
|
+
import { ColumnMode, DB, Field, SqlService, SqlType } from './sql.js';
|
|
13
|
+
class BaseAuditUser {
|
|
14
14
|
}
|
|
15
15
|
__decorate([
|
|
16
|
-
Field({ type: SqlType.varchar, length:
|
|
16
|
+
Field({ type: SqlType.varchar, length: 32, id: true, notNull: true, uuidShort: true }),
|
|
17
17
|
__metadata("design:type", String)
|
|
18
|
-
],
|
|
18
|
+
], BaseAuditUser.prototype, "auditId", void 0);
|
|
19
19
|
__decorate([
|
|
20
|
-
Field({ type: SqlType.varchar, length:
|
|
20
|
+
Field({ type: SqlType.varchar, length: 32, comment: '密码' }),
|
|
21
21
|
__metadata("design:type", String)
|
|
22
|
-
],
|
|
22
|
+
], BaseAuditUser.prototype, "password", void 0);
|
|
23
23
|
__decorate([
|
|
24
|
-
Field({ type: SqlType.varchar, length:
|
|
24
|
+
Field({ type: SqlType.varchar, length: 255, comment: '省' }),
|
|
25
25
|
__metadata("design:type", String)
|
|
26
|
-
],
|
|
27
|
-
|
|
26
|
+
], BaseAuditUser.prototype, "userProvinceCode", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
Field({ type: SqlType.varchar, length: 255, comment: '省' }),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], BaseAuditUser.prototype, "userProvince", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
Field({ type: SqlType.varchar, length: 32, comment: '显示名称' }),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], BaseAuditUser.prototype, "labelName", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
Field({ type: SqlType.varchar, length: 32, comment: '备注名称' }),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], BaseAuditUser.prototype, "remarkName", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
Field({ type: SqlType.varchar, length: 32, comment: '初始密码' }),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], BaseAuditUser.prototype, "upassword", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
Field({ type: SqlType.char, length: 1, def: 0, comment: '是否中心' }),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], BaseAuditUser.prototype, "baseType", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
Field({ type: SqlType.varchar, length: 32 }),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], BaseAuditUser.prototype, "userId", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
Field({ type: SqlType.varchar, length: 32 }),
|
|
53
|
+
__metadata("design:type", String)
|
|
54
|
+
], BaseAuditUser.prototype, "companyId", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
Field({ type: SqlType.varchar, length: 32 }),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], BaseAuditUser.prototype, "username", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
Field({ type: SqlType.char, length: 1, def: 0, comment: '状态' }),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], BaseAuditUser.prototype, "userStatus", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
Field({ type: SqlType.char, length: 1, def: 0, comment: '账户分组' }),
|
|
65
|
+
__metadata("design:type", String)
|
|
66
|
+
], BaseAuditUser.prototype, "groupId", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
Field({ type: SqlType.varchar, length: 10 }),
|
|
69
|
+
__metadata("design:type", String)
|
|
70
|
+
], BaseAuditUser.prototype, "startDate", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
Field({ type: SqlType.varchar, length: 10 }),
|
|
73
|
+
__metadata("design:type", String)
|
|
74
|
+
], BaseAuditUser.prototype, "endDate", void 0);
|
|
75
|
+
let BaseAuditUserService = class BaseAuditUserService extends SqlService {
|
|
28
76
|
};
|
|
29
|
-
|
|
30
|
-
DB({
|
|
31
|
-
|
|
32
|
-
})
|
|
33
|
-
], AmaService2);
|
|
34
|
-
// interface Menu {
|
|
35
|
-
// resourceid: string;
|
|
36
|
-
// resourcepid: string;
|
|
37
|
-
// resourcename: string;
|
|
38
|
-
// children: Menu[];
|
|
39
|
-
// }
|
|
77
|
+
BaseAuditUserService = __decorate([
|
|
78
|
+
DB({ tableName: 'base_audit_user', clz: BaseAuditUser })
|
|
79
|
+
], BaseAuditUserService);
|
|
40
80
|
export async function go2() {
|
|
41
81
|
await Boot({
|
|
42
82
|
Mysql: {
|
|
43
|
-
host: '
|
|
44
|
-
port:
|
|
83
|
+
host: '127.0.0.1',
|
|
84
|
+
port: 3306,
|
|
45
85
|
user: 'root',
|
|
46
|
-
password: '
|
|
86
|
+
password: 'abcd1234',
|
|
47
87
|
// 数据库名
|
|
48
|
-
database: '
|
|
88
|
+
database: 'sportevent',
|
|
49
89
|
debug: false
|
|
50
90
|
},
|
|
51
|
-
log: '
|
|
91
|
+
log: 'trace',
|
|
52
92
|
columnMode: ColumnMode.HUMP,
|
|
53
93
|
sqlDir: 'E:/pro/baja-lite/xml',
|
|
54
94
|
sqlMap: {
|
|
55
95
|
['test.test']: `SELECT * FROM cp_user {{#username}} WHERE username = :username {{/username}}`
|
|
56
96
|
}
|
|
57
97
|
});
|
|
58
|
-
const service = new
|
|
59
|
-
await service.transaction({
|
|
98
|
+
const service = new BaseAuditUserService();
|
|
99
|
+
const list = await service.transaction({
|
|
60
100
|
fn: async (conn) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
// sellerSku: 'sellerSku1',
|
|
65
|
-
// sellerSku2: 'SellerSKU11',
|
|
66
|
-
// }, {
|
|
67
|
-
// sellerSku2: 'SellerSKU2',
|
|
68
|
-
// sellerSku: 'SellerSKU22',
|
|
69
|
-
// }, {
|
|
70
|
-
// sellerSku2: 'SellerSKU3',
|
|
71
|
-
// sellerSku: 'SellerSKU33',
|
|
72
|
-
// }, {
|
|
73
|
-
// sellerSku2: '',
|
|
74
|
-
// sellerSku: 'SellerSKU44',
|
|
75
|
-
// site: '1234'
|
|
76
|
-
// });
|
|
77
|
-
// const rt = await service.insert({
|
|
78
|
-
// data: list,
|
|
79
|
-
// conn,
|
|
80
|
-
// // skipEmptyString: false,
|
|
81
|
-
// // skipUndefined: false
|
|
82
|
-
// mode: InsertMode.InsertWithTempTable,
|
|
83
|
-
// existConditionOtherThanIds: ['sellerSku']
|
|
84
|
-
// });
|
|
85
|
-
// console.log(11, rt);
|
|
86
|
-
// const rt2 = await service.update({
|
|
87
|
-
// data: {
|
|
88
|
-
// sellerSku: 'SellerSKU1',
|
|
89
|
-
// sellerSku2: 'SellerSKU21',
|
|
90
|
-
// site: 'site1'
|
|
91
|
-
// },
|
|
92
|
-
// conn, skipEmptyString: false
|
|
93
|
-
// });
|
|
94
|
-
// console.log(22, rt2);
|
|
95
|
-
// const rt3 = await service.delete({
|
|
96
|
-
// where: [
|
|
97
|
-
// { sellerSku2: 'SellerSKU23', sellerSku: 'SellerSKU3' }
|
|
98
|
-
// ],
|
|
99
|
-
// mode: DeleteMode.TempTable,
|
|
100
|
-
// conn
|
|
101
|
-
// });
|
|
102
|
-
// console.log(33, rt3);
|
|
103
|
-
// const rt4 = await service.template({
|
|
104
|
-
// where: { sellerSku2: 'SellerSKU22', sellerSku: 'sellerSku2' },
|
|
105
|
-
// templateResult: TemplateResult.Many
|
|
106
|
-
// })
|
|
107
|
-
// console.log(44, rt4);
|
|
108
|
-
const rt5 = await service.select({
|
|
109
|
-
sqlId: 'test.test',
|
|
110
|
-
params: { username: '1111' },
|
|
111
|
-
selectResult: SelectResult.RS_CS
|
|
112
|
-
});
|
|
113
|
-
console.log(55, rt5.length);
|
|
114
|
-
// const rt6 = await service.stream().eq('sellerSku', 'SellerSKU1').excuteSelect({
|
|
115
|
-
// selectResult: SelectResult.Many_Row_Many_Column,
|
|
116
|
-
// });
|
|
117
|
-
// console.log(66, rt6);
|
|
118
|
-
return 1;
|
|
101
|
+
await service.stream().eq('baseType', '0').in('auditId', ['162400829591265280', '162201628882247680']).excuteSelect();
|
|
102
|
+
const data = await service.stream().in('auditId', ['162400829591265280', '162201628882247680']).update('labelName', '333').excuteUpdate({ conn });
|
|
103
|
+
return data;
|
|
119
104
|
}
|
|
120
105
|
});
|
|
121
|
-
|
|
122
|
-
// sql: 'SELECT resourceid, resourcepid,resourcename FROM cp_resource ',
|
|
123
|
-
// params: {
|
|
124
|
-
// site: '1234',
|
|
125
|
-
// matchInfo: { reportType: 'yyyy', id: '11' }
|
|
126
|
-
// },
|
|
127
|
-
// // mapper: [
|
|
128
|
-
// // ['site', ['info', 'bSist'], 989],
|
|
129
|
-
// // ['site', ['info2', 'bSist'], 33],
|
|
130
|
-
// // ['site', ['Bsite'], 0]
|
|
131
|
-
// // ]
|
|
132
|
-
// });
|
|
133
|
-
// console.log(data);
|
|
106
|
+
console.log(11, list);
|
|
134
107
|
}
|
|
135
108
|
go2();
|