- stay.pension 업종, kr.jeonbuk.gunsan 지역 계층 추가 - 스테이머뭄 업체 시드 (services/features/audiences/nearby/seasons 프로필) - mock provider 를 프로필 배열 조합 기반으로 확장해 실제 로컬 검색 패턴(동반자·시설·인근 관광지·시즌·질문형) 전개 - POST /v1/merchants/:id/generate?count=N 으로 생성 개수 오버라이드 - tsconfig.build.json 추가 — scripts/ 가 dist 루트를 바꾸던 문제 수정 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
54 lines
1.8 KiB
TypeScript
54 lines
1.8 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,
|
|
@Query('count') count?: string,
|
|
) {
|
|
const target = count ? Math.min(Math.max(1, Number(count)), 500) : undefined;
|
|
if (sync === 'true' || sync === '1') {
|
|
return this.generation.runForMerchant(id, 'manual', target);
|
|
}
|
|
const m = await this.merchants.findWithTaxonomy(id);
|
|
const jobId = await this.queue.enqueue(m.id, 'manual');
|
|
return { queued: true, jobId };
|
|
}
|
|
}
|