perf: 优化成功后跳过的提示

This commit is contained in:
xiaojunnuo
2024-08-13 20:30:42 +08:00
parent ffc4e71783
commit 7b451bbf6e
33 changed files with 151 additions and 252 deletions
@@ -1,12 +1,4 @@
import {
Provide,
Controller,
Post,
Inject,
Body,
Query,
ALL,
} from '@midwayjs/core';
import { Provide, Controller, Post, Inject, Body, Query, ALL } from '@midwayjs/core';
import { UserService } from '../service/user-service.js';
import { CrudController } from '../../../basic/crud-controller.js';
import { RoleService } from '../service/role-service.js';
@@ -191,4 +191,17 @@ export class UserService extends BaseService<UserEntity> {
};
await this.update(param);
}
async delete(ids: any) {
if (typeof ids === 'string') {
ids = ids.split(',');
ids = ids.map(id => parseInt(id));
}
if (ids instanceof Array) {
if (ids.includes(1)) {
throw new CommonException('不能删除管理员');
}
}
await super.delete(ids);
}
}
@@ -8,8 +8,8 @@ export class AutoRegisterCron {
@Inject()
pipelineService: PipelineService;
@Config('preview.enabled')
private preview: boolean;
@Config('cron.onlyAdminUser')
private onlyAdminUser: boolean;
// @Inject()
// echoPlugin: EchoPlugin;
@@ -19,7 +19,7 @@ export class AutoRegisterCron {
@Init()
async init() {
logger.info('加载定时trigger开始');
await this.pipelineService.onStartup(this.immediateTriggerOnce, this.preview);
await this.pipelineService.onStartup(this.immediateTriggerOnce, this.onlyAdminUser);
// logger.info(this.echoPlugin, this.echoPlugin.test);
// logger.info('加载定时trigger完成');
//
@@ -136,10 +136,13 @@ export class HistoryService extends BaseService<HistoryEntity> {
}
async deleteByIds(ids: number[], userId: number) {
await this.repository.delete({
const condition: any = {
id: In(ids),
userId,
});
};
if (userId != null) {
condition.userId = userId;
}
await this.repository.delete(condition);
await this.logService.deleteByHistoryIds(ids);
}
@@ -149,10 +149,10 @@ export class PipelineService extends BaseService<PipelineEntity> {
/**
* 应用启动后初始加载记录
*/
async onStartup(immediateTriggerOnce: boolean, preview: boolean) {
async onStartup(immediateTriggerOnce: boolean, onlyAdminUser: boolean) {
logger.info('加载定时trigger开始');
await this.foreachPipeline(async entity => {
if (preview && entity.userId !== 1) {
if (onlyAdminUser && entity.userId !== 1) {
return;
}
const pipeline = JSON.parse(entity.content ?? '{}');