mirror of
https://github.com/certd/certd.git
synced 2026-07-22 02:47:32 +08:00
fix: 修复正常批量删除流水线报权限不足的bug
This commit is contained in:
@@ -253,7 +253,6 @@ export abstract class BaseService<T> {
|
||||
if (!Array.isArray(ids)) {
|
||||
ids = [ids];
|
||||
}
|
||||
ids = this.filterIds(ids);
|
||||
const res = await this.getRepository().find({
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
@@ -266,7 +265,7 @@ export abstract class BaseService<T> {
|
||||
},
|
||||
});
|
||||
if (!res || res.length === ids.length) {
|
||||
return;
|
||||
return ids;
|
||||
}
|
||||
throw new PermissionException("权限不足");
|
||||
}
|
||||
@@ -280,6 +279,12 @@ export abstract class BaseService<T> {
|
||||
});
|
||||
}
|
||||
async batchDelete(ids: number[], userId: number, projectId?: number): Promise<number> {
|
||||
if (!ids || ids.length === 0) {
|
||||
throw new ValidateException("ids不能为空");
|
||||
}
|
||||
if (!Array.isArray(ids)) {
|
||||
ids = [ids];
|
||||
}
|
||||
ids = this.filterIds(ids);
|
||||
if (userId != null) {
|
||||
const userProjectQuery = this.buildUserProjectQuery(userId, projectId);
|
||||
|
||||
@@ -806,6 +806,8 @@ export class SiteInfoService extends BaseService<SiteInfoEntity> {
|
||||
}
|
||||
|
||||
async batchDelete(ids: number[], userId: number, projectId?: number): Promise<number> {
|
||||
|
||||
ids = this.filterIds(ids);
|
||||
const userProjectQuery = this.buildUserProjectQuery(userId, projectId);
|
||||
await this.repository.delete({
|
||||
id: In(ids),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Config, Inject, Provide, Scope, ScopeEnum, sleep } from "@midwayjs/core";
|
||||
import { InjectEntityModel } from "@midwayjs/typeorm";
|
||||
import { In, MoreThan, Repository } from "typeorm";
|
||||
import { AccessService, BaseService, isEnterprise, NeedSuiteException, NeedVIPException, PageReq, SysPublicSettings, SysSettingsService, SysSiteInfo } from "@certd/lib-server";
|
||||
import { AccessService, BaseService, isEnterprise, NeedSuiteException, NeedVIPException, PageReq, SysPublicSettings, SysSettingsService, SysSiteInfo, ValidateException } from "@certd/lib-server";
|
||||
import { PipelineEntity } from "../entity/pipeline.js";
|
||||
import { PipelineDetail } from "../entity/vo/pipeline-detail.js";
|
||||
import { Executor, IAccessService, ICnameProxyService, INotificationService, Notification, Pipeline, pluginRegistry, ResultType, RunHistory, RunnableCollection, SysInfo, UserInfo } from "@certd/pipeline";
|
||||
@@ -966,15 +966,19 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
if (!isPlus()) {
|
||||
throw new NeedVIPException("此功能需要升级Certd专业版");
|
||||
}
|
||||
if (!ids || ids.length === 0) {
|
||||
throw new ValidateException("ids不能为空");
|
||||
}
|
||||
ids = this.filterIds(ids);
|
||||
|
||||
if (userId && userId > 0) {
|
||||
await this.checkUserId(ids, userId);
|
||||
}
|
||||
if (projectId) {
|
||||
await this.checkUserId(ids, projectId, "projectId");
|
||||
}
|
||||
for (const id of ids) {
|
||||
if (userId && userId > 0) {
|
||||
await this.checkUserId(id, userId);
|
||||
}
|
||||
if (projectId) {
|
||||
await this.checkUserId(id, projectId, "projectId");
|
||||
}
|
||||
await this.delete(id);
|
||||
ids.push(id);
|
||||
}
|
||||
return ids.length;
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ export class TemplateService extends BaseService<TemplateEntity> {
|
||||
}
|
||||
|
||||
async batchDelete(ids: number[], userId: number, projectId?: number): Promise<number> {
|
||||
ids = this.filterIds(ids);
|
||||
const where: any = {
|
||||
id: In(ids),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user