[feat] negodata: 협력사 총매출액(total_revenue) 추가 + 우선선정(priority) 제거
Helped-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
3176ec4262
commit
1ac42ddc9c
24 files changed
+61
-124
No files matched your search
@@ -124,7 +124,7 @@ class suppliers(MainTableMixin, MAIN_BASE):
|
||||
manager_name = Column(String(50), nullable=True)
|
||||
manager_email = Column(String(255), nullable=True)
|
||||
manager_contact_number = Column(String(20), nullable=True) # ERD 오타(manger) 교정
|
||||
priority = Column(String(10), nullable=True) # True/False 가 아닌 string value 가능
|
||||
total_revenue = Column(BigInteger, nullable=True) # 총매출액(원)
|
||||
|
||||
|
||||
class nego_cards(MainTableMixin, MAIN_BASE):
|
||||
|
||||
@@ -14,7 +14,7 @@ from common.utils.gtime import GTime
|
||||
# 협력사 CRUD. 모든 조회/변경은 company_id 로 스코프된다(멀티테넌트).
|
||||
class ISupplierCRUD(ABC):
|
||||
@abstractmethod
|
||||
async def search(self, cdb: AsyncSession, company_id, search, priority, skip, limit) -> Tuple[ErrorType, list, int]:
|
||||
async def search(self, cdb: AsyncSession, company_id, search, skip, limit) -> Tuple[ErrorType, list, int]:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@@ -44,7 +44,7 @@ class ISupplierCRUD(ABC):
|
||||
|
||||
class SupplierCRUD(ISupplierCRUD):
|
||||
async def search(
|
||||
self, cdb: AsyncSession, company_id, search: Optional[str], priority: Optional[str], skip: int, limit: int
|
||||
self, cdb: AsyncSession, company_id, search: Optional[str], skip: int, limit: int
|
||||
) -> Tuple[ErrorType, list, int]:
|
||||
try:
|
||||
conditions = [suppliers.deleted == False, suppliers.company_id == company_id] # noqa: E712
|
||||
@@ -56,8 +56,6 @@ class SupplierCRUD(ISupplierCRUD):
|
||||
suppliers.manager_name.ilike(f"%{search}%"),
|
||||
)
|
||||
)
|
||||
if priority:
|
||||
conditions.append(suppliers.priority == priority)
|
||||
where = and_(*conditions)
|
||||
|
||||
cnt_err, cnt_rows = await DB_SESSION_MNG.execute(cdb, select(func.count()).select_from(suppliers).where(where))
|
||||
|
||||
@@ -17,7 +17,7 @@ class Req_CreateSupplier(SupplierProtocol):
|
||||
manager_name: Optional[str] = None
|
||||
manager_email: Optional[str] = None
|
||||
manager_contact_number: Optional[str] = None
|
||||
priority: Optional[str] = None
|
||||
total_revenue: Optional[int] = None # 총매출액(원)
|
||||
|
||||
|
||||
class Req_UpdateSupplier(SupplierProtocol):
|
||||
@@ -26,7 +26,7 @@ class Req_UpdateSupplier(SupplierProtocol):
|
||||
manager_name: Optional[str] = None
|
||||
manager_email: Optional[str] = None
|
||||
manager_contact_number: Optional[str] = None
|
||||
priority: Optional[str] = None
|
||||
total_revenue: Optional[int] = None
|
||||
|
||||
|
||||
class SupplierData(WebPacketProtocol):
|
||||
@@ -40,7 +40,7 @@ class SupplierData(WebPacketProtocol):
|
||||
manager_name: Optional[str] = None
|
||||
manager_email: Optional[str] = None
|
||||
manager_contact_number: Optional[str] = None
|
||||
priority: Optional[str] = None
|
||||
total_revenue: Optional[int] = None # 총매출액(원)
|
||||
created_at: Optional[datetime] = None
|
||||
updated_at: Optional[datetime] = None
|
||||
|
||||
|
||||
@@ -24,10 +24,9 @@ async def list_suppliers(
|
||||
service: SupplierService = Depends(),
|
||||
user_info: UserInfo = Depends(IsValidAccessToken),
|
||||
search: str | None = Query(None, description="협력사명/코드/담당자명 검색"),
|
||||
priority: str | None = Query(None, description="우선순위 필터(HIGH/MEDIUM/LOW)"),
|
||||
pg: PageParams = Depends(),
|
||||
):
|
||||
return RemoveNoneResponse(await service.list_suppliers(user_info.company_id, search, priority, pg))
|
||||
return RemoveNoneResponse(await service.list_suppliers(user_info.company_id, search, pg))
|
||||
|
||||
|
||||
@router.post(path="/create", response_model=Res_Supplier, summary="협력사 등록")
|
||||
|
||||
@@ -38,14 +38,14 @@ class SupplierService:
|
||||
return ErrorType.SUPPLIER_NOT_FOUND, None
|
||||
return ErrorType.SUCCESS, supplier
|
||||
|
||||
async def list_suppliers(self, company_id: str, search, priority, pg: PageParams) -> Res_SupplierList:
|
||||
async def list_suppliers(self, company_id: str, search, pg: PageParams) -> Res_SupplierList:
|
||||
res = Res_SupplierList(page=pg.page, size=pg.size)
|
||||
company_uuid = uuid.UUID(company_id)
|
||||
|
||||
err_type, rows, total = await DB_SESSION_MNG.execute_lambda(
|
||||
suppliers.DBType(),
|
||||
DBWRType.DB_READ.value,
|
||||
lambda s: self.supplier_crud.search(s, company_uuid, search, priority, pg.skip, pg.size),
|
||||
lambda s: self.supplier_crud.search(s, company_uuid, search, pg.skip, pg.size),
|
||||
)
|
||||
if err_type != ErrorType.SUCCESS:
|
||||
res.result.SetResult(err_type)
|
||||
@@ -105,7 +105,7 @@ class SupplierService:
|
||||
manager_name=req.manager_name,
|
||||
manager_email=req.manager_email,
|
||||
manager_contact_number=req.manager_contact_number,
|
||||
priority=req.priority,
|
||||
total_revenue=req.total_revenue,
|
||||
)
|
||||
err_type = await DB_SESSION_MNG.execute_lambda_run(
|
||||
[suppliers.DBType()],
|
||||
|
||||
Reference in new issue
Block a user