발행된 사이트에 업체별 SEO/AEO 키워드를 제공하는 서비스. - PostgreSQL 16 + pgvector/ltree/pg_trgm 단일 스토어 (정확·의미·계층 조회를 한 엔진에서 처리) - 키워드는 전역 사전 + merchant_keyword 연결 테이블 구조 - 4단계 계단식 중복제거: 금칙어 → normalized 완전일치 → pg_trgm → 코사인 유사도, 걸린 표기는 aliases[] 로 흡수 - BullMQ 생성 큐 (발행 즉시 / 일 1회 크론 / 성과 기반) - OpenAI Structured Outputs + mock provider (API 키 없이 로컬 전 구간 동작) - 서빙 API: /v1/sites/:id/seo, /aeo, /performance, /keywords/search - docs/architecture.html 설계 도식 JSON-LD 조립과 o2o-site-AEO 연동은 후속 작업. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
49 lines
1.7 KiB
TypeScript
49 lines
1.7 KiB
TypeScript
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
|
|
import { GenerationService } from '../generation/generation.service';
|
|
import { GenerationQueue } from '../generation/generation.queue';
|
|
import { MerchantsService, UpsertMerchantDto } from './merchants.service';
|
|
|
|
@Controller('v1/merchants')
|
|
export class MerchantsController {
|
|
constructor(
|
|
private readonly merchants: MerchantsService,
|
|
private readonly generation: GenerationService,
|
|
private readonly queue: GenerationQueue,
|
|
) {}
|
|
|
|
@Get()
|
|
list() {
|
|
return this.merchants.list();
|
|
}
|
|
|
|
@Get(':id')
|
|
get(@Param('id') id: string) {
|
|
return this.merchants.findWithTaxonomy(id);
|
|
}
|
|
|
|
/** o2o-site-AEO 사이트 발행 웹훅: 업체 등록 + 키워드 생성 예약 */
|
|
@Post('publish')
|
|
async publish(@Body() dto: UpsertMerchantDto & { generate?: boolean; sync?: boolean }) {
|
|
const merchant = await this.merchants.upsert(dto);
|
|
if (dto.generate === false) return { merchant, generation: 'skipped' };
|
|
|
|
if (dto.sync) {
|
|
const stats = await this.generation.runForMerchant(merchant.id, 'published');
|
|
return { merchant, generation: stats };
|
|
}
|
|
const jobId = await this.queue.enqueue(merchant.id, 'published');
|
|
return { merchant, generation: { queued: true, jobId } };
|
|
}
|
|
|
|
/** 수동 재생성 */
|
|
@Post(':id/generate')
|
|
async generate(@Param('id') id: string, @Query('sync') sync?: string) {
|
|
if (sync === 'true' || sync === '1') {
|
|
return this.generation.runForMerchant(id, 'manual');
|
|
}
|
|
const m = await this.merchants.findWithTaxonomy(id);
|
|
const jobId = await this.queue.enqueue(m.id, 'manual');
|
|
return { queued: true, jobId };
|
|
}
|
|
}
|