[refactor] backend services/router 정리 — chat 분리·staticmethod 집약·protocol 문서화·테스트 보강

- router: 채팅 라우터/프로토콜을 negotiation/ 에서 chat/ 으로 분리(git mv, URL 유지).
  chat_protocol.py → chat/protocol.py (폴더당 protocol.py convention 복원), router 등록·import 갱신.
- chat_service: 순수 헬퍼/매퍼를 모듈 함수 → 클래스 @staticmethod 로 이동하고 클래스 상단에 집약.
- protocol: Req 모델 + 코드/enum 필드에 Field(description=...) 추가(Swagger 노출),
  Req 문자열 필드에 max_length(DB 컬럼 정합) 추가 → 초과 입력이 DB 오류 대신 422.
- models: updated_at 에 onupdate 추가 → UPDATE 시 자동 갱신(negodata convention 일치).
- tests: negotiation reject e2e 6케이스 + chat 순수 헬퍼 단위 4케이스 추가(45→55 passed).
- enums: 장황한 주석/docstring 축약(코드값 변경 없음).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
민헌andClaude Opus 4.8 committed 2026-06-25 11:07:54 +09:00
1 parent b4dc862912
commit 1a933409a3
10 files changed
+261 -177

No files matched your search

+25 -23
View File
@@ -1,3 +1,5 @@
from pydantic import Field
from common.models.gmodel import Res_WebPacketProtocol, WebPacketProtocol
@@ -7,28 +9,28 @@ class AuthProtocol(WebPacketProtocol):
class Req_Login(AuthProtocol):
id: str = ""
pw: str = ""
id: str = Field("", description="로그인 ID")
pw: str = Field("", description="비밀번호(평문, 서버에서 bcrypt 해시·검증)")
class Res_Login(Res_WebPacketProtocol):
su_id: str = ""
name: str = "" # 유저 개인 이름
supplier_id: str = "" # 소속 공급사(partner.suppliers)
supplier_name: str = "" # 공급사명
role: int = 0
access_token: str = ""
refresh_token: str = ""
su_id: str = Field("", description="유저 식별자(uuid)")
name: str = Field("", description="유저 개인 이름")
supplier_id: str = Field("", description="소속 공급사 uuid(partner.suppliers)")
supplier_name: str = Field("", description="공급사명")
role: int = Field(0, description="권한 코드 1=user, 2=manager (UserRole)")
access_token: str = Field("", description="액세스 토큰(JWT)")
refresh_token: str = Field("", description="리프레시 토큰(JWT)")
class Req_CreateAccount(AuthProtocol):
supplier_id: str = "" # 소속 공급사(partner.suppliers.supplier_id)
id: str = "" # 로그인 ID
pw: str = ""
name: str = ""
email: str = ""
contact_number: str = ""
role: int = 1 # 1=user, 2=manager (UserRole)
supplier_id: str = Field("", max_length=36, description="소속 공급사 uuid(partner.suppliers.supplier_id)")
id: str = Field("", max_length=20, description="로그인 ID")
pw: str = Field("", description="비밀번호(평문, 서버에서 bcrypt 해시)")
name: str = Field("", max_length=50, description="이름")
email: str = Field("", max_length=255, description="이메일")
contact_number: str = Field("", max_length=20, description="연락처")
role: int = Field(1, description="권한 코드 1=user, 2=manager (UserRole)")
class Res_CreateAccount(Res_WebPacketProtocol):
@@ -36,16 +38,16 @@ class Res_CreateAccount(Res_WebPacketProtocol):
class Res_RefreshToken(Res_WebPacketProtocol):
access_token: str = ""
access_token: str = Field("", description="재발급된 액세스 토큰(JWT)")
class Res_Me(Res_WebPacketProtocol):
su_id: str = ""
id: str = ""
name: str = ""
supplier_id: str = ""
supplier_name: str = ""
role: int = 0
su_id: str = Field("", description="유저 식별자(uuid)")
id: str = Field("", description="로그인 ID")
name: str = Field("", description="유저 개인 이름")
supplier_id: str = Field("", description="소속 공급사 uuid")
supplier_name: str = Field("", description="공급사명")
role: int = Field(0, description="권한 코드 1=user, 2=manager (UserRole)")
class Res_Logout(Res_WebPacketProtocol):