midway-fatcms 0.0.11 → 0.0.13
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/configuration.d.ts +0 -2
- package/dist/configuration.js +14 -12
- package/dist/controller/gateway/CrudMtdGatewayController.js +2 -1
- package/dist/controller/gateway/DocGatewayController.js +7 -5
- package/dist/controller/gateway/PublicApiController.js +32 -3
- package/dist/controller/gateway/StaticController.d.ts +0 -2
- package/dist/controller/gateway/StaticController.js +4 -39
- package/dist/controller/home.controller.js +2 -1
- package/dist/controller/manage/AccountRoleManageApi.d.ts +2 -1
- package/dist/controller/manage/AccountRoleManageApi.js +34 -0
- package/dist/controller/manage/DataDictManageApi.d.ts +2 -0
- package/dist/controller/manage/DataDictManageApi.js +41 -9
- package/dist/controller/manage/DocManageApi.js +2 -2
- package/dist/controller/manage/UserAccountManageApi.js +4 -3
- package/dist/controller/render/AppRenderController.js +7 -6
- package/dist/libs/crud-pro/CrudPro.d.ts +0 -1
- package/dist/libs/crud-pro/CrudPro.js +2 -11
- package/dist/libs/crud-pro/exceptions.d.ts +6 -0
- package/dist/libs/crud-pro/exceptions.js +6 -0
- package/dist/libs/crud-pro/models/keys.d.ts +1 -0
- package/dist/libs/crud-pro/models/keys.js +1 -0
- package/dist/libs/crud-pro/services/CrudProExecuteFuncService.js +2 -2
- package/dist/libs/crud-pro/services/CrudProFieldUpdateService.js +3 -0
- package/dist/libs/crud-pro/services/CrudProTableMetaService.js +2 -2
- package/dist/libs/crud-pro/utils/DatabaseName.js +11 -0
- package/dist/libs/crud-pro/utils/DateTimeUtils.js +1 -1
- package/dist/libs/crud-pro/utils/SqlErrorParseUtils.d.ts +22 -0
- package/dist/libs/crud-pro/utils/SqlErrorParseUtils.js +219 -0
- package/dist/libs/utils/functions.d.ts +8 -1
- package/dist/libs/utils/functions.js +29 -1
- package/dist/service/AuthService.js +1 -1
- package/dist/service/anyapi/AnyApiService.js +1 -1
- package/dist/service/crudstd/CrudStdService.js +8 -3
- package/dist/service/curd/CurdMixByDictService.js +1 -1
- package/dist/service/curd/CurdMixBySysConfigService.js +1 -1
- package/dist/service/curd/CurdMixByWorkbenchService.js +1 -1
- package/dist/service/curd/fixCfgModel.js +3 -1
- package/dist/service/proxyapi/ProxyApiLoadService.js +3 -0
- package/package.json +1 -1
- package/src/configuration.ts +18 -11
- package/src/controller/gateway/CrudMtdGatewayController.ts +2 -1
- package/src/controller/gateway/DocGatewayController.ts +9 -5
- package/src/controller/gateway/PublicApiController.ts +39 -4
- package/src/controller/gateway/StaticController.ts +11 -40
- package/src/controller/home.controller.ts +3 -1
- package/src/controller/manage/AccountRoleManageApi.ts +38 -0
- package/src/controller/manage/DataDictManageApi.ts +48 -11
- package/src/controller/manage/DocManageApi.ts +2 -2
- package/src/controller/manage/UserAccountManageApi.ts +4 -3
- package/src/controller/render/AppRenderController.ts +9 -7
- package/src/libs/crud-pro/CrudPro.ts +2 -12
- package/src/libs/crud-pro/exceptions.ts +6 -0
- package/src/libs/crud-pro/models/keys.ts +1 -0
- package/src/libs/crud-pro/services/CrudProExecuteFuncService.ts +3 -2
- package/src/libs/crud-pro/services/CrudProFieldUpdateService.ts +5 -0
- package/src/libs/crud-pro/services/CrudProTableMetaService.ts +2 -2
- package/src/libs/crud-pro/utils/DatabaseName.ts +12 -0
- package/src/libs/crud-pro/utils/DateTimeUtils.ts +1 -1
- package/src/libs/crud-pro/utils/SqlErrorParseUtils.ts +236 -0
- package/src/libs/utils/functions.ts +37 -2
- package/src/service/AuthService.ts +2 -2
- package/src/service/anyapi/AnyApiService.ts +2 -2
- package/src/service/crudstd/CrudStdService.ts +9 -4
- package/src/service/curd/CurdMixByDictService.ts +1 -1
- package/src/service/curd/CurdMixBySysConfigService.ts +1 -1
- package/src/service/curd/CurdMixByWorkbenchService.ts +1 -1
- package/src/service/curd/fixCfgModel.ts +3 -1
- package/src/service/proxyapi/ProxyApiLoadService.ts +4 -1
package/dist/configuration.d.ts
CHANGED
package/dist/configuration.js
CHANGED
|
@@ -89,14 +89,20 @@ let ContainerLifeCycle = class ContainerLifeCycle {
|
|
|
89
89
|
* 会通过 Redis 广播通知所有节点刷新缓存。
|
|
90
90
|
*/
|
|
91
91
|
async initCacheRefreshRedis() {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
setTimeout(async () => {
|
|
93
|
+
const app = this.app;
|
|
94
|
+
const ctx = app.createAnonymousContext();
|
|
95
|
+
const redisService = await ctx.requestContext.getAsync(redis_1.RedisService);
|
|
96
|
+
try {
|
|
97
|
+
(0, CacheRefreshRedisSubscriber_1.initCacheRefreshPublishClient)(redisService);
|
|
98
|
+
(0, CacheRefreshRedisSubscriber_1.initCacheRefreshSubscriber)(redisService);
|
|
99
|
+
this.app.getLogger().info('ContainerLifeCycle ==> initCacheRefreshRedis success');
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
// Redis 未配置或不可用时,降级为单节点模式(仅刷新本节点缓存)
|
|
103
|
+
this.app.getLogger().warn('ContainerLifeCycle ==> initCacheRefreshRedis Redis不可用,降级为单节点模式:', e.message);
|
|
104
|
+
}
|
|
105
|
+
}, 1000 * 60);
|
|
100
106
|
}
|
|
101
107
|
/**
|
|
102
108
|
* 注册各类型缓存的刷新器到 CacheRefreshHub
|
|
@@ -159,10 +165,6 @@ __decorate([
|
|
|
159
165
|
(0, core_1.App)(),
|
|
160
166
|
__metadata("design:type", Object)
|
|
161
167
|
], ContainerLifeCycle.prototype, "app", void 0);
|
|
162
|
-
__decorate([
|
|
163
|
-
(0, core_1.Inject)(),
|
|
164
|
-
__metadata("design:type", redis_1.RedisService)
|
|
165
|
-
], ContainerLifeCycle.prototype, "redisService", void 0);
|
|
166
168
|
ContainerLifeCycle = __decorate([
|
|
167
169
|
(0, core_1.Configuration)({
|
|
168
170
|
// namespace: 'fatcms',
|
|
@@ -23,6 +23,7 @@ const CurdProService_1 = require("../../service/curd/CurdProService");
|
|
|
23
23
|
const CurdMixService_1 = require("../../service/curd/CurdMixService");
|
|
24
24
|
const DatabaseName_1 = require("../../libs/crud-pro/utils/DatabaseName");
|
|
25
25
|
const global_config_1 = require("../../libs/global-config/global-config");
|
|
26
|
+
const functions_1 = require("../../libs/utils/functions");
|
|
26
27
|
const QUERY_AS_LIST = ['condition', 'data'];
|
|
27
28
|
function pickAsQuery(query_as_pick, query) {
|
|
28
29
|
if (query_as_pick && typeof query_as_pick === 'string') {
|
|
@@ -48,7 +49,7 @@ let CrudMtdGatewayController = class CrudMtdGatewayController extends ApiBaseSer
|
|
|
48
49
|
return common_dto_1.CommonResult.errorRes('method参数不存在');
|
|
49
50
|
}
|
|
50
51
|
const methodInfo = (await this.curdProService.getCachedCfgByMethod(methodCode));
|
|
51
|
-
if (!methodInfo ||
|
|
52
|
+
if (!methodInfo || !(0, functions_1.isEntityOK)(methodInfo)) {
|
|
52
53
|
return common_dto_1.CommonResult.errorRes('接口不存在或已下线: ' + methodCode);
|
|
53
54
|
}
|
|
54
55
|
this.logInfo('methodInfo=== ', methodInfo);
|
|
@@ -20,6 +20,7 @@ const global_config_1 = require("../../libs/global-config/global-config");
|
|
|
20
20
|
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
21
21
|
const WorkbenchService_1 = require("../../service/WorkbenchService");
|
|
22
22
|
const common_dto_1 = require("../../libs/utils/common-dto");
|
|
23
|
+
const functions_1 = require("../../libs/utils/functions");
|
|
23
24
|
const fatcms_request_1 = require("../../libs/utils/fatcms-request");
|
|
24
25
|
function checkIsNumber(value, name) {
|
|
25
26
|
if (value === null || value === '' || typeof value === 'undefined') {
|
|
@@ -82,12 +83,13 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
|
|
|
82
83
|
sqlDatabase: SystemDbName,
|
|
83
84
|
sqlDbType: SystemDbType,
|
|
84
85
|
});
|
|
85
|
-
// 更新PV数据
|
|
86
86
|
const docObj = res.getOneObj();
|
|
87
|
-
if (docObj) {
|
|
88
|
-
|
|
89
|
-
await this.updateDocPV(docId, docLibId, pv);
|
|
87
|
+
if (!(0, functions_1.isEntityOK)(docObj)) {
|
|
88
|
+
return common_dto_1.CommonResult.errorRes("文档不存在");
|
|
90
89
|
}
|
|
90
|
+
// 更新PV数据
|
|
91
|
+
const pv = parseInt(docObj.pv) || 0;
|
|
92
|
+
await this.updateDocPV(docId, docLibId, pv);
|
|
91
93
|
return res;
|
|
92
94
|
}
|
|
93
95
|
/**
|
|
@@ -134,7 +136,7 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
|
|
|
134
136
|
sqlDbType: SystemDbType,
|
|
135
137
|
});
|
|
136
138
|
const docLibInfo = s.getOneObj();
|
|
137
|
-
if (!docLibInfo) {
|
|
139
|
+
if (!(0, functions_1.isEntityOK)(docLibInfo)) {
|
|
138
140
|
throw '此文档库查询失败';
|
|
139
141
|
}
|
|
140
142
|
const workbench_code_array = docLibInfo.workbench_code_array;
|
|
@@ -58,8 +58,28 @@ let PublicApiController = class PublicApiController extends BaseApiController_1.
|
|
|
58
58
|
const workbenchMenuCodeSet = new Set(workbenchMenuCodeArray);
|
|
59
59
|
const allMenuList = await this.sysMenuService.getCachedMenusList();
|
|
60
60
|
const menuList = allMenuList.filter(e => {
|
|
61
|
-
return workbenchMenuCodeSet.has(e.menu_code) && e
|
|
61
|
+
return workbenchMenuCodeSet.has(e.menu_code) && (0, functions_1.isEntityOK)(e);
|
|
62
62
|
});
|
|
63
|
+
const addPermissionInfo = (menu_list, level) => {
|
|
64
|
+
if (!Array.isArray(menu_list)) {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
if (level > 10) {
|
|
68
|
+
return menu_list;
|
|
69
|
+
}
|
|
70
|
+
return menu_list.map(e => {
|
|
71
|
+
if (Array.isArray(e.children)) {
|
|
72
|
+
e.children = addPermissionInfo(e.children, level + 1);
|
|
73
|
+
}
|
|
74
|
+
const view_auth_config = e.view_auth_config;
|
|
75
|
+
const view_auth_type = e.view_auth_type || keys_1.KeysOfAuthType.byFuncCode;
|
|
76
|
+
if (!view_auth_config) {
|
|
77
|
+
return { ...e, hasPermission: true };
|
|
78
|
+
}
|
|
79
|
+
const hasPermission = this.ctx.userSession.isAuthPass(view_auth_type, view_auth_config);
|
|
80
|
+
return { ...e, hasPermission };
|
|
81
|
+
});
|
|
82
|
+
};
|
|
63
83
|
const mapResult = {};
|
|
64
84
|
for (let i = 0; i < menuList.length; i++) {
|
|
65
85
|
const rowElement = cloneObject(menuList[i]);
|
|
@@ -69,7 +89,8 @@ let PublicApiController = class PublicApiController extends BaseApiController_1.
|
|
|
69
89
|
const hasPermission = this.ctx.userSession.isAuthPass(view_auth_type, view_auth_config);
|
|
70
90
|
const menu_config_content = rowElement.menu_config_content;
|
|
71
91
|
delete rowElement.menu_config_content;
|
|
72
|
-
|
|
92
|
+
let menu_list = (0, functions_1.parseJsonObject)(menu_config_content) || [];
|
|
93
|
+
menu_list = addPermissionInfo(menu_list, 0);
|
|
73
94
|
mapResult[menu_code] = { ...rowElement, menu_list, hasPermission };
|
|
74
95
|
}
|
|
75
96
|
// 特殊的devops菜单
|
|
@@ -97,10 +118,18 @@ let PublicApiController = class PublicApiController extends BaseApiController_1.
|
|
|
97
118
|
resultData.appData = await this.sysAppService.deletePrivateField(appInfo);
|
|
98
119
|
}
|
|
99
120
|
if (pathname && workbenchCode) {
|
|
100
|
-
|
|
121
|
+
const pageData = await this.sysAppService.getSysAppPageOne({
|
|
101
122
|
page_path: pathname,
|
|
102
123
|
workbench_code: workbenchCode
|
|
103
124
|
});
|
|
125
|
+
if (pageData) {
|
|
126
|
+
const clonePageInfo = { ...pageData };
|
|
127
|
+
const view_auth_config = clonePageInfo.view_auth_config;
|
|
128
|
+
const view_auth_type = clonePageInfo.view_auth_type;
|
|
129
|
+
const hasPermission = this.ctx.userSession.isAuthPass(view_auth_type, view_auth_config);
|
|
130
|
+
clonePageInfo.hasPermission = hasPermission;
|
|
131
|
+
resultData.pageData = clonePageInfo;
|
|
132
|
+
}
|
|
104
133
|
}
|
|
105
134
|
return common_dto_1.CommonResult.successRes(resultData);
|
|
106
135
|
}
|
|
@@ -12,10 +12,8 @@ interface HttpGetRes {
|
|
|
12
12
|
export declare class StaticController extends BaseApiController {
|
|
13
13
|
protected ctx: Context;
|
|
14
14
|
private getLocalPaths;
|
|
15
|
-
private initNotFoundList;
|
|
16
15
|
private responseLocalFile;
|
|
17
16
|
proxyStaticFile(ossName: string, relativePath: string): Promise<string>;
|
|
18
|
-
saveNotFoundList(): Promise<void>;
|
|
19
17
|
httpsGet(url: string): Promise<HttpGetRes>;
|
|
20
18
|
writeResponseToFile(httpsGetRes: HttpGetRes, localFilePath: string, localHeaderPath: string): Promise<void>;
|
|
21
19
|
getMimeType(filePath: string): any;
|
|
@@ -37,9 +37,8 @@ function getPathConfig(ossName) {
|
|
|
37
37
|
remoteBaseUrl,
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
// 404
|
|
40
|
+
// 404列表缓存: 只再内存中记录。重启后继续
|
|
41
41
|
let notFoundList = new Set();
|
|
42
|
-
let notFoundListIsInit = false;
|
|
43
42
|
/**
|
|
44
43
|
* 静态文件代理功能
|
|
45
44
|
*/
|
|
@@ -48,31 +47,10 @@ let StaticController = class StaticController extends BaseApiController_1.BaseAp
|
|
|
48
47
|
const app = schedule_1.ANONYMOUS_CONTEXT.getApp();
|
|
49
48
|
const appDir = app.getAppDir();
|
|
50
49
|
const localDir = path.join(appDir, './public/static'); // 本地文件存储目录
|
|
51
|
-
const notFoundListFile = path.join(localDir, '__404__list.json'); // 404列表文件
|
|
52
50
|
return {
|
|
53
51
|
localDir,
|
|
54
|
-
notFoundListFile,
|
|
55
52
|
};
|
|
56
53
|
}
|
|
57
|
-
async initNotFoundList() {
|
|
58
|
-
if (notFoundListIsInit) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
notFoundListIsInit = true;
|
|
62
|
-
const { localDir, notFoundListFile } = this.getLocalPaths();
|
|
63
|
-
try {
|
|
64
|
-
// 确保本地存储目录存在
|
|
65
|
-
await fs.mkdir(localDir, { recursive: true });
|
|
66
|
-
const data = await fs.readFile(notFoundListFile, 'utf8');
|
|
67
|
-
notFoundList = new Set(JSON.parse(data));
|
|
68
|
-
console.log(`已加载${notFoundList.size}个404记录`);
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
if (error.code !== 'ENOENT') {
|
|
72
|
-
console.error('读取404列表失败:', error);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
54
|
async responseLocalFile(localFilePath, localHeaderPath, relativePath) {
|
|
77
55
|
const headers = {
|
|
78
56
|
'Cache-Control': 'public, max-age=31536000',
|
|
@@ -84,8 +62,10 @@ let StaticController = class StaticController extends BaseApiController_1.BaseAp
|
|
|
84
62
|
if (stats.isFile()) {
|
|
85
63
|
const headerDataStr = await fs.readFile(localHeaderPath, 'utf8');
|
|
86
64
|
const headerData = (0, functions_1.parseJsonObject)(headerDataStr);
|
|
87
|
-
if (headerData) {
|
|
65
|
+
if (headerData && headerData['last-modified']) {
|
|
88
66
|
headers['last-modified'] = headerData['last-modified'];
|
|
67
|
+
}
|
|
68
|
+
if (headerData && headerData['etag']) {
|
|
89
69
|
headers['etag'] = headerData['etag'];
|
|
90
70
|
}
|
|
91
71
|
}
|
|
@@ -117,7 +97,6 @@ let StaticController = class StaticController extends BaseApiController_1.BaseAp
|
|
|
117
97
|
return false;
|
|
118
98
|
}
|
|
119
99
|
async proxyStaticFile(ossName, relativePath) {
|
|
120
|
-
await this.initNotFoundList();
|
|
121
100
|
const { localDir } = this.getLocalPaths();
|
|
122
101
|
const PATH_CONFIG = getPathConfig(ossName);
|
|
123
102
|
// 构建本地路径和远程路径
|
|
@@ -149,7 +128,6 @@ let StaticController = class StaticController extends BaseApiController_1.BaseAp
|
|
|
149
128
|
else if (remoteRes.statusCode === 404) {
|
|
150
129
|
// 记录404并返回
|
|
151
130
|
notFoundList.add(relativePath);
|
|
152
|
-
await this.saveNotFoundList();
|
|
153
131
|
this.logInfo(`[StaticController]远程文件不存在,已记录404: ${relativePath}`);
|
|
154
132
|
this.ctx.status = 404;
|
|
155
133
|
return this.ctx.render('500', { errorMsg: ' 远程文件不存在,已记录404' });
|
|
@@ -171,19 +149,6 @@ let StaticController = class StaticController extends BaseApiController_1.BaseAp
|
|
|
171
149
|
this.ctx.status = 500;
|
|
172
150
|
return this.ctx.render('500', { errorMsg: '未知异常' });
|
|
173
151
|
}
|
|
174
|
-
// 保存404列表
|
|
175
|
-
async saveNotFoundList() {
|
|
176
|
-
const { notFoundListFile } = this.getLocalPaths();
|
|
177
|
-
try {
|
|
178
|
-
// 确保存储404列表的目录存在
|
|
179
|
-
const dir = path.dirname(notFoundListFile);
|
|
180
|
-
await fs.mkdir(dir, { recursive: true });
|
|
181
|
-
await fs.writeFile(notFoundListFile, JSON.stringify(Array.from(notFoundList), null), 'utf8');
|
|
182
|
-
}
|
|
183
|
-
catch (error) {
|
|
184
|
-
this.logError('[StaticController]保存404列表失败:', error);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
152
|
// 封装https请求为异步函数
|
|
188
153
|
async httpsGet(url) {
|
|
189
154
|
return new Promise((resolve, reject) => {
|
|
@@ -16,12 +16,13 @@ const WorkbenchService_1 = require("../service/WorkbenchService");
|
|
|
16
16
|
const render_utils_1 = require("../libs/utils/render-utils");
|
|
17
17
|
const crypto_utils_1 = require("../libs/utils/crypto-utils");
|
|
18
18
|
const AuthService_1 = require("../service/AuthService");
|
|
19
|
+
const functions_1 = require("../libs/utils/functions");
|
|
19
20
|
let HomeController = class HomeController extends BaseApiController_1.BaseApiController {
|
|
20
21
|
async home() {
|
|
21
22
|
const host = this.ctx.request.host;
|
|
22
23
|
const hostname = this.ctx.request.hostname;
|
|
23
24
|
const workbenchInfo = await this.workbenchService.getCurrentHostWorkbenchInfo();
|
|
24
|
-
if (!
|
|
25
|
+
if (!(0, functions_1.isEntityOK)(workbenchInfo)) {
|
|
25
26
|
this.logInfo(`域名不存在:hostname = ${hostname}, host=${host}`);
|
|
26
27
|
const infos = {
|
|
27
28
|
host,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Context } from '@midwayjs/koa';
|
|
2
2
|
import { BaseApiController } from '../base/BaseApiController';
|
|
3
|
+
import { CommonResult } from '../../libs/utils/common-dto';
|
|
3
4
|
export declare class AccountRoleManageApi extends BaseApiController {
|
|
4
5
|
protected ctx: Context;
|
|
5
6
|
getAccountRoleList(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
6
7
|
getAccountRoleOne(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
7
|
-
createAccountRole(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
8
|
+
createAccountRole(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext | CommonResult>;
|
|
8
9
|
updateAccountRole(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
9
10
|
deleteAccountRole(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
10
11
|
}
|
|
@@ -18,6 +18,9 @@ const cacherefresh_middleware_1 = require("../../middleware/cacherefresh.middlew
|
|
|
18
18
|
const bizmodels_1 = require("../../models/bizmodels");
|
|
19
19
|
const SystemPerm_1 = require("../../models/SystemPerm");
|
|
20
20
|
const CurdMixUtils_1 = require("../../service/curd/CurdMixUtils");
|
|
21
|
+
const SystemTables_1 = require("../../models/SystemTables");
|
|
22
|
+
const global_config_1 = require("../../libs/global-config/global-config");
|
|
23
|
+
const common_dto_1 = require("../../libs/utils/common-dto");
|
|
21
24
|
let AccountRoleManageApi = class AccountRoleManageApi extends BaseApiController_1.BaseApiController {
|
|
22
25
|
async getAccountRoleList() {
|
|
23
26
|
return this.executeSysSimpleSQL('sys_perm_user_role', keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_PAGE, {
|
|
@@ -40,6 +43,37 @@ let AccountRoleManageApi = class AccountRoleManageApi extends BaseApiController_
|
|
|
40
43
|
return this.executeSysSimpleSQL('sys_perm_user_role', keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE);
|
|
41
44
|
}
|
|
42
45
|
async createAccountRole() {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
48
|
+
const body = this.ctx.request.body;
|
|
49
|
+
const accountId = (_a = body.data) === null || _a === void 0 ? void 0 : _a.account_id;
|
|
50
|
+
const roleCode = (_b = body.data) === null || _b === void 0 ? void 0 : _b.role_code;
|
|
51
|
+
// 校验 account_id 是否存在
|
|
52
|
+
if (accountId) {
|
|
53
|
+
const accountInfoRes = await this.curdMixService.getQuickCrud({
|
|
54
|
+
sqlDatabase: SystemDbName,
|
|
55
|
+
sqlDbType: SystemDbType,
|
|
56
|
+
sqlTable: SystemTables_1.SystemTables.sys_user_account,
|
|
57
|
+
}).isExist({
|
|
58
|
+
condition: { account_id: accountId }
|
|
59
|
+
});
|
|
60
|
+
if (!accountInfoRes.exists) {
|
|
61
|
+
return common_dto_1.CommonResult.errorRes(`账户ID '${accountId}' 不存在`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// 校验 role_code 是否存在
|
|
65
|
+
if (roleCode) {
|
|
66
|
+
const roleInfoRes = await this.curdMixService.getQuickCrud({
|
|
67
|
+
sqlDatabase: SystemDbName,
|
|
68
|
+
sqlDbType: SystemDbType,
|
|
69
|
+
sqlTable: SystemTables_1.SystemTables.sys_perm_role,
|
|
70
|
+
}).isExist({
|
|
71
|
+
condition: { role_code: roleCode }
|
|
72
|
+
});
|
|
73
|
+
if (!roleInfoRes.exists) {
|
|
74
|
+
return common_dto_1.CommonResult.errorRes(`角色编码 '${roleCode}' 不存在`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
43
77
|
return this.executeSysSimpleSQL('sys_perm_user_role', keys_1.KeysOfSimpleSQL.SIMPLE_INSERT, {
|
|
44
78
|
validateCfg: {
|
|
45
79
|
'data.account_id': [keys_1.KeysOfValidators.REQUIRED, keys_1.KeysOfValidators.STRING],
|
|
@@ -6,6 +6,8 @@ export declare class DataDictManageApi extends BaseApiController {
|
|
|
6
6
|
getDataDictList(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
7
7
|
getDataDictOne(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
8
8
|
createDataDict(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
9
|
+
/** 查询 dict_code 是否仅被软删除记录占用(不含 deleted_at=0 的活跃记录) */
|
|
10
|
+
private isSoftDeletedDictCode;
|
|
9
11
|
updateDataDict(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
10
12
|
deleteDataDict(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext | CommonResult>;
|
|
11
13
|
getDataDictItemList(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
@@ -18,6 +18,8 @@ const cacherefresh_middleware_1 = require("../../middleware/cacherefresh.middlew
|
|
|
18
18
|
const bizmodels_1 = require("../../models/bizmodels");
|
|
19
19
|
const SystemPerm_1 = require("../../models/SystemPerm");
|
|
20
20
|
const common_dto_1 = require("../../libs/utils/common-dto");
|
|
21
|
+
const exceptions_1 = require("../../libs/crud-pro/exceptions");
|
|
22
|
+
const global_config_1 = require("../../libs/global-config/global-config");
|
|
21
23
|
let DataDictManageApi = class DataDictManageApi extends BaseApiController_1.BaseApiController {
|
|
22
24
|
async getDataDictList() {
|
|
23
25
|
return this.executeSysSimpleSQL('sys_data_dict', keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_PAGE, {
|
|
@@ -30,18 +32,48 @@ let DataDictManageApi = class DataDictManageApi extends BaseApiController_1.Base
|
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
34
|
async createDataDict() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
var _a;
|
|
36
|
+
const body = this.ctx.request.body;
|
|
37
|
+
const dict_code = (_a = body === null || body === void 0 ? void 0 : body.data) === null || _a === void 0 ? void 0 : _a.dict_code;
|
|
38
|
+
try {
|
|
39
|
+
return await this.executeSysSimpleSQL('sys_data_dict', keys_1.KeysOfSimpleSQL.SIMPLE_INSERT, {
|
|
40
|
+
enableSoftDelete: true,
|
|
41
|
+
validateCfg: {
|
|
42
|
+
'data.dict_code': [keys_1.KeysOfValidators.REQUIRED],
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
if ((e === null || e === void 0 ? void 0 : e.code) === exceptions_1.Exceptions.RUN_SQL_EXCEPTION_ER_DUP_ENTRY && dict_code) {
|
|
48
|
+
const isSoftDeleted = await this.isSoftDeletedDictCode(dict_code);
|
|
49
|
+
if (isSoftDeleted) {
|
|
50
|
+
throw new exceptions_1.CommonException(exceptions_1.Exceptions.RUN_SQL_EXCEPTION_ER_DUP_ENTRY, '该 dict_code 对应的数据曾被软删除,无法直接创建。请联系 DBA 处理,或更换 dict_code 后重试。');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
throw e;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** 查询 dict_code 是否仅被软删除记录占用(不含 deleted_at=0 的活跃记录) */
|
|
57
|
+
async isSoftDeletedDictCode(dict_code) {
|
|
58
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
59
|
+
const result = await this.curdMixService.executeCrudByCfg({ condition: { dict_code } }, {
|
|
60
|
+
sqlTable: 'sys_data_dict',
|
|
61
|
+
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
62
|
+
sqlDatabase: SystemDbName,
|
|
63
|
+
sqlDbType: SystemDbType,
|
|
64
|
+
enableSoftDelete: false,
|
|
38
65
|
});
|
|
66
|
+
const row = result.getOneObj();
|
|
67
|
+
if (!row) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return Number(row.deleted_at) !== 0;
|
|
39
71
|
}
|
|
40
72
|
async updateDataDict() {
|
|
41
73
|
return this.executeSysSimpleSQL('sys_data_dict', keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
42
74
|
enableSoftDelete: true,
|
|
43
75
|
validateCfg: {
|
|
44
|
-
'condition.id': [keys_1.KeysOfValidators.REQUIRED
|
|
76
|
+
'condition.id': [keys_1.KeysOfValidators.REQUIRED],
|
|
45
77
|
},
|
|
46
78
|
});
|
|
47
79
|
}
|
|
@@ -55,7 +87,7 @@ let DataDictManageApi = class DataDictManageApi extends BaseApiController_1.Base
|
|
|
55
87
|
return this.executeSysSimpleSQL('sys_data_dict', keys_1.KeysOfSimpleSQL.SIMPLE_DELETE, {
|
|
56
88
|
enableSoftDelete: true,
|
|
57
89
|
validateCfg: {
|
|
58
|
-
'condition.id': [keys_1.KeysOfValidators.REQUIRED
|
|
90
|
+
'condition.id': [keys_1.KeysOfValidators.REQUIRED],
|
|
59
91
|
'condition.dict_code': [keys_1.KeysOfValidators.REQUIRED],
|
|
60
92
|
},
|
|
61
93
|
});
|
|
@@ -85,7 +117,7 @@ let DataDictManageApi = class DataDictManageApi extends BaseApiController_1.Base
|
|
|
85
117
|
return this.executeSysSimpleSQL('sys_data_dict_item', keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
86
118
|
enableSoftDelete: true,
|
|
87
119
|
validateCfg: {
|
|
88
|
-
'condition.id': [keys_1.KeysOfValidators.REQUIRED
|
|
120
|
+
'condition.id': [keys_1.KeysOfValidators.REQUIRED],
|
|
89
121
|
},
|
|
90
122
|
});
|
|
91
123
|
}
|
|
@@ -93,7 +125,7 @@ let DataDictManageApi = class DataDictManageApi extends BaseApiController_1.Base
|
|
|
93
125
|
return this.executeSysSimpleSQL('sys_data_dict_item', keys_1.KeysOfSimpleSQL.SIMPLE_DELETE, {
|
|
94
126
|
enableSoftDelete: true,
|
|
95
127
|
validateCfg: {
|
|
96
|
-
'condition.id': [keys_1.KeysOfValidators.REQUIRED
|
|
128
|
+
'condition.id': [keys_1.KeysOfValidators.REQUIRED],
|
|
97
129
|
'condition.dict_code': [keys_1.KeysOfValidators.REQUIRED],
|
|
98
130
|
},
|
|
99
131
|
});
|
|
@@ -75,7 +75,7 @@ let DocManageApi = class DocManageApi extends BaseApiController_1.BaseApiControl
|
|
|
75
75
|
return this.executeSysSimpleSQL('sys_doc', keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
76
76
|
enableSoftDelete: true,
|
|
77
77
|
validateCfg: {
|
|
78
|
-
'condition.id': [keys_1.KeysOfValidators.REQUIRED
|
|
78
|
+
'condition.id': [keys_1.KeysOfValidators.REQUIRED],
|
|
79
79
|
},
|
|
80
80
|
updateCfg: {
|
|
81
81
|
...updateCfg,
|
|
@@ -87,7 +87,7 @@ let DocManageApi = class DocManageApi extends BaseApiController_1.BaseApiControl
|
|
|
87
87
|
return this.executeSysSimpleSQL('sys_doc', keys_1.KeysOfSimpleSQL.SIMPLE_DELETE, {
|
|
88
88
|
enableSoftDelete: true,
|
|
89
89
|
validateCfg: {
|
|
90
|
-
'condition.id': [keys_1.KeysOfValidators.REQUIRED
|
|
90
|
+
'condition.id': [keys_1.KeysOfValidators.REQUIRED],
|
|
91
91
|
},
|
|
92
92
|
updateCfg: {
|
|
93
93
|
'condition.workbench_code': { contextAsString: bizmodels_1.CTX_WORKBENCH_CODE },
|
|
@@ -13,13 +13,13 @@ exports.UserAccountManageApi = void 0;
|
|
|
13
13
|
const core_1 = require("@midwayjs/core");
|
|
14
14
|
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
15
15
|
const BaseApiController_1 = require("../base/BaseApiController");
|
|
16
|
-
const functions_1 = require("../../libs/utils/functions");
|
|
17
16
|
const permission_middleware_1 = require("../../middleware/permission.middleware");
|
|
18
17
|
const SystemPerm_1 = require("../../models/SystemPerm");
|
|
19
18
|
const exceptions_1 = require("../../libs/crud-pro/exceptions");
|
|
20
19
|
const SystemTables_1 = require("../../models/SystemTables");
|
|
21
20
|
const global_config_1 = require("../../libs/global-config/global-config");
|
|
22
21
|
const common_dto_1 = require("../../libs/utils/common-dto");
|
|
22
|
+
const MixinUtils_1 = require("../../libs/crud-pro/utils/MixinUtils");
|
|
23
23
|
const accountNameBlacklist = new Set(['sa', 'root', 'admin', 'superadmin', 'administrator', 'sys', 'sysop', 'schedule_user']);
|
|
24
24
|
function checkAccountCreateBlacklist(value) {
|
|
25
25
|
if (!value) {
|
|
@@ -73,16 +73,17 @@ let UserAccountManageApi = class UserAccountManageApi extends BaseApiController_
|
|
|
73
73
|
}
|
|
74
74
|
async createUserAccount() {
|
|
75
75
|
const body = this.ctx.request.body;
|
|
76
|
-
body.data.account_id = (0, functions_1.createUniqueId)();
|
|
77
76
|
const { generateUserAccountId } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
78
77
|
if (typeof generateUserAccountId === 'function') {
|
|
79
78
|
body.data.account_id = await generateUserAccountId(body.data);
|
|
80
79
|
}
|
|
80
|
+
else {
|
|
81
|
+
body.data.account_id = MixinUtils_1.MixinUtils.generateSnowflakeId();
|
|
82
|
+
}
|
|
81
83
|
const result = await this.executeSysSimpleSQL(SystemTables_1.SystemTables.sys_user_account, keys_1.KeysOfSimpleSQL.SIMPLE_INSERT, {
|
|
82
84
|
validateCfg: {
|
|
83
85
|
'data.login_name': LOGIN_NAME_VALIDATE,
|
|
84
86
|
'data.nick_name': [keys_1.KeysOfValidators.REQUIRED, keys_1.KeysOfValidators.STRING, 'length:2,20', checkAccountCreateBlacklist],
|
|
85
|
-
'data.avatar': [keys_1.KeysOfValidators.REQUIRED, keys_1.KeysOfValidators.STRING],
|
|
86
87
|
},
|
|
87
88
|
});
|
|
88
89
|
return result;
|
|
@@ -20,6 +20,7 @@ const render_utils_1 = require("../../libs/utils/render-utils");
|
|
|
20
20
|
const crypto_utils_1 = require("../../libs/utils/crypto-utils");
|
|
21
21
|
const SysAppService_1 = require("../../service/SysAppService");
|
|
22
22
|
const AuthService_1 = require("../../service/AuthService");
|
|
23
|
+
const functions_1 = require("../../libs/utils/functions");
|
|
23
24
|
/**
|
|
24
25
|
* 渲染独立外部应用
|
|
25
26
|
*/
|
|
@@ -28,13 +29,9 @@ let AppRenderController = class AppRenderController extends BaseApiController_1.
|
|
|
28
29
|
const appPathArr = appPath.split('/');
|
|
29
30
|
const appCode = appPathArr[0];
|
|
30
31
|
const appInfo = await this.sysAppService.getSysAppOne(appCode);
|
|
31
|
-
if (!appInfo) {
|
|
32
|
+
if (!(0, functions_1.isEntityOK)(appInfo)) {
|
|
32
33
|
this.ctx.status = 404;
|
|
33
|
-
return this.ctx.render('404_app', { appCode, errorMsg: '
|
|
34
|
-
}
|
|
35
|
-
if (appInfo.status !== 1) {
|
|
36
|
-
this.ctx.status = 404;
|
|
37
|
-
return this.ctx.render('404_app', { appCode, errorMsg: ' 应用已下线' });
|
|
34
|
+
return this.ctx.render('404_app', { appCode, errorMsg: '应用不存在或已下线' });
|
|
38
35
|
}
|
|
39
36
|
const isSupportWorkbench = await this.isSupportCurrentWorkbench(appInfo);
|
|
40
37
|
if (!isSupportWorkbench) {
|
|
@@ -42,6 +39,10 @@ let AppRenderController = class AppRenderController extends BaseApiController_1.
|
|
|
42
39
|
return this.ctx.render('404_app', { appCode, errorMsg: ' 应用没有绑定此站点' });
|
|
43
40
|
}
|
|
44
41
|
const workbenchInfo = await this.workbenchService.getCurrentHostWorkbenchInfo();
|
|
42
|
+
if (!(0, functions_1.isEntityOK)(workbenchInfo)) {
|
|
43
|
+
this.ctx.status = 404;
|
|
44
|
+
return this.ctx.render('404_app', { appCode, errorMsg: '站点不存在或已下线' });
|
|
45
|
+
}
|
|
45
46
|
const html_content = appInfo.html_content || '<b style="color: red">错误:未配置HTML模版,请检查!!</b>';
|
|
46
47
|
const userInfo = await this.getUserAndRefreshSessionInfo();
|
|
47
48
|
// 形如(不带域名):/ns/app/abc-app-path?aa=2332
|
|
@@ -7,6 +7,7 @@ const CurdProServiceHub_1 = require("./services/CurdProServiceHub");
|
|
|
7
7
|
const exceptions_1 = require("./exceptions");
|
|
8
8
|
const RequestCfgModel_1 = require("./models/RequestCfgModel");
|
|
9
9
|
const MixinUtils_1 = require("./utils/MixinUtils");
|
|
10
|
+
const SqlErrorParseUtils_1 = require("./utils/SqlErrorParseUtils");
|
|
10
11
|
const keys_1 = require("./models/keys");
|
|
11
12
|
class CrudPro {
|
|
12
13
|
constructor() {
|
|
@@ -355,19 +356,9 @@ class CrudPro {
|
|
|
355
356
|
const message = MixinUtils_1.MixinUtils.getErrorMessage(e);
|
|
356
357
|
const logger = this.executeContext.getLogger();
|
|
357
358
|
logger.error('RUN_SQL_EXCEPTION', message);
|
|
358
|
-
throw
|
|
359
|
+
throw SqlErrorParseUtils_1.SqlErrorParseUtils.parseRunSqlException(e || {});
|
|
359
360
|
}
|
|
360
361
|
}
|
|
361
|
-
parseRunSqlException(e) {
|
|
362
|
-
const sqlMessage = '' + e.sqlMessage;
|
|
363
|
-
if (e.code === 'ER_DUP_ENTRY' && sqlMessage.startsWith('Duplicate entry')) {
|
|
364
|
-
return new exceptions_1.CommonException(exceptions_1.Exceptions.RUN_SQL_EXCEPTION_ER_DUP_ENTRY, '此对象实体已存在,不能创建重复对象');
|
|
365
|
-
}
|
|
366
|
-
if (e.code === 'ER_NO_SUCH_TABLE') {
|
|
367
|
-
return new exceptions_1.CommonException(exceptions_1.Exceptions.RUN_SQL_EXCEPTION_ER_NO_SUCH_TABLE, '查询的表不存在:' + sqlMessage);
|
|
368
|
-
}
|
|
369
|
-
return e;
|
|
370
|
-
}
|
|
371
362
|
async afterExecuteSQLList() {
|
|
372
363
|
return this.executeContext.contextFunc.afterExecuteSQLList();
|
|
373
364
|
}
|
|
@@ -79,6 +79,12 @@ export declare enum Exceptions {
|
|
|
79
79
|
RUN_SQL_EXCEPTION = "RUN_SQL_EXCEPTION",
|
|
80
80
|
RUN_SQL_EXCEPTION_ER_DUP_ENTRY = "RUN_SQL_EXCEPTION_ER_DUP_ENTRY",
|
|
81
81
|
RUN_SQL_EXCEPTION_ER_NO_SUCH_TABLE = "RUN_SQL_EXCEPTION_ER_NO_SUCH_TABLE",
|
|
82
|
+
RUN_SQL_EXCEPTION_ER_FK_PARENT_REFERENCED = "RUN_SQL_EXCEPTION_ER_FK_PARENT_REFERENCED",
|
|
83
|
+
RUN_SQL_EXCEPTION_ER_FK_PARENT_NOT_FOUND = "RUN_SQL_EXCEPTION_ER_FK_PARENT_NOT_FOUND",
|
|
84
|
+
RUN_SQL_EXCEPTION_ER_NOT_NULL = "RUN_SQL_EXCEPTION_ER_NOT_NULL",
|
|
85
|
+
RUN_SQL_EXCEPTION_ER_DATA_TOO_LONG = "RUN_SQL_EXCEPTION_ER_DATA_TOO_LONG",
|
|
86
|
+
RUN_SQL_EXCEPTION_ER_BAD_FIELD = "RUN_SQL_EXCEPTION_ER_BAD_FIELD",
|
|
87
|
+
RUN_SQL_EXCEPTION_ER_DEADLOCK = "RUN_SQL_EXCEPTION_ER_DEADLOCK",
|
|
82
88
|
RUN_IS_NEED_EXECUTE_ERR = "RUN_IS_NEED_EXECUTE_ERR",
|
|
83
89
|
RUN_PICK_ERR_VISITOR_NULL = "RUN_PICK_ERR_VISITOR_NULL",
|
|
84
90
|
RUN_PICK_ERR_VISITOR_FIELD = "RUN_PICK_ERR_VISITOR_FIELD",
|
|
@@ -83,6 +83,12 @@ var Exceptions;
|
|
|
83
83
|
Exceptions["RUN_SQL_EXCEPTION"] = "RUN_SQL_EXCEPTION";
|
|
84
84
|
Exceptions["RUN_SQL_EXCEPTION_ER_DUP_ENTRY"] = "RUN_SQL_EXCEPTION_ER_DUP_ENTRY";
|
|
85
85
|
Exceptions["RUN_SQL_EXCEPTION_ER_NO_SUCH_TABLE"] = "RUN_SQL_EXCEPTION_ER_NO_SUCH_TABLE";
|
|
86
|
+
Exceptions["RUN_SQL_EXCEPTION_ER_FK_PARENT_REFERENCED"] = "RUN_SQL_EXCEPTION_ER_FK_PARENT_REFERENCED";
|
|
87
|
+
Exceptions["RUN_SQL_EXCEPTION_ER_FK_PARENT_NOT_FOUND"] = "RUN_SQL_EXCEPTION_ER_FK_PARENT_NOT_FOUND";
|
|
88
|
+
Exceptions["RUN_SQL_EXCEPTION_ER_NOT_NULL"] = "RUN_SQL_EXCEPTION_ER_NOT_NULL";
|
|
89
|
+
Exceptions["RUN_SQL_EXCEPTION_ER_DATA_TOO_LONG"] = "RUN_SQL_EXCEPTION_ER_DATA_TOO_LONG";
|
|
90
|
+
Exceptions["RUN_SQL_EXCEPTION_ER_BAD_FIELD"] = "RUN_SQL_EXCEPTION_ER_BAD_FIELD";
|
|
91
|
+
Exceptions["RUN_SQL_EXCEPTION_ER_DEADLOCK"] = "RUN_SQL_EXCEPTION_ER_DEADLOCK";
|
|
86
92
|
Exceptions["RUN_IS_NEED_EXECUTE_ERR"] = "RUN_IS_NEED_EXECUTE_ERR";
|
|
87
93
|
Exceptions["RUN_PICK_ERR_VISITOR_NULL"] = "RUN_PICK_ERR_VISITOR_NULL";
|
|
88
94
|
Exceptions["RUN_PICK_ERR_VISITOR_FIELD"] = "RUN_PICK_ERR_VISITOR_FIELD";
|
|
@@ -13,6 +13,7 @@ var KeysOfFunCtx;
|
|
|
13
13
|
KeysOfFunCtx["CURRENT_VALUE"] = "$current";
|
|
14
14
|
KeysOfFunCtx["VISITOR"] = "visitor";
|
|
15
15
|
KeysOfFunCtx["VISITOR_ATTR"] = "visitor.";
|
|
16
|
+
KeysOfFunCtx["VISITOR_AVATAR"] = "visitor.avatar";
|
|
16
17
|
KeysOfFunCtx["REQUEST"] = "req.";
|
|
17
18
|
KeysOfFunCtx["RESULT"] = "res.";
|
|
18
19
|
})(KeysOfFunCtx = exports.KeysOfFunCtx || (exports.KeysOfFunCtx = {}));
|
|
@@ -82,8 +82,8 @@ class CrudProExecuteFuncService extends CrudProServiceBase_1.CrudProServiceBase
|
|
|
82
82
|
if (pickString.startsWith(keys_1.KeysOfFunCtx.VISITOR_ATTR)) {
|
|
83
83
|
const reqModel = funcCtx === null || funcCtx === void 0 ? void 0 : funcCtx.reqModel;
|
|
84
84
|
const attrValue = _.get(reqModel, pickString); // visitor.nickName
|
|
85
|
-
if (isNil(attrValue)) {
|
|
86
|
-
throw new exceptions_1.CommonException(exceptions_1.Exceptions.RUN_PICK_ERR_VISITOR_NULL, '
|
|
85
|
+
if (isNil(attrValue) && ![`${keys_1.KeysOfFunCtx.VISITOR_AVATAR}`].includes(pickString)) {
|
|
86
|
+
throw new exceptions_1.CommonException(exceptions_1.Exceptions.RUN_PICK_ERR_VISITOR_NULL, '获取用户字段${pickString}失败, 可能用户没有登陆');
|
|
87
87
|
}
|
|
88
88
|
return attrValue;
|
|
89
89
|
}
|