perf: 流水线支持批量修改分组,批量删除

This commit is contained in:
xiaojunnuo
2024-12-01 02:10:40 +08:00
parent 0772d3b3fd
commit a847e66c4f
25 changed files with 653 additions and 79 deletions
@@ -0,0 +1,33 @@
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
@Entity('pi_pipeline_group')
export class PipelineGroupEntity {
@PrimaryGeneratedColumn()
id: number;
@Column({ name: 'user_id', comment: '用户id' })
userId: number;
@Column({ name: 'name', comment: '分组名称' })
name: string;
@Column({ name: 'icon', comment: '图标' })
icon: string;
@Column({ name: 'favorite', comment: '收藏' })
favorite: boolean;
@Column({
name: 'create_time',
comment: '创建时间',
default: () => 'CURRENT_TIMESTAMP',
})
createTime: Date;
@Column({
name: 'update_time',
comment: '修改时间',
default: () => 'CURRENT_TIMESTAMP',
})
updateTime: Date;
}
@@ -14,13 +14,12 @@ export class PipelineEntity {
@Column({ comment: '配置', length: 40960 })
content: string;
@Column({
name: 'keep_history_count',
comment: '历史记录保持数量',
nullable: true,
})
@Column({ name: 'keep_history_count', comment: '历史记录保持数量', nullable: true })
keepHistoryCount: number;
@Column({ name: 'group_id', comment: '分组id', nullable: true })
groupId: number;
@Column({ comment: '备注', length: 100, nullable: true })
remark: string;
@@ -0,0 +1,28 @@
import { Provide, Scope, ScopeEnum } from '@midwayjs/core';
import { BaseService } from '@certd/lib-server';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Repository } from 'typeorm';
import { PipelineGroupEntity } from '../entity/pipeline-group.js';
import { merge } from 'lodash-es';
@Provide()
@Scope(ScopeEnum.Singleton)
export class PipelineGroupService extends BaseService<PipelineGroupEntity> {
@InjectEntityModel(PipelineGroupEntity)
repository: Repository<PipelineGroupEntity>;
//@ts-ignore
getRepository() {
return this.repository;
}
async add(bean: any) {
bean = merge(
{
favorite: false,
},
bean
);
return await this.repository.save(bean);
}
}
@@ -554,4 +554,21 @@ export class PipelineService extends BaseService<PipelineEntity> {
return result;
}
async batchDelete(ids: number[], userId: number) {
for (const id of ids) {
await this.checkUserId(id, userId);
await this.delete(id);
}
}
async batchUpdateGroup(ids: number[], groupId: number, userId: any) {
await this.repository.update(
{
id: In(ids),
userId,
},
{ groupId }
);
}
}