midway-fatcms 0.0.1-beta.18 → 0.0.1-beta.19
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/.eslintrc.json +3 -1
- package/dist/controller/gateway/AsyncTaskController.js +3 -3
- package/dist/controller/gateway/DocGatewayController.js +1 -1
- package/dist/controller/gateway/PublicApiController.js +4 -6
- package/dist/controller/gateway/StaticController.js +25 -22
- package/dist/controller/helpers.controller.d.ts +1 -1
- package/dist/controller/manage/CrudStandardDesignApi.d.ts +1 -1
- package/dist/controller/manage/CrudStandardDesignApi.js +4 -16
- package/dist/controller/manage/DataDictManageApi.d.ts +1 -1
- package/dist/controller/manage/DeployManageApi.d.ts +1 -1
- package/dist/controller/manage/DeployManageApi.js +32 -30
- package/dist/controller/manage/MenuManageApi.js +1 -1
- package/dist/controller/manage/SuperAdminManageApi.d.ts +2 -2
- package/dist/controller/manage/SysConfigMangeApi.d.ts +1 -1
- package/dist/controller/manage/SysConfigMangeApi.js +3 -3
- package/dist/controller/manage/SystemInfoManageApi.d.ts +1 -1
- package/dist/controller/manage/SystemInfoManageApi.js +7 -1
- package/dist/controller/manage/UserAccountManageApi.d.ts +1 -1
- package/dist/controller/manage/WorkbenchMangeApi.js +1 -1
- package/dist/controller/myinfo/AuthController.js +1 -1
- package/dist/controller/render/AppRenderController.js +6 -2
- package/dist/controller/test.controller.d.ts +1 -1
- package/dist/controller/test.controller.js +4 -4
- package/dist/libs/crud-pro/models/ExecuteContext.d.ts +1 -1
- package/dist/libs/crud-pro/models/TransactionSqlServer.js +1 -1
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.js +1 -1
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +7 -6
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.d.ts +1 -1
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +2 -4
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +6 -15
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +5 -4
- package/dist/libs/crud-pro/services/CrudProTableMetaService.js +2 -2
- package/dist/libs/crud-pro/utils/MixinUtils.js +1 -1
- package/dist/libs/crud-pro/utils/ValidateUtils.js +1 -1
- package/dist/libs/utils/fatcms-request.js +2 -2
- package/dist/middleware/forbidden.middleware.js +4 -20
- package/dist/middleware/global.middleware.js +1 -4
- package/dist/models/AsyncTaskModel.d.ts +2 -1
- package/dist/models/RedisKeys.d.ts +8 -0
- package/dist/models/RedisKeys.js +11 -0
- package/dist/schedule/runSchedule.d.ts +1 -0
- package/dist/schedule/runSchedule.js +9 -6
- package/dist/service/UserSessionService.js +2 -1
- package/dist/service/VisitStatService.d.ts +1 -1
- package/dist/service/VisitStatService.js +16 -25
- package/dist/service/asyncTask/AsyncTaskRunnerService.d.ts +9 -3
- package/dist/service/asyncTask/AsyncTaskRunnerService.js +57 -21
- package/dist/service/asyncTask/AsyncTaskService.d.ts +1 -1
- package/dist/service/asyncTask/AsyncTaskService.js +3 -2
- package/package.json +1 -1
- package/src/controller/base/BaseApiController.ts +6 -6
- package/src/controller/gateway/AsyncTaskController.ts +17 -22
- package/src/controller/gateway/CrudMtdGatewayController.ts +7 -7
- package/src/controller/gateway/CrudStdGatewayController.ts +4 -4
- package/src/controller/gateway/DocGatewayController.ts +17 -17
- package/src/controller/gateway/FileController.ts +8 -9
- package/src/controller/gateway/ProxyApiGatewayController.ts +4 -4
- package/src/controller/gateway/PublicApiController.ts +19 -22
- package/src/controller/gateway/StaticController.ts +234 -264
- package/src/controller/helpers.controller.ts +1 -1
- package/src/controller/home.controller.ts +0 -5
- package/src/controller/manage/AnyApiMangeApi.ts +4 -4
- package/src/controller/manage/AppLogMangeApi.ts +3 -3
- package/src/controller/manage/AppMangeApi.ts +5 -5
- package/src/controller/manage/AppPageMangeApi.ts +3 -3
- package/src/controller/manage/AppSchemaHistoryApi.ts +1 -1
- package/src/controller/manage/CrudMethodsMangeApi.ts +3 -3
- package/src/controller/manage/CrudStandardDesignApi.ts +25 -77
- package/src/controller/manage/DataDictManageApi.ts +4 -4
- package/src/controller/manage/DeployManageApi.ts +84 -91
- package/src/controller/manage/DocLibManageApi.ts +3 -3
- package/src/controller/manage/DocManageApi.ts +3 -3
- package/src/controller/manage/MenuManageApi.ts +9 -14
- package/src/controller/manage/SuperAdminManageApi.ts +2 -10
- package/src/controller/manage/SysConfigMangeApi.ts +8 -11
- package/src/controller/manage/SystemInfoManageApi.ts +11 -6
- package/src/controller/manage/UserAccountManageApi.ts +2 -2
- package/src/controller/manage/WorkbenchMangeApi.ts +6 -6
- package/src/controller/myinfo/AuthController.ts +4 -8
- package/src/controller/render/AppRenderController.ts +8 -8
- package/src/controller/test.controller.ts +17 -17
- package/src/index.ts +0 -1
- package/src/libs/crud-pro/CrudPro.ts +0 -1
- package/src/libs/crud-pro/interfaces.ts +1 -3
- package/src/libs/crud-pro/models/ExecuteContext.ts +1 -4
- package/src/libs/crud-pro/models/ExecuteContextFunc.ts +1 -2
- package/src/libs/crud-pro/models/RequestModel.ts +1 -1
- package/src/libs/crud-pro/models/ResModel.ts +7 -12
- package/src/libs/crud-pro/models/SqlCfgModel.ts +1 -1
- package/src/libs/crud-pro/models/Transaction.ts +8 -9
- package/src/libs/crud-pro/models/TransactionPostgres.ts +1 -1
- package/src/libs/crud-pro/models/TransactionSqlServer.ts +8 -13
- package/src/libs/crud-pro/services/CrudProCachedCfgService.ts +1 -3
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +36 -48
- package/src/libs/crud-pro/services/CrudProGenSqlCondition.ts +19 -38
- package/src/libs/crud-pro/services/CrudProGenSqlService.ts +15 -32
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +23 -27
- package/src/libs/crud-pro/services/CrudProServiceBase.ts +1 -2
- package/src/libs/crud-pro/services/CrudProTableMetaService.ts +6 -14
- package/src/libs/crud-pro/utils/DateTimeUtils.ts +2 -2
- package/src/libs/crud-pro/utils/MixinUtils.ts +1 -1
- package/src/libs/crud-pro/utils/ValidateUtils.ts +1 -3
- package/src/libs/crud-pro/utils/pool/MySQLUtils.ts +1 -1
- package/src/libs/crud-pro/utils/pool/PostgresUtils.ts +3 -3
- package/src/libs/crud-pro/utils/pool/SqlServerUtils.ts +3 -3
- package/src/libs/global-config/global-config.ts +0 -5
- package/src/libs/utils/crypto-utils.ts +2 -4
- package/src/libs/utils/errorToString.ts +3 -8
- package/src/libs/utils/fatcms-request.ts +9 -21
- package/src/libs/utils/ordernum-utils.ts +2 -6
- package/src/libs/utils/parseConfig.ts +7 -15
- package/src/middleware/forbidden.middleware.ts +6 -25
- package/src/middleware/global.middleware.ts +10 -21
- package/src/models/AsyncTaskModel.ts +3 -2
- package/src/models/RedisKeys.ts +13 -0
- package/src/models/bizmodels.ts +1 -2
- package/src/schedule/runSchedule.ts +16 -11
- package/src/service/UserSessionService.ts +5 -4
- package/src/service/VisitStatService.ts +55 -71
- package/src/service/asyncTask/AsyncTaskRunnerService.ts +119 -88
- package/src/service/asyncTask/AsyncTaskService.ts +9 -9
|
@@ -2,31 +2,29 @@ import { Controller, Inject, Post, Query } from '@midwayjs/core';
|
|
|
2
2
|
|
|
3
3
|
import { Context } from '@midwayjs/koa';
|
|
4
4
|
import { BaseApiController } from '../base/BaseApiController';
|
|
5
|
-
import {AsyncTaskService} from
|
|
6
|
-
import {SysAsyncTaskEntity, SysAsyncTaskStatus} from
|
|
7
|
-
import {KeysOfSimpleSQL} from
|
|
8
|
-
import {SystemTables} from
|
|
9
|
-
import {CommonException} from
|
|
10
|
-
import {checkLogin} from
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
throw new CommonException("参数不正确");
|
|
5
|
+
import { AsyncTaskService } from '@/service/asyncTask/AsyncTaskService';
|
|
6
|
+
import { SysAsyncTaskEntity, SysAsyncTaskStatus } from '@/models/AsyncTaskModel';
|
|
7
|
+
import { KeysOfSimpleSQL } from '@/libs/crud-pro/models/keys';
|
|
8
|
+
import { SystemTables } from '@/models/SystemTables';
|
|
9
|
+
import { CommonException } from '@/libs/crud-pro/exceptions';
|
|
10
|
+
import { checkLogin } from '@/middleware/permission.middleware';
|
|
11
|
+
|
|
12
|
+
function fixMyTasksCondition(body: any, ctx: Context) {
|
|
13
|
+
if (!body.condition) {
|
|
14
|
+
throw new CommonException('参数不正确');
|
|
16
15
|
}
|
|
17
16
|
body.condition.created_by = ctx.userSession.getSessionInfo().accountId;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
throw new CommonException("参数不正确");
|
|
19
|
+
function fixCancelBodyData(body: any, id: number) {
|
|
20
|
+
if (!body.data || !body.condition) {
|
|
21
|
+
throw new CommonException('参数不正确');
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
// fix condition
|
|
27
25
|
const conditionObj: SysAsyncTaskEntity = (body.condition || {}) as any;
|
|
28
26
|
conditionObj.id = id;
|
|
29
|
-
body.condition =
|
|
27
|
+
body.condition = conditionObj;
|
|
30
28
|
|
|
31
29
|
// fix data
|
|
32
30
|
const dataObj: SysAsyncTaskEntity = (body.data || {}) as any;
|
|
@@ -34,10 +32,9 @@ function fixCancelBodyData(body:any, id: number) {
|
|
|
34
32
|
body.data = dataObj;
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
throw new CommonException("参数不正确");
|
|
35
|
+
function fixCreateBodyData(body: any, ctx: Context) {
|
|
36
|
+
if (!body.data) {
|
|
37
|
+
throw new CommonException('参数不正确');
|
|
41
38
|
}
|
|
42
39
|
|
|
43
40
|
const sessionInfo = ctx.userSession.getSessionInfo();
|
|
@@ -48,7 +45,6 @@ function fixCreateBodyData(body:any, ctx: Context) {
|
|
|
48
45
|
dataObj.created_user_session = JSON.stringify(sessionInfo); // 创建人的session信息。用于执行时的鉴权。
|
|
49
46
|
}
|
|
50
47
|
|
|
51
|
-
|
|
52
48
|
/**
|
|
53
49
|
* 异步任务框架
|
|
54
50
|
*/
|
|
@@ -84,5 +80,4 @@ export class AsyncTaskController extends BaseApiController {
|
|
|
84
80
|
await this.executeSysSimpleSQL(SystemTables.sys_async_tasks, KeysOfSimpleSQL.SIMPLE_UPDATE);
|
|
85
81
|
return { success: true };
|
|
86
82
|
}
|
|
87
|
-
|
|
88
83
|
}
|
|
@@ -2,13 +2,13 @@ import * as _ from 'lodash';
|
|
|
2
2
|
import { decamelizeKeys } from 'humps';
|
|
3
3
|
import { Controller, Inject, Param, All } from '@midwayjs/core';
|
|
4
4
|
import { Context } from '@midwayjs/koa';
|
|
5
|
-
import { CommonResult } from '
|
|
6
|
-
import { WorkbenchService } from '
|
|
7
|
-
import { API_BASE_TYPE, ApiBaseService } from '
|
|
8
|
-
import { CurdProService } from '
|
|
9
|
-
import { CurdMixService } from '
|
|
10
|
-
import { IRequestCfgModel2 } from '
|
|
11
|
-
import { parseDatabaseName } from
|
|
5
|
+
import { CommonResult } from '@/libs/utils/common-dto';
|
|
6
|
+
import { WorkbenchService } from '@/service/WorkbenchService';
|
|
7
|
+
import { API_BASE_TYPE, ApiBaseService } from '@/service/base/ApiBaseService';
|
|
8
|
+
import { CurdProService } from '@/service/curd/CurdProService';
|
|
9
|
+
import { CurdMixService } from '@/service/curd/CurdMixService';
|
|
10
|
+
import { IRequestCfgModel2 } from '@/models/bizmodels';
|
|
11
|
+
import { parseDatabaseName } from '@/libs/crud-pro/utils/DatabaseName';
|
|
12
12
|
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
13
13
|
|
|
14
14
|
const QUERY_AS_LIST = ['condition', 'data'];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Controller, Inject, Post } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
-
import { CrudStdService, SPECIAL_SETTING_KEY } from '
|
|
5
|
-
import { KeysOfSimpleSQL } from '
|
|
6
|
-
import { IRequestModel } from '
|
|
7
|
-
import { CommonResult } from '
|
|
4
|
+
import { CrudStdService, SPECIAL_SETTING_KEY } from '@/service/crudstd/CrudStdService';
|
|
5
|
+
import { KeysOfSimpleSQL } from '@/libs/crud-pro/models/keys';
|
|
6
|
+
import { IRequestModel } from '@/libs/crud-pro/interfaces';
|
|
7
|
+
import { CommonResult } from '@/libs/utils/common-dto';
|
|
8
8
|
|
|
9
9
|
interface ICrudStdActionParams {
|
|
10
10
|
appCode: string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {Get, Controller, Inject, Query} from '@midwayjs/core';
|
|
2
|
-
import {Context} from '@midwayjs/koa';
|
|
3
|
-
import {BaseApiController} from '../base/BaseApiController';
|
|
4
|
-
import { SystemTables} from '
|
|
1
|
+
import { Get, Controller, Inject, Query } from '@midwayjs/core';
|
|
2
|
+
import { Context } from '@midwayjs/koa';
|
|
3
|
+
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
+
import { SystemTables } from '@/models/SystemTables';
|
|
5
5
|
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
6
|
-
import {KeysOfSimpleSQL} from '
|
|
7
|
-
import {WorkbenchService} from '
|
|
8
|
-
import {CommonResult} from '
|
|
6
|
+
import { KeysOfSimpleSQL } from '@/libs/crud-pro/models/keys';
|
|
7
|
+
import { WorkbenchService } from '@/service/WorkbenchService';
|
|
8
|
+
import { CommonResult } from '@/libs/utils/common-dto';
|
|
9
9
|
|
|
10
10
|
function checkIsNumber(value: string, name: string) {
|
|
11
11
|
if (!value) {
|
|
@@ -28,21 +28,21 @@ export class DocGatewayController extends BaseApiController {
|
|
|
28
28
|
@Inject()
|
|
29
29
|
protected workbenchService: WorkbenchService;
|
|
30
30
|
|
|
31
|
-
|
|
32
31
|
private async updateDocPV(docId: string, docLibId: string, pv: number) {
|
|
33
32
|
const ip = this.ctx.headers['x-real-ip'];
|
|
34
33
|
const lockKey = `doc_ip_pv_${docId}_${ip}`;
|
|
35
34
|
const EXPIRE_TIME = 5 * 60 * 1000; // 在五分钟内,同一个IP地址重复刷新同一篇文章,认为是一个PV
|
|
36
|
-
const nxRes = await this.redisService.set(lockKey, 1, 'EX', EXPIRE_TIME, 'NX')
|
|
35
|
+
const nxRes = await this.redisService.set(lockKey, 1, 'EX', EXPIRE_TIME, 'NX');
|
|
37
36
|
if (nxRes !== 'OK') {
|
|
38
37
|
return;
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
const {SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
40
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
42
41
|
|
|
43
|
-
await this.curdMixService.executeCrudByCfg(
|
|
42
|
+
await this.curdMixService.executeCrudByCfg(
|
|
43
|
+
{
|
|
44
44
|
data: {
|
|
45
|
-
pv: pv + 1
|
|
45
|
+
pv: pv + 1,
|
|
46
46
|
},
|
|
47
47
|
condition: {
|
|
48
48
|
id: parseInt(docId),
|
|
@@ -54,10 +54,10 @@ export class DocGatewayController extends BaseApiController {
|
|
|
54
54
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
55
55
|
sqlDatabase: SystemDbName,
|
|
56
56
|
sqlDbType: SystemDbType,
|
|
57
|
-
}
|
|
57
|
+
}
|
|
58
|
+
);
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
|
|
61
61
|
/**
|
|
62
62
|
* @param docId
|
|
63
63
|
* @param docLibId 文档库
|
|
@@ -72,7 +72,7 @@ export class DocGatewayController extends BaseApiController {
|
|
|
72
72
|
return docLibInfoRes;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
const {SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
75
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
76
76
|
|
|
77
77
|
const res = await this.curdMixService.executeCrudByCfg(
|
|
78
78
|
{
|
|
@@ -111,7 +111,7 @@ export class DocGatewayController extends BaseApiController {
|
|
|
111
111
|
return docLibInfoRes;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
const {SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
114
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
115
115
|
|
|
116
116
|
return this.curdMixService.executeCrudByCfg(
|
|
117
117
|
{
|
|
@@ -141,7 +141,7 @@ export class DocGatewayController extends BaseApiController {
|
|
|
141
141
|
async getDocLibInfo(@Query('docLibId') docLibId: string) {
|
|
142
142
|
checkIsNumber(docLibId, 'docLibId');
|
|
143
143
|
|
|
144
|
-
const {SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
144
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
145
145
|
|
|
146
146
|
const s = await this.curdMixService.executeCrudByCfg(
|
|
147
147
|
{
|
|
@@ -2,18 +2,17 @@ import { Get, Post, Inject, Controller, Files, Fields, Param, Query } from '@mid
|
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import * as _ from 'lodash';
|
|
4
4
|
import { BaseApiController } from '../base/BaseApiController';
|
|
5
|
-
import { BizException } from '
|
|
6
|
-
import {AccessType, FILE_GET_TYPES} from '
|
|
7
|
-
import { FileCenterService, PATH_PREFIX, toDownloadPaths, isImageFile } from '
|
|
8
|
-
import { checkPermission } from '
|
|
9
|
-
import { CommonResult } from '
|
|
10
|
-
import {SystemFuncCode} from
|
|
5
|
+
import { BizException } from '@/models/devops';
|
|
6
|
+
import { AccessType, FILE_GET_TYPES } from '@/models/bizmodels';
|
|
7
|
+
import { FileCenterService, PATH_PREFIX, toDownloadPaths, isImageFile } from '@/service/FileCenterService';
|
|
8
|
+
import { checkPermission } from '@/middleware/permission.middleware';
|
|
9
|
+
import { CommonResult } from '@/libs/utils/common-dto';
|
|
10
|
+
import { SystemFuncCode } from '@/models/SystemPerm';
|
|
11
11
|
|
|
12
12
|
function isTrue(obj: any) {
|
|
13
13
|
return obj === true || obj === 'true';
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
/**
|
|
18
17
|
* 文件上传下载服务
|
|
19
18
|
*/
|
|
@@ -31,7 +30,7 @@ export class FileController extends BaseApiController {
|
|
|
31
30
|
* @param fields
|
|
32
31
|
* @param queryData
|
|
33
32
|
*/
|
|
34
|
-
@Post('/uploadFile',
|
|
33
|
+
@Post('/uploadFile', { middleware: [checkPermission([SystemFuncCode.DocMangeWrite, SystemFuncCode.FileMangeWrite, SystemFuncCode.UserAccountMangeWrite])] })
|
|
35
34
|
async uploadFile(@Files() files, @Fields() fields, @Query() queryData): Promise<CommonResult> {
|
|
36
35
|
const accessType = queryData?.accessType || fields?.accessType || AccessType.open;
|
|
37
36
|
const referer = this.ctx.req.headers.referer;
|
|
@@ -64,7 +63,7 @@ export class FileController extends BaseApiController {
|
|
|
64
63
|
* @param streaming 是否直接返回流,默认返回 302 跳转
|
|
65
64
|
*/
|
|
66
65
|
@Get('/get/:byMethod/:fileKey*')
|
|
67
|
-
async downloadFile(@Param('byMethod') byMethod: string
|
|
66
|
+
async downloadFile(@Param('byMethod') byMethod: string, @Param('fileKey') fileKey: string) {
|
|
68
67
|
if (!fileKey) {
|
|
69
68
|
throw new BizException('fileKey不能为空');
|
|
70
69
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { All, Controller, Inject, Query } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
-
import { ProxyApiService } from '
|
|
5
|
-
import { WorkbenchService } from '
|
|
6
|
-
import { CommonResult } from '
|
|
7
|
-
import { ProxyApiLoadService } from '
|
|
4
|
+
import { ProxyApiService } from '@/service/proxyapi/ProxyApiService';
|
|
5
|
+
import { WorkbenchService } from '@/service/WorkbenchService';
|
|
6
|
+
import { CommonResult } from '@/libs/utils/common-dto';
|
|
7
|
+
import { ProxyApiLoadService } from '@/service/proxyapi/ProxyApiLoadService';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* 只支持前缀匹配
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {Controller, Get, Inject, Post} from '@midwayjs/core';
|
|
2
|
-
import {Context} from '@midwayjs/koa';
|
|
1
|
+
import { Controller, Get, Inject, Post } from '@midwayjs/core';
|
|
2
|
+
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import * as _ from 'lodash';
|
|
4
|
-
import {BaseApiController} from '../base/BaseApiController';
|
|
5
|
-
import {SystemTables} from '
|
|
6
|
-
import {EnumInfoService} from '
|
|
7
|
-
import {CommonResult} from '
|
|
8
|
-
import {parseJsonObject} from '
|
|
9
|
-
import {WorkbenchService} from '
|
|
10
|
-
import {SystemRoleCode} from
|
|
11
|
-
import {KeysOfAuthType} from
|
|
4
|
+
import { BaseApiController } from '../base/BaseApiController';
|
|
5
|
+
import { SystemTables } from '@/models/SystemTables';
|
|
6
|
+
import { EnumInfoService } from '@/service/EnumInfoService';
|
|
7
|
+
import { CommonResult } from '@/libs/utils/common-dto';
|
|
8
|
+
import { parseJsonObject } from '@/libs/utils/functions';
|
|
9
|
+
import { WorkbenchService } from '@/service/WorkbenchService';
|
|
10
|
+
import { SystemRoleCode } from '@/models/SystemPerm';
|
|
11
|
+
import { KeysOfAuthType } from '@/libs/crud-pro/models/keys';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* 公开的API,无需鉴权,所有人可以直接访问
|
|
@@ -52,12 +52,12 @@ export class PublicApiController extends BaseApiController {
|
|
|
52
52
|
return CommonResult.errorRes('param workbenchMenuCode is null');
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
const workbenchMenuCodeStr =
|
|
56
|
-
const workbenchMenuCodeArray =
|
|
55
|
+
const workbenchMenuCodeStr = '' + workbenchMenuCode;
|
|
56
|
+
const workbenchMenuCodeArray = workbenchMenuCodeStr.split(',');
|
|
57
57
|
|
|
58
58
|
const condition = {
|
|
59
59
|
menu_code: {
|
|
60
|
-
|
|
60
|
+
$in: workbenchMenuCodeArray,
|
|
61
61
|
},
|
|
62
62
|
};
|
|
63
63
|
const rows = await this.sysDBUtil.getList({ condition }, SystemTables.sys_menus);
|
|
@@ -72,22 +72,19 @@ export class PublicApiController extends BaseApiController {
|
|
|
72
72
|
const view_auth_config = rowElement.view_auth_config;
|
|
73
73
|
const view_auth_type = rowElement.view_auth_type;
|
|
74
74
|
|
|
75
|
-
const hasPermission
|
|
75
|
+
const hasPermission = this.ctx.userSession.isAuthPass(view_auth_type, view_auth_config);
|
|
76
76
|
|
|
77
77
|
const menu_config_content = rowElement.menu_config_content;
|
|
78
78
|
delete rowElement.menu_config_content;
|
|
79
79
|
const menu_list = parseJsonObject(menu_config_content) || [];
|
|
80
|
-
map[menu_code] = { ...rowElement, menu_list, hasPermission }
|
|
80
|
+
map[menu_code] = { ...rowElement, menu_list, hasPermission };
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
84
83
|
// 特殊的devops菜单
|
|
85
84
|
map['devops'] = {
|
|
86
85
|
menu_list: [], // 这个特殊的菜单在前端写死。
|
|
87
|
-
hasPermission: this.ctx.userSession.isAuthPass(KeysOfAuthType.byRoleCode, [
|
|
88
|
-
|
|
89
|
-
])
|
|
90
|
-
}
|
|
86
|
+
hasPermission: this.ctx.userSession.isAuthPass(KeysOfAuthType.byRoleCode, [SystemRoleCode.DevOpsWriter, SystemRoleCode.DevOpsViewer, SystemRoleCode.SuperAdmin]),
|
|
87
|
+
};
|
|
91
88
|
|
|
92
89
|
return CommonResult.successRes(map);
|
|
93
90
|
}
|
|
@@ -108,7 +105,7 @@ export class PublicApiController extends BaseApiController {
|
|
|
108
105
|
if (oneData && oneData['app_schema']) {
|
|
109
106
|
oneData['app_schema'] = parseJsonObject(oneData['app_schema']);
|
|
110
107
|
}
|
|
111
|
-
resultData[key] = oneData
|
|
108
|
+
resultData[key] = oneData;
|
|
112
109
|
}
|
|
113
110
|
};
|
|
114
111
|
|
|
@@ -126,7 +123,7 @@ export class PublicApiController extends BaseApiController {
|
|
|
126
123
|
const body = this.ctx.request.body as any;
|
|
127
124
|
const query = this.ctx.query || {};
|
|
128
125
|
let codeList = _.get(body, 'codeList');
|
|
129
|
-
|
|
126
|
+
const refreshCache = `${_.get(body, 'refreshCache')}` === 'true' || query.refreshCache === 'true';
|
|
130
127
|
|
|
131
128
|
if (query.codeList) {
|
|
132
129
|
//codeList=dict@@SexEnum,sysCfgEnum@@EntityStatusEnum
|