[feat] negodata: 견적·카드 검색/필터 서버사이드 전환 + 견적 상세 Sheet 리팩터

- 백엔드: quotation 목록 search 파라미터(name/number ILIKE) 추가; card 목록 is_wildcard 탭 필터 + total_nego/total_wild 탭 카운트 추가; status/type 코드 int 비교 보정
- 프론트: cards/quotation 검색·상태·유형 필터·페이지네이션을 useServerList 기반 서버사이드로 전환; 엔터 즉시검색 + 디바운스 500ms·최소 2글자; 죽은 client 필터 훅(useCardFilters/useQuotationFilters) 제거
- generated 파라미터/응답 타입 손보강(listCardsParams.is_wildcard, listQuotationsParams.search, resCardList.total_nego/total_wild) — orval 재생성 시 동일
- 견적 상세 Drawer→Sheet 분리, useOverlayParams→useOverlayRouter, CreateQuotationWizard→QuotationCreateModal

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
minaChoiandClaude Opus 4.8 committed 2026-06-19 17:03:53 +09:00
1 parent c3d96fb7d3
commit 6fa024137f
36 files changed
+1172 -967

No files matched your search

+7 -4
View File
@@ -2,7 +2,7 @@ from abc import ABC, abstractmethod
from datetime import datetime
from typing import Optional, Tuple
from sqlalchemy import select, func, and_, update
from sqlalchemy import select, func, and_, or_, update
from sqlalchemy.ext.asyncio import AsyncSession
from common.database.db_session_manager import DB_SESSION_MNG
@@ -19,7 +19,7 @@ from common.utils.gtime import GTime
class IQuotationCRUD(ABC):
@abstractmethod
async def search(
self, cdb: AsyncSession, status, type_, start_from, start_to, skip, limit
self, cdb: AsyncSession, search, status, type_, start_from, start_to, skip, limit
) -> Tuple[ErrorType, list, int]:
pass
@@ -88,6 +88,7 @@ class QuotationCRUD(IQuotationCRUD):
async def search(
self,
cdb: AsyncSession,
search: Optional[str],
status: Optional[str],
type_: Optional[str],
start_from: Optional[datetime],
@@ -97,10 +98,12 @@ class QuotationCRUD(IQuotationCRUD):
) -> Tuple[ErrorType, list, int]:
try:
conditions = [quotations.deleted == False] # noqa: E712
if search:
conditions.append(or_(quotations.name.ilike(f"%{search}%"), quotations.number.ilike(f"%{search}%")))
if status:
conditions.append(quotations.status == status)
conditions.append(quotations.status == int(status)) # status/type 는 SMALLINT 코드 — 문자열 쿼리값을 정수로
if type_:
conditions.append(quotations.type == type_)
conditions.append(quotations.type == int(type_))
if start_from:
conditions.append(quotations.start_time >= start_from)
if start_to:
+2 -1
View File
@@ -21,9 +21,10 @@ async def list_cards(
service: CardService = Depends(),
user_info: UserInfo = Depends(IsValidAccessToken),
search: str | None = Query(None, description="카드명/카드번호/스크립트 검색"),
is_wildcard: bool | None = Query(None, description="탭 필터: 미지정=전체 / false=협상카드 / true=와일드카드"),
pg: PageParams = Depends(),
):
return RemoveNoneResponse(await service.list_cards(user_info.user_id, search, pg))
return RemoveNoneResponse(await service.list_cards(user_info.user_id, search, is_wildcard, pg))
@router.post(path="/create", response_model=Res_Card, summary="협상카드 등록")
@@ -57,6 +57,8 @@ class Res_Card(Res_WebPacketProtocol):
class Res_CardList(Res_PageProtocol):
cards: list[CardData] = []
total_nego: int = 0 # 협상카드 탭 카운트(검색 필터 반영)
total_wild: int = 0 # 와일드카드 탭 카운트(검색 필터 반영)
class Res_DeleteCard(Res_WebPacketProtocol):
@@ -31,13 +31,14 @@ router = APIRouter(prefix="/v1/quotation", tags=["Quotation"], responses={404: {
async def list_quotations(
service: QuotationService = Depends(),
user_info: UserInfo = Depends(IsValidAccessToken),
search: str | None = Query(None, description="견적명/견적번호 검색"),
status: str | None = Query(None, description="상태 필터(정확히 일치)"),
type: str | None = Query(None, description="유형 필터(정확히 일치)"),
start_from: datetime | None = Query(None, description="시작일시 이후(ISO)"),
start_to: datetime | None = Query(None, description="시작일시 이전(ISO)"),
pg: PageParams = Depends(),
):
return RemoveNoneResponse(await service.list_quotations(status, type, start_from, start_to, pg))
return RemoveNoneResponse(await service.list_quotations(search, status, type, start_from, start_to, pg))
@router.post(path="/create", response_model=Res_CreateQuotation, summary="견적 생성")
+17 -4
View File
@@ -79,18 +79,23 @@ class CardService:
return ErrorType.CARD_NOT_FOUND, None, None, None, False
# ---- 목록 ----------------------------------------------------------------
async def list_cards(self, user_id: str, search, pg: PageParams) -> Res_CardList:
async def list_cards(self, user_id: str, search, is_wildcard, pg: PageParams) -> Res_CardList:
"""is_wildcard: None=전체(두 테이블 머지) / False=협상카드만 / True=와일드카드만.
탭이 무엇이든 양쪽 카운트(total_nego/total_wild)는 항상 채운다(검색 필터 반영).
선택 안 된 탭은 limit=0 으로 카운트만 받아 행은 가져오지 않는다."""
res = Res_CardList(page=pg.page, size=pg.size)
if not user_id:
return res
user_uuid = uuid.UUID(user_id)
# 합쳐서 정렬/페이징하므로 각 테이블에서 skip+limit 까지 받아온다(카드 수가 적어 충분).
fetch = pg.skip + pg.size
nego_limit = 0 if is_wildcard is True else fetch
wild_limit = 0 if is_wildcard is False else fetch
err_n, nego_rows, total_n = await DB_SESSION_MNG.execute_lambda(
nego_cards.DBType(),
DBWRType.DB_READ.value,
lambda s: self.card_crud.search(s, nego_cards, user_uuid, search, 0, fetch),
lambda s: self.card_crud.search(s, nego_cards, user_uuid, search, 0, nego_limit),
)
if err_n != ErrorType.SUCCESS:
res.result.SetResult(err_n)
@@ -99,7 +104,7 @@ class CardService:
err_w, wild_rows, total_w = await DB_SESSION_MNG.execute_lambda(
wild_cards.DBType(),
DBWRType.DB_READ.value,
lambda s: self.card_crud.search(s, wild_cards, user_uuid, search, 0, fetch),
lambda s: self.card_crud.search(s, wild_cards, user_uuid, search, 0, wild_limit),
)
if err_w != ErrorType.SUCCESS:
res.result.SetResult(err_w)
@@ -108,7 +113,15 @@ class CardService:
merged = [self._nego_to_data(r) for r in nego_rows] + [self._wild_to_data(r) for r in wild_rows]
merged.sort(key=lambda c: c.created_at or "", reverse=True)
res.cards = merged[pg.skip : pg.skip + pg.size]
res.total = total_n + total_w
res.total_nego = total_n
res.total_wild = total_w
# 선택된 탭 기준 페이지네이션 총건수(전체=합산).
if is_wildcard is True:
res.total = total_w
elif is_wildcard is False:
res.total = total_n
else:
res.total = total_n + total_w
return res
# ---- 단건 조회 -----------------------------------------------------------
@@ -82,13 +82,13 @@ class QuotationService:
return ErrorType.QUOTATION_NOT_FOUND, None
return ErrorType.SUCCESS, quotation
async def list_quotations(self, status, type_, start_from, start_to, pg: PageParams) -> Res_QuotationList:
async def list_quotations(self, search, status, type_, start_from, start_to, pg: PageParams) -> Res_QuotationList:
res = Res_QuotationList(page=pg.page, size=pg.size)
err_type, rows, total = await DB_SESSION_MNG.execute_lambda(
quotations.DBType(),
DBWRType.DB_READ.value,
lambda s: self.quotation_crud.search(s, status, type_, start_from, start_to, pg.skip, pg.size),
lambda s: self.quotation_crud.search(s, search, status, type_, start_from, start_to, pg.skip, pg.size),
)
if err_type != ErrorType.SUCCESS:
res.result.SetResult(err_type)