midway-fatcms 0.0.1-beta.68 → 0.0.1-beta.70
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 +1 -0
- package/dist/controller/gateway/CrudStdGatewayController.d.ts +1 -0
- package/dist/controller/gateway/CrudStdGatewayController.js +7 -13
- package/dist/controller/gateway/PublicApiController.d.ts +2 -1
- package/dist/controller/gateway/PublicApiController.js +31 -37
- package/dist/controller/manage/AppMangeApi.d.ts +3 -1
- package/dist/controller/manage/AppMangeApi.js +13 -0
- package/dist/controller/manage/SysConfigMangeApi.d.ts +1 -0
- package/dist/controller/manage/SysConfigMangeApi.js +9 -2
- package/dist/controller/manage/UserAccountManageApi.d.ts +4 -2
- package/dist/controller/manage/UserAccountManageApi.js +24 -0
- package/dist/controller/manage/WorkbenchMangeApi.js +2 -2
- package/dist/controller/render/AppRenderController.d.ts +1 -0
- package/dist/controller/render/AppRenderController.js +6 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/libs/crud-pro/interfaces.d.ts +1 -0
- package/dist/libs/crud-pro/models/SqlCfgModel.d.ts +1 -0
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +2 -2
- package/dist/libs/crud-pro/services/CrudProServiceBase.js +2 -4
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.d.ts +1 -1
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.js +4 -1
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.d.ts +1 -1
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.js +4 -1
- package/dist/models/bizmodels.d.ts +4 -3
- package/dist/models/bizmodels.js +4 -3
- package/dist/service/EnumInfoService.d.ts +1 -0
- package/dist/service/EnumInfoService.js +10 -17
- package/dist/service/SysAppService.d.ts +14 -0
- package/dist/service/SysAppService.js +96 -0
- package/dist/service/SysConfigService.d.ts +3 -0
- package/dist/service/SysConfigService.js +29 -12
- package/dist/service/WorkbenchService.d.ts +10 -5
- package/dist/service/WorkbenchService.js +54 -42
- package/dist/service/base/cache/CacheServiceFactory.d.ts +5 -0
- package/dist/service/base/cache/CacheServiceFactory.js +6 -1
- package/dist/service/crudstd/CrudStdService.d.ts +2 -14
- package/dist/service/crudstd/CrudStdService.js +6 -39
- package/dist/service/curd/CrudProQuick.d.ts +9 -3
- package/dist/service/curd/CrudProQuick.js +19 -3
- package/dist/service/curd/CurdMixByAccountService.js +4 -4
- package/dist/service/curd/CurdMixBySysConfigService.js +2 -2
- package/dist/service/curd/CurdMixByWorkbenchService.js +2 -2
- package/package.json +1 -1
- package/src/config/config.default.ts +1 -0
- package/src/controller/gateway/CrudStdGatewayController.ts +7 -13
- package/src/controller/gateway/PublicApiController.ts +39 -49
- package/src/controller/manage/AppMangeApi.ts +14 -1
- package/src/controller/manage/SysConfigMangeApi.ts +16 -8
- package/src/controller/manage/UserAccountManageApi.ts +28 -0
- package/src/controller/manage/WorkbenchMangeApi.ts +2 -2
- package/src/controller/render/AppRenderController.ts +5 -14
- package/src/index.ts +1 -0
- package/src/libs/crud-pro/interfaces.ts +1 -0
- package/src/libs/crud-pro/models/SqlCfgModel.ts +1 -0
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +2 -2
- package/src/libs/crud-pro/services/CrudProServiceBase.ts +15 -17
- package/src/libs/crud-pro/utils/sqlConvert/convertMsSql.ts +5 -1
- package/src/libs/crud-pro/utils/sqlConvert/convertPgSql.ts +6 -1
- package/src/models/bizmodels.ts +5 -3
- package/src/service/EnumInfoService.ts +9 -22
- package/src/service/SysAppService.ts +88 -0
- package/src/service/SysConfigService.ts +30 -16
- package/src/service/WorkbenchService.ts +78 -61
- package/src/service/base/cache/CacheServiceFactory.ts +12 -1
- package/src/service/crudstd/CrudStdService.ts +7 -43
- package/src/service/curd/CrudProQuick.ts +22 -3
- package/src/service/curd/CurdMixByAccountService.ts +4 -4
- package/src/service/curd/CurdMixBySysConfigService.ts +3 -2
- package/src/service/curd/CurdMixByWorkbenchService.ts +2 -2
|
@@ -54,13 +54,13 @@ let CurdMixByAccountService = class CurdMixByAccountService {
|
|
|
54
54
|
executeContext[TMP_CTX_KEY] = MixinUtils_1.MixinUtils.toNewMap(userInfos, (obj) => obj.account_id);
|
|
55
55
|
executeContext[TMP_CTX_KEY2] = isArrayModeMap;
|
|
56
56
|
}
|
|
57
|
-
async getFromCache(
|
|
57
|
+
async getFromCache(accountId) {
|
|
58
58
|
const cacheService = this.cacheServiceFactory.getCacheServiceByName(bizmodels_1.CacheNameEnum.CurdMixByAccount);
|
|
59
|
-
return cacheService.getJsonObject(
|
|
59
|
+
return cacheService.getJsonObject(accountId);
|
|
60
60
|
}
|
|
61
|
-
async setToCache(
|
|
61
|
+
async setToCache(accountId, value) {
|
|
62
62
|
const cacheService = this.cacheServiceFactory.getCacheServiceByName(bizmodels_1.CacheNameEnum.CurdMixByAccount);
|
|
63
|
-
return cacheService.setJsonObject(
|
|
63
|
+
return cacheService.setJsonObject(accountId, value);
|
|
64
64
|
}
|
|
65
65
|
async queryUserAccountIdList(accountIds) {
|
|
66
66
|
const resultRowMap = {};
|
|
@@ -25,11 +25,11 @@ const dictMixUtils = new CurdMixUtils_1.CrudMixUtils(CurdMixUtils_1.RelatedType.
|
|
|
25
25
|
const TMP_CTX_KEY = _.uniqueId('CurdMixBySysConfigService');
|
|
26
26
|
let CurdMixBySysConfigService = class CurdMixBySysConfigService {
|
|
27
27
|
async getFromCache(code) {
|
|
28
|
-
const cacheService = this.cacheServiceFactory.getCacheServiceByName(bizmodels_1.CacheNameEnum.
|
|
28
|
+
const cacheService = this.cacheServiceFactory.getCacheServiceByName(bizmodels_1.CacheNameEnum.GetSysConfigOne);
|
|
29
29
|
return cacheService.getJsonObject(code);
|
|
30
30
|
}
|
|
31
31
|
async setToCache(code, value) {
|
|
32
|
-
const cacheService = this.cacheServiceFactory.getCacheServiceByName(bizmodels_1.CacheNameEnum.
|
|
32
|
+
const cacheService = this.cacheServiceFactory.getCacheServiceByName(bizmodels_1.CacheNameEnum.GetSysConfigOne);
|
|
33
33
|
return cacheService.setJsonObject(code, value);
|
|
34
34
|
}
|
|
35
35
|
async queryConfigRowsUseCache(codes) {
|
|
@@ -26,9 +26,9 @@ let CurdMixByWorkbenchService = class CurdMixByWorkbenchService {
|
|
|
26
26
|
async loadWorkbenchListMap() {
|
|
27
27
|
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
28
28
|
return await this.cacheServiceFactory.getJsonObjectCache({
|
|
29
|
-
cacheKey:
|
|
30
|
-
refreshCache: false,
|
|
29
|
+
cacheKey: bizmodels_1.CacheNameEnum.CurdMixByWorkbench,
|
|
31
30
|
cacheName: bizmodels_1.CacheNameEnum.CurdMixByWorkbench,
|
|
31
|
+
refreshCache: false,
|
|
32
32
|
getter: async () => {
|
|
33
33
|
const reqJson = {
|
|
34
34
|
columns: 'workbench_code,workbench_name,workbench_domain',
|
package/package.json
CHANGED
|
@@ -172,6 +172,7 @@ export default (appInfo: any) => {
|
|
|
172
172
|
cacheConfig: {
|
|
173
173
|
UserSessionBySessionId: { cacheLevel: 'REDIS', cacheSecond: 3600 * 24 * 30 },
|
|
174
174
|
UserSessionByAsyncTaskId: { cacheLevel: 'REDIS', cacheSecond: 3600 },
|
|
175
|
+
CurdMixByLinkToCustom: { cacheLevel: 'MEMORY', cacheSecond: 60 * 5 },
|
|
175
176
|
}
|
|
176
177
|
},
|
|
177
178
|
|
|
@@ -5,6 +5,7 @@ import { CrudStdService, SPECIAL_SETTING_KEY, ICrudStdActionParams, IRequestMode
|
|
|
5
5
|
import { KeysOfSimpleSQL } from '@/libs/crud-pro/models/keys';
|
|
6
6
|
import { CommonResult } from '@/libs/utils/common-dto';
|
|
7
7
|
import { checkLogin } from '@/middleware/permission.middleware';
|
|
8
|
+
import {SysAppService} from "@/service/SysAppService";
|
|
8
9
|
|
|
9
10
|
type ICrudStdParams = { stdAction: ICrudStdActionParams } & IRequestModelCrudProExt;
|
|
10
11
|
|
|
@@ -21,6 +22,9 @@ export class CrudStdGatewayController extends BaseApiController {
|
|
|
21
22
|
@Inject()
|
|
22
23
|
private crudStdService: CrudStdService;
|
|
23
24
|
|
|
25
|
+
@Inject()
|
|
26
|
+
private sysAppService: SysAppService;
|
|
27
|
+
|
|
24
28
|
/**
|
|
25
29
|
* 获取零代码应用基本信息
|
|
26
30
|
*/
|
|
@@ -30,19 +34,9 @@ export class CrudStdGatewayController extends BaseApiController {
|
|
|
30
34
|
const body = decodeBody as ICrudStdParams;
|
|
31
35
|
const appCode = body.stdAction.appCode;
|
|
32
36
|
const parsedAppInfo = await this.crudStdService.getParsedCrudStdAppInfo(appCode);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
delete parsedAppInfo2.created_by;
|
|
37
|
-
delete parsedAppInfo2.workbench_code_array;
|
|
38
|
-
delete parsedAppInfo2.modified_at;
|
|
39
|
-
delete parsedAppInfo2.modified_by;
|
|
40
|
-
delete parsedAppInfo2.modified_desc;
|
|
41
|
-
delete parsedAppInfo2.std_crud_db;
|
|
42
|
-
delete parsedAppInfo2.std_crud_tbl;
|
|
43
|
-
return CommonResult.successNotNull(parsedAppInfo2);
|
|
44
|
-
}
|
|
45
|
-
return CommonResult.successNotNull(null);
|
|
37
|
+
|
|
38
|
+
const parsedAppInfo2 = await this.sysAppService.deletePrivateField(parsedAppInfo);
|
|
39
|
+
return CommonResult.successNotNull(parsedAppInfo2);
|
|
46
40
|
}
|
|
47
41
|
|
|
48
42
|
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {Controller, Get, Inject, Post} from '@midwayjs/core';
|
|
2
|
+
import {Context} from '@midwayjs/koa';
|
|
3
3
|
import * as _ from 'lodash';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
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
|
+
import {CacheServiceFactory} from '@/service/base/cache/CacheServiceFactory';
|
|
13
|
+
import {CacheNameEnum} from "@/models/bizmodels";
|
|
14
|
+
import {checkLogin} from "@/middleware/permission.middleware";
|
|
15
|
+
import {SysAppService} from "@/service/SysAppService";
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* 公开的API,无需鉴权,所有人可以直接访问
|
|
20
20
|
*/
|
|
21
|
-
@Controller('/ns/gw/api/publicApi')
|
|
21
|
+
@Controller('/ns/gw/api/publicApi', { middleware: [checkLogin()] })
|
|
22
22
|
export class PublicApiController extends BaseApiController {
|
|
23
23
|
@Inject()
|
|
24
24
|
protected ctx: Context;
|
|
@@ -32,12 +32,15 @@ export class PublicApiController extends BaseApiController {
|
|
|
32
32
|
@Inject()
|
|
33
33
|
private cacheServiceFactory: CacheServiceFactory;
|
|
34
34
|
|
|
35
|
+
@Inject()
|
|
36
|
+
private sysAppService: SysAppService;
|
|
37
|
+
|
|
35
38
|
/**
|
|
36
39
|
* 获取所有站点列表
|
|
37
40
|
*/
|
|
38
41
|
@Get('/getAllWorkbenchInfoList')
|
|
39
42
|
async getAllWorkbenchInfoList(): Promise<CommonResult> {
|
|
40
|
-
const entities = await this.workbenchService.getAllWorkbenchInfoList(
|
|
43
|
+
const entities = await this.workbenchService.getAllWorkbenchInfoList();
|
|
41
44
|
const entities2 = entities.map(e => {
|
|
42
45
|
return {
|
|
43
46
|
workbench_domain: e.workbench_domain,
|
|
@@ -110,38 +113,25 @@ export class PublicApiController extends BaseApiController {
|
|
|
110
113
|
async getNavPageInfo(): Promise<CommonResult> {
|
|
111
114
|
const body = this.ctx.request.body as any;
|
|
112
115
|
const { workbenchCode, appCode, pathname } = body;
|
|
113
|
-
const resultData: any = {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const values = Object.values(condition).filter(Boolean);
|
|
117
|
-
// 查询条件不能为空
|
|
118
|
-
if (values.length > 0) {
|
|
119
|
-
const oneData = await this.sysDBUtil.getOne({ condition }, tableName);
|
|
120
|
-
if (oneData && oneData['app_schema']) {
|
|
121
|
-
oneData['app_schema'] = parseJsonObject(oneData['app_schema']);
|
|
122
|
-
}
|
|
123
|
-
return oneData;
|
|
124
|
-
}
|
|
125
|
-
return null;
|
|
116
|
+
const resultData: any = {
|
|
117
|
+
appData: null,
|
|
118
|
+
pageData: null,
|
|
126
119
|
};
|
|
127
120
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
cacheKey,
|
|
133
|
-
cacheName: CacheNameEnum.GetNavPageInfo,
|
|
134
|
-
getter: async () => {
|
|
135
|
-
return await getOneImpl(condition, tableName);
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
if (oneData) {
|
|
139
|
-
resultData[key] = oneData;
|
|
121
|
+
if (appCode) {
|
|
122
|
+
const appInfo = await this.sysAppService.getSysAppOne(appCode);
|
|
123
|
+
if (appInfo && appInfo['app_schema']) {
|
|
124
|
+
appInfo['app_schema'] = parseJsonObject(appInfo['app_schema']);
|
|
140
125
|
}
|
|
141
|
-
|
|
126
|
+
resultData.appData = await this.sysAppService.deletePrivateField(appInfo);
|
|
127
|
+
}
|
|
142
128
|
|
|
143
|
-
|
|
144
|
-
|
|
129
|
+
if (pathname && workbenchCode) {
|
|
130
|
+
resultData.pageData = await this.sysAppService.getSysAppPageOne({
|
|
131
|
+
page_path: pathname,
|
|
132
|
+
workbench_code: workbenchCode
|
|
133
|
+
});
|
|
134
|
+
}
|
|
145
135
|
|
|
146
136
|
return CommonResult.successRes(resultData);
|
|
147
137
|
}
|
|
@@ -178,11 +168,11 @@ export class PublicApiController extends BaseApiController {
|
|
|
178
168
|
*/
|
|
179
169
|
@Post('/getSysAppInfoByAppCode')
|
|
180
170
|
async getSysAppInfoByAppCode() {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
});
|
|
171
|
+
const body = this.ctx.request.body as any;
|
|
172
|
+
const app_code = body?.condition?.app_code;
|
|
173
|
+
const appInfo = await this.sysAppService.getSysAppOne(app_code);
|
|
174
|
+
const appInfo2 = await this.sysAppService.deletePrivateField(appInfo);
|
|
175
|
+
return CommonResult.successRes({ row: appInfo2 });
|
|
186
176
|
}
|
|
187
177
|
|
|
188
178
|
|
|
@@ -4,11 +4,15 @@ import { KeysOfSimpleSQL, KeysOfValidators } from '@/libs/crud-pro/models/keys';
|
|
|
4
4
|
import { BaseApiController } from '../base/BaseApiController';
|
|
5
5
|
import { checkPermission } from '@/middleware/permission.middleware';
|
|
6
6
|
import { SystemFuncCode } from '@/models/SystemPerm';
|
|
7
|
+
import {SysAppService} from "@/service/SysAppService";
|
|
7
8
|
|
|
8
9
|
@Controller('/ns/api/manage/app', { middleware: [checkPermission(SystemFuncCode.AppMangeRead)] })
|
|
9
10
|
export class AppMangeApi extends BaseApiController {
|
|
10
11
|
@Inject()
|
|
11
|
-
ctx: Context;
|
|
12
|
+
protected ctx: Context;
|
|
13
|
+
|
|
14
|
+
@Inject()
|
|
15
|
+
protected sysAppService: SysAppService
|
|
12
16
|
|
|
13
17
|
@Post('/getAppList')
|
|
14
18
|
async getAppList() {
|
|
@@ -33,6 +37,11 @@ export class AppMangeApi extends BaseApiController {
|
|
|
33
37
|
|
|
34
38
|
@Post('/updateApp', { middleware: [checkPermission(SystemFuncCode.AppMangeWrite)] })
|
|
35
39
|
async updateApp() {
|
|
40
|
+
const body = this.ctx.request.body as any;
|
|
41
|
+
const appCode = body?.condition?.app_code;
|
|
42
|
+
|
|
43
|
+
await this.sysAppService.removeSysAppOneCache(appCode);
|
|
44
|
+
|
|
36
45
|
return this.executeSysSimpleSQL('sys_app', KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
37
46
|
validateCfg: {
|
|
38
47
|
'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMERIC],
|
|
@@ -43,6 +52,10 @@ export class AppMangeApi extends BaseApiController {
|
|
|
43
52
|
|
|
44
53
|
@Post('/deleteApp', { middleware: [checkPermission(SystemFuncCode.AppMangeWrite)] })
|
|
45
54
|
async deleteApp() {
|
|
55
|
+
const body = this.ctx.request.body as any;
|
|
56
|
+
const appCode = body?.condition?.app_code;
|
|
57
|
+
await this.sysAppService.removeSysAppOneCache(appCode);
|
|
58
|
+
|
|
46
59
|
return this.executeSysSimpleSQL('sys_app', KeysOfSimpleSQL.SIMPLE_DELETE, {
|
|
47
60
|
validateCfg: {
|
|
48
61
|
'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMERIC],
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { Controller, Inject, Post } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { KeysOfSimpleSQL, KeysOfValidators } from '
|
|
3
|
+
import { KeysOfSimpleSQL, KeysOfValidators } from '@/libs/crud-pro/models/keys';
|
|
4
4
|
import { BaseApiController } from '../base/BaseApiController';
|
|
5
|
-
import { checkPermission } from '
|
|
6
|
-
import { SystemFuncCode } from '
|
|
7
|
-
import { CTX_WORKBENCH_CODE } from '
|
|
8
|
-
import { SystemTables } from '
|
|
9
|
-
import { CommonResult } from '
|
|
5
|
+
import { checkPermission } from '@/middleware/permission.middleware';
|
|
6
|
+
import { SystemFuncCode } from '@/models/SystemPerm';
|
|
7
|
+
import { CTX_WORKBENCH_CODE } from '@/models/bizmodels';
|
|
8
|
+
import { SystemTables } from '@/models/SystemTables';
|
|
9
|
+
import { CommonResult } from '@/libs/utils/common-dto';
|
|
10
10
|
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
11
|
+
import {SysConfigService} from "@/service/SysConfigService";
|
|
11
12
|
|
|
12
13
|
@Controller('/ns/api/manage/sysconfig', { middleware: [checkPermission(SystemFuncCode.SysConfigMangeRead)] })
|
|
13
14
|
export class SysConfigMangeApi extends BaseApiController {
|
|
14
15
|
@Inject()
|
|
15
16
|
ctx: Context;
|
|
16
17
|
|
|
18
|
+
@Inject()
|
|
19
|
+
private sysConfigService: SysConfigService
|
|
20
|
+
|
|
17
21
|
@Post('/getSysConfigList')
|
|
18
22
|
async getSysConfigList() {
|
|
19
23
|
return this.executeSysSimpleSQL('sys_configs', KeysOfSimpleSQL.SIMPLE_QUERY_PAGE, {
|
|
@@ -57,12 +61,12 @@ export class SysConfigMangeApi extends BaseApiController {
|
|
|
57
61
|
return CommonResult.errorRes('id不能为空');
|
|
58
62
|
}
|
|
59
63
|
|
|
60
|
-
const sysConfig = await this.curdMixService.getBbUtil(SystemDbName, SystemDbType).
|
|
64
|
+
const sysConfig = await this.curdMixService.getBbUtil(SystemDbName, SystemDbType).getUniqueOne({ condition: body.condition }, SystemTables.sys_configs);
|
|
61
65
|
if (!sysConfig) {
|
|
62
66
|
return CommonResult.errorRes('配置项不存在');
|
|
63
67
|
}
|
|
64
68
|
|
|
65
|
-
const { edit_auth_type, edit_auth_config } = sysConfig;
|
|
69
|
+
const { edit_auth_type, edit_auth_config, config_code } = sysConfig;
|
|
66
70
|
if (edit_auth_type) {
|
|
67
71
|
const isOK = this.ctx.userSession.isAuthPass(edit_auth_type, edit_auth_config);
|
|
68
72
|
if (!isOK) {
|
|
@@ -70,6 +74,10 @@ export class SysConfigMangeApi extends BaseApiController {
|
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
76
|
|
|
77
|
+
// 移除缓存
|
|
78
|
+
await this.sysConfigService.removeSysConfigOneCache(config_code);
|
|
79
|
+
|
|
80
|
+
|
|
73
81
|
return this.executeSysSimpleSQL('sys_configs', KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
74
82
|
validateCfg: {
|
|
75
83
|
'data.workbench_code': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING, 'length:1,64'],
|
|
@@ -8,6 +8,9 @@ import { SystemFuncCode } from '../../models/SystemPerm';
|
|
|
8
8
|
import { CommonException, Exceptions } from '../../libs/crud-pro/exceptions';
|
|
9
9
|
import { SystemTables } from '../../models/SystemTables';
|
|
10
10
|
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
11
|
+
import {CacheServiceFactory} from "@/service/base/cache/CacheServiceFactory";
|
|
12
|
+
import {CacheNameEnum} from "@/models/bizmodels";
|
|
13
|
+
import {CommonResult} from "@/libs/utils/common-dto";
|
|
11
14
|
|
|
12
15
|
const accountNameBlacklist = new Set(['sa', 'root', 'admin', 'superadmin', 'administrator', 'sys', 'sysop', 'schedule_user']);
|
|
13
16
|
function checkAccountCreateBlacklist(value: string) {
|
|
@@ -26,6 +29,9 @@ export class UserAccountManageApi extends BaseApiController {
|
|
|
26
29
|
@Inject()
|
|
27
30
|
protected ctx: Context;
|
|
28
31
|
|
|
32
|
+
@Inject()
|
|
33
|
+
private cacheServiceFactory: CacheServiceFactory;
|
|
34
|
+
|
|
29
35
|
@Post('/getUserAccountList')
|
|
30
36
|
async getUserAccountList() {
|
|
31
37
|
return this.executeSysSimpleSQL(SystemTables.sys_user_account, KeysOfSimpleSQL.SIMPLE_QUERY_PAGE, {
|
|
@@ -42,6 +48,28 @@ export class UserAccountManageApi extends BaseApiController {
|
|
|
42
48
|
|
|
43
49
|
@Post('/updateUserAccount', { middleware: [checkPermission(SystemFuncCode.UserAccountMangeWrite)] })
|
|
44
50
|
async updateUserAccount() {
|
|
51
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
52
|
+
const body = this.ctx.request.body as any;
|
|
53
|
+
const id = body.condition.id;
|
|
54
|
+
if (!id) {
|
|
55
|
+
return CommonResult.errorRes('id不能为空');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const userAccountInfo = await this.curdMixService.getBbUtil(SystemDbName, SystemDbType).getUniqueOne({
|
|
59
|
+
condition: body.condition
|
|
60
|
+
}, SystemTables.sys_user_account);
|
|
61
|
+
|
|
62
|
+
if (!userAccountInfo) {
|
|
63
|
+
return CommonResult.errorRes('用户信息不存在');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const accountId = userAccountInfo.account_id;
|
|
67
|
+
|
|
68
|
+
await this.cacheServiceFactory.removeItemCache({
|
|
69
|
+
cacheName: CacheNameEnum.CurdMixByAccount,
|
|
70
|
+
cacheKey: accountId,
|
|
71
|
+
});
|
|
72
|
+
|
|
45
73
|
return this.executeSysSimpleSQL(SystemTables.sys_user_account, KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
46
74
|
validateCfg: {
|
|
47
75
|
'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMERIC],
|
|
@@ -28,7 +28,7 @@ export class WorkbenchMangeApi extends BaseApiController {
|
|
|
28
28
|
@Post('/createWorkbench', { middleware: [checkPermission(SystemFuncCode.WorkbenchMangeWrite)] })
|
|
29
29
|
async createWorkbench() {
|
|
30
30
|
// 清除运行时缓存
|
|
31
|
-
this.workbenchService.clearCache();
|
|
31
|
+
await this.workbenchService.clearCache();
|
|
32
32
|
|
|
33
33
|
const body = this.ctx.request.body as any;
|
|
34
34
|
const dataObj: any = body.data || {};
|
|
@@ -47,7 +47,7 @@ export class WorkbenchMangeApi extends BaseApiController {
|
|
|
47
47
|
@Post('/updateWorkbench', { middleware: [checkPermission(SystemFuncCode.WorkbenchMangeWrite)] })
|
|
48
48
|
async updateWorkbench() {
|
|
49
49
|
// 清除运行时缓存
|
|
50
|
-
this.workbenchService.clearCache();
|
|
50
|
+
await this.workbenchService.clearCache();
|
|
51
51
|
|
|
52
52
|
return this.executeSysSimpleSQL(SystemTables.sys_workbench, KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
53
53
|
validateCfg: {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { Inject, Controller, Get, Param } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
-
import { KeysOfSimpleSQL } from '@/libs/crud-pro/models/keys';
|
|
5
|
-
import { SystemTables } from '@/models/SystemTables';
|
|
6
4
|
import { WorkbenchService } from '@/service/WorkbenchService';
|
|
7
5
|
import { createRenderUtils } from '@/libs/utils/render-utils';
|
|
8
6
|
import { privateAES } from '@/libs/utils/crypto-utils';
|
|
9
|
-
import {
|
|
7
|
+
import { SysAppService } from "@/service/SysAppService";
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
10
|
* 渲染独立外部应用
|
|
@@ -19,24 +17,17 @@ export class AppRenderController extends BaseApiController {
|
|
|
19
17
|
@Inject()
|
|
20
18
|
private workbenchService: WorkbenchService;
|
|
21
19
|
|
|
20
|
+
@Inject()
|
|
21
|
+
private sysAppService: SysAppService
|
|
22
|
+
|
|
22
23
|
@Get('/:appPath+')
|
|
23
24
|
async home(@Param('appPath') appPath: string): Promise<string> {
|
|
24
|
-
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
25
25
|
|
|
26
26
|
const appPathArr = appPath.split('/');
|
|
27
27
|
const appCode = appPathArr[0];
|
|
28
28
|
|
|
29
|
-
const
|
|
30
|
-
{ condition: { app_code: appCode } },
|
|
31
|
-
{
|
|
32
|
-
sqlTable: SystemTables.sys_app,
|
|
33
|
-
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
34
|
-
sqlDatabase: SystemDbName,
|
|
35
|
-
sqlDbType: SystemDbType,
|
|
36
|
-
}
|
|
37
|
-
);
|
|
29
|
+
const appInfo = await this.sysAppService.getSysAppOne(appCode);
|
|
38
30
|
|
|
39
|
-
const { row: appInfo } = res.getResModel();
|
|
40
31
|
if (!appInfo) {
|
|
41
32
|
this.ctx.status = 404;
|
|
42
33
|
return this.ctx.render('404_app', { appCode, errorMsg: ' 应用不存在' });
|
package/src/index.ts
CHANGED
|
@@ -46,6 +46,7 @@ export * from './service/AuthService';
|
|
|
46
46
|
export * from './service/EnumInfoService';
|
|
47
47
|
export * from './service/FileCenterService';
|
|
48
48
|
export * from './service/SysConfigService';
|
|
49
|
+
export * from './service/SysAppService';
|
|
49
50
|
export * from './service/UserAccountService';
|
|
50
51
|
export * from './service/UserSessionService';
|
|
51
52
|
export * from './service/VisitStatService';
|
|
@@ -137,6 +137,7 @@ export interface ISqlCfgModel extends IBaseCfgModel {
|
|
|
137
137
|
originSql?: string; // 有特殊占位符的SQL, 原始的SQL
|
|
138
138
|
validate?: IFuncCfgModel; //执行前,进行校验,校验不通过就抛出异常. 校验函数可以返回 boolean或直接抛出异常
|
|
139
139
|
executeWhen?: IFuncCfgModel; //满足表达式的结果,才能执行。 默认:true 校验函数必须返回 boolean
|
|
140
|
+
isNativeSQL?: boolean; // 可以运行的SQL。在postgres/sqlserver环境下也可以使用问号。
|
|
140
141
|
executeSql?: string; // 可以运行的SQL。在postgres/sqlserver环境下也可以使用问号。
|
|
141
142
|
executeSqlArgs?: any[]; //可以运行的SQL的参数
|
|
142
143
|
crudType?: string;
|
|
@@ -18,6 +18,7 @@ class SqlCfgModel {
|
|
|
18
18
|
originSql: string; // 有特殊占位符的SQL, 原始的SQL constructor(resName: string, originSql: string) {}
|
|
19
19
|
validate: IFuncCfgModel; //执行前,进行校验,校验不通过就抛出异常. 校验函数可以返回 boolean或直接抛出异常
|
|
20
20
|
executeWhen: IFuncCfgModel; //满足表达式的结果,才能执行。 默认:true 校验函数必须返回 booleansetResPicker(resPicker: string) {}
|
|
21
|
+
isNativeSQL?: boolean; // 可以运行的SQL。在postgres/sqlserver环境下也可以使用问号。
|
|
21
22
|
executeSql: string; // 可以运行的SQL
|
|
22
23
|
executeSqlArgs: any[]; //可以运行的SQL的参数setExecuteWhen(executeWhenFunCfg: IFuncCfgModel) {}
|
|
23
24
|
crudType: KeyOfCrudTypes = null;
|
|
@@ -41,7 +41,7 @@ class CrudProExecuteSqlService extends CrudProServiceBase {
|
|
|
41
41
|
// import { PoolClient } from 'pg';
|
|
42
42
|
|
|
43
43
|
const pgClient: PoolClient = connection as any;
|
|
44
|
-
const pgSql = replaceQuestionMarks(sqlCfgModel.executeSql);
|
|
44
|
+
const pgSql = replaceQuestionMarks(sqlCfgModel.executeSql, sqlCfgModel.isNativeSQL);
|
|
45
45
|
queryRes = await pgClient.query({
|
|
46
46
|
text: pgSql,
|
|
47
47
|
values: executeSqlArgs || [],
|
|
@@ -52,7 +52,7 @@ class CrudProExecuteSqlService extends CrudProServiceBase {
|
|
|
52
52
|
} else if (sqlCfgModel.sqlDbType === SqlDbType.sqlserver) {
|
|
53
53
|
// SQLServer
|
|
54
54
|
|
|
55
|
-
const mssql = replaceQuestionMarksForMssql(sqlCfgModel.executeSql);
|
|
55
|
+
const mssql = replaceQuestionMarksForMssql(sqlCfgModel.executeSql, sqlCfgModel.isNativeSQL);
|
|
56
56
|
queryRes = await connection.query(mssql, executeSqlArgs);
|
|
57
57
|
this.logger.debug('[CrudProExecuteSqlService] executeSqlCfgModel_sqlserver', mssql, executeSqlArgs, sqlCfgModel.resPicker);
|
|
58
58
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import * as _ from 'lodash';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
2
|
+
import {ICurdProServiceHub} from '../models/ServiceHub';
|
|
3
|
+
import {ICrudProCfg, IExecuteUnsafeQueryCtx, ILogger, IPoolConnectionClient} from '../interfaces';
|
|
4
|
+
import {SqlCfgModel} from '../models/SqlCfgModel';
|
|
5
|
+
import {ExecuteContext} from '../models/ExecuteContext';
|
|
6
|
+
import {MixinUtils} from '../utils/MixinUtils';
|
|
7
|
+
import {TypeUtils} from '../utils/TypeUtils';
|
|
8
|
+
import {CompareUtils} from '../utils/CompareUtils';
|
|
9
|
+
import {DateTimeUtils} from '../utils/DateTimeUtils';
|
|
10
|
+
import {IExecuteContextFunc} from '../models/ExecuteContextFunc';
|
|
11
|
+
import {DEFAULT_MAX_LIMIT} from '../defaultConfigs';
|
|
12
|
+
import {SqlDbType} from '../models/keys';
|
|
13
|
+
import {replaceQuestionMarks} from '../utils/sqlConvert/convertPgSql';
|
|
14
|
+
import {replaceQuestionMarksForMssql} from '../utils/sqlConvert/convertMsSql';
|
|
15
15
|
|
|
16
16
|
function createBuildInExecuteFuncMap() {
|
|
17
17
|
return {
|
|
@@ -74,11 +74,9 @@ class CrudProServiceBase {
|
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
if (sqlCfgModel.sqlDbType === SqlDbType.postgres) {
|
|
77
|
-
|
|
78
|
-
sqlCfgModel.executeSql = pgSql;
|
|
77
|
+
sqlCfgModel.executeSql = replaceQuestionMarks(sqlCfgModel.executeSql, false);
|
|
79
78
|
} else if (sqlCfgModel.sqlDbType === SqlDbType.sqlserver) {
|
|
80
|
-
|
|
81
|
-
sqlCfgModel.executeSql = mssql;
|
|
79
|
+
sqlCfgModel.executeSql = replaceQuestionMarksForMssql(sqlCfgModel.executeSql, false);
|
|
82
80
|
}
|
|
83
81
|
|
|
84
82
|
const connection = await this.getTxConnectionBySqlCfg(sqlCfgModel);
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
function replaceQuestionMarksForMssql(sql: string): string {
|
|
1
|
+
function replaceQuestionMarksForMssql(sql: string, isNativeSQL: boolean): string {
|
|
2
|
+
if (isNativeSQL === true) {
|
|
3
|
+
return sql;
|
|
4
|
+
}
|
|
5
|
+
|
|
2
6
|
let count = 0;
|
|
3
7
|
return sql.replace(/\?/g, () => {
|
|
4
8
|
count = count + 1;
|
package/src/models/bizmodels.ts
CHANGED
|
@@ -138,12 +138,14 @@ export enum CacheNameEnum {
|
|
|
138
138
|
CurdMixByAccount = 'CurdMixByAccount',
|
|
139
139
|
CurdMixByDict = 'CurdMixByDict',
|
|
140
140
|
CurdMixByLinkToCustom = 'CurdMixByLinkToCustom',
|
|
141
|
-
CurdMixBySysConfig = 'CurdMixBySysConfig',
|
|
142
141
|
CurdMixByWorkbench = 'CurdMixByWorkbench',
|
|
143
|
-
|
|
142
|
+
GetSysConfigOne = 'GetSysConfigOne',
|
|
143
|
+
GetWorkbenchCachedObj = 'GetWorkbenchCachedObj',
|
|
144
|
+
GetSysAppOne = 'GetSysAppOne',
|
|
145
|
+
GetSysAppPageOne = 'GetSysAppPageOne',
|
|
144
146
|
GetWorkbenchMenu = 'GetWorkbenchMenu',
|
|
145
|
-
GetNavPageInfo = 'GetNavPageInfo',
|
|
146
147
|
GetEnumInfoByCode = 'GetEnumInfoByCode',
|
|
148
|
+
|
|
147
149
|
UserSessionBySessionId = 'UserSessionBySessionId', // 只能是Redis
|
|
148
150
|
UserSessionByAsyncTaskId = 'UserSessionByAsyncTaskId', // 只能是Redis
|
|
149
151
|
}
|
|
@@ -9,6 +9,7 @@ import {CurdMixByLinkToCustomService} from './curd/CurdMixByLinkToCustomService'
|
|
|
9
9
|
import {GLOBAL_STATIC_CONFIG} from '@/libs/global-config/global-config';
|
|
10
10
|
import {CacheServiceFactory} from './base/cache/CacheServiceFactory';
|
|
11
11
|
import { CacheNameEnum } from "@/models/bizmodels";
|
|
12
|
+
import { SysConfigService } from "@/service/SysConfigService";
|
|
12
13
|
|
|
13
14
|
interface IQueryEnumInfo {
|
|
14
15
|
type: RelatedType;
|
|
@@ -25,7 +26,6 @@ function filterEmpty(e: IEnumInfo): boolean {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
|
|
28
|
-
|
|
29
29
|
@Provide()
|
|
30
30
|
export class EnumInfoService {
|
|
31
31
|
@Inject()
|
|
@@ -39,12 +39,18 @@ export class EnumInfoService {
|
|
|
39
39
|
@Inject()
|
|
40
40
|
private cacheServiceFactory: CacheServiceFactory;
|
|
41
41
|
|
|
42
|
+
@Inject()
|
|
43
|
+
private sysConfigService: SysConfigService
|
|
44
|
+
|
|
42
45
|
async queryEnumInfo(codeList: IQueryEnumInfo[], refreshCache: boolean): Promise<IQueryEnumResult[]> {
|
|
43
46
|
|
|
44
47
|
const getEnumInfoByCode = async (type: RelatedType, code: string) => {
|
|
45
48
|
if (type === RelatedType.linkToCustom) {
|
|
46
49
|
return await this.queryEnumInfoByLinkToCustom(code);
|
|
47
50
|
}
|
|
51
|
+
if (type === RelatedType.sysCfgEnum) {
|
|
52
|
+
return await this.queryEnumInfoBySysCfgEnum(code);
|
|
53
|
+
}
|
|
48
54
|
|
|
49
55
|
const cacheKey = `${type}@@${code}`;
|
|
50
56
|
return await this.cacheServiceFactory.getJsonObjectCache({
|
|
@@ -52,9 +58,7 @@ export class EnumInfoService {
|
|
|
52
58
|
refreshCache,
|
|
53
59
|
cacheName: CacheNameEnum.GetEnumInfoByCode,
|
|
54
60
|
getter: async () => {
|
|
55
|
-
if (type === RelatedType.
|
|
56
|
-
return await this.queryEnumInfoBySysCfgEnum(code);
|
|
57
|
-
} else if (type === RelatedType.dict) {
|
|
61
|
+
if (type === RelatedType.dict) {
|
|
58
62
|
return await this.queryEnumInfoItemByDict(code);
|
|
59
63
|
}
|
|
60
64
|
return [];
|
|
@@ -92,24 +96,7 @@ export class EnumInfoService {
|
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
private async queryEnumInfoBySysCfgEnum(code: string): Promise<IEnumInfo[]> {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
const res1 = await this.curdProService.executeCrudByCfg(
|
|
98
|
-
{
|
|
99
|
-
condition: { config_code: code },
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
sqlTable: SystemTables.sys_configs,
|
|
103
|
-
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
104
|
-
sqlDatabase: SystemDbName,
|
|
105
|
-
sqlDbType: SystemDbType,
|
|
106
|
-
}
|
|
107
|
-
);
|
|
108
|
-
const obj = res1.getOneObj();
|
|
109
|
-
if (!obj) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
|
|
99
|
+
const obj = await this.sysConfigService.getSysConfigOne(code);
|
|
113
100
|
const rows = parseConfigContentToEnumInfo(obj);
|
|
114
101
|
return rows.map(e => ({ label: e.label, value: e.value, style: e.style, children: e.children })).filter(filterEmpty);
|
|
115
102
|
}
|