baja-lite 1.3.27 → 1.3.28
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/boot-remote.d.ts +2 -0
- package/{src/boot-remote.ts → boot-remote.js} +6 -7
- package/boot.d.ts +2 -0
- package/{src/boot.ts → boot.js} +31 -38
- package/code.d.ts +2 -0
- package/{src/code.ts → code.js} +71 -66
- package/convert-xml.d.ts +10 -0
- package/{src/convert-xml.ts → convert-xml.js} +105 -155
- package/enum.d.ts +18 -0
- package/enum.js +59 -0
- package/error.d.ts +5 -0
- package/error.js +13 -0
- package/fn.d.ts +128 -0
- package/fn.js +172 -0
- package/{src/index.ts → index.d.ts} +11 -12
- package/index.js +11 -0
- package/list.d.ts +10 -0
- package/{src/list.ts → list.js} +8 -9
- package/math.d.ts +83 -0
- package/math.js +451 -0
- package/object.d.ts +83 -0
- package/object.js +221 -0
- package/package.json +1 -1
- package/snowflake.d.ts +12 -0
- package/{src/snowflake.ts → snowflake.js} +33 -52
- package/sql.d.ts +1798 -0
- package/sql.js +4802 -0
- package/sqlite.d.ts +32 -0
- package/{src/sqlite.ts → sqlite.js} +53 -52
- package/string.d.ts +17 -0
- package/string.js +105 -0
- package/test-mysql.d.ts +2 -0
- package/test-mysql.js +109 -0
- package/test-postgresql.d.ts +2 -0
- package/{src/test-postgresql.ts → test-postgresql.js} +91 -80
- package/test-sqlite.d.ts +1 -0
- package/{src/test-sqlite.ts → test-sqlite.js} +90 -80
- package/test-xml.d.ts +1 -0
- package/{src/test-xml.ts → test-xml.js} +1 -1
- package/test.d.ts +1 -0
- package/{src/test.ts → test.js} +2 -3
- package/wx/base.d.ts +11 -0
- package/wx/base.js +78 -0
- package/wx/mini.d.ts +52 -0
- package/wx/mini.js +112 -0
- package/wx/organ.d.ts +65 -0
- package/wx/organ.js +171 -0
- package/{src/wx/types.ts → wx/types.d.ts} +21 -10
- package/wx/types.js +1 -0
- package/wx.js +3 -0
- package/.eslintignore +0 -7
- package/.eslintrc.cjs +0 -89
- package/.prettierrc +0 -4
- package/.vscode/settings.json +0 -8
- package/ci.js +0 -29
- package/package-cjs.json +0 -17
- package/src/enum.ts +0 -71
- package/src/error.ts +0 -11
- package/src/fn.ts +0 -295
- package/src/math.ts +0 -405
- package/src/object.ts +0 -247
- package/src/sql.ts +0 -5023
- package/src/string.ts +0 -111
- package/src/test-mysql.ts +0 -144
- package/src/wx/base.ts +0 -76
- package/src/wx/mini.ts +0 -147
- package/src/wx/organ.ts +0 -290
- package/tsconfig.cjs.json +0 -42
- package/tsconfig.json +0 -44
- package/tsconfig.tsbuildinfo +0 -1
- package/xml/event-report.xml +0 -13
- package/yarn.lock +0 -1757
- /package/{Readme.md → README.md} +0 -0
- /package/{src/wx.ts → wx.d.ts} +0 -0
package/sqlite.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SqliteRemoteInterface } from './sql.js';
|
|
2
|
+
export declare abstract class SqliteRemoteClass implements SqliteRemoteInterface {
|
|
3
|
+
private dbList;
|
|
4
|
+
/** 原始存放路径 */
|
|
5
|
+
abstract getStoreName(dbName: string): string;
|
|
6
|
+
/** 导入时,备份源文件路径 */
|
|
7
|
+
abstract getBackName(dbName: string): string;
|
|
8
|
+
abstract BetterSqlite3: any;
|
|
9
|
+
/** 实现复制 */
|
|
10
|
+
abstract cpSync(from: string, to: string, option?: {
|
|
11
|
+
force: true;
|
|
12
|
+
}): void;
|
|
13
|
+
/**
|
|
14
|
+
* 设置可执行权限
|
|
15
|
+
```
|
|
16
|
+
const fd = openSync(dbPath, 1);
|
|
17
|
+
fchmodSync(fd, 777);
|
|
18
|
+
closeSync(fd);
|
|
19
|
+
```
|
|
20
|
+
*/
|
|
21
|
+
abstract setMod(name: string): void;
|
|
22
|
+
abstract trace: boolean;
|
|
23
|
+
execute(inData: Uint8Array): Promise<Uint8Array>;
|
|
24
|
+
pluck(inData: Uint8Array): Promise<Uint8Array>;
|
|
25
|
+
get(inData: Uint8Array): Promise<Uint8Array>;
|
|
26
|
+
raw(inData: Uint8Array): Promise<Uint8Array>;
|
|
27
|
+
query(inData: Uint8Array): Promise<Uint8Array>;
|
|
28
|
+
initDB(dbName: string): void;
|
|
29
|
+
export(dbName: string, exportPath: string): Promise<void>;
|
|
30
|
+
restore(dbName: string, importPath: string): void;
|
|
31
|
+
close(dbName?: string): void;
|
|
32
|
+
}
|
|
@@ -1,34 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { extensionCodec, logger } from './sql.js';
|
|
2
2
|
import Sqlstring from 'sqlstring';
|
|
3
3
|
import { encode, decode } from "@msgpack/msgpack";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
abstract BetterSqlite3: any;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/** 实现复制 */
|
|
14
|
-
abstract cpSync(from: string, to: string, option?: { force: true }): void;
|
|
15
|
-
/**
|
|
16
|
-
* 设置可执行权限
|
|
17
|
-
```
|
|
18
|
-
const fd = openSync(dbPath, 1);
|
|
19
|
-
fchmodSync(fd, 777);
|
|
20
|
-
closeSync(fd);
|
|
21
|
-
```
|
|
22
|
-
*/
|
|
23
|
-
abstract setMod(name: string): void;
|
|
24
|
-
abstract trace: boolean;
|
|
25
|
-
async execute(inData: Uint8Array): Promise<Uint8Array> {
|
|
26
|
-
const [dbName, sql, params] = decode(inData) as [dbName: string, sql?: string | undefined, params?: any];
|
|
4
|
+
export class SqliteRemoteClass {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.dbList = {};
|
|
7
|
+
}
|
|
8
|
+
async execute(inData) {
|
|
9
|
+
const [dbName, sql, params] = decode(inData);
|
|
27
10
|
logger.debug(sql, params ?? '');
|
|
28
11
|
try {
|
|
29
|
-
if (!sql) {
|
|
12
|
+
if (!sql) {
|
|
13
|
+
return encode({ affectedRows: 0, insertId: 0n }, { extensionCodec });
|
|
14
|
+
}
|
|
15
|
+
;
|
|
30
16
|
if (this.trace) {
|
|
31
|
-
logger.trace(Sqlstring.format(sql
|
|
17
|
+
logger.trace(Sqlstring.format(sql, params));
|
|
32
18
|
}
|
|
33
19
|
const result = this.dbList[dbName].prepare(sql).run(params ?? {});
|
|
34
20
|
if (this.trace) {
|
|
@@ -36,7 +22,8 @@ export abstract class SqliteRemoteClass implements SqliteRemoteInterface {
|
|
|
36
22
|
}
|
|
37
23
|
const { changes, lastInsertRowid } = result;
|
|
38
24
|
return encode({ affectedRows: changes, insertId: lastInsertRowid ? BigInt(lastInsertRowid) : 0n }, { extensionCodec });
|
|
39
|
-
}
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
40
27
|
logger.error(`
|
|
41
28
|
error: ${error},
|
|
42
29
|
sql: ${sql},
|
|
@@ -45,17 +32,21 @@ export abstract class SqliteRemoteClass implements SqliteRemoteInterface {
|
|
|
45
32
|
throw error;
|
|
46
33
|
}
|
|
47
34
|
}
|
|
48
|
-
async pluck(inData
|
|
49
|
-
const [dbName, sql, params] = decode(inData)
|
|
35
|
+
async pluck(inData) {
|
|
36
|
+
const [dbName, sql, params] = decode(inData);
|
|
50
37
|
logger.debug(sql, params ?? '');
|
|
51
38
|
try {
|
|
52
39
|
logger.debug(sql, params ?? '');
|
|
53
|
-
if (!sql) {
|
|
40
|
+
if (!sql) {
|
|
41
|
+
return encode(null);
|
|
42
|
+
}
|
|
43
|
+
;
|
|
54
44
|
if (this.trace) {
|
|
55
|
-
logger.trace(Sqlstring.format(sql
|
|
45
|
+
logger.trace(Sqlstring.format(sql, params));
|
|
56
46
|
}
|
|
57
47
|
return encode(this.dbList[dbName].prepare(sql).pluck().get(params ?? {}), { extensionCodec });
|
|
58
|
-
}
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
59
50
|
logger.error(`
|
|
60
51
|
error: ${error},
|
|
61
52
|
sql: ${sql},
|
|
@@ -64,15 +55,16 @@ export abstract class SqliteRemoteClass implements SqliteRemoteInterface {
|
|
|
64
55
|
throw error;
|
|
65
56
|
}
|
|
66
57
|
}
|
|
67
|
-
async get(inData
|
|
68
|
-
const [dbName, sql, params] = decode(inData)
|
|
58
|
+
async get(inData) {
|
|
59
|
+
const [dbName, sql, params] = decode(inData);
|
|
69
60
|
logger.debug(sql, params ?? '');
|
|
70
61
|
try {
|
|
71
62
|
if (this.trace) {
|
|
72
|
-
logger.trace(Sqlstring.format(sql
|
|
63
|
+
logger.trace(Sqlstring.format(sql, params));
|
|
73
64
|
}
|
|
74
65
|
return encode(this.dbList[dbName].prepare(sql).get(params ?? {}), { extensionCodec });
|
|
75
|
-
}
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
76
68
|
logger.error(`
|
|
77
69
|
error: ${error},
|
|
78
70
|
sql: ${sql},
|
|
@@ -81,16 +73,20 @@ export abstract class SqliteRemoteClass implements SqliteRemoteInterface {
|
|
|
81
73
|
throw error;
|
|
82
74
|
}
|
|
83
75
|
}
|
|
84
|
-
async raw(inData
|
|
85
|
-
const [dbName, sql, params] = decode(inData)
|
|
76
|
+
async raw(inData) {
|
|
77
|
+
const [dbName, sql, params] = decode(inData);
|
|
86
78
|
logger.debug(sql, params ?? '');
|
|
87
79
|
try {
|
|
88
|
-
if (!sql) {
|
|
80
|
+
if (!sql) {
|
|
81
|
+
return encode([]);
|
|
82
|
+
}
|
|
83
|
+
;
|
|
89
84
|
if (this.trace) {
|
|
90
|
-
logger.trace(Sqlstring.format(sql
|
|
85
|
+
logger.trace(Sqlstring.format(sql, params));
|
|
91
86
|
}
|
|
92
87
|
return encode(this.dbList[dbName].prepare(sql).raw().all(params ?? {}), { extensionCodec });
|
|
93
|
-
}
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
94
90
|
logger.error(`
|
|
95
91
|
error: ${error},
|
|
96
92
|
sql: ${sql},
|
|
@@ -99,16 +95,20 @@ export abstract class SqliteRemoteClass implements SqliteRemoteInterface {
|
|
|
99
95
|
throw error;
|
|
100
96
|
}
|
|
101
97
|
}
|
|
102
|
-
async query(inData
|
|
103
|
-
const [dbName, sql, params] = decode(inData)
|
|
98
|
+
async query(inData) {
|
|
99
|
+
const [dbName, sql, params] = decode(inData);
|
|
104
100
|
logger.debug(sql, params ?? '');
|
|
105
101
|
try {
|
|
106
|
-
if (!sql) {
|
|
102
|
+
if (!sql) {
|
|
103
|
+
encode([]);
|
|
104
|
+
}
|
|
105
|
+
;
|
|
107
106
|
if (this.trace) {
|
|
108
|
-
logger.trace(Sqlstring.format(sql
|
|
107
|
+
logger.trace(Sqlstring.format(sql, params));
|
|
109
108
|
}
|
|
110
109
|
return encode(this.dbList[dbName].prepare(sql).all(params ?? {}), { extensionCodec });
|
|
111
|
-
}
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
112
|
logger.error(`
|
|
113
113
|
error: ${error},
|
|
114
114
|
sql: ${sql},
|
|
@@ -117,7 +117,7 @@ export abstract class SqliteRemoteClass implements SqliteRemoteInterface {
|
|
|
117
117
|
throw error;
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
initDB(dbName
|
|
120
|
+
initDB(dbName) {
|
|
121
121
|
if (!this.dbList[dbName]) {
|
|
122
122
|
this.dbList[dbName] = new this.BetterSqlite3(this.getStoreName(dbName), { fileMustExist: false });
|
|
123
123
|
this.dbList[dbName].pragma('journal_mode = WAL');
|
|
@@ -133,10 +133,10 @@ export abstract class SqliteRemoteClass implements SqliteRemoteInterface {
|
|
|
133
133
|
`);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
async export(dbName
|
|
136
|
+
async export(dbName, exportPath) {
|
|
137
137
|
await this.dbList[dbName].backup(exportPath);
|
|
138
138
|
}
|
|
139
|
-
restore(dbName
|
|
139
|
+
restore(dbName, importPath) {
|
|
140
140
|
if (this.dbList[dbName]) {
|
|
141
141
|
this.dbList[dbName].close();
|
|
142
142
|
this.dbList[dbName] = null;
|
|
@@ -147,15 +147,16 @@ export abstract class SqliteRemoteClass implements SqliteRemoteInterface {
|
|
|
147
147
|
this.setMod(nn);
|
|
148
148
|
this.initDB(dbName);
|
|
149
149
|
}
|
|
150
|
-
close(dbName
|
|
150
|
+
close(dbName) {
|
|
151
151
|
if (dbName) {
|
|
152
152
|
this.dbList[dbName]?.close();
|
|
153
153
|
this.dbList[dbName] = null;
|
|
154
|
-
}
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
155
156
|
for (const db of Object.values(this.dbList)) {
|
|
156
157
|
db?.close();
|
|
157
158
|
}
|
|
158
159
|
this.dbList = {};
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
|
-
}
|
|
162
|
+
}
|
package/string.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通过uri获取key
|
|
3
|
+
* @param uri
|
|
4
|
+
*/
|
|
5
|
+
export declare const getPicKey: (uri: string) => string;
|
|
6
|
+
export declare const emptyString: (source: any, skipEmptyString?: boolean) => boolean;
|
|
7
|
+
export declare const notEmptyString: (source: any, skipEmptyString?: boolean) => boolean;
|
|
8
|
+
export declare const safeString: (source?: string) => string;
|
|
9
|
+
export declare const trimObject: <T>(data: any) => T;
|
|
10
|
+
export declare const randomNumber: (len: number) => string;
|
|
11
|
+
export declare const randomString: (len: number) => string;
|
|
12
|
+
export declare const randomString2: (len: number) => string;
|
|
13
|
+
export declare const randomString3: (len: number) => string;
|
|
14
|
+
export declare const buildWxStr: (data: {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
}, maxLabelLength: number, ...titles: string[]) => string;
|
|
17
|
+
export declare const replaceChineseCode: (str: string) => string;
|
package/string.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通过uri获取key
|
|
3
|
+
* @param uri
|
|
4
|
+
*/
|
|
5
|
+
export const getPicKey = (uri) => {
|
|
6
|
+
const arr = /key=([0-9a-zA-Z.]+)/.exec(uri);
|
|
7
|
+
if (arr && arr.length === 2) {
|
|
8
|
+
return arr[1];
|
|
9
|
+
}
|
|
10
|
+
return uri;
|
|
11
|
+
};
|
|
12
|
+
export const emptyString = (source, skipEmptyString = true) => {
|
|
13
|
+
return (source === null ||
|
|
14
|
+
source === undefined ||
|
|
15
|
+
(skipEmptyString === true && (source === '' || `${source}`.replace(/\s/g, '') === '')));
|
|
16
|
+
};
|
|
17
|
+
export const notEmptyString = (source, skipEmptyString = true) => {
|
|
18
|
+
return emptyString(source, skipEmptyString) === false;
|
|
19
|
+
};
|
|
20
|
+
export const safeString = (source) => {
|
|
21
|
+
if (source) {
|
|
22
|
+
return `${source}`.replace(/'/g, '');
|
|
23
|
+
}
|
|
24
|
+
return '';
|
|
25
|
+
};
|
|
26
|
+
export const trimObject = (data) => {
|
|
27
|
+
if (data) {
|
|
28
|
+
for (const k in data) {
|
|
29
|
+
if (typeof data[k] === 'string') {
|
|
30
|
+
data[k] = data[k].trim();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return data;
|
|
35
|
+
};
|
|
36
|
+
export const randomNumber = (len) => {
|
|
37
|
+
return `${parseInt(`${(Math.random() * 9 + 1) * Math.pow(10, (len - 1))}`, 10)}`;
|
|
38
|
+
};
|
|
39
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
40
|
+
const charLen = chars.length;
|
|
41
|
+
export const randomString = (len) => {
|
|
42
|
+
return Array.from(new Array(len)).map(() => chars.charAt(Math.floor(Math.random() * charLen))).join('');
|
|
43
|
+
};
|
|
44
|
+
const chars2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
|
45
|
+
const charLen2 = chars2.length;
|
|
46
|
+
export const randomString2 = (len) => {
|
|
47
|
+
return Array.from(new Array(len)).map(() => chars2.charAt(Math.floor(Math.random() * charLen2))).join('');
|
|
48
|
+
};
|
|
49
|
+
const chars3 = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
50
|
+
const charLen3 = chars3.length;
|
|
51
|
+
export const randomString3 = (len) => {
|
|
52
|
+
return Array.from(new Array(len)).map(() => chars3.charAt(Math.floor(Math.random() * charLen3))).join('');
|
|
53
|
+
};
|
|
54
|
+
export const buildWxStr = (data, maxLabelLength, ...titles) => {
|
|
55
|
+
let str = titles.join('\r\n');
|
|
56
|
+
str += '\r\n\r\n';
|
|
57
|
+
const items = new Array();
|
|
58
|
+
// const maxLength = maxLabelLength * 2;
|
|
59
|
+
for (const [key, value] of Object.entries(data)) {
|
|
60
|
+
if (notEmptyString(value)) {
|
|
61
|
+
const len = maxLabelLength - key.length;
|
|
62
|
+
items.push(`${key}:${''.padEnd(len * 3 + (len > 0 ? 1 : 0), ' ')}${value}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
str += items.join('\r\n');
|
|
66
|
+
return str;
|
|
67
|
+
};
|
|
68
|
+
const chinese = /[\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3008|\u3009|\u3010|\u3011|\u300e|\u300f|\u300c|\u300d|\ufe43|\ufe44|\u3014|\u3015|\u2026|\u2014|\uff5e|\ufe4f|\uffe5]/g;
|
|
69
|
+
const table = {
|
|
70
|
+
'!': '!',
|
|
71
|
+
'¥': '$',
|
|
72
|
+
'…': '.',
|
|
73
|
+
'(': '(',
|
|
74
|
+
')': ')',
|
|
75
|
+
'《': '<',
|
|
76
|
+
'》': '>',
|
|
77
|
+
'?': '?',
|
|
78
|
+
':': ':',
|
|
79
|
+
'“': `'`,
|
|
80
|
+
'”': `'`,
|
|
81
|
+
'’': `'`,
|
|
82
|
+
'‘': `'`,
|
|
83
|
+
',': ',',
|
|
84
|
+
'。': '.',
|
|
85
|
+
'、': '/',
|
|
86
|
+
';': ';',
|
|
87
|
+
'〈': '<',
|
|
88
|
+
'〉': '>',
|
|
89
|
+
'【': '[',
|
|
90
|
+
'】': ']',
|
|
91
|
+
'『': '[',
|
|
92
|
+
'』': ']',
|
|
93
|
+
'「': '[',
|
|
94
|
+
'」': ']',
|
|
95
|
+
'﹃': '[',
|
|
96
|
+
'﹄': ']',
|
|
97
|
+
'〔': '(',
|
|
98
|
+
'〕': ')',
|
|
99
|
+
'—': '-',
|
|
100
|
+
'~': '~',
|
|
101
|
+
'﹏': '~'
|
|
102
|
+
};
|
|
103
|
+
export const replaceChineseCode = (str) => {
|
|
104
|
+
return str.replace(chinese, (a) => table[a] || '');
|
|
105
|
+
};
|
package/test-mysql.d.ts
ADDED
package/test-mysql.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Field, SqlType } from 'baja-lite-field';
|
|
11
|
+
import 'reflect-metadata';
|
|
12
|
+
import { Boot } from './boot.js';
|
|
13
|
+
import { ColumnMode, DB, SqlService } from './sql.js';
|
|
14
|
+
class BaseAuditUser {
|
|
15
|
+
}
|
|
16
|
+
__decorate([
|
|
17
|
+
Field({ type: SqlType.varchar, length: 32, id: true, notNull: true, uuidShort: true }),
|
|
18
|
+
__metadata("design:type", String)
|
|
19
|
+
], BaseAuditUser.prototype, "auditId", void 0);
|
|
20
|
+
__decorate([
|
|
21
|
+
Field({ type: SqlType.varchar, length: 32, comment: '密码' }),
|
|
22
|
+
__metadata("design:type", String)
|
|
23
|
+
], BaseAuditUser.prototype, "password", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
Field({ type: SqlType.varchar, length: 255, comment: '省' }),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], BaseAuditUser.prototype, "userProvinceCode", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
Field({ type: SqlType.varchar, length: 255, comment: '省' }),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], BaseAuditUser.prototype, "userProvince", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
Field({ type: SqlType.varchar, length: 32, comment: '显示名称' }),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], BaseAuditUser.prototype, "labelName", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
Field({ type: SqlType.varchar, length: 32, comment: '备注名称' }),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], BaseAuditUser.prototype, "remarkName", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
Field({ type: SqlType.varchar, length: 32, comment: '初始密码' }),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], BaseAuditUser.prototype, "upassword", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
Field({ type: SqlType.char, length: 1, def: 0, comment: '是否中心' }),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], BaseAuditUser.prototype, "baseType", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
Field({ type: SqlType.varchar, length: 32 }),
|
|
50
|
+
__metadata("design:type", String)
|
|
51
|
+
], BaseAuditUser.prototype, "userId", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
Field({ type: SqlType.varchar, length: 32 }),
|
|
54
|
+
__metadata("design:type", String)
|
|
55
|
+
], BaseAuditUser.prototype, "companyId", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
Field({ type: SqlType.varchar, length: 32 }),
|
|
58
|
+
__metadata("design:type", String)
|
|
59
|
+
], BaseAuditUser.prototype, "username", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
Field({ type: SqlType.char, length: 1, def: 0, comment: '状态' }),
|
|
62
|
+
__metadata("design:type", String)
|
|
63
|
+
], BaseAuditUser.prototype, "userStatus", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
Field({ type: SqlType.char, length: 1, def: 0, comment: '账户分组' }),
|
|
66
|
+
__metadata("design:type", String)
|
|
67
|
+
], BaseAuditUser.prototype, "groupId", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
Field({ type: SqlType.varchar, length: 10 }),
|
|
70
|
+
__metadata("design:type", String)
|
|
71
|
+
], BaseAuditUser.prototype, "startDate", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
Field({ type: SqlType.varchar, length: 10 }),
|
|
74
|
+
__metadata("design:type", String)
|
|
75
|
+
], BaseAuditUser.prototype, "endDate", void 0);
|
|
76
|
+
let BaseAuditUserService = class BaseAuditUserService extends SqlService {
|
|
77
|
+
};
|
|
78
|
+
BaseAuditUserService = __decorate([
|
|
79
|
+
DB({ tableName: 'base_audit_user', clz: BaseAuditUser })
|
|
80
|
+
], BaseAuditUserService);
|
|
81
|
+
export async function go2() {
|
|
82
|
+
await Boot({
|
|
83
|
+
Mysql: {
|
|
84
|
+
host: '127.0.0.1',
|
|
85
|
+
port: 3306,
|
|
86
|
+
user: 'root',
|
|
87
|
+
password: 'abcd1234',
|
|
88
|
+
// 数据库名
|
|
89
|
+
database: 'sportevent',
|
|
90
|
+
debug: false
|
|
91
|
+
},
|
|
92
|
+
log: 'trace',
|
|
93
|
+
columnMode: ColumnMode.HUMP,
|
|
94
|
+
sqlDir: 'E:/pro/baja-lite/xml',
|
|
95
|
+
sqlMap: {
|
|
96
|
+
['test.test']: `SELECT * FROM cp_user {{#username}} WHERE username = :username {{/username}}`
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
const service = new BaseAuditUserService();
|
|
100
|
+
const list = await service.transaction({
|
|
101
|
+
fn: async (conn) => {
|
|
102
|
+
await service.stream().eq('baseType', '0').in('auditId', ['162400829591265280', '162201628882247680']).excuteSelect();
|
|
103
|
+
const data = await service.stream().in('auditId', ['162400829591265280', '162201628882247680']).update('labelName', '333').excuteUpdate({ conn });
|
|
104
|
+
return data;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
console.log(11, list);
|
|
108
|
+
}
|
|
109
|
+
go2();
|
|
@@ -1,80 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { DBType, Field, SqlType } from 'baja-lite-field';
|
|
11
|
+
import 'reflect-metadata';
|
|
12
|
+
import { Boot } from './boot.js';
|
|
13
|
+
import { ColumnMode, DB, SelectResult, SqlService, } from './sql.js';
|
|
14
|
+
class AmaFuck2 {
|
|
15
|
+
}
|
|
16
|
+
__decorate([
|
|
17
|
+
Field({ type: SqlType.int, length: 200, id: true, uuid: true }),
|
|
18
|
+
__metadata("design:type", Number)
|
|
19
|
+
], AmaFuck2.prototype, "userid", void 0);
|
|
20
|
+
__decorate([
|
|
21
|
+
Field({ type: SqlType.varchar, length: 200, def: '333' }),
|
|
22
|
+
__metadata("design:type", String)
|
|
23
|
+
], AmaFuck2.prototype, "username", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
Field({ type: SqlType.varchar, length: 200 }),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], AmaFuck2.prototype, "pwd", void 0);
|
|
28
|
+
let AmaService2 = class AmaService2 extends SqlService {
|
|
29
|
+
};
|
|
30
|
+
AmaService2 = __decorate([
|
|
31
|
+
DB({
|
|
32
|
+
tableName: 'nfc_user', clz: AmaFuck2, dbType: DBType.Postgresql
|
|
33
|
+
})
|
|
34
|
+
], AmaService2);
|
|
35
|
+
// interface Menu {
|
|
36
|
+
// resourceid: string;
|
|
37
|
+
// resourcepid: string;
|
|
38
|
+
// resourcename: string;
|
|
39
|
+
// children: Menu[];
|
|
40
|
+
// }
|
|
41
|
+
export async function go2() {
|
|
42
|
+
await Boot({
|
|
43
|
+
Postgresql: {
|
|
44
|
+
database: 'nfc',
|
|
45
|
+
user: 'postgres',
|
|
46
|
+
password: 'abcd1234',
|
|
47
|
+
port: 5432,
|
|
48
|
+
host: '127.0.0.1'
|
|
49
|
+
},
|
|
50
|
+
log: 'info',
|
|
51
|
+
columnMode: ColumnMode.HUMP,
|
|
52
|
+
sqlDir: 'E:/pro/baja-lite/xml',
|
|
53
|
+
sqlMap: {
|
|
54
|
+
['test.test']: `SELECT * FROM nfc_user {{#username}} WHERE username = :username {{/username}}`
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const service = new AmaService2();
|
|
58
|
+
await service.transaction({
|
|
59
|
+
fn: async (conn) => {
|
|
60
|
+
const rt5 = await service.select({
|
|
61
|
+
sqlId: 'test.test',
|
|
62
|
+
params: { username: '1111' },
|
|
63
|
+
selectResult: SelectResult.RS_CS,
|
|
64
|
+
conn
|
|
65
|
+
});
|
|
66
|
+
console.log(55, rt5.length);
|
|
67
|
+
await service.insert({
|
|
68
|
+
data: {
|
|
69
|
+
userid: 22,
|
|
70
|
+
username: '222',
|
|
71
|
+
pwd: '333'
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return 1;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
// const data = await service.select<Menu>({
|
|
78
|
+
// sql: 'SELECT resourceid, resourcepid,resourcename FROM cp_resource ',
|
|
79
|
+
// params: {
|
|
80
|
+
// site: '1234',
|
|
81
|
+
// matchInfo: { reportType: 'yyyy', id: '11' }
|
|
82
|
+
// },
|
|
83
|
+
// // mapper: [
|
|
84
|
+
// // ['site', ['info', 'bSist'], 989],
|
|
85
|
+
// // ['site', ['info2', 'bSist'], 33],
|
|
86
|
+
// // ['site', ['Bsite'], 0]
|
|
87
|
+
// // ]
|
|
88
|
+
// });
|
|
89
|
+
// console.log(data);
|
|
90
|
+
}
|
|
91
|
+
go2();
|
package/test-sqlite.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'reflect-metadata';
|