- 删除 models/product_type_config.json
- 删除 json/product_type_config_list.json (CRUD定义)
- 删除 wwwroot/product_type_config_manage.ui 和 product_type_config_list/ 目录
- 删除 wwwroot/api/product_type_config_{create,update,delete}.dspy
- core.py: 移除 get_operator_config/set_operator_config 方法
- core.py: get_product_detail 不再查询 operator_config
- __init__.py: 移除 wrapper 函数和 env 注册
- product_detail.dspy: 移除 operator_config 查询逻辑
- scripts/load_path.py: 移除所有 product_type_config 权限路径
- menu.ui: 移除"运营商配置"菜单项
- index.ui: 移除"运营商配置"卡片,更新标题描述
- README.md: 移除相关文档
78 lines
2.4 KiB
Python
78 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
产品详情标准化接口 (按机构隔离)
|
|
参数:
|
|
product_id: 产品ID
|
|
product_code: 产品编码 (可选)
|
|
org_id: 机构ID (可选,不传则用当前用户机构)
|
|
返回:
|
|
{success, data: {product_info, category_info, extra_parsed}}
|
|
说明:
|
|
product_info 包含产品全部信息
|
|
extra_parsed 是 extra_json 解析后的结构化数据
|
|
"""
|
|
import json
|
|
|
|
result = {'success': False, 'data': {}}
|
|
|
|
try:
|
|
user_id = await get_user()
|
|
org_id = params_kw.get('org_id', None) or (await get_userorgid()) or '0'
|
|
|
|
product_id = params_kw.get('product_id', '')
|
|
product_code = params_kw.get('product_code', '')
|
|
|
|
if not product_id and not product_code:
|
|
result['error'] = '缺少product_id或product_code参数'
|
|
return json.dumps(result, ensure_ascii=False)
|
|
|
|
dbname = get_module_dbname('product_management')
|
|
conditions = ["p.org_id = ${org_id}$"]
|
|
params = {'org_id': org_id}
|
|
|
|
if product_id:
|
|
conditions.append("p.id = ${product_id}$")
|
|
params['product_id'] = product_id
|
|
elif product_code:
|
|
conditions.append("p.product_code = ${product_code}$")
|
|
params['product_code'] = product_code
|
|
|
|
where_clause = " AND ".join(conditions)
|
|
|
|
sql = f"""SELECT p.*, pc.name as category_name, pc.description as category_description
|
|
FROM product p
|
|
LEFT JOIN product_category pc ON p.category_id = pc.id AND p.org_id = pc.org_id
|
|
WHERE {where_clause}"""
|
|
|
|
async with DBPools().sqlorContext(dbname) as sor:
|
|
rows = await sor.sqlExe(sql, params)
|
|
if not rows:
|
|
result['error'] = '产品不存在或无权访问'
|
|
return json.dumps(result, ensure_ascii=False)
|
|
|
|
product_info = dict(rows[0])
|
|
|
|
# Parse extra_json
|
|
extra_parsed = {}
|
|
extra_str = product_info.get('extra_json', '')
|
|
if extra_str:
|
|
try:
|
|
extra_parsed = json.loads(extra_str)
|
|
except:
|
|
extra_parsed = {'_raw': extra_str}
|
|
product_info['extra_parsed'] = extra_parsed
|
|
|
|
result['data'] = {
|
|
'product_info': product_info,
|
|
'category_info': {
|
|
'name': product_info.get('category_name'),
|
|
'description': product_info.get('category_description')
|
|
}
|
|
}
|
|
result['success'] = True
|
|
|
|
except Exception as e:
|
|
result['error'] = str(e)
|
|
|
|
return json.dumps(result, ensure_ascii=False, default=str)
|