Initial commit with Email Import Wizard and Task Processor updates
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { Controller, Get, Post, Body, Param, UseGuards } from '@nestjs/common';
|
||||
import { KontonummernService } from './kontonummern.service';
|
||||
import { JwtOrApiKeyGuard } from '../auth/jwt-or-apikey.guard';
|
||||
|
||||
export class CreateKontonummerDto {
|
||||
correspondentId: number;
|
||||
nummer: string;
|
||||
}
|
||||
|
||||
@Controller('api/kontonummern')
|
||||
@UseGuards(JwtOrApiKeyGuard)
|
||||
export class KontonummernController {
|
||||
constructor(private readonly kontonummernService: KontonummernService) {}
|
||||
|
||||
@Get('FromCorrespondent/:id')
|
||||
async getByCorrespondent(@Param('id') id: string) {
|
||||
return this.kontonummernService.findByCorrespondent(parseInt(id, 10));
|
||||
}
|
||||
|
||||
@Post()
|
||||
async create(@Body() dto: CreateKontonummerDto) {
|
||||
return this.kontonummernService.create(dto.correspondentId, dto.nummer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { KontonummernController } from './kontonummern.controller';
|
||||
import { KontonummernService } from './kontonummern.service';
|
||||
import { Kontonummer } from '../database/entities';
|
||||
import { AuthModule } from '../auth/auth.module';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([Kontonummer]), AuthModule],
|
||||
controllers: [KontonummernController],
|
||||
providers: [KontonummernService],
|
||||
exports: [KontonummernService],
|
||||
})
|
||||
export class KontonummernModule {}
|
||||
@@ -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