mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 17:08:18 +00:00
changes
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { DataSource, FindManyOptions, Repository } from 'typeorm';
|
||||
import { PriorityConfig } from '../entities/priority-config.entity';
|
||||
import { IPriorityConfigsRepository } from '../interfaces/priority-configs.repository.interface';
|
||||
|
||||
@Injectable()
|
||||
export class PriorityConfigsRepository implements IPriorityConfigsRepository {
|
||||
private readonly repo: Repository<PriorityConfig>;
|
||||
|
||||
constructor(private readonly dataSource: DataSource) {
|
||||
this.repo = this.dataSource.getRepository(PriorityConfig);
|
||||
}
|
||||
|
||||
async findById(id: string): Promise<PriorityConfig | null> {
|
||||
return this.repo.findOne({ where: { id } });
|
||||
}
|
||||
|
||||
async findAll(options?: FindManyOptions<PriorityConfig>): Promise<PriorityConfig[]> {
|
||||
return this.repo.find(options);
|
||||
}
|
||||
|
||||
async findAndCount(options?: FindManyOptions<PriorityConfig>): Promise<[PriorityConfig[], number]> {
|
||||
return this.repo.findAndCount(options);
|
||||
}
|
||||
|
||||
async findAllActive(): Promise<PriorityConfig[]> {
|
||||
return this.repo.find({
|
||||
where: { isActive: true },
|
||||
order: { displayOrder: 'ASC' },
|
||||
});
|
||||
}
|
||||
|
||||
async create(data: Partial<PriorityConfig>): Promise<PriorityConfig> {
|
||||
const entity = this.repo.create(data);
|
||||
return this.repo.save(entity);
|
||||
}
|
||||
|
||||
async update(id: string, data: Partial<PriorityConfig>): Promise<PriorityConfig | null> {
|
||||
await this.repo.update(id, data);
|
||||
return this.findById(id);
|
||||
}
|
||||
|
||||
async softDelete(id: string): Promise<void> {
|
||||
await this.repo.softDelete(id);
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { DataSource, FindManyOptions, Repository } from 'typeorm';
|
||||
import { PriorityRule } from '../entities/priority-rule.entity';
|
||||
import { IPriorityRulesRepository } from '../interfaces/priority-rules.repository.interface';
|
||||
|
||||
@Injectable()
|
||||
export class PriorityRulesRepository implements IPriorityRulesRepository {
|
||||
private readonly repo: Repository<PriorityRule>;
|
||||
|
||||
constructor(private readonly dataSource: DataSource) {
|
||||
this.repo = this.dataSource.getRepository(PriorityRule);
|
||||
}
|
||||
|
||||
findById(id: string): Promise<PriorityRule | null> {
|
||||
return this.repo.findOne({ where: { id } });
|
||||
}
|
||||
|
||||
findAllActive(): Promise<PriorityRule[]> {
|
||||
return this.repo.find({ where: { isActive: true } });
|
||||
}
|
||||
|
||||
findAll(options?: FindManyOptions<PriorityRule>): Promise<PriorityRule[]> {
|
||||
return this.repo.find(options);
|
||||
}
|
||||
|
||||
findAndCount(options?: FindManyOptions<PriorityRule>): Promise<[PriorityRule[], number]> {
|
||||
return this.repo.findAndCount(options);
|
||||
}
|
||||
|
||||
async create(data: Partial<PriorityRule>): Promise<PriorityRule> {
|
||||
const entity = this.repo.create(data);
|
||||
return this.repo.save(entity);
|
||||
}
|
||||
|
||||
async update(id: string, data: Partial<PriorityRule>): Promise<PriorityRule | null> {
|
||||
await this.repo.update(id, data);
|
||||
return this.findById(id);
|
||||
}
|
||||
|
||||
async softDelete(id: string): Promise<void> {
|
||||
await this.repo.softDelete(id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user