INSIGHT-MVP/packages/crm-service/src/enrichment/enrichment.controller.ts
Thomas Reitz 63cb05d4d8 feat(crm): Phase 2.2-2.4 backend + contract files — vollständige CRM-Service Implementierung
- Phase 2.3 Forecast: probability-Feld in PipelineStage, GET /crm/deals/forecast Endpoint
- Phase 2.2 Import: ImportModule mit preview/execute/history Endpoints (CSV, XLSX, vCard)
- Phase 2.4 Enrichment: EnrichmentModule mit /enrich + /settings/integrations/north-data
- Contracts: ContractsModule mit CRUD + File-Upload Endpoints (Multer, max 25MB)
- Migrations: 20260312_contract_files, 20260312_phase23_forecast
- docker-compose.crm.yml: uploads Volume für Vertragsdokumente

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 22:06:58 +01:00

77 lines
2 KiB
TypeScript

import {
Controller,
Post,
Get,
Put,
Param,
Body,
ParseUUIDPipe,
UseGuards,
} from '@nestjs/common';
import {
ApiTags,
ApiOperation,
ApiBearerAuth,
ApiParam,
} from '@nestjs/swagger';
import { CurrentUser, JwtPayload } from '../common/decorators';
import { TenantGuard } from '../auth/guards/tenant.guard';
import { singleResponse } from '../common/dto/pagination.dto';
import { EnrichmentService } from './enrichment.service';
import { UpdateNorthDataSettingsDto } from './dto/enrichment-settings.dto';
@ApiTags('Datenanreicherung (Enrichment)')
@ApiBearerAuth('access-token')
@UseGuards(TenantGuard)
@Controller()
export class EnrichmentController {
constructor(private readonly enrichmentService: EnrichmentService) {}
@Post('companies/:id/enrich')
@ApiOperation({
summary: 'Unternehmensdaten anreichern (Vorschlaege, kein Auto-Write)',
})
@ApiParam({ name: 'id', type: 'string', format: 'uuid' })
async enrich(
@CurrentUser() user: JwtPayload,
@Param('id', ParseUUIDPipe) id: string,
) {
const result = await this.enrichmentService.enrichCompany(
user.tenantId!,
id,
);
return singleResponse(result);
}
@Get('settings/integrations/north-data')
@ApiOperation({ summary: 'North Data Einstellungen abrufen' })
async getSettings(@CurrentUser() user: JwtPayload) {
const settings = await this.enrichmentService.getNorthDataSettings(
user.tenantId!,
);
return singleResponse({
...settings,
apiKey: settings.apiKey
? `****${settings.apiKey.slice(-4)}`
: null,
});
}
@Put('settings/integrations/north-data')
@ApiOperation({ summary: 'North Data Einstellungen aktualisieren' })
async updateSettings(
@CurrentUser() user: JwtPayload,
@Body() dto: UpdateNorthDataSettingsDto,
) {
const settings = await this.enrichmentService.updateNorthDataSettings(
user.tenantId!,
dto,
);
return singleResponse({
...settings,
apiKey: settings.apiKey
? `****${settings.apiKey.slice(-4)}`
: null,
});
}
}