midway-fatcms 0.0.13 → 0.0.15
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/controller/base/BaseApiController.d.ts +2 -0
- package/dist/controller/base/BaseApiController.js +5 -0
- package/dist/controller/helpers.controller.d.ts +2 -0
- package/dist/controller/helpers.controller.js +17 -0
- package/dist/controller/myinfo/AuthController.js +17 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/models/SystemTables.d.ts +1 -0
- package/dist/models/SystemTables.js +1 -0
- package/dist/service/ActionLogService.d.ts +14 -0
- package/dist/service/ActionLogService.js +50 -0
- package/dist/service/crudstd/CrudStdService.d.ts +1 -2
- package/dist/service/crudstd/CrudStdService.js +1 -2
- package/dist/service/curd/CurdMixByDictService.js +1 -0
- package/package.json +1 -1
- package/src/controller/base/BaseApiController.ts +3 -1
- package/src/controller/helpers.controller.ts +24 -2
- package/src/controller/myinfo/AuthController.ts +23 -1
- package/src/index.ts +1 -1
- package/src/models/SystemTables.ts +1 -2
- package/src/service/ActionLogService.ts +52 -0
- package/src/service/crudstd/CrudStdService.ts +1 -2
- package/src/service/curd/CurdMixByDictService.ts +1 -0
|
@@ -5,6 +5,7 @@ import { KeysOfSimpleSQL } from '../../libs/crud-pro/models/keys';
|
|
|
5
5
|
import { UserAccountService } from '../../service/UserAccountService';
|
|
6
6
|
import { BaseService } from '../../service/base/BaseService';
|
|
7
7
|
import { ConfigChangelogService } from '../../service/ConfigChangelogService';
|
|
8
|
+
import { ActionLogService } from '../../service/ActionLogService';
|
|
8
9
|
export interface IExecuteSimpleSqlParams {
|
|
9
10
|
updateCfg?: Record<string, IFuncCfgModel>;
|
|
10
11
|
allowCfg?: Record<string, string[]>;
|
|
@@ -28,6 +29,7 @@ export declare class BaseApiController extends BaseService {
|
|
|
28
29
|
protected ctx: Context;
|
|
29
30
|
protected curdMixService: CurdMixService;
|
|
30
31
|
protected userAccountService: UserAccountService;
|
|
32
|
+
protected actionLogService: ActionLogService;
|
|
31
33
|
protected configChangelogService: ConfigChangelogService;
|
|
32
34
|
/**
|
|
33
35
|
* 检查用户是否在指定时间内重复执行了某个操作
|
|
@@ -24,6 +24,7 @@ const aes_128_cbc_1 = require("aes-128-cbc");
|
|
|
24
24
|
const md5 = require("md5");
|
|
25
25
|
const AsymmetricCrypto_1 = require("../../libs/utils/AsymmetricCrypto");
|
|
26
26
|
const ConfigChangelogService_1 = require("../../service/ConfigChangelogService");
|
|
27
|
+
const ActionLogService_1 = require("../../service/ActionLogService");
|
|
27
28
|
let BaseApiController = class BaseApiController extends BaseService_1.BaseService {
|
|
28
29
|
/**
|
|
29
30
|
* 检查用户是否在指定时间内重复执行了某个操作
|
|
@@ -310,6 +311,10 @@ __decorate([
|
|
|
310
311
|
(0, core_1.Inject)(),
|
|
311
312
|
__metadata("design:type", UserAccountService_1.UserAccountService)
|
|
312
313
|
], BaseApiController.prototype, "userAccountService", void 0);
|
|
314
|
+
__decorate([
|
|
315
|
+
(0, core_1.Inject)(),
|
|
316
|
+
__metadata("design:type", ActionLogService_1.ActionLogService)
|
|
317
|
+
], BaseApiController.prototype, "actionLogService", void 0);
|
|
313
318
|
__decorate([
|
|
314
319
|
(0, core_1.Inject)(),
|
|
315
320
|
__metadata("design:type", ConfigChangelogService_1.ConfigChangelogService)
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import { CommonResult } from '../libs/utils/common-dto';
|
|
4
|
+
import { ActionLogService } from '../service/ActionLogService';
|
|
4
5
|
export declare class HelpersApi {
|
|
5
6
|
protected ctx: Context;
|
|
6
7
|
private midwayWebRouterService;
|
|
8
|
+
protected actionLogService: ActionLogService;
|
|
7
9
|
getApiEnv(): Promise<{
|
|
8
10
|
env: string;
|
|
9
11
|
href: string;
|
|
@@ -24,6 +24,7 @@ const SystemPerm_1 = require("../models/SystemPerm");
|
|
|
24
24
|
const permission_middleware_1 = require("../middleware/permission.middleware");
|
|
25
25
|
const CacheRefreshRedisSubscriber_1 = require("../service/base/cache-refresh/CacheRefreshRedisSubscriber");
|
|
26
26
|
const CacheServiceFactory_1 = require("../service/base/cache/CacheServiceFactory");
|
|
27
|
+
const ActionLogService_1 = require("../service/ActionLogService");
|
|
27
28
|
// http://127.0.0.1:7002/ns/api/helpers/getApiScript?prefix=/ns/api/manage
|
|
28
29
|
// http://127.0.0.1:7002/ns/api/helpers/getApiScript
|
|
29
30
|
// http://127.0.0.1:7002/ns/api/helpers/getApiEnv
|
|
@@ -141,6 +142,12 @@ let HelpersApi = class HelpersApi {
|
|
|
141
142
|
const cacheName = cacheNameParam;
|
|
142
143
|
const cacheServiceFactory = await this.ctx.requestContext.getAsync(CacheServiceFactory_1.CacheServiceFactory);
|
|
143
144
|
await cacheServiceFactory.refreshByCacheName(cacheName, this.ctx);
|
|
145
|
+
await this.actionLogService.insertActionLogTable({
|
|
146
|
+
actionModule: '系统工具',
|
|
147
|
+
actionName: '刷新缓存',
|
|
148
|
+
actionMessage: '刷新缓存成功',
|
|
149
|
+
actionTarget: cacheNameParam
|
|
150
|
+
});
|
|
144
151
|
return common_dto_1.CommonResult.successRes({
|
|
145
152
|
message: `业务缓存 ${cacheName} 已刷新`,
|
|
146
153
|
cacheName,
|
|
@@ -148,6 +155,12 @@ let HelpersApi = class HelpersApi {
|
|
|
148
155
|
}
|
|
149
156
|
const category = categoryParam ? categoryParam : undefined;
|
|
150
157
|
await (0, CacheRefreshRedisSubscriber_1.refreshCacheWithBroadcast)(this.ctx, category);
|
|
158
|
+
await this.actionLogService.insertActionLogTable({
|
|
159
|
+
actionModule: '系统工具',
|
|
160
|
+
actionName: '刷新缓存',
|
|
161
|
+
actionMessage: '刷新缓存成功',
|
|
162
|
+
actionTarget: cacheNameParam
|
|
163
|
+
});
|
|
151
164
|
return common_dto_1.CommonResult.successRes({
|
|
152
165
|
message: `缓存已刷新${category ? '(' + category + ')' : '(全部)'}(已广播集群)`,
|
|
153
166
|
category: category || 'ALL',
|
|
@@ -184,6 +197,10 @@ __decorate([
|
|
|
184
197
|
(0, core_1.Inject)(),
|
|
185
198
|
__metadata("design:type", core_1.MidwayWebRouterService)
|
|
186
199
|
], HelpersApi.prototype, "midwayWebRouterService", void 0);
|
|
200
|
+
__decorate([
|
|
201
|
+
(0, core_1.Inject)(),
|
|
202
|
+
__metadata("design:type", ActionLogService_1.ActionLogService)
|
|
203
|
+
], HelpersApi.prototype, "actionLogService", void 0);
|
|
187
204
|
__decorate([
|
|
188
205
|
(0, core_1.Get)('/getApiEnv'),
|
|
189
206
|
__metadata("design:type", Function),
|
|
@@ -53,6 +53,12 @@ let AuthController = class AuthController extends BaseApiController_1.BaseApiCon
|
|
|
53
53
|
}
|
|
54
54
|
const userSessionInfo = await this.authService.createUserSession(loginName, workbench.workbench_code);
|
|
55
55
|
this.ctx.cookies.set(userSession_1.SESSION_ID_KEY, userSessionInfo.sessionId, userSession_1.sessionCookieCfg);
|
|
56
|
+
await this.actionLogService.insertActionLogTable({
|
|
57
|
+
actionModule: '用户账号',
|
|
58
|
+
actionName: '登录',
|
|
59
|
+
actionMessage: '登录成功',
|
|
60
|
+
actionTarget: `${userSessionInfo === null || userSessionInfo === void 0 ? void 0 : userSessionInfo.nickName}(${userSessionInfo === null || userSessionInfo === void 0 ? void 0 : userSessionInfo.accountId})`
|
|
61
|
+
});
|
|
56
62
|
return common_dto_1.CommonResult.successMsg('登录成功', removePrivateField(userSessionInfo));
|
|
57
63
|
}
|
|
58
64
|
/**
|
|
@@ -87,12 +93,22 @@ let AuthController = class AuthController extends BaseApiController_1.BaseApiCon
|
|
|
87
93
|
* 修改我自己的密码
|
|
88
94
|
*/
|
|
89
95
|
async changeMyPassword() {
|
|
96
|
+
var _a;
|
|
90
97
|
const { unsaltedPwd } = this.ctx.request.body;
|
|
91
98
|
const loginName = this.ctx.userSession.getSessionInfo().loginName;
|
|
92
99
|
if (loginName === 'devopsviewer') {
|
|
93
100
|
return common_dto_1.CommonResult.errorRes('开放体验账号不支持修改密码');
|
|
94
101
|
}
|
|
95
|
-
|
|
102
|
+
const res = await this.userAccountService.chgUserPassword(loginName, unsaltedPwd);
|
|
103
|
+
if (res.success) {
|
|
104
|
+
await this.actionLogService.insertActionLogTable({
|
|
105
|
+
actionModule: '用户账号',
|
|
106
|
+
actionName: '修改密码',
|
|
107
|
+
actionMessage: '修改密码成功',
|
|
108
|
+
actionTarget: (_a = this.ctx.userSession.getSessionInfo()) === null || _a === void 0 ? void 0 : _a.nickName
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return res;
|
|
96
112
|
}
|
|
97
113
|
/**
|
|
98
114
|
* 校验权限接口,给前端用的。用于界面按钮级权限控制
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export * from './controller/gateway/AsyncTaskController';
|
|
|
12
12
|
export * from './controller/helpers.controller';
|
|
13
13
|
export * from './controller/home.controller';
|
|
14
14
|
export * from './controller/manage/AnyApiMangeApi';
|
|
15
|
-
export * from './controller/manage/AppLogMangeApi';
|
|
16
15
|
export * from './controller/manage/AppMangeApi';
|
|
17
16
|
export * from './controller/manage/AppPageMangeApi';
|
|
18
17
|
export * from './controller/manage/AppSchemaHistoryApi';
|
|
@@ -48,6 +47,7 @@ export * from './middleware/tx.middleware';
|
|
|
48
47
|
export * from './middleware/permission.middleware';
|
|
49
48
|
export * from './middleware/redislock.middleware';
|
|
50
49
|
export * from './service/AuthService';
|
|
50
|
+
export * from './service/ActionLogService';
|
|
51
51
|
export * from './service/EnumInfoService';
|
|
52
52
|
export * from './service/FileCenterService';
|
|
53
53
|
export * from './service/SysConfigService';
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,6 @@ __exportStar(require("./controller/gateway/AsyncTaskController"), exports);
|
|
|
30
30
|
__exportStar(require("./controller/helpers.controller"), exports);
|
|
31
31
|
__exportStar(require("./controller/home.controller"), exports);
|
|
32
32
|
__exportStar(require("./controller/manage/AnyApiMangeApi"), exports);
|
|
33
|
-
__exportStar(require("./controller/manage/AppLogMangeApi"), exports);
|
|
34
33
|
__exportStar(require("./controller/manage/AppMangeApi"), exports);
|
|
35
34
|
__exportStar(require("./controller/manage/AppPageMangeApi"), exports);
|
|
36
35
|
__exportStar(require("./controller/manage/AppSchemaHistoryApi"), exports);
|
|
@@ -66,6 +65,7 @@ __exportStar(require("./middleware/tx.middleware"), exports);
|
|
|
66
65
|
__exportStar(require("./middleware/permission.middleware"), exports);
|
|
67
66
|
__exportStar(require("./middleware/redislock.middleware"), exports);
|
|
68
67
|
__exportStar(require("./service/AuthService"), exports);
|
|
68
|
+
__exportStar(require("./service/ActionLogService"), exports);
|
|
69
69
|
__exportStar(require("./service/EnumInfoService"), exports);
|
|
70
70
|
__exportStar(require("./service/FileCenterService"), exports);
|
|
71
71
|
__exportStar(require("./service/SysConfigService"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseService } from "../service/base/BaseService";
|
|
2
|
+
import { CrudWriteResult } from '../libs/crud-pro/models/CrudResult';
|
|
3
|
+
export interface IActionLoginInfo {
|
|
4
|
+
actionModule: string;
|
|
5
|
+
actionName: string;
|
|
6
|
+
actionMessage: string;
|
|
7
|
+
actionTarget: string;
|
|
8
|
+
createdBy?: string;
|
|
9
|
+
modifiedBy?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class ActionLogService extends BaseService {
|
|
12
|
+
private curdMixService;
|
|
13
|
+
insertActionLogTable(logInfo: IActionLoginInfo): Promise<CrudWriteResult>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ActionLogService = void 0;
|
|
13
|
+
const core_1 = require("@midwayjs/core");
|
|
14
|
+
const CurdMixService_1 = require("./curd/CurdMixService");
|
|
15
|
+
const SystemTables_1 = require("../models/SystemTables");
|
|
16
|
+
const global_config_1 = require("../libs/global-config/global-config");
|
|
17
|
+
const BaseService_1 = require("../service/base/BaseService");
|
|
18
|
+
const DateTimeUtils_1 = require("../libs/crud-pro/utils/DateTimeUtils");
|
|
19
|
+
let ActionLogService = class ActionLogService extends BaseService_1.BaseService {
|
|
20
|
+
async insertActionLogTable(logInfo) {
|
|
21
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
22
|
+
const actionTable = this.curdMixService.getQuickCrud({
|
|
23
|
+
sqlDatabase: SystemDbName,
|
|
24
|
+
sqlDbType: SystemDbType,
|
|
25
|
+
sqlTable: SystemTables_1.SystemTables.sys_action_log,
|
|
26
|
+
});
|
|
27
|
+
const sessionInfo = this.ctx.userSession.getSessionInfo();
|
|
28
|
+
return actionTable.insert({
|
|
29
|
+
data: {
|
|
30
|
+
action_module: logInfo.actionModule,
|
|
31
|
+
action_name: logInfo.actionName,
|
|
32
|
+
action_message: logInfo.actionMessage,
|
|
33
|
+
created_by: logInfo.createdBy || (sessionInfo === null || sessionInfo === void 0 ? void 0 : sessionInfo.accountId) || '',
|
|
34
|
+
created_at: DateTimeUtils_1.DateTimeUtils.getCurrentTimeString(),
|
|
35
|
+
modified_at: DateTimeUtils_1.DateTimeUtils.getCurrentTimeString(),
|
|
36
|
+
modified_by: logInfo.modifiedBy || (sessionInfo === null || sessionInfo === void 0 ? void 0 : sessionInfo.accountId) || '',
|
|
37
|
+
status: 1,
|
|
38
|
+
action_target: logInfo.actionTarget
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, core_1.Inject)(),
|
|
45
|
+
__metadata("design:type", CurdMixService_1.CurdMixService)
|
|
46
|
+
], ActionLogService.prototype, "curdMixService", void 0);
|
|
47
|
+
ActionLogService = __decorate([
|
|
48
|
+
(0, core_1.Provide)()
|
|
49
|
+
], ActionLogService);
|
|
50
|
+
exports.ActionLogService = ActionLogService;
|
|
@@ -35,8 +35,7 @@ export declare class CrudStdService extends ApiBaseService {
|
|
|
35
35
|
private handleResultDataPermissionBySettingKey;
|
|
36
36
|
/**
|
|
37
37
|
* 获取appInfo 并且拿到当前settingKey相关的信息
|
|
38
|
-
* @param
|
|
39
|
-
* @param settingKey
|
|
38
|
+
* @param stdAction
|
|
40
39
|
*/
|
|
41
40
|
getParsedCrudStdAppForSettingKey(stdAction: ICrudStdActionParams): Promise<ICrudStdAppInfoForSettingKey>;
|
|
42
41
|
/**
|
|
@@ -155,8 +155,7 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
157
|
* 获取appInfo 并且拿到当前settingKey相关的信息
|
|
158
|
-
* @param
|
|
159
|
-
* @param settingKey
|
|
158
|
+
* @param stdAction
|
|
160
159
|
*/
|
|
161
160
|
async getParsedCrudStdAppForSettingKey(stdAction) {
|
|
162
161
|
const { appCode, settingKey, buttonSettingKey } = stdAction || {};
|
|
@@ -59,6 +59,7 @@ let CurdMixByDictService = class CurdMixByDictService {
|
|
|
59
59
|
let selectedRows = [];
|
|
60
60
|
if (noCacheCodes.length > 0) {
|
|
61
61
|
const res1 = await this.curdProService.executeCrudByCfg({
|
|
62
|
+
columns: ['dict_code', 'label', 'value', 'style', 'code'],
|
|
62
63
|
condition: { dict_code: { $in: noCacheCodes }, deleted_at: 0, status: 1 },
|
|
63
64
|
}, {
|
|
64
65
|
sqlTable: SystemTables_1.SystemTables.sys_data_dict_item,
|
package/package.json
CHANGED
|
@@ -15,6 +15,7 @@ import * as md5 from 'md5';
|
|
|
15
15
|
import { AsymmetricCrypto } from '@/libs/utils/AsymmetricCrypto';
|
|
16
16
|
import { IRequestCfgModel2 } from "@/models/bizmodels";
|
|
17
17
|
import { ConfigChangelogService, isChangelogTable, ChangelogAction } from '@/service/ConfigChangelogService';
|
|
18
|
+
import { ActionLogService } from '@/service/ActionLogService'
|
|
18
19
|
|
|
19
20
|
export interface IExecuteSimpleSqlParams {
|
|
20
21
|
updateCfg?: Record<string, IFuncCfgModel>;
|
|
@@ -49,7 +50,8 @@ export class BaseApiController extends BaseService {
|
|
|
49
50
|
@Inject()
|
|
50
51
|
protected userAccountService: UserAccountService;
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
@Inject()
|
|
54
|
+
protected actionLogService: ActionLogService;
|
|
53
55
|
|
|
54
56
|
@Inject()
|
|
55
57
|
protected configChangelogService: ConfigChangelogService;
|
|
@@ -6,12 +6,13 @@ import { CommonException, Exceptions } from '@/libs/crud-pro/exceptions';
|
|
|
6
6
|
import { createUniqueId } from '@/libs/utils/functions';
|
|
7
7
|
import { privateAES } from '@/libs/utils/crypto-utils';
|
|
8
8
|
import { CommonResult } from '@/libs/utils/common-dto';
|
|
9
|
-
import {SystemFuncCode, SystemRoleCode} from "@/models/SystemPerm";
|
|
9
|
+
import { SystemFuncCode, SystemRoleCode } from "@/models/SystemPerm";
|
|
10
10
|
import { checkPermission } from '@/middleware/permission.middleware';
|
|
11
11
|
import { refreshCacheWithBroadcast } from '@/service/base/cache-refresh/CacheRefreshRedisSubscriber';
|
|
12
12
|
import { CacheRefreshCategory } from '@/models/CacheRefreshCategory';
|
|
13
13
|
import { CacheNameEnum } from '@/models/bizmodels';
|
|
14
14
|
import { CacheServiceFactory } from '@/service/base/cache/CacheServiceFactory';
|
|
15
|
+
import { ActionLogService } from '@/service/ActionLogService';
|
|
15
16
|
|
|
16
17
|
// http://127.0.0.1:7002/ns/api/helpers/getApiScript?prefix=/ns/api/manage
|
|
17
18
|
// http://127.0.0.1:7002/ns/api/helpers/getApiScript
|
|
@@ -26,6 +27,9 @@ export class HelpersApi {
|
|
|
26
27
|
@Inject()
|
|
27
28
|
private midwayWebRouterService: MidwayWebRouterService;
|
|
28
29
|
|
|
30
|
+
@Inject()
|
|
31
|
+
protected actionLogService: ActionLogService;
|
|
32
|
+
|
|
29
33
|
|
|
30
34
|
@Get('/getApiEnv')
|
|
31
35
|
async getApiEnv() {
|
|
@@ -166,6 +170,15 @@ export class HelpersApi {
|
|
|
166
170
|
const cacheName = cacheNameParam as CacheNameEnum;
|
|
167
171
|
const cacheServiceFactory = await this.ctx.requestContext.getAsync(CacheServiceFactory);
|
|
168
172
|
await cacheServiceFactory.refreshByCacheName(cacheName, this.ctx as any);
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
await this.actionLogService.insertActionLogTable({
|
|
176
|
+
actionModule: '系统工具',
|
|
177
|
+
actionName: '刷新缓存',
|
|
178
|
+
actionMessage: '刷新缓存成功',
|
|
179
|
+
actionTarget: cacheNameParam
|
|
180
|
+
});
|
|
181
|
+
|
|
169
182
|
return CommonResult.successRes({
|
|
170
183
|
message: `业务缓存 ${cacheName} 已刷新`,
|
|
171
184
|
cacheName,
|
|
@@ -174,6 +187,15 @@ export class HelpersApi {
|
|
|
174
187
|
|
|
175
188
|
const category = categoryParam ? categoryParam as CacheRefreshCategory : undefined;
|
|
176
189
|
await refreshCacheWithBroadcast(this.ctx, category);
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
await this.actionLogService.insertActionLogTable({
|
|
193
|
+
actionModule: '系统工具',
|
|
194
|
+
actionName: '刷新缓存',
|
|
195
|
+
actionMessage: '刷新缓存成功',
|
|
196
|
+
actionTarget: cacheNameParam
|
|
197
|
+
});
|
|
198
|
+
|
|
177
199
|
return CommonResult.successRes({
|
|
178
200
|
message: `缓存已刷新${category ? '(' + category + ')' : '(全部)'}(已广播集群)`,
|
|
179
201
|
category: category || 'ALL',
|
|
@@ -183,7 +205,7 @@ export class HelpersApi {
|
|
|
183
205
|
private checkLocalPermissionEnv() {
|
|
184
206
|
|
|
185
207
|
//是否是开发者
|
|
186
|
-
|
|
208
|
+
const isDevelopUser = (): boolean => {
|
|
187
209
|
const isDevOpsWriter = this.ctx.userSession?.hasRole(SystemRoleCode.DevOpsWriter);
|
|
188
210
|
const isSuperAdmin = this.ctx.userSession?.hasRole(SystemRoleCode.SuperAdmin);
|
|
189
211
|
const isHelpersTools = this.ctx.userSession?.hasPermission(SystemFuncCode.HelpersTools);
|
|
@@ -60,6 +60,15 @@ export class AuthController extends BaseApiController {
|
|
|
60
60
|
|
|
61
61
|
const userSessionInfo = await this.authService.createUserSession(loginName, workbench.workbench_code);
|
|
62
62
|
this.ctx.cookies.set(SESSION_ID_KEY, userSessionInfo.sessionId, sessionCookieCfg);
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
await this.actionLogService.insertActionLogTable({
|
|
66
|
+
actionModule: '用户账号',
|
|
67
|
+
actionName: '登录',
|
|
68
|
+
actionMessage: '登录成功',
|
|
69
|
+
actionTarget: `${userSessionInfo?.nickName}(${userSessionInfo?.accountId})`
|
|
70
|
+
});
|
|
71
|
+
|
|
63
72
|
return CommonResult.successMsg('登录成功', removePrivateField(userSessionInfo));
|
|
64
73
|
}
|
|
65
74
|
|
|
@@ -112,7 +121,20 @@ export class AuthController extends BaseApiController {
|
|
|
112
121
|
return CommonResult.errorRes('开放体验账号不支持修改密码');
|
|
113
122
|
}
|
|
114
123
|
|
|
115
|
-
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
const res = await this.userAccountService.chgUserPassword(loginName, unsaltedPwd);
|
|
127
|
+
|
|
128
|
+
if (res.success) {
|
|
129
|
+
await this.actionLogService.insertActionLogTable({
|
|
130
|
+
actionModule: '用户账号',
|
|
131
|
+
actionName: '修改密码',
|
|
132
|
+
actionMessage: '修改密码成功',
|
|
133
|
+
actionTarget: this.ctx.userSession.getSessionInfo()?.nickName
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return res;
|
|
116
138
|
}
|
|
117
139
|
|
|
118
140
|
/**
|
package/src/index.ts
CHANGED
|
@@ -12,7 +12,6 @@ export * from './controller/gateway/AsyncTaskController';
|
|
|
12
12
|
export * from './controller/helpers.controller';
|
|
13
13
|
export * from './controller/home.controller';
|
|
14
14
|
export * from './controller/manage/AnyApiMangeApi';
|
|
15
|
-
export * from './controller/manage/AppLogMangeApi';
|
|
16
15
|
export * from './controller/manage/AppMangeApi';
|
|
17
16
|
export * from './controller/manage/AppPageMangeApi';
|
|
18
17
|
export * from './controller/manage/AppSchemaHistoryApi';
|
|
@@ -49,6 +48,7 @@ export * from './middleware/tx.middleware';
|
|
|
49
48
|
export * from './middleware/permission.middleware';
|
|
50
49
|
export * from './middleware/redislock.middleware';
|
|
51
50
|
export * from './service/AuthService';
|
|
51
|
+
export * from './service/ActionLogService';
|
|
52
52
|
export * from './service/EnumInfoService';
|
|
53
53
|
export * from './service/FileCenterService';
|
|
54
54
|
export * from './service/SysConfigService';
|
|
@@ -22,8 +22,7 @@ export const SystemTables = {
|
|
|
22
22
|
sys_visit_stats: 'sys_visit_stats',
|
|
23
23
|
sys_async_tasks: 'sys_async_tasks',
|
|
24
24
|
sys_config_changelog: 'sys_config_changelog',
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
sys_action_log: 'sys_action_log',
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
export const SystemDevOpsWorkbench = 'devops';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Inject, Provide } from '@midwayjs/core';
|
|
2
|
+
import { CurdMixService } from './curd/CurdMixService';
|
|
3
|
+
import { SystemTables } from '@/models/SystemTables';
|
|
4
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
5
|
+
import { BaseService } from "@/service/base/BaseService";
|
|
6
|
+
import { DateTimeUtils } from '@/libs/crud-pro/utils/DateTimeUtils';
|
|
7
|
+
import { CrudWriteResult } from '@/libs/crud-pro/models/CrudResult';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export interface IActionLoginInfo {
|
|
11
|
+
actionModule: string;
|
|
12
|
+
actionName: string;
|
|
13
|
+
actionMessage: string;
|
|
14
|
+
actionTarget: string;
|
|
15
|
+
createdBy?: string;
|
|
16
|
+
modifiedBy?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Provide()
|
|
20
|
+
export class ActionLogService extends BaseService {
|
|
21
|
+
|
|
22
|
+
@Inject()
|
|
23
|
+
private curdMixService: CurdMixService;
|
|
24
|
+
|
|
25
|
+
public async insertActionLogTable(logInfo: IActionLoginInfo): Promise<CrudWriteResult> {
|
|
26
|
+
|
|
27
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
28
|
+
const actionTable = this.curdMixService.getQuickCrud({
|
|
29
|
+
sqlDatabase: SystemDbName,
|
|
30
|
+
sqlDbType: SystemDbType,
|
|
31
|
+
sqlTable: SystemTables.sys_action_log,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const sessionInfo = this.ctx.userSession.getSessionInfo();
|
|
35
|
+
return actionTable.insert({
|
|
36
|
+
data: {
|
|
37
|
+
action_module: logInfo.actionModule,
|
|
38
|
+
action_name: logInfo.actionName,
|
|
39
|
+
action_message: logInfo.actionMessage,
|
|
40
|
+
created_by: logInfo.createdBy || sessionInfo?.accountId || '',
|
|
41
|
+
created_at: DateTimeUtils.getCurrentTimeString(),
|
|
42
|
+
modified_at: DateTimeUtils.getCurrentTimeString(),
|
|
43
|
+
modified_by: logInfo.modifiedBy || sessionInfo?.accountId || '',
|
|
44
|
+
status: 1,
|
|
45
|
+
action_target: logInfo.actionTarget
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
}
|
|
@@ -219,8 +219,7 @@ export class CrudStdService extends ApiBaseService {
|
|
|
219
219
|
|
|
220
220
|
/**
|
|
221
221
|
* 获取appInfo 并且拿到当前settingKey相关的信息
|
|
222
|
-
* @param
|
|
223
|
-
* @param settingKey
|
|
222
|
+
* @param stdAction
|
|
224
223
|
*/
|
|
225
224
|
public async getParsedCrudStdAppForSettingKey(stdAction: ICrudStdActionParams): Promise<ICrudStdAppInfoForSettingKey> {
|
|
226
225
|
const { appCode, settingKey, buttonSettingKey } = stdAction || {};
|
|
@@ -68,6 +68,7 @@ export class CurdMixByDictService implements IExecuteContextHandler {
|
|
|
68
68
|
if (noCacheCodes.length > 0) {
|
|
69
69
|
const res1 = await this.curdProService.executeCrudByCfg(
|
|
70
70
|
{
|
|
71
|
+
columns: ['dict_code', 'label', 'value', 'style', 'code'],
|
|
71
72
|
condition: { dict_code: { $in: noCacheCodes }, deleted_at: 0, status: 1 },
|
|
72
73
|
},
|
|
73
74
|
{
|