fix: DBPools Singleton - manually set db.databases after getting instance
This commit is contained in:
parent
8be3566338
commit
248a0fa979
@ -24,7 +24,9 @@ async def create_customer(
|
|||||||
"""创建客户档案"""
|
"""创建客户档案"""
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools(config.databases)
|
db = DBPools()
|
||||||
|
|
||||||
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('customer_management') as sor:
|
async with db.sqlorContext('customer_management') as sor:
|
||||||
customer_id = str(uuid.uuid4()).replace('-', '')
|
customer_id = str(uuid.uuid4()).replace('-', '')
|
||||||
|
|
||||||
@ -78,7 +80,9 @@ async def initiate_handover(
|
|||||||
"""发起客户交接流程"""
|
"""发起客户交接流程"""
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools(config.databases)
|
db = DBPools()
|
||||||
|
|
||||||
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('customer_management') as sor:
|
async with db.sqlorContext('customer_management') as sor:
|
||||||
# 获取客户信息
|
# 获取客户信息
|
||||||
customer_records = await sor.R("customers", {"filters": [{"field": "id", "op": "=", "value": customer_id}]})
|
customer_records = await sor.R("customers", {"filters": [{"field": "id", "op": "=", "value": customer_id}]})
|
||||||
@ -210,7 +214,9 @@ async def complete_handover_preparation(handover_id: str) -> Dict:
|
|||||||
"""完成交接准备阶段"""
|
"""完成交接准备阶段"""
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools(config.databases)
|
db = DBPools()
|
||||||
|
|
||||||
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('customer_management') as sor:
|
async with db.sqlorContext('customer_management') as sor:
|
||||||
handover_records = await sor.R("customer_handover", {"filters": [{"field": "id", "op": "=", "value": handover_id}]})
|
handover_records = await sor.R("customer_handover", {"filters": [{"field": "id", "op": "=", "value": handover_id}]})
|
||||||
if not handover_records or len(handover_records) == 0:
|
if not handover_records or len(handover_records) == 0:
|
||||||
@ -238,7 +244,9 @@ async def approve_handover(handover_id: str, approver_id: str = None) -> Dict:
|
|||||||
"""审核交接清单"""
|
"""审核交接清单"""
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools(config.databases)
|
db = DBPools()
|
||||||
|
|
||||||
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('customer_management') as sor:
|
async with db.sqlorContext('customer_management') as sor:
|
||||||
approver_id = approver_id or get_current_user_id()
|
approver_id = approver_id or get_current_user_id()
|
||||||
|
|
||||||
@ -268,7 +276,9 @@ async def confirm_handover(handover_id: str, confirm_by: str = None) -> Dict:
|
|||||||
"""确认接收客户"""
|
"""确认接收客户"""
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools(config.databases)
|
db = DBPools()
|
||||||
|
|
||||||
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('customer_management') as sor:
|
async with db.sqlorContext('customer_management') as sor:
|
||||||
confirm_by = confirm_by or get_current_user_id()
|
confirm_by = confirm_by or get_current_user_id()
|
||||||
|
|
||||||
@ -329,7 +339,9 @@ async def recycle_to_pool(customer_id: str, inactive_days: int = None, reason: s
|
|||||||
"""回收客户到公海池"""
|
"""回收客户到公海池"""
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools(config.databases)
|
db = DBPools()
|
||||||
|
|
||||||
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('customer_management') as sor:
|
async with db.sqlorContext('customer_management') as sor:
|
||||||
customer_records = await sor.R("customers", {"filters": [{"field": "id", "op": "=", "value": customer_id}]})
|
customer_records = await sor.R("customers", {"filters": [{"field": "id", "op": "=", "value": customer_id}]})
|
||||||
if not customer_records or len(customer_records) == 0:
|
if not customer_records or len(customer_records) == 0:
|
||||||
@ -372,7 +384,9 @@ async def claim_from_pool(pool_id: str, new_owner_id: str = None):
|
|||||||
"""从公海池认领客户"""
|
"""从公海池认领客户"""
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools(config.databases)
|
db = DBPools()
|
||||||
|
|
||||||
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('customer_management') as sor:
|
async with db.sqlorContext('customer_management') as sor:
|
||||||
new_owner_id = new_owner_id or get_current_user_id()
|
new_owner_id = new_owner_id or get_current_user_id()
|
||||||
|
|
||||||
@ -415,7 +429,9 @@ async def get_customer_360_view(customer_id: str) -> Dict:
|
|||||||
"""获取客户360度视图"""
|
"""获取客户360度视图"""
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools(config.databases)
|
db = DBPools()
|
||||||
|
|
||||||
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('customer_management') as sor:
|
async with db.sqlorContext('customer_management') as sor:
|
||||||
# 客户基本信息
|
# 客户基本信息
|
||||||
customer_records = await sor.R("customers", {"filters": [{"field": "id", "op": "=", "value": customer_id}]})
|
customer_records = await sor.R("customers", {"filters": [{"field": "id", "op": "=", "value": customer_id}]})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user