git 저장소가 없어 히스토리·협업 기반이 아예 없던 상태를 연다.
함께 문서를 재편했다. 그동안 문서가 있어도 "이 제품이 뭘 푸는가"와
"어떻게 도는가"를 담은 문서가 없어서, 목표 문장이 backend/frontend
README 두 곳에 복붙돼 있었다 — 상위 문서가 없어 아래로 샌 것이다.
신설
README.md 레포 진입점 + 문서 지도 + 문서 규칙 4가지
AGENTS.md 에이전트·신규 합류자용 함정 목록과 규약
(CLAUDE.md 는 여기로 걸린 심볼릭 링크)
docs/PRODUCT.md 제품 정의 — 문제·사용자·원칙·**non-goals**·성공 기준
docs/ARCHITECTURE.md payload 경계·발행 파이프라인·서빙 결정·앱 분리 설계
이동
backend/docs/DECISIONS.md → docs/DECISIONS.md
백엔드만의 결정이 아니다. 게다가 코드 주석 ~25곳이 이미
`docs/DECISIONS.md` 로 적고 있어 레포 루트 기준으로는 그게 맞다.
갱신
docs/DEPLOY.md 서빙 결정 반영 — nginx 정적 서빙이 지금 경로(3절),
Azure 는 나중에 켤 때(4절)로 분리
docs/ARCHITECTURE.md 사이트 = 한 장(2026-08-31) 구조 반영
docs/COLLECTION_SEO_AEO_FLOW.md
robots.txt·sitemap.xml 은 오리진 루트에만 굽는다는 점 명시
frontend/site/scripts/prerender.ts
헤더 주석의 렌더 보고서 경로가 실제(422줄)와 달라 수정
.gitignore
★ CLAUDE.md 를 더 이상 무시하지 않는다. 에이전트 지침은 팀과 모든
에이전트가 공유하는 규약이라 커밋해야 한다 — 무시하면 클론한 사람이
"배포 후 republish_all.py 필수" 같은 함정을 전달받지 못한다.
개인용 오버라이드는 ~/.claude/CLAUDE.md 에 둔다.
219 lines
9.3 KiB
Python
219 lines
9.3 KiB
Python
from typing import Optional
|
|
from uuid import UUID
|
|
|
|
from fastapi import APIRouter, Depends, Query
|
|
|
|
from common.enums import PlaceCategory, PlaceStatus
|
|
from common.models.gmodel import PageParams, UserInfo
|
|
from router.v1.validator.dependencies import IsValidAccessToken, RemoveNoneResponse
|
|
from router.v1.job.protocol import Res_Job
|
|
from services.place_service import PlaceService
|
|
from .protocol import (
|
|
Req_CreateLink,
|
|
Req_CreatePlace,
|
|
Req_CreateUnit,
|
|
Req_StartCollect,
|
|
Req_StartCopy,
|
|
Req_StartVision,
|
|
Req_UpdatePlace,
|
|
Req_VerifyPlace,
|
|
Req_VerifyPlaceByUrl,
|
|
Res_Link,
|
|
Res_LinkList,
|
|
Res_Place,
|
|
Res_PlaceList,
|
|
Res_StartCollect,
|
|
Res_StartCopy,
|
|
Res_StartVision,
|
|
Res_VerifyCandidates,
|
|
Res_Unit,
|
|
Res_UnitList,
|
|
)
|
|
|
|
# 사업장 라우터. 모든 조회·변경은 토큰의 회사(company_id)로 스코프된다.
|
|
router = APIRouter(prefix="/v1/place", tags=["Place"], responses={404: {"description": "Not found"}})
|
|
|
|
|
|
@router.get(path="/list", response_model=Res_PlaceList, summary="사업장 목록")
|
|
async def list_places(
|
|
service: PlaceService = Depends(),
|
|
user_info: UserInfo = Depends(IsValidAccessToken),
|
|
pg: PageParams = Depends(),
|
|
search: Optional[str] = Query(None, description="상호명·주소 부분일치"),
|
|
category: Optional[PlaceCategory] = Query(None, description="업종"),
|
|
status: Optional[PlaceStatus] = Query(None, description="상태"),
|
|
):
|
|
return RemoveNoneResponse(await service.list_places(user_info, pg, search, category, status))
|
|
|
|
|
|
@router.post(
|
|
path="",
|
|
response_model=Res_Place,
|
|
summary="사업장 등록",
|
|
description="상호명 하나로 시작한다. 주소·좌표는 동일 업소 검증(verify)이 채운다.",
|
|
)
|
|
async def create_place(req: Req_CreatePlace, service: PlaceService = Depends(), user_info: UserInfo = Depends(IsValidAccessToken)):
|
|
return RemoveNoneResponse(await service.create_place(user_info, req))
|
|
|
|
|
|
@router.get(path="/{place_id}", response_model=Res_Place, summary="사업장 단건")
|
|
async def get_place(place_id: UUID, service: PlaceService = Depends(), user_info: UserInfo = Depends(IsValidAccessToken)):
|
|
return RemoveNoneResponse(await service.get_place(user_info, str(place_id)))
|
|
|
|
|
|
@router.patch(path="/{place_id}", response_model=Res_Place, summary="사업장 수정")
|
|
async def update_place(
|
|
place_id: UUID, req: Req_UpdatePlace, service: PlaceService = Depends(), user_info: UserInfo = Depends(IsValidAccessToken)
|
|
):
|
|
return RemoveNoneResponse(await service.update_place(user_info, str(place_id), req))
|
|
|
|
|
|
@router.delete(path="/{place_id}", response_model=Res_Place, summary="사업장 삭제")
|
|
async def delete_place(
|
|
place_id: UUID, service: PlaceService = Depends(), user_info: UserInfo = Depends(IsValidAccessToken)
|
|
):
|
|
return RemoveNoneResponse(await service.delete_place(user_info, str(place_id)))
|
|
|
|
|
|
@router.get(path="/{place_id}/collect/active", response_model=Res_Job, summary="진행 중인 수집 잡")
|
|
async def get_active_collect(
|
|
place_id: UUID, service: PlaceService = Depends(), user_info: UserInfo = Depends(IsValidAccessToken)
|
|
):
|
|
return RemoveNoneResponse(await service.get_active_collect(user_info, str(place_id)))
|
|
|
|
|
|
@router.post(
|
|
path="/{place_id}/verify",
|
|
response_model=Res_Place,
|
|
summary="동일 업소 검증",
|
|
description="카카오 로컬 조회 결과를 박제해 동일 업소를 확정한다. ★ 이걸 통과해야 수집이 열린다.",
|
|
)
|
|
async def verify_place(
|
|
place_id: UUID, req: Req_VerifyPlace, service: PlaceService = Depends(), user_info: UserInfo = Depends(IsValidAccessToken)
|
|
):
|
|
return RemoveNoneResponse(await service.verify_place(user_info, str(place_id), req))
|
|
|
|
|
|
@router.post(
|
|
path="/{place_id}/verify/by-url",
|
|
response_model=Res_Place,
|
|
summary="네이버 플레이스 URL 로 동일 업소 확정",
|
|
description="사장님이 붙여넣은 네이버 플레이스 주소로 상호·주소·좌표를 읽어 확정하고, "
|
|
"그 URL 을 수집 채널로 등록·확정한다. "
|
|
"★ 상호 검색이 실패하는 가게(동명·지점명 표기 차이)를 위한 확실한 경로다.",
|
|
)
|
|
async def verify_place_by_url(
|
|
place_id: UUID, req: Req_VerifyPlaceByUrl, service: PlaceService = Depends(), user_info: UserInfo = Depends(IsValidAccessToken)
|
|
):
|
|
return RemoveNoneResponse(await service.verify_place_by_url(user_info, str(place_id), req))
|
|
|
|
|
|
@router.get(path="/{place_id}/unit/list", response_model=Res_UnitList, summary="하위 단위 목록(객실·메뉴·프로그램)")
|
|
async def list_units(place_id: UUID, service: PlaceService = Depends(), user_info: UserInfo = Depends(IsValidAccessToken)):
|
|
return RemoveNoneResponse(await service.list_units(user_info, str(place_id)))
|
|
|
|
|
|
@router.post(path="/{place_id}/unit", response_model=Res_Unit, summary="하위 단위 등록")
|
|
async def create_unit(
|
|
place_id: UUID, req: Req_CreateUnit, service: PlaceService = Depends(), user_info: UserInfo = Depends(IsValidAccessToken)
|
|
):
|
|
return RemoveNoneResponse(await service.create_unit(user_info, str(place_id), req))
|
|
|
|
|
|
@router.get(
|
|
path="/{place_id}/link/list",
|
|
response_model=Res_LinkList,
|
|
summary="채널 URL 목록",
|
|
description="confirmed_only=true 면 크롤링 대상(확정된 URL)만.",
|
|
)
|
|
async def list_links(
|
|
place_id: UUID,
|
|
service: PlaceService = Depends(),
|
|
user_info: UserInfo = Depends(IsValidAccessToken),
|
|
confirmed_only: bool = Query(False),
|
|
):
|
|
return RemoveNoneResponse(await service.list_links(user_info, str(place_id), confirmed_only))
|
|
|
|
|
|
@router.post(
|
|
path="/{place_id}/link",
|
|
response_model=Res_Link,
|
|
summary="채널 URL 등록",
|
|
description="등록만으로는 크롤링 대상이 되지 않는다 — 확정(confirm)이 따로 필요하다.",
|
|
)
|
|
async def create_link(
|
|
place_id: UUID, req: Req_CreateLink, service: PlaceService = Depends(), user_info: UserInfo = Depends(IsValidAccessToken)
|
|
):
|
|
return RemoveNoneResponse(await service.create_link(user_info, str(place_id), req))
|
|
|
|
|
|
@router.post(
|
|
path="/{place_id}/link/{link_id}/confirm",
|
|
response_model=Res_Link,
|
|
summary="채널 URL 확정",
|
|
description="★ 확정된 URL 만 크롤링 대상이 된다. 사업장 검증이 끝나야 확정할 수 있다.",
|
|
)
|
|
async def confirm_link(
|
|
place_id: UUID, link_id: UUID, service: PlaceService = Depends(), user_info: UserInfo = Depends(IsValidAccessToken)
|
|
):
|
|
return RemoveNoneResponse(await service.confirm_link(user_info, str(place_id), str(link_id)))
|
|
|
|
|
|
@router.post(
|
|
path="/{place_id}/collect",
|
|
response_model=Res_StartCollect,
|
|
summary="수집 시작(비동기)",
|
|
description="수집 파이프라인을 큐에 넣고 즉시 job_id 를 돌려준다. 한 건에 몇 분 걸리므로 "
|
|
"GET /v1/job/{job_id} 로 진행 상태를 폴링한다. "
|
|
"★ 동일 업소 검증과 채널 URL 확정이 끝나야 시작할 수 있다.",
|
|
)
|
|
async def start_collect(
|
|
place_id: UUID, req: Req_StartCollect, service: PlaceService = Depends(), user_info: UserInfo = Depends(IsValidAccessToken)
|
|
):
|
|
return RemoveNoneResponse(await service.start_collect(user_info, str(place_id), req))
|
|
|
|
|
|
@router.post(
|
|
path="/{place_id}/vision",
|
|
response_model=Res_StartVision,
|
|
summary="사진 분석 시작(비동기)",
|
|
description="Gemini Vision 으로 사진 분류 라벨과 alt 를 생성한다. 수집이 사진을 저장하면 자동으로 걸리며, "
|
|
"사장님이 직접 올린 사진이나 재분석(force)에 이 엔드포인트를 쓴다. "
|
|
"★ 신뢰도가 낮은 결과는 자동 반영되지 않고 사람 확인 큐에 남는다.",
|
|
)
|
|
async def start_vision(
|
|
place_id: UUID, req: Req_StartVision, service: PlaceService = Depends(), user_info: UserInfo = Depends(IsValidAccessToken)
|
|
):
|
|
return RemoveNoneResponse(await service.start_vision(user_info, str(place_id), req))
|
|
|
|
|
|
@router.get(
|
|
path="/{place_id}/verify/candidates",
|
|
response_model=Res_VerifyCandidates,
|
|
summary="동일 업소 후보 조회",
|
|
description="외부 장소 DB(카카오 키가 있으면 카카오, 없으면 네이버)에서 후보를 찾아 그대로 돌려준다. "
|
|
"★ 서버가 자동 확정하지 않는다 — UI 가 후보를 보여주고 사람이 고른 뒤 POST /verify 로 확정한다. "
|
|
"auto_selectable=true 면 판정이 명확해 '이거 맞나요?' 한 번만 물어도 된다.",
|
|
)
|
|
async def verify_candidates(
|
|
place_id: UUID,
|
|
service: PlaceService = Depends(),
|
|
user_info: UserInfo = Depends(IsValidAccessToken),
|
|
query: Optional[str] = Query(None, description="검색어. 비우면 등록된 상호명"),
|
|
):
|
|
return RemoveNoneResponse(await service.find_candidates(user_info, str(place_id), query))
|
|
|
|
|
|
@router.post(
|
|
path="/{place_id}/copy",
|
|
response_model=Res_StartCopy,
|
|
summary="소개문·FAQ 생성(비동기)",
|
|
description="확인된 fact 만 근거로 소개문과 FAQ 를 작성한다. "
|
|
"★ 근거 없는 수치·시설 언급은 코드로 검증해 반려한다(LLM 은 사실을 만들지 않는다). "
|
|
"생성물도 미검증 상태로 들어가 사람이 승인해야 사이트에 나간다.",
|
|
)
|
|
async def start_copy(
|
|
place_id: UUID, req: Req_StartCopy, service: PlaceService = Depends(), user_info: UserInfo = Depends(IsValidAccessToken)
|
|
):
|
|
return RemoveNoneResponse(await service.start_copy(user_info, str(place_id), req))
|