supplychain/wwwroot/api/platform_supply_relations_create.dspy
Hermes Agent 2dd2953757 fix: rewrite all create dspy files to use pre-loaded functions
- Removed all imports (json, ServerEnv, datetime, getID)
- Replaced datetime.now().strftime with timestampstr()
- Added id=getID(), created_at=timestampstr(), updated_at=timestampstr()
- Added resellerid from user org context
- Used DBPools().sqlorContext pattern
- Pass data dict directly to sor.C() without field filtering
- Fixed: suppliers, sub_distributors, sub_resellers, distribution_agreements,
  distribution_agreement_items, supply_contracts, supply_contract_items,
  platform_supply_products, platform_supply_relations, product_supplier_mapping,
  sales_ledger, supplychain_accounting
2026-06-17 17:49:48 +08:00

24 lines
854 B
Plaintext

result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
try:
user_id = await get_user()
user_orgid = (await get_userorgid()) or '0'
dbname = get_module_dbname('supplychain')
data = dict(params_kw)
data['id'] = getID()
data['resellerid'] = user_orgid
data['created_by'] = user_id
data['created_at'] = timestampstr()
data['updated_at'] = timestampstr()
async with DBPools().sqlorContext(dbname) as sor:
await sor.C('platform_supply_relations', data)
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '平台供应关系创建成功', 'type': 'success'}}
except Exception as e:
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
return json.dumps(result, ensure_ascii=False)