Initial commit with Email Import Wizard and Task Processor updates
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Kontonummer } from '../database/entities';
|
||||
|
||||
@Injectable()
|
||||
export class KontonummernService {
|
||||
constructor(
|
||||
@InjectRepository(Kontonummer)
|
||||
private readonly kontonummerRepo: Repository<Kontonummer>,
|
||||
) {}
|
||||
|
||||
async findByCorrespondent(correspondentId: number): Promise<Kontonummer[]> {
|
||||
return this.kontonummerRepo.find({
|
||||
where: { CorrespondentId: correspondentId },
|
||||
});
|
||||
}
|
||||
|
||||
async create(correspondentId: number, nummer: string): Promise<Kontonummer> {
|
||||
const existing = await this.kontonummerRepo.findOne({
|
||||
where: { CorrespondentId: correspondentId, Nummer: nummer },
|
||||
});
|
||||
|
||||
if (existing) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
const kontonummer = this.kontonummerRepo.create({
|
||||
CorrespondentId: correspondentId,
|
||||
Nummer: nummer,
|
||||
});
|
||||
|
||||
return this.kontonummerRepo.save(kontonummer);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user