midway-fatcms 0.0.1-beta.4 → 0.0.1-beta.6
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/dist/config/config.default.js +48 -11
- package/dist/controller/manage/CrudStandardDesignApi.js +83 -68
- package/dist/controller/manage/UserAccountManageApi.d.ts +1 -1
- package/dist/index.d.ts +26 -4
- package/dist/index.js +26 -4
- package/package.json +1 -1
- package/src/config/config.default.ts +54 -23
- package/src/controller/home.controller.ts +6 -6
- package/src/controller/manage/CrudStandardDesignApi.ts +139 -94
- package/src/index.ts +32 -4
- package/dist/controller/medstatistic/MedAdminController.d.ts +0 -35
- package/dist/controller/medstatistic/MedAdminController.js +0 -205
- package/dist/controller/medstatistic/MedClientController.d.ts +0 -28
- package/dist/controller/medstatistic/MedClientController.js +0 -188
- package/dist/controller/medstatistic/MedMessageService.d.ts +0 -19
- package/dist/controller/medstatistic/MedMessageService.js +0 -95
- package/dist/controller/medstatistic/MedScoreService.d.ts +0 -21
- package/dist/controller/medstatistic/MedScoreService.js +0 -107
- package/dist/controller/medstatistic/constants.d.ts +0 -32
- package/dist/controller/medstatistic/constants.js +0 -43
- package/src/controller/medstatistic/MedAdminController.ts +0 -221
- package/src/controller/medstatistic/MedClientController.ts +0 -188
- package/src/controller/medstatistic/MedMessageService.ts +0 -89
- package/src/controller/medstatistic/MedScoreService.ts +0 -108
- package/src/controller/medstatistic/constants.ts +0 -63
|
@@ -4,13 +4,11 @@ import { BaseApiController } from '../base/BaseApiController';
|
|
|
4
4
|
import { parseCreateSqlToTitleMap } from '../../libs/utils/parseCreateSql';
|
|
5
5
|
import { checkPermission } from '../../middleware/permission.middleware';
|
|
6
6
|
import { SystemFuncCode } from '../../models/SystemPerm';
|
|
7
|
-
import {KeyOfCrudTypes, KeysOfSimpleSQL, SqlDbType} from '../../libs/crud-pro/models/keys';
|
|
7
|
+
import { KeyOfCrudTypes, KeysOfSimpleSQL, SqlDbType } from '../../libs/crud-pro/models/keys';
|
|
8
8
|
import { SystemTables } from '../../models/SystemTables';
|
|
9
|
-
import {CommonException} from "../../libs/crud-pro/exceptions";
|
|
10
|
-
import {parseDatabaseName, toDatabaseNameStr} from "../../libs/crud-pro/utils/DatabaseName";
|
|
11
|
-
import {CommonResult} from "../../libs/utils/common-dto";
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
import { CommonException } from "../../libs/crud-pro/exceptions";
|
|
10
|
+
import { parseDatabaseName, toDatabaseNameStr } from "../../libs/crud-pro/utils/DatabaseName";
|
|
11
|
+
import { CommonResult } from "../../libs/utils/common-dto";
|
|
14
12
|
|
|
15
13
|
|
|
16
14
|
@Controller('/ns/api/manage/CrudStandardDesignApi', { middleware: [checkPermission(SystemFuncCode.CrudStandardDesignRead)] })
|
|
@@ -30,19 +28,25 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
30
28
|
const postgresList = Object.keys(this.postgres2Config || {});
|
|
31
29
|
const sqlServerList = Object.keys(this.sqlserver2Config || {});
|
|
32
30
|
|
|
33
|
-
const toSelectList= (dbCfgNameList:string[], dbType: SqlDbType)=> {
|
|
34
|
-
return dbCfgNameList.map(
|
|
35
|
-
const dbName = item;
|
|
31
|
+
const toSelectList = (dbCfgNameList: string[], dbType: SqlDbType) => {
|
|
32
|
+
return dbCfgNameList.map(dbName => {
|
|
36
33
|
const value = toDatabaseNameStr(dbType, dbName);
|
|
37
|
-
return {value, label: value, dbName, dbType}
|
|
34
|
+
return { value, label: value, dbName, dbType };
|
|
38
35
|
});
|
|
39
|
-
}
|
|
36
|
+
};
|
|
40
37
|
|
|
41
38
|
const mysqlObjList = toSelectList(mysqlList, SqlDbType.mysql);
|
|
42
39
|
const postgresObjList = toSelectList(postgresList, SqlDbType.postgres);
|
|
43
40
|
const sqlserverObjList = toSelectList(sqlServerList, SqlDbType.sqlserver);
|
|
44
41
|
|
|
45
|
-
const databaseList = [
|
|
42
|
+
const databaseList = [
|
|
43
|
+
...mysqlObjList,
|
|
44
|
+
...postgresObjList,
|
|
45
|
+
...sqlserverObjList,
|
|
46
|
+
].filter((obj: any) => {
|
|
47
|
+
const value = '' + obj.value;
|
|
48
|
+
return !value.endsWith('_fatcms_inner_demo_config');
|
|
49
|
+
});
|
|
46
50
|
|
|
47
51
|
return {
|
|
48
52
|
success: true,
|
|
@@ -51,7 +55,7 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
@Post('/getTableList')
|
|
54
|
-
async getTableList():
|
|
58
|
+
async getTableList(): Promise<CommonResult> {
|
|
55
59
|
const { databaseName } = this.ctx.request.body as any;
|
|
56
60
|
const { dbType, dbName } = parseDatabaseName(databaseName);
|
|
57
61
|
|
|
@@ -144,7 +148,10 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
144
148
|
*/
|
|
145
149
|
@Post('/getRoleOptionsList')
|
|
146
150
|
async getRoleOptionsList() {
|
|
147
|
-
return this.executeSysSimpleSQL(
|
|
151
|
+
return this.executeSysSimpleSQL(
|
|
152
|
+
SystemTables.sys_perm_role,
|
|
153
|
+
KeysOfSimpleSQL.SIMPLE_QUERY_PAGE
|
|
154
|
+
);
|
|
148
155
|
}
|
|
149
156
|
|
|
150
157
|
/**
|
|
@@ -152,21 +159,24 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
152
159
|
*/
|
|
153
160
|
@Post('/getFuncOptionsList')
|
|
154
161
|
async getFuncOptionsList() {
|
|
155
|
-
return this.executeSysSimpleSQL(
|
|
162
|
+
return this.executeSysSimpleSQL(
|
|
163
|
+
SystemTables.sys_perm_func,
|
|
164
|
+
KeysOfSimpleSQL.SIMPLE_QUERY_PAGE
|
|
165
|
+
);
|
|
156
166
|
}
|
|
157
167
|
|
|
158
168
|
private async getTableListOfSqlserver(dbName: string): Promise<CommonResult> {
|
|
159
169
|
const dbConfig = this.sqlserver2Config[dbName];
|
|
160
170
|
if (!dbConfig) {
|
|
161
|
-
throw new CommonException(
|
|
171
|
+
throw new CommonException(
|
|
172
|
+
'DB_NOT_FOUND',
|
|
173
|
+
'数据库配置没有找到:' + dbName
|
|
174
|
+
);
|
|
162
175
|
}
|
|
163
176
|
|
|
164
177
|
const dbType = SqlDbType.sqlserver;
|
|
165
178
|
|
|
166
|
-
const sql =
|
|
167
|
-
"SELECT name as tablename \n" +
|
|
168
|
-
"FROM sys.tables" +
|
|
169
|
-
"";
|
|
179
|
+
const sql = 'SELECT name as tablename FROM sys.tables';
|
|
170
180
|
const arr = await this.curdMixService.executeSQL({
|
|
171
181
|
executeSql: sql,
|
|
172
182
|
sqlDatabase: dbName,
|
|
@@ -177,92 +187,111 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
177
187
|
|
|
178
188
|
|
|
179
189
|
const tableNames: string[] = arr.map(v => {
|
|
180
|
-
const tableName = v.tablename
|
|
190
|
+
const tableName = v.tablename;
|
|
181
191
|
return {
|
|
182
|
-
value: tableName
|
|
192
|
+
value: tableName, //[dbName, dbType, tableName].join(SPLIT_CONST),
|
|
183
193
|
label: tableName,
|
|
184
|
-
dbName,
|
|
185
|
-
|
|
186
|
-
|
|
194
|
+
dbName,
|
|
195
|
+
dbType,
|
|
196
|
+
tableName,
|
|
197
|
+
};
|
|
187
198
|
});
|
|
188
199
|
return CommonResult.successRes(tableNames);
|
|
189
|
-
|
|
190
200
|
}
|
|
191
201
|
|
|
192
|
-
|
|
193
202
|
private async getTableListOfPostgreSQL(dbName: string): Promise<CommonResult> {
|
|
194
203
|
|
|
195
204
|
const dbConfig = this.postgres2Config[dbName];
|
|
196
205
|
if (!dbConfig) {
|
|
197
|
-
throw new CommonException(
|
|
206
|
+
throw new CommonException(
|
|
207
|
+
'DB_NOT_FOUND',
|
|
208
|
+
'数据库配置没有找到:' + dbName
|
|
209
|
+
);
|
|
198
210
|
}
|
|
199
211
|
|
|
212
|
+
const dbType = SqlDbType.postgres;
|
|
213
|
+
const schemaname = 'public';
|
|
200
214
|
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
"FROM pg_tables\n" +
|
|
215
|
+
const tableListSql =
|
|
216
|
+
'' +
|
|
217
|
+
'SELECT tablename\n' +
|
|
218
|
+
'FROM pg_tables\n' +
|
|
206
219
|
`WHERE schemaname = '${schemaname}' \n` +
|
|
207
|
-
|
|
220
|
+
'ORDER BY tablename;';
|
|
208
221
|
|
|
209
|
-
const
|
|
222
|
+
const viewListSql =
|
|
223
|
+
'' +
|
|
224
|
+
'SELECT viewname as tablename\n' +
|
|
225
|
+
'FROM pg_views\n' +
|
|
226
|
+
`WHERE schemaname = '${schemaname}' \n` +
|
|
227
|
+
'ORDER BY viewname;';
|
|
228
|
+
|
|
229
|
+
const toSelectOptions = async (executeSql: string, tableType: string) => {
|
|
230
|
+
const arr = await this.curdMixService.executeSQL({
|
|
231
|
+
executeSql: executeSql,
|
|
232
|
+
sqlDatabase: dbName,
|
|
233
|
+
sqlDdType: dbType,
|
|
234
|
+
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
235
|
+
executeSqlArgs: [],
|
|
236
|
+
});
|
|
237
|
+
return arr.map(v => {
|
|
238
|
+
const tableName = v.tablename;
|
|
239
|
+
return {
|
|
240
|
+
value: tableName, //[dbName, dbType, tableName].join(SPLIT_CONST),
|
|
241
|
+
label: tableName,
|
|
242
|
+
dbName,
|
|
243
|
+
dbType,
|
|
244
|
+
tableName,
|
|
245
|
+
tableType,
|
|
246
|
+
};
|
|
247
|
+
});
|
|
248
|
+
};
|
|
210
249
|
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
sqlDatabase: dbName,
|
|
214
|
-
sqlDdType: dbType,
|
|
215
|
-
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
216
|
-
executeSqlArgs: [],
|
|
217
|
-
});
|
|
250
|
+
const tableNames: any[] = await toSelectOptions(tableListSql, 'table');
|
|
251
|
+
const viewNames: any[] = await toSelectOptions(viewListSql, 'view');
|
|
218
252
|
|
|
253
|
+
const tableNameMerge = [...tableNames, ...viewNames];
|
|
219
254
|
|
|
220
|
-
|
|
221
|
-
const tableName = v.tablename
|
|
222
|
-
return {
|
|
223
|
-
value: tableName , //[dbName, dbType, tableName].join(SPLIT_CONST),
|
|
224
|
-
label: tableName,
|
|
225
|
-
dbName, dbType,
|
|
226
|
-
tableName
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
return CommonResult.successRes(tableNames);
|
|
255
|
+
return CommonResult.successRes(tableNameMerge);
|
|
230
256
|
}
|
|
231
257
|
|
|
232
258
|
|
|
233
259
|
private async getTableFieldsOfSqlServer(dbName: string, tableName: string): Promise<CommonResult> {
|
|
234
260
|
const dbConfig = this.sqlserver2Config[dbName];
|
|
235
261
|
if (!dbConfig) {
|
|
236
|
-
throw new CommonException(
|
|
262
|
+
throw new CommonException(
|
|
263
|
+
'DB_NOT_FOUND',
|
|
264
|
+
'数据库配置没有找到:' + dbName
|
|
265
|
+
);
|
|
237
266
|
}
|
|
238
267
|
|
|
239
|
-
const columnArraySql =
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
268
|
+
const columnArraySql =
|
|
269
|
+
'' +
|
|
270
|
+
'SELECT\n' +
|
|
271
|
+
' c.name AS column_name,\n' +
|
|
272
|
+
' t.name AS data_type,\n' +
|
|
273
|
+
' c.max_length AS max_length,\n' +
|
|
274
|
+
' c.precision,\n' +
|
|
275
|
+
' c.scale,\n' +
|
|
276
|
+
' c.is_nullable,\n' +
|
|
277
|
+
' c.is_identity,\n' +
|
|
278
|
+
' dc.definition AS column_default, \n' +
|
|
279
|
+
' ep.value AS column_description \n' +
|
|
280
|
+
'FROM\n' +
|
|
281
|
+
' sys.columns c\n' +
|
|
282
|
+
' JOIN\n' +
|
|
283
|
+
' sys.types t ON c.user_type_id = t.user_type_id\n' +
|
|
284
|
+
' LEFT JOIN\n' +
|
|
285
|
+
' sys.default_constraints dc\n' +
|
|
286
|
+
' ON c.default_object_id = dc.object_id \n' +
|
|
287
|
+
' LEFT JOIN\n' +
|
|
288
|
+
' sys.extended_properties ep\n' +
|
|
289
|
+
' ON c.object_id = ep.major_id\n' +
|
|
290
|
+
' AND c.column_id = ep.minor_id\n' +
|
|
291
|
+
'WHERE\n' +
|
|
263
292
|
` c.object_id = OBJECT_ID('${tableName}') \n` +
|
|
264
|
-
|
|
265
|
-
|
|
293
|
+
' ORDER BY\n' +
|
|
294
|
+
' c.column_id;';
|
|
266
295
|
|
|
267
296
|
const dbType = SqlDbType.sqlserver;
|
|
268
297
|
|
|
@@ -275,16 +304,25 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
275
304
|
});
|
|
276
305
|
|
|
277
306
|
const fields = columnArray.map(columnObj => {
|
|
278
|
-
const {
|
|
307
|
+
const {
|
|
308
|
+
column_name,
|
|
309
|
+
is_nullable,
|
|
310
|
+
column_default,
|
|
311
|
+
data_type,
|
|
312
|
+
is_identity,
|
|
313
|
+
column_description,
|
|
314
|
+
...others
|
|
315
|
+
} = columnObj;
|
|
316
|
+
|
|
279
317
|
return {
|
|
280
318
|
fieldIndex: column_name || '',
|
|
281
|
-
fieldTitle: column_description || column_name ||
|
|
319
|
+
fieldTitle: column_description || column_name || '',
|
|
282
320
|
isNullable: is_nullable,
|
|
283
|
-
defaultValue: column_default ||
|
|
321
|
+
defaultValue: column_default || '',
|
|
284
322
|
extra: others,
|
|
285
323
|
// key: column_name, // 索引
|
|
286
324
|
type: data_type,
|
|
287
|
-
is_identity: is_identity
|
|
325
|
+
is_identity: is_identity,
|
|
288
326
|
};
|
|
289
327
|
});
|
|
290
328
|
|
|
@@ -293,17 +331,18 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
293
331
|
tableName,
|
|
294
332
|
tableTitle: tableName,
|
|
295
333
|
});
|
|
296
|
-
|
|
297
|
-
|
|
298
334
|
}
|
|
299
335
|
|
|
300
336
|
private async getTableFieldsOfPostgreSQL(dbName: string, tableName: string) {
|
|
301
337
|
const dbConfig = this.postgres2Config[dbName];
|
|
302
338
|
if (!dbConfig) {
|
|
303
|
-
throw new CommonException(
|
|
339
|
+
throw new CommonException(
|
|
340
|
+
'DB_NOT_FOUND',
|
|
341
|
+
'数据库配置没有找到:' + dbName
|
|
342
|
+
);
|
|
304
343
|
}
|
|
305
344
|
|
|
306
|
-
const schemaname =
|
|
345
|
+
const schemaname = 'public';
|
|
307
346
|
|
|
308
347
|
const columnArraySql = `
|
|
309
348
|
|
|
@@ -313,7 +352,7 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
313
352
|
WHERE table_schema = $1 and table_name = $2
|
|
314
353
|
ORDER BY ordinal_position;
|
|
315
354
|
|
|
316
|
-
`.trim();
|
|
355
|
+
`.trim();
|
|
317
356
|
|
|
318
357
|
const dbType = SqlDbType.postgres;
|
|
319
358
|
|
|
@@ -322,22 +361,28 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
322
361
|
sqlDatabase: dbName,
|
|
323
362
|
sqlDdType: dbType,
|
|
324
363
|
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
325
|
-
executeSqlArgs: [
|
|
364
|
+
executeSqlArgs: [schemaname, tableName],
|
|
326
365
|
});
|
|
327
366
|
|
|
328
|
-
|
|
329
|
-
|
|
330
367
|
const fields = columnArray.map(columnObj => {
|
|
331
|
-
const {
|
|
368
|
+
const {
|
|
369
|
+
column_name,
|
|
370
|
+
is_nullable,
|
|
371
|
+
column_default,
|
|
372
|
+
data_type,
|
|
373
|
+
is_identity,
|
|
374
|
+
...others
|
|
375
|
+
} = columnObj;
|
|
376
|
+
|
|
332
377
|
return {
|
|
333
378
|
fieldIndex: column_name || '',
|
|
334
379
|
fieldTitle: column_name || '',
|
|
335
380
|
isNullable: is_nullable,
|
|
336
|
-
defaultValue: column_default ||
|
|
381
|
+
defaultValue: column_default || '',
|
|
337
382
|
extra: others,
|
|
338
383
|
// key: column_name, // 索引
|
|
339
384
|
type: data_type,
|
|
340
|
-
is_identity: is_identity
|
|
385
|
+
is_identity: is_identity,
|
|
341
386
|
};
|
|
342
387
|
});
|
|
343
388
|
|
package/src/index.ts
CHANGED
|
@@ -30,10 +30,6 @@ export * from './controller/manage/SysConfigMangeApi';
|
|
|
30
30
|
export * from './controller/manage/SystemInfoManageApi';
|
|
31
31
|
export * from './controller/manage/UserAccountManageApi';
|
|
32
32
|
export * from './controller/manage/WorkbenchMangeApi';
|
|
33
|
-
export * from './controller/medstatistic/MedAdminController';
|
|
34
|
-
export * from './controller/medstatistic/MedClientController';
|
|
35
|
-
export * from './controller/medstatistic/MedMessageService';
|
|
36
|
-
export * from './controller/medstatistic/MedScoreService';
|
|
37
33
|
export * from './controller/myinfo/AuthController';
|
|
38
34
|
export * from './controller/myinfo/MyInfoController';
|
|
39
35
|
export * from './controller/render/AppRenderController';
|
|
@@ -69,3 +65,35 @@ export * from './service/curd/CurdMixService';
|
|
|
69
65
|
export * from './service/curd/CurdProService';
|
|
70
66
|
export * from './service/proxyapi/ProxyApiLoadService';
|
|
71
67
|
export * from './service/proxyapi/ProxyApiService';
|
|
68
|
+
export * from './models/userSession';
|
|
69
|
+
export * from './models/bizmodels';
|
|
70
|
+
export * from './models/SystemEntities';
|
|
71
|
+
export * from './models/SystemPerm';
|
|
72
|
+
export * from './models/contextLogger';
|
|
73
|
+
export * from './models/devops';
|
|
74
|
+
export * from './models/SystemTables';
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
export * from './libs/utils/common-dto';
|
|
78
|
+
export * from './libs/utils/crypto-utils';
|
|
79
|
+
export * from './libs/utils/fatcms-request';
|
|
80
|
+
export * from './libs/utils/functions';
|
|
81
|
+
export * from './libs/utils/ordernum-utils';
|
|
82
|
+
export * from './libs/utils/parseConfig';
|
|
83
|
+
|
|
84
|
+
export * from './libs/crud-pro/CrudPro';
|
|
85
|
+
export * from './libs/crud-pro/defaultConfigs';
|
|
86
|
+
export * from './libs/crud-pro/exceptions';
|
|
87
|
+
export * from './libs/crud-pro/interfaces';
|
|
88
|
+
|
|
89
|
+
export * from './libs/crud-pro/models/ExecuteContext';
|
|
90
|
+
export * from './libs/crud-pro/models/FuncContext';
|
|
91
|
+
export * from './libs/crud-pro/models/RequestModel';
|
|
92
|
+
export * from './libs/crud-pro/models/SqlCfgModel';
|
|
93
|
+
export * from './libs/crud-pro/models/Transaction';
|
|
94
|
+
export * from './libs/crud-pro/models/keys';
|
|
95
|
+
export * from './libs/crud-pro/models/ExecuteContextFunc';
|
|
96
|
+
export * from './libs/crud-pro/models/RequestCfgModel';
|
|
97
|
+
export * from './libs/crud-pro/models/SqlSegArg';
|
|
98
|
+
|
|
99
|
+
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Context } from '@midwayjs/koa';
|
|
2
|
-
import { BaseApiController } from '../base/BaseApiController';
|
|
3
|
-
import { AuthService } from '../../service/AuthService';
|
|
4
|
-
import { CommonResult } from '../../libs/utils/common-dto';
|
|
5
|
-
import { WorkbenchService } from "../../service/WorkbenchService";
|
|
6
|
-
import { SysConfigService } from "../../service/SysConfigService";
|
|
7
|
-
import { MedScoreService } from "./MedScoreService";
|
|
8
|
-
import { MedMessageService } from "./MedMessageService";
|
|
9
|
-
interface IUserRechargeRule {
|
|
10
|
-
score: number;
|
|
11
|
-
authentication_score: number;
|
|
12
|
-
recharge_package: any[];
|
|
13
|
-
vip_package: any[];
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* medstatistic 管理端
|
|
17
|
-
*/
|
|
18
|
-
export declare class MedAdminController extends BaseApiController {
|
|
19
|
-
protected ctx: Context;
|
|
20
|
-
protected authService: AuthService;
|
|
21
|
-
protected workbenchService: WorkbenchService;
|
|
22
|
-
protected sysConfigService: SysConfigService;
|
|
23
|
-
protected medScoreService: MedScoreService;
|
|
24
|
-
protected medMessageService: MedMessageService;
|
|
25
|
-
/**
|
|
26
|
-
* 审批后自动充值30个积分
|
|
27
|
-
*/
|
|
28
|
-
recharge_by_authentication_success(): Promise<CommonResult>;
|
|
29
|
-
/**
|
|
30
|
-
* 将DB中的数据同步到Redis,因为PHP的程序需要。
|
|
31
|
-
*/
|
|
32
|
-
sync_med_user_recharge_rule_to_redis(): Promise<CommonResult>;
|
|
33
|
-
get_med_user_recharge_rule(): Promise<IUserRechargeRule>;
|
|
34
|
-
}
|
|
35
|
-
export {};
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.MedAdminController = void 0;
|
|
13
|
-
const core_1 = require("@midwayjs/core");
|
|
14
|
-
const _ = require("lodash");
|
|
15
|
-
const BaseApiController_1 = require("../base/BaseApiController");
|
|
16
|
-
const AuthService_1 = require("../../service/AuthService");
|
|
17
|
-
const common_dto_1 = require("../../libs/utils/common-dto");
|
|
18
|
-
const WorkbenchService_1 = require("../../service/WorkbenchService");
|
|
19
|
-
const permission_middleware_1 = require("../../middleware/permission.middleware");
|
|
20
|
-
const SysConfigService_1 = require("../../service/SysConfigService");
|
|
21
|
-
const functions_1 = require("../../libs/utils/functions");
|
|
22
|
-
const exceptions_1 = require("../../libs/crud-pro/exceptions");
|
|
23
|
-
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
24
|
-
const ordernum_utils_1 = require("../../libs/utils/ordernum-utils");
|
|
25
|
-
const MedScoreService_1 = require("./MedScoreService");
|
|
26
|
-
const DateTimeUtils_1 = require("../../libs/crud-pro/utils/DateTimeUtils");
|
|
27
|
-
const MedMessageService_1 = require("./MedMessageService");
|
|
28
|
-
const constants_1 = require("./constants");
|
|
29
|
-
const MED_STATISTIC_DB = "medstatistic";
|
|
30
|
-
/**
|
|
31
|
-
* medstatistic 管理端
|
|
32
|
-
*/
|
|
33
|
-
let MedAdminController = class MedAdminController extends BaseApiController_1.BaseApiController {
|
|
34
|
-
/**
|
|
35
|
-
* 审批后自动充值30个积分
|
|
36
|
-
*/
|
|
37
|
-
async recharge_by_authentication_success() {
|
|
38
|
-
const body = this.ctx.request.body; // {user_id}
|
|
39
|
-
const user_id = parseInt(body.user_id); // med的C端用户user_id
|
|
40
|
-
if (!user_id) {
|
|
41
|
-
throw new exceptions_1.CommonException("user_id不存在");
|
|
42
|
-
}
|
|
43
|
-
const authRes = await this.curdMixService.executeCrudByCfg({
|
|
44
|
-
condition: {
|
|
45
|
-
user_id: user_id,
|
|
46
|
-
},
|
|
47
|
-
}, {
|
|
48
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
49
|
-
sqlTable: "fa_user_authentication",
|
|
50
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
51
|
-
});
|
|
52
|
-
const authResOne = authRes.getOneObj();
|
|
53
|
-
if (!authResOne || `${authResOne.status}` !== '1') {
|
|
54
|
-
throw new exceptions_1.CommonException("未提交认证资料或认证审批未通过");
|
|
55
|
-
}
|
|
56
|
-
const RECHARGE_TYPE_FOR_AUTH = '3';
|
|
57
|
-
// 查询之前有没有通过积分认证获得积分
|
|
58
|
-
const fa_user_rechargeRes = await this.curdMixService.executeCrudByCfg({
|
|
59
|
-
condition: {
|
|
60
|
-
user_id: user_id,
|
|
61
|
-
type: RECHARGE_TYPE_FOR_AUTH
|
|
62
|
-
},
|
|
63
|
-
}, {
|
|
64
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
65
|
-
sqlTable: "fa_user_recharge",
|
|
66
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
67
|
-
});
|
|
68
|
-
const fa_user_rechargeResOne = fa_user_rechargeRes.getOneObj();
|
|
69
|
-
if (fa_user_rechargeResOne) {
|
|
70
|
-
return common_dto_1.CommonResult.errorRes("用户已经获得认证积分");
|
|
71
|
-
}
|
|
72
|
-
const rechargeRule = await this.get_med_user_recharge_rule();
|
|
73
|
-
// 插入充值记录
|
|
74
|
-
await this.curdMixService.executeCrudByCfg({
|
|
75
|
-
data: {
|
|
76
|
-
user_id: user_id,
|
|
77
|
-
type: RECHARGE_TYPE_FOR_AUTH,
|
|
78
|
-
paid: 1,
|
|
79
|
-
order_no: (0, ordernum_utils_1.generateOrderNumber)('CZ'),
|
|
80
|
-
money: 0,
|
|
81
|
-
score: rechargeRule.authentication_score,
|
|
82
|
-
pay_time: DateTimeUtils_1.DateTimeUtils.getCurrentTimeStampSecond(),
|
|
83
|
-
createtime: DateTimeUtils_1.DateTimeUtils.getCurrentTimeStampSecond(),
|
|
84
|
-
},
|
|
85
|
-
}, {
|
|
86
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
87
|
-
sqlTable: "fa_user_recharge",
|
|
88
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
89
|
-
});
|
|
90
|
-
// 查询用户信息
|
|
91
|
-
const userRes = await this.curdMixService.executeCrudByCfg({
|
|
92
|
-
condition: {
|
|
93
|
-
id: user_id,
|
|
94
|
-
},
|
|
95
|
-
}, {
|
|
96
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
97
|
-
sqlTable: "fa_user",
|
|
98
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
99
|
-
});
|
|
100
|
-
const userOne = userRes.getOneObj();
|
|
101
|
-
if (!userOne) {
|
|
102
|
-
return common_dto_1.CommonResult.errorRes("用户信息没有查询到");
|
|
103
|
-
}
|
|
104
|
-
// 更新用户日志。
|
|
105
|
-
await this.medScoreService.updateScore(user_id, MedScoreService_1.UpdateScorePM.increase, rechargeRule.authentication_score, "用户认证通过获得积分");
|
|
106
|
-
// 更新认证状态
|
|
107
|
-
await this.curdMixService.executeCrudByCfg({
|
|
108
|
-
condition: {
|
|
109
|
-
id: user_id,
|
|
110
|
-
},
|
|
111
|
-
data: {
|
|
112
|
-
is_authentication: 1
|
|
113
|
-
}
|
|
114
|
-
}, {
|
|
115
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
116
|
-
sqlTable: "fa_user",
|
|
117
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
118
|
-
});
|
|
119
|
-
// 发送消息
|
|
120
|
-
// title:string, content: string, received_by: string | number, msgObj: ISendUserReceivedMsg
|
|
121
|
-
const title = "您的身份认证请求,已经审批通过";
|
|
122
|
-
await this.medMessageService.insertMessage(title, title, user_id, {
|
|
123
|
-
target_object_id: authResOne.id,
|
|
124
|
-
target_object_type: constants_1.TARGET_OBJECT_TYPE_USER_AUTHENTICATION,
|
|
125
|
-
msg_type: constants_1.MsgType.user_auth_pass
|
|
126
|
-
});
|
|
127
|
-
return common_dto_1.CommonResult.successMsg('用户认证审批通过获得积分' + rechargeRule.authentication_score);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* 将DB中的数据同步到Redis,因为PHP的程序需要。
|
|
131
|
-
*/
|
|
132
|
-
async sync_med_user_recharge_rule_to_redis() {
|
|
133
|
-
const ruleObj = await this.get_med_user_recharge_rule();
|
|
134
|
-
await this.redisService.set("score", ruleObj.score);
|
|
135
|
-
await this.redisService.set("authentication_score", ruleObj.authentication_score);
|
|
136
|
-
await this.redisService.set("recharge_package", JSON.stringify(ruleObj.recharge_package.map((obj0) => {
|
|
137
|
-
const obj = {};
|
|
138
|
-
obj.score = "" + obj0.score;
|
|
139
|
-
obj.price = "" + obj0.price;
|
|
140
|
-
return obj;
|
|
141
|
-
})));
|
|
142
|
-
await this.redisService.set("vip_package", JSON.stringify(ruleObj.vip_package.map((obj0) => {
|
|
143
|
-
const obj = {};
|
|
144
|
-
obj.score = "" + obj0.score;
|
|
145
|
-
obj.day = "" + obj0.day;
|
|
146
|
-
return obj;
|
|
147
|
-
})));
|
|
148
|
-
return common_dto_1.CommonResult.successRes("SUCCESS");
|
|
149
|
-
}
|
|
150
|
-
async get_med_user_recharge_rule() {
|
|
151
|
-
const rowObj = await this.sysConfigService.getSysConfigOne("med_user_recharge_rule");
|
|
152
|
-
const configContentObj = (0, functions_1.parseJsonObject)(rowObj.config_content);
|
|
153
|
-
const configContentData = configContentObj.data || {};
|
|
154
|
-
const recharge_package = configContentData.recharge_package || [];
|
|
155
|
-
const vip_package = configContentData.vip_package || [];
|
|
156
|
-
const authentication_score = Number(_.get(configContentData, 'score_setting.authentication_score')) || 30;
|
|
157
|
-
const score = Number(_.get(configContentData, 'score_setting.score')) || 1;
|
|
158
|
-
return {
|
|
159
|
-
score,
|
|
160
|
-
authentication_score,
|
|
161
|
-
recharge_package,
|
|
162
|
-
vip_package
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
__decorate([
|
|
167
|
-
(0, core_1.Inject)(),
|
|
168
|
-
__metadata("design:type", Object)
|
|
169
|
-
], MedAdminController.prototype, "ctx", void 0);
|
|
170
|
-
__decorate([
|
|
171
|
-
(0, core_1.Inject)(),
|
|
172
|
-
__metadata("design:type", AuthService_1.AuthService)
|
|
173
|
-
], MedAdminController.prototype, "authService", void 0);
|
|
174
|
-
__decorate([
|
|
175
|
-
(0, core_1.Inject)(),
|
|
176
|
-
__metadata("design:type", WorkbenchService_1.WorkbenchService)
|
|
177
|
-
], MedAdminController.prototype, "workbenchService", void 0);
|
|
178
|
-
__decorate([
|
|
179
|
-
(0, core_1.Inject)(),
|
|
180
|
-
__metadata("design:type", SysConfigService_1.SysConfigService)
|
|
181
|
-
], MedAdminController.prototype, "sysConfigService", void 0);
|
|
182
|
-
__decorate([
|
|
183
|
-
(0, core_1.Inject)(),
|
|
184
|
-
__metadata("design:type", MedScoreService_1.MedScoreService)
|
|
185
|
-
], MedAdminController.prototype, "medScoreService", void 0);
|
|
186
|
-
__decorate([
|
|
187
|
-
(0, core_1.Inject)(),
|
|
188
|
-
__metadata("design:type", MedMessageService_1.MedMessageService)
|
|
189
|
-
], MedAdminController.prototype, "medMessageService", void 0);
|
|
190
|
-
__decorate([
|
|
191
|
-
(0, core_1.Post)('/recharge_by_authentication_success', { middleware: [(0, permission_middleware_1.checkPermission)("BizOperationUserAdmin")] }),
|
|
192
|
-
__metadata("design:type", Function),
|
|
193
|
-
__metadata("design:paramtypes", []),
|
|
194
|
-
__metadata("design:returntype", Promise)
|
|
195
|
-
], MedAdminController.prototype, "recharge_by_authentication_success", null);
|
|
196
|
-
__decorate([
|
|
197
|
-
(0, core_1.Post)('/sync_med_user_recharge_rule_to_redis', { middleware: [(0, permission_middleware_1.checkPermission)("BizOperationUserAdmin")] }),
|
|
198
|
-
__metadata("design:type", Function),
|
|
199
|
-
__metadata("design:paramtypes", []),
|
|
200
|
-
__metadata("design:returntype", Promise)
|
|
201
|
-
], MedAdminController.prototype, "sync_med_user_recharge_rule_to_redis", null);
|
|
202
|
-
MedAdminController = __decorate([
|
|
203
|
-
(0, core_1.Controller)('/ns/api/medadmin')
|
|
204
|
-
], MedAdminController);
|
|
205
|
-
exports.MedAdminController = MedAdminController;
|