feat: 支持关卡配置分享
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { ShareParticipant } from '../entities/share-participant.entity';
|
||||
|
||||
@Injectable()
|
||||
export class ShareParticipantRepository {
|
||||
constructor(
|
||||
@InjectRepository(ShareParticipant)
|
||||
private readonly repository: Repository<ShareParticipant>,
|
||||
) {}
|
||||
|
||||
/** 添加参与者(已存在则忽略) */
|
||||
async addParticipant(
|
||||
shareConfigId: string,
|
||||
participantId: string,
|
||||
): Promise<void> {
|
||||
await this.repository
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(ShareParticipant)
|
||||
.values({ shareConfigId, participantId })
|
||||
.orIgnore()
|
||||
.execute();
|
||||
}
|
||||
|
||||
async countByShareConfigId(shareConfigId: string): Promise<number> {
|
||||
return this.repository.count({ where: { shareConfigId } });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user