[feat] negodata: 회사 커스터마이징(설정·라벨·커스텀필드·엑셀·상품공급사#20·분류카테고리#17)·일괄삭제·로그export·구분·카드 전체선택·부가정보 표시

This commit is contained in:
minaChoi committed 2026-07-22 15:20:24 +09:00
1 parent 1e4726f4cc
commit 88edcfed63
75 files changed
+1802 -126

No files matched your search

@@ -0,0 +1,45 @@
import uuid
from fastapi import Depends
from common.database.db_session_manager import DB_SESSION_MNG
from common.database.model.models import companies
from common.enums import DBWRType, ErrorType
from crud.user_crud import IUserCRUD, UserCRUD
from router.v1.company.protocol import Req_UpdateCompanySettings, Res_CompanySettings
class CompanySettingsService:
"""회사별 커스터마이징 설정(companies.settings JSONB) 조회/수정.
- 조회는 로그인 유저 전원(브랜딩/라벨을 앱 부팅 시 로드), 수정은 라우터에서 RequireOwner 로 게이트.
- company_id 는 토큰값만 쓴다 → 남의 회사 설정 접근 불가.
"""
def __init__(self, user_crud: IUserCRUD = Depends(UserCRUD)):
self.user_crud = user_crud
async def get_settings(self, company_id: str) -> Res_CompanySettings:
res = Res_CompanySettings()
err_type, company = await DB_SESSION_MNG.execute_lambda(
companies.DBType(),
DBWRType.DB_READ.value,
lambda s: self.user_crud.get_company(s, uuid.UUID(company_id)),
)
if err_type != ErrorType.SUCCESS or company is None:
res.result.SetResult(err_type if err_type != ErrorType.SUCCESS else ErrorType.ACCOUNT_NOT_FOUND)
return res
res.settings = company.settings
return res
async def update_settings(self, company_id: str, req: Req_UpdateCompanySettings) -> Res_CompanySettings:
res = Res_CompanySettings()
err_type = await DB_SESSION_MNG.execute_lambda_run(
[companies.DBType()],
[lambda s: self.user_crud.update_company_settings(s, uuid.UUID(company_id), req.settings)],
)
if err_type != ErrorType.SUCCESS:
res.result.SetResult(err_type)
return res
res.settings = req.settings
return res
+10
View File
@@ -67,6 +67,16 @@ class ItemService:
if nm_err == ErrorType.SUCCESS:
for d in res.items:
d.creator_name = name_map.get(d.user_id)
# 공급사명 배치 조인 — 페이지 상품의 item_id를 모아 IN 쿼리 1회로 {item_id:[공급사명]} 맵을 만들어 매핑.
item_ids = [r.item_id for r in rows]
if item_ids:
sn_err, supplier_map = await DB_SESSION_MNG.execute_lambda(
items.DBType(), DBWRType.DB_READ.value,
lambda s: self.item_crud.supplier_name_map(s, item_ids),
)
if sn_err == ErrorType.SUCCESS:
for d in res.items:
d.supplier_names = supplier_map.get(d.item_id, [])
res.total = total
return res
@@ -877,6 +877,7 @@ class QuotationService:
reject_price=r.reject_price,
reject_delivery_type=r.reject_delivery_type,
email_sent_at=r.email_sent_at,
custom=r.custom,
url=self._session_chat_url(r.session_id),
)
for r in rows
@@ -85,10 +85,11 @@ class SupplierItemService:
if err_type != ErrorType.SUCCESS:
res.result.SetResult(err_type)
return res
# Row(supplier_item_id, item_id, name, code, supply_type)
# Row(supplier_item_id, item_id, name, code, supply_type, category, manufacturer)
res.supplier_items = [
SupplierItemData(
supplier_item_id=r[0], item_id=r[1], item_name=r[2], item_code=r[3], supply_type=r[4]
supplier_item_id=r[0], item_id=r[1], item_name=r[2], item_code=r[3], supply_type=r[4],
item_category=r[5], item_manufacturer=r[6],
)
for r in rows
]
@@ -109,8 +110,10 @@ class SupplierItemService:
if err_type != ErrorType.SUCCESS:
res.result.SetResult(err_type)
return res
# Row(supplier_id, supply_type)
res.suppliers = [ItemSupplyType(supplier_id=r[0], supply_type=r[1]) for r in rows]
# Row(supplier_id, supply_type, name, supplier_item_id)
res.suppliers = [
ItemSupplyType(supplier_id=r[0], supply_type=r[1], supplier_name=r[2], supplier_item_id=r[3]) for r in rows
]
return res
async def create(self, company_id: str, req: Req_CreateSupplierItem) -> Res_SupplierItem:
@@ -170,6 +170,7 @@ class SupplierService:
manager_email=req.manager_email,
manager_contact_number=req.manager_contact_number,
total_revenue=req.total_revenue,
custom=req.custom,
)
err_type = await DB_SESSION_MNG.execute_lambda_run(
[suppliers.DBType()],