@gingkoo/base-server 0.0.1-alpha.0 → 0.0.1-alpha.1
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/README.md +7 -0
- package/app.js +32 -40
- package/backend/common/entity.js +55 -0
- package/backend/common/enum.js +247 -0
- package/backend/common/fss/index.js +18 -0
- package/backend/common/fss/routers/attachment.js +45 -0
- package/backend/common/fss/routers/download.js +43 -0
- package/backend/common/fss/routers/import_export.js +113 -0
- package/backend/common/fss/routers/resources.js +149 -0
- package/backend/common/fss/routers/upload.js +81 -0
- package/backend/common/fss/services/import_export.js +159 -0
- package/backend/common/fss/services/index.js +92 -0
- package/backend/common/fss/utils.js +39 -0
- package/backend/common/ginfo/config.js +5 -0
- package/backend/common/ginfo/index.js +62 -0
- package/backend/common/index_template.html +28 -0
- package/backend/common/logger/index.js +96 -0
- package/backend/common/mapping.js +98 -0
- package/backend/common/middleware/auth.js +97 -0
- package/backend/common/middleware/cors.js +13 -0
- package/backend/common/middleware/response.js +25 -0
- package/backend/common/page_engine.js +487 -0
- package/backend/common/schedule.js +45 -0
- package/backend/common/services/dataCombine.js +67 -0
- package/backend/common/services/dept.js +37 -0
- package/backend/common/services/dict.js +487 -0
- package/backend/common/services/email.js +49 -0
- package/backend/common/services/generalConfig.js +137 -0
- package/backend/common/services/login.js +18 -0
- package/backend/common/services/notice.js +260 -0
- package/backend/common/services/permission.js +500 -0
- package/backend/common/services/roles.js +57 -0
- package/backend/common/services/send-notice.js +86 -0
- package/backend/common/services/task.js +259 -0
- package/backend/common/services/user.js +673 -0
- package/backend/common/socket.js +18 -0
- package/backend/common/sse/index.js +81 -0
- package/backend/common/sse/router.js +30 -0
- package/backend/common/task.js +75 -0
- package/backend/common/wechat/index.js +9 -0
- package/backend/common/wechat/routers/auth.js +238 -0
- package/{modules/user/frontend → backend/common/wechat/routers}/index.html +14 -7
- package/backend/common/wechat/services/auth.js +209 -0
- package/backend/common/wechat/services/notice.js +171 -0
- package/backend/config/index.js +63 -0
- package/backend/config/path.js +3 -0
- package/backend/router.js +96 -0
- package/backend/routers/app.js +222 -0
- package/backend/routers/automate.js +276 -0
- package/backend/routers/dict.js +370 -0
- package/backend/routers/email.js +85 -0
- package/backend/routers/generalConfig.js +276 -0
- package/backend/routers/idm.js +245 -0
- package/backend/routers/module.js +357 -0
- package/backend/routers/notice.js +138 -0
- package/backend/routers/pages.js +46 -0
- package/backend/routers/permission.js +985 -0
- package/backend/routers/setting.js +184 -0
- package/backend/routers/team/index.js +22 -0
- package/backend/routers/team/routers/mapping.js +29 -0
- package/backend/routers/team/routers/member.js +72 -0
- package/backend/routers/team/routers/membermanage.js +289 -0
- package/backend/routers/team/routers/pages.js +47 -0
- package/backend/routers/team/routers/roles.js +92 -0
- package/backend/routers/team/routers/teaminfo.js +27 -0
- package/backend/routers/team/routers/usergroup.js +213 -0
- package/backend/routers/team/services/mapping.js +101 -0
- package/backend/routers/team/services/member.js +206 -0
- package/backend/routers/team/services/roles.js +71 -0
- package/backend/routers/team/services/teaminfo.js +20 -0
- package/backend/routers/team/services/usergroup.js +128 -0
- package/backend/routers/user.js +436 -0
- package/backend/services/automate.js +60 -0
- package/backend/services/config.js +14 -0
- package/backend/services/module.js +298 -0
- package/backend/services/permission.js +192 -0
- package/backend/services/services.js +115 -0
- package/backend/services/setting.js +190 -0
- package/backend/services/token.js +42 -0
- package/backend/space.js +52 -0
- package/backend/space_mapping.js +15 -0
- package/backend/utils/avatar.js +48 -0
- package/backend/utils/color_gen_helper.js +20 -0
- package/backend/utils/date.js +66 -0
- package/backend/utils/excel.js +446 -0
- package/backend/utils/fs/doc.md +64 -0
- package/backend/utils/fs/index.js +127 -0
- package/backend/utils/jwt.js +54 -0
- package/backend/utils/modules/sequence.js +93 -0
- package/backend/utils/object.js +31 -0
- package/backend/utils/page-query-helper/index.js +61 -0
- package/backend/utils/path.js +123 -0
- package/backend/utils/run.js +25 -0
- package/backend/utils/tokenize.js +82 -0
- package/backend/utils/typeof.js +5 -0
- package/backend/utils/util.js +153 -0
- package/backend/views/api/index.js +32 -0
- package/backend/views/api/index.xml +49 -0
- package/backend/views/dict/index.js +80 -0
- package/backend/views/dict/index.xml +52 -0
- package/backend/views/index.js +32 -0
- package/backend/views/members_manage/index.js +68 -0
- package/backend/views/members_manage/index.xml +68 -0
- package/backend/views/roles/index.js +17 -0
- package/backend/views/roles/index.xml +47 -0
- package/backend/views/usergroup/index.js +68 -0
- package/backend/views/usergroup/index.xml +65 -0
- package/dist/assets/css/index-cc834b52.css +3 -0
- package/dist/assets/css/index-cc834b52.css.gz +0 -0
- package/dist/assets/js/index-9eef7474.js +762 -0
- package/dist/assets/js/index-9eef7474.js.gz +0 -0
- package/dist/assets/js/react-cropper.es-d3337769.js +10 -0
- package/dist/assets/js/react-cropper.es-d3337769.js.gz +0 -0
- package/dist/assets/png/u9-2348c304.png +0 -0
- package/dist/assets/woff2/materialicons-83be7b2f.woff2 +0 -0
- package/dist/index.html +162 -0
- package/package.json +60 -5
- package/common/router.js +0 -42
- package/modules/user/backend/index.js +0 -19
- package/modules/user/backend/routers/user.js +0 -11
- package/modules/user/frontend/index.js +0 -1
- package/serve.js +0 -9
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
const _ = require('lodash');
|
|
2
|
+
const { v4: uuidv4 } = require('uuid');
|
|
3
|
+
const {
|
|
4
|
+
sqlExecutor,
|
|
5
|
+
updateSqlBuilder,
|
|
6
|
+
insertSqlBuilder,
|
|
7
|
+
queryParamsBuilder,
|
|
8
|
+
checkTableFilterFields,
|
|
9
|
+
deleteSqlBuilder,
|
|
10
|
+
pageQuery,
|
|
11
|
+
} = require('@gingkoo/node-tools');
|
|
12
|
+
|
|
13
|
+
const entity = require('../entity');
|
|
14
|
+
|
|
15
|
+
module.exports = {
|
|
16
|
+
/**
|
|
17
|
+
* 创建文件导入导出的 任务
|
|
18
|
+
* @param {object} options
|
|
19
|
+
* @param {string} options.STATUS 状态 'Pending' | 'Loaded' | 'Success' | 'Error
|
|
20
|
+
* @param {string} options.TASK_TYPE 任务TYPE
|
|
21
|
+
* @param {string} options.TASK_NAME 任务Name
|
|
22
|
+
* @param {number} options.THREADS 线程数
|
|
23
|
+
* @param {number} options.REC_NUM 记录数
|
|
24
|
+
* @param {number} options.REC_CUR_NUM 已读记录数
|
|
25
|
+
* @param {number} options.REC_ERR_NUM 错误记录数
|
|
26
|
+
* @param {string} options.TASK_STEP 任务当前步骤
|
|
27
|
+
* @param {string} options.FILE_NAME 文件名
|
|
28
|
+
* @param {string} options.FILE_DIR 文件目录
|
|
29
|
+
* @param {string} options.FULL_PATH 存放路径
|
|
30
|
+
* @param {number} options.FILE_SIZE 文件大小
|
|
31
|
+
* @param {string} options.TASK_SERVICE 后续处理服务
|
|
32
|
+
* @param {string} options.SERVICE_PARAMS 后续处理参数
|
|
33
|
+
* @param {string} options.PROCESS_INFO 处理进度信息
|
|
34
|
+
* @param {string} options.EXT_INFO_1 处理附加信息
|
|
35
|
+
* @param {string} options.EXT_INFO_2 处理附加信息
|
|
36
|
+
* @param {string} options.USER_ID 通知的用户ids
|
|
37
|
+
* @param {string} options.MODULE_ID 模块ID
|
|
38
|
+
*/
|
|
39
|
+
async creatTask(options) {
|
|
40
|
+
if (!options || !_.isPlainObject(options)) {
|
|
41
|
+
return [{ message: '服务端错误:稍后再试' }];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let {
|
|
45
|
+
THREADS = 0,
|
|
46
|
+
REC_NUM = 0,
|
|
47
|
+
REC_CUR_NUM = 0,
|
|
48
|
+
REC_ERR_NUM = 0,
|
|
49
|
+
TASK_STEP = '',
|
|
50
|
+
FILE_NAME = '',
|
|
51
|
+
FILE_DIR = '',
|
|
52
|
+
FULL_PATH = '',
|
|
53
|
+
FILE_SIZE = 0,
|
|
54
|
+
TASK_SERVICE = '',
|
|
55
|
+
SERVICE_PARAMS = '',
|
|
56
|
+
PROCESS_INFO = '',
|
|
57
|
+
EXT_INFO_1 = '',
|
|
58
|
+
EXT_INFO_2 = '',
|
|
59
|
+
USER_ID = '',
|
|
60
|
+
MODULE_ID = '',
|
|
61
|
+
TASK_NAME = '',
|
|
62
|
+
TASK_TYPE = '',
|
|
63
|
+
defaultDate = null,
|
|
64
|
+
DATA_CRT_DATE = '',
|
|
65
|
+
DATA_CRT_TIME = '',
|
|
66
|
+
DATA_UPD_DATE = '',
|
|
67
|
+
DATA_UPD_TIME = '',
|
|
68
|
+
} = options;
|
|
69
|
+
|
|
70
|
+
let strUUID = uuidv4().replaceAll('-', '');
|
|
71
|
+
let taskProps = {
|
|
72
|
+
ORG_ID: global.orgid,
|
|
73
|
+
TASK_ID: strUUID,
|
|
74
|
+
STATUS: 'Pending',
|
|
75
|
+
THREADS,
|
|
76
|
+
REC_NUM,
|
|
77
|
+
REC_CUR_NUM,
|
|
78
|
+
REC_ERR_NUM,
|
|
79
|
+
TASK_STEP,
|
|
80
|
+
FILE_NAME,
|
|
81
|
+
FILE_DIR,
|
|
82
|
+
FULL_PATH,
|
|
83
|
+
FILE_SIZE,
|
|
84
|
+
TASK_SERVICE,
|
|
85
|
+
SERVICE_PARAMS,
|
|
86
|
+
PROCESS_INFO,
|
|
87
|
+
EXT_INFO_1,
|
|
88
|
+
EXT_INFO_2,
|
|
89
|
+
USER_ID,
|
|
90
|
+
MODULE_ID,
|
|
91
|
+
TASK_NAME,
|
|
92
|
+
TASK_TYPE,
|
|
93
|
+
DATA_CRT_DATE,
|
|
94
|
+
DATA_CRT_TIME,
|
|
95
|
+
DATA_UPD_DATE,
|
|
96
|
+
DATA_UPD_TIME,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
let sqlResult = insertSqlBuilder(entity.BASE_BG_TASK, taskProps, [], { defaultDate });
|
|
100
|
+
let dbResult = await sqlExecutor(sqlResult.sql, sqlResult.params);
|
|
101
|
+
if (dbResult.error) {
|
|
102
|
+
return [dbResult.error];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return [false, { TASK: strUUID }];
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 更新文件导入导出的 任务
|
|
110
|
+
* @param {object} options
|
|
111
|
+
* @param {string} options.TASK_ID 任务id
|
|
112
|
+
* @param {string} options.STATUS 状态 'Pending' | 'Loaded' | 'Success' | 'Error
|
|
113
|
+
* @param {string} options.TASK_TYPE 任务TYPE
|
|
114
|
+
* @param {string} options.TASK_NAME 任务Name
|
|
115
|
+
* @param {number} options.THREADS 线程数
|
|
116
|
+
* @param {number} options.REC_NUM 记录数
|
|
117
|
+
* @param {number} options.REC_CUR_NUM 已读记录数
|
|
118
|
+
* @param {number} options.REC_ERR_NUM 错误记录数
|
|
119
|
+
* @param {string} options.TASK_STEP 任务当前步骤
|
|
120
|
+
* @param {string} options.FILE_NAME 文件名
|
|
121
|
+
* @param {string} options.FILE_DIR 文件目录
|
|
122
|
+
* @param {string} options.FULL_PATH 存放路径
|
|
123
|
+
* @param {number} options.FILE_SIZE 文件大小
|
|
124
|
+
* @param {string} options.TASK_SERVICE 后续处理服务
|
|
125
|
+
* @param {string} options.SERVICE_PARAMS 后续处理参数
|
|
126
|
+
* @param {string} options.PROCESS_INFO 处理进度信息
|
|
127
|
+
* @param {string} options.EXT_INFO_1 处理附加信息
|
|
128
|
+
* @param {string} options.EXT_INFO_2 处理附加信息
|
|
129
|
+
* @param {string} options.USER_ID 通知的用户ids
|
|
130
|
+
* @param {string} options.MODULE_ID 模块ID
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
updateTask(options) {
|
|
134
|
+
if (!options || !_.isPlainObject(options)) return void 0;
|
|
135
|
+
let { TASK_ID, notupdate = null, ...rest } = options;
|
|
136
|
+
if (!TASK_ID) return void 0;
|
|
137
|
+
|
|
138
|
+
let usable = [
|
|
139
|
+
'STATUS',
|
|
140
|
+
'TASK_TYPE',
|
|
141
|
+
'TASK_NAME',
|
|
142
|
+
'THREADS',
|
|
143
|
+
'REC_NUM',
|
|
144
|
+
'REC_CUR_NUM',
|
|
145
|
+
'REC_ERR_NUM',
|
|
146
|
+
'TASK_STEP',
|
|
147
|
+
'FILE_NAME',
|
|
148
|
+
'FILE_DIR',
|
|
149
|
+
'FULL_PATH',
|
|
150
|
+
'FILE_SIZE',
|
|
151
|
+
'TASK_SERVICE',
|
|
152
|
+
'SERVICE_PARAMS',
|
|
153
|
+
'PROCESS_INFO',
|
|
154
|
+
'EXT_INFO_1',
|
|
155
|
+
'EXT_INFO_2',
|
|
156
|
+
'USER_ID',
|
|
157
|
+
'MODULE_ID',
|
|
158
|
+
'DATA_CRT_DATE',
|
|
159
|
+
'DATA_CRT_TIME',
|
|
160
|
+
'DATA_UPD_DATE',
|
|
161
|
+
'DATA_UPD_TIME',
|
|
162
|
+
];
|
|
163
|
+
let _params = {};
|
|
164
|
+
|
|
165
|
+
for (var it in rest) {
|
|
166
|
+
if (~usable.indexOf(it)) {
|
|
167
|
+
_params[it] = rest[it];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (Object.keys(_params).length) {
|
|
171
|
+
let { sql, params } = updateSqlBuilder(
|
|
172
|
+
entity.BASE_BG_TASK,
|
|
173
|
+
_params,
|
|
174
|
+
{
|
|
175
|
+
TASK_ID,
|
|
176
|
+
ORG_ID: global.orgid,
|
|
177
|
+
},
|
|
178
|
+
null,
|
|
179
|
+
notupdate,
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
sqlExecutor(sql, params);
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
*
|
|
188
|
+
* @param {*} filter 查询条件
|
|
189
|
+
* @param {*} sqlOps 查询参数格式
|
|
190
|
+
* @param {*} customSql 自定义sql语句,直接拼接
|
|
191
|
+
* @returns
|
|
192
|
+
*/
|
|
193
|
+
async selectTask(filter, sqlOps = {}, customSql) {
|
|
194
|
+
let sql = `select * from ${entity.BASE_BG_TASK} where ORG_ID=? `;
|
|
195
|
+
let params = [global.orgid];
|
|
196
|
+
let newFilter = await checkTableFilterFields(filter, entity.BASE_BG_TASK);
|
|
197
|
+
if (newFilter && Object.keys(newFilter)?.length) {
|
|
198
|
+
let queryParam = queryParamsBuilder(newFilter, null, null, sqlOps);
|
|
199
|
+
sql = sql + ' and ' + queryParam.sql;
|
|
200
|
+
params = params.concat(queryParam.params);
|
|
201
|
+
}
|
|
202
|
+
if (customSql) {
|
|
203
|
+
sql += ` ${customSql}`;
|
|
204
|
+
}
|
|
205
|
+
let dbResult = await sqlExecutor(sql, params);
|
|
206
|
+
if (dbResult.error) {
|
|
207
|
+
console.log(dbResult.error);
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
return dbResult.results;
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
async deleteTask(filter) {
|
|
214
|
+
let newFilter = await checkTableFilterFields(filter, entity.BASE_BG_TASK);
|
|
215
|
+
if (!newFilter || !Object.keys(filter).length) {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
let sqlResult = deleteSqlBuilder(entity.BASE_BG_TASK, newFilter);
|
|
220
|
+
|
|
221
|
+
let dbResult = await sqlExecutor(sqlResult.sql, sqlResult.params);
|
|
222
|
+
if (dbResult.error) {
|
|
223
|
+
console.log(dbResult.error);
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
return true;
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
async selectTaskPaging(filter, customSql, sqlOps = {}, pageInfo) {
|
|
230
|
+
let sql = `select * from ${entity.BASE_BG_TASK} where ORG_ID=? `;
|
|
231
|
+
let params = [global.orgid];
|
|
232
|
+
let newFilter = await checkTableFilterFields(filter, entity.BASE_BG_TASK);
|
|
233
|
+
if (newFilter && Object.keys(newFilter)?.length) {
|
|
234
|
+
let queryParam = queryParamsBuilder(newFilter, null, null, sqlOps);
|
|
235
|
+
sql = sql + ' and ' + queryParam.sql;
|
|
236
|
+
params = params.concat(queryParam.params);
|
|
237
|
+
}
|
|
238
|
+
if (customSql) {
|
|
239
|
+
sql += ` ${customSql}`;
|
|
240
|
+
}
|
|
241
|
+
if (pageInfo?.page || pageInfo?.pageSize) {
|
|
242
|
+
let dbResult = await pageQuery(
|
|
243
|
+
sql,
|
|
244
|
+
params,
|
|
245
|
+
Number(pageInfo?.pageSize),
|
|
246
|
+
Number(pageInfo?.page) - 1,
|
|
247
|
+
);
|
|
248
|
+
if (!dbResult) return null;
|
|
249
|
+
return dbResult;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
let { error, results } = await sqlExecutor(sql, params);
|
|
253
|
+
if (error) {
|
|
254
|
+
console.log(error);
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
return results;
|
|
258
|
+
},
|
|
259
|
+
};
|