A1: corp 다업종 자동 brand resolve + 운영 외 업종 차단#188
Merged
Conversation
다업종 법인 (예: (주)더본코리아 = 빽다방·홍콩반점·빽보이피자·새마을식당...) 가입자가
시뮬 시 회원가입 top_brand (빽다방) 와 다른 업종 (중식) 선택하면 같은 corp 의
해당 업종 가장 큰 brand (홍콩반점0410) 자동 매핑.
운영 외 업종 (예: 치킨) 선택 시 HTTPException(400) + 운영 가능 업종 list 응답.
신규 파일:
- backend/src/services/corp_brand_resolver.py
* get_corp_industries(biz_number) — corp 운영 brand+업종 list
* resolve_brand_for_industry(biz_number, industry) — 자동 brand 매핑
* corpNm 정규화 ('(주)', '㈜', '주식회사' 등 noise 제거 + ILIKE 매칭)
수정:
- backend/src/schemas/simulation_input.py
* biz_number: str | None Optional 필드 추가 (corp 검증 트리거)
- backend/src/main.py
* _validate_and_resolve_brand(input_data) helper 추가
* /analyze, /analyze/llm, /analyze/llm/async, /analyze/quick,
/predict, /predict/async, /simulate 7개 endpoint 시작에 호출
검증 (실제 DB):
- 더본코리아 가입자 → 커피=빽다방(1712) / 중식=홍콩반점0410(293) /
피자=빽보이피자(243) / 한식=한신포차(129+11alt) / 서양식=롤링파스타 /
주점=백스비어 → 모두 정확 매핑
- 치킨/편의점 → INDUSTRY_NOT_OPERATED 거부 + operated_industries 8종 응답
엣지 케이스:
- biz_number 미입력 (개인사업자/비회원) → 검증 skip, 기존 동작 (input.brand_name 그대로)
- USER_NOT_FOUND / CORP_NOT_IN_FTC → 경고 로그 + skip (회원가입 안 됐거나 FTC 미등록 corp)
- 같은 업종 brand 여러개 (한식 12 brand) → frcsCnt 큰 것 1개 + alternatives list
API 응답 (frontend 처리):
- 200 OK + brand_name override 적용
- 400 INDUSTRY_NOT_OPERATED + {company_name, requested_industry, operated_industries, message}
DB 변경: 0 (read-only resolver, 시뮬 input 단계 검증)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
다업종 법인 가입자가 시뮬 시 회원가입 top_brand (자동 매핑된 1개) 와 다른 업종 선택하면 같은 corp 의 해당 업종 가장 큰 brand 자동 매핑. 운영 외 업종 선택 시 차단.
동작 시나리오 (실제 검증 완료)
(주)더본코리아 가입자가 시뮬 시 업종 선택:
신규 파일
backend/src/services/corp_brand_resolver.pyget_corp_industries(biz_number)— corp 운영 brand+업종 listresolve_brand_for_industry(biz_number, industry)— 자동 매핑(주)/㈜/주식회사noise 제거 + ILIKE)수정
schemas/simulation_input.pybiz_number: str | NoneOptional 필드 추가 (트리거)main.py_validate_and_resolve_brand()helper + 7 endpoint 시작에 호출검증 적용 endpoint:
/analyze,/analyze/llm,/analyze/llm/async,/analyze/quick,/predict,/predict/async,/simulate.API 응답
성공
{ // 기존 시뮬 응답 그대로 (brand_name 자동 override) }운영 외 업종 (HTTP 400)
{ "detail": { "error": "INDUSTRY_NOT_OPERATED", "company_name": "(주)더본코리아", "requested_industry": "치킨", "operated_industries": ["분식","서양식","제과제빵","주점","중식","커피","피자","한식"], "message": "'치킨' 업종은 (주)더본코리아 운영 brand 에 없습니다. 운영 가능 업종: ..." } }엣지 케이스
biz_number미입력input.brand_name그대로 (개인사업자/비회원 호환)alternativeslist 응답DB 변경
없음. read-only resolver + 시뮬 input 단계 검증만.
Test plan
ruff check/format통과후속 권장
biz_number자동 첨부 (auth 토큰에서 추출)🤖 Generated with Claude Code