fix: CRUD endpoint return format - remove json.dumps, use widgettype format
This commit is contained in:
parent
82f873ea5c
commit
16541bcf48
7
reallife_asset.egg-info/PKG-INFO
Normal file
7
reallife_asset.egg-info/PKG-INFO
Normal file
@ -0,0 +1,7 @@
|
||||
Metadata-Version: 2.4
|
||||
Name: reallife_asset
|
||||
Version: 1.0.0
|
||||
Summary: Real Person Portrait Asset Management Module - supports multiple vendors (Volcengine Ark, etc.)
|
||||
Requires-Python: >=3.8
|
||||
Requires-Dist: sqlor
|
||||
Requires-Dist: bricks_for_python
|
||||
11
reallife_asset.egg-info/SOURCES.txt
Normal file
11
reallife_asset.egg-info/SOURCES.txt
Normal file
@ -0,0 +1,11 @@
|
||||
README.md
|
||||
pyproject.toml
|
||||
reallife_asset/__init__.py
|
||||
reallife_asset/init.py
|
||||
reallife_asset/rl_volcengine_client.py
|
||||
reallife_asset/volcengine_client.py
|
||||
reallife_asset.egg-info/PKG-INFO
|
||||
reallife_asset.egg-info/SOURCES.txt
|
||||
reallife_asset.egg-info/dependency_links.txt
|
||||
reallife_asset.egg-info/requires.txt
|
||||
reallife_asset.egg-info/top_level.txt
|
||||
1
reallife_asset.egg-info/dependency_links.txt
Normal file
1
reallife_asset.egg-info/dependency_links.txt
Normal file
@ -0,0 +1 @@
|
||||
|
||||
2
reallife_asset.egg-info/requires.txt
Normal file
2
reallife_asset.egg-info/requires.txt
Normal file
@ -0,0 +1,2 @@
|
||||
sqlor
|
||||
bricks_for_python
|
||||
1
reallife_asset.egg-info/top_level.txt
Normal file
1
reallife_asset.egg-info/top_level.txt
Normal file
@ -0,0 +1 @@
|
||||
reallife_asset
|
||||
BIN
reallife_asset/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
reallife_asset/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
reallife_asset/__pycache__/init.cpython-310.pyc
Normal file
BIN
reallife_asset/__pycache__/init.cpython-310.pyc
Normal file
Binary file not shown.
BIN
reallife_asset/__pycache__/rl_volcengine_client.cpython-310.pyc
Normal file
BIN
reallife_asset/__pycache__/rl_volcengine_client.cpython-310.pyc
Normal file
Binary file not shown.
BIN
scripts/__pycache__/load_path.cpython-310.pyc
Normal file
BIN
scripts/__pycache__/load_path.cpython-310.pyc
Normal file
Binary file not shown.
@ -16,10 +16,10 @@ result = await rl_create_asset(
|
||||
user_id=user_id
|
||||
)
|
||||
|
||||
return json.dumps({
|
||||
return {
|
||||
"widgettype": "Message",
|
||||
"options": {
|
||||
"message": f"素材上传已提交: {result.get('vendor_asset_id', '')}" if result.get('success') else result.get('message', '上传失败'),
|
||||
"type": "success" if result.get('success') else "error"
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -6,10 +6,10 @@ if not rid:
|
||||
|
||||
result = await rl_delete_asset(rid)
|
||||
|
||||
return json.dumps({
|
||||
return {
|
||||
"widgettype": "Message",
|
||||
"options": {
|
||||
"message": "删除成功" if result.get("success") else result.get("message", "删除失败"),
|
||||
"type": "success" if result.get("success") else "error"
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -14,10 +14,10 @@ result = await rl_create_validate_session(
|
||||
user_id=user_id
|
||||
)
|
||||
|
||||
return json.dumps({
|
||||
return {
|
||||
"widgettype": "Message",
|
||||
"options": {
|
||||
"message": f"认证链接已生成: {result.get('h5_link', '')}",
|
||||
"type": "success" if result.get('success') else "error"
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -6,10 +6,10 @@ if not rid:
|
||||
|
||||
result = await rl_delete_group(rid)
|
||||
|
||||
return json.dumps({
|
||||
return {
|
||||
"widgettype": "Message",
|
||||
"options": {
|
||||
"message": "删除成功" if result.get("success") else result.get("message", "删除失败"),
|
||||
"type": "success" if result.get("success") else "error"
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -5,11 +5,11 @@ now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
dbname = get_module_dbname('reallife_asset')
|
||||
db = DBPools()
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
upd = {"update_time": now}
|
||||
upd = {"update_time": now, "id": rid}
|
||||
for f in ['name', 'title', 'description', 'status']:
|
||||
v = params_kw.get(f)
|
||||
if v is not None:
|
||||
upd[f] = v
|
||||
await sor.U("rl_asset_group", {**upd, "id": rid})
|
||||
await sor.U("rl_asset_group", upd)
|
||||
|
||||
return {"success": True, "message": "更新成功"}
|
||||
return {"widgettype":"Message","options":{"title":"更新成功","message":"ok","cwidth":16,"cheight":9,"timeout":3}}
|
||||
|
||||
@ -5,11 +5,11 @@ now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
dbname = get_module_dbname('reallife_asset')
|
||||
db = DBPools()
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
upd = {"update_time": now}
|
||||
upd = {"update_time": now, "id": rid, "org_id": org_id}
|
||||
for f in ['name', 'status']:
|
||||
v = params_kw.get(f)
|
||||
if v is not None:
|
||||
upd[f] = v
|
||||
await sor.U("rl_asset", upd, {"id": rid, "org_id": org_id})
|
||||
await sor.U("rl_asset", upd)
|
||||
|
||||
return {"success": True, "message": "更新成功"}
|
||||
return {"widgettype":"Message","options":{"title":"更新成功","message":"ok","cwidth":16,"cheight":9,"timeout":3}}
|
||||
|
||||
@ -17,4 +17,4 @@ dbname = get_module_dbname('reallife_asset')
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
await sor.I("rl_org_group", data)
|
||||
|
||||
return {"success": True, "id": id}
|
||||
return {"widgettype":"Message","options":{"title":"创建成功","message":"ok","cwidth":16,"cheight":9,"timeout":3,"user_data": data}}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
id = params_kw.get('id', '')
|
||||
if not id: return {"success": False, "message": "id required"}
|
||||
if not id:
|
||||
return {"widgettype":"Error","options":{"title":"删除失败","message":"id required","cwidth":16,"cheight":9,"timeout":3}}
|
||||
|
||||
db = DBPools()
|
||||
dbname = get_module_dbname('reallife_asset')
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
await sor.D("rl_org_group", {"id": id})
|
||||
|
||||
return {"success": True}
|
||||
return {"widgettype":"Message","options":{"title":"删除成功","message":"ok","cwidth":16,"cheight":9,"timeout":3}}
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
id = params_kw.get('id', '')
|
||||
if not id: return {"success": False, "message": "id required"}
|
||||
if not id:
|
||||
return {"widgettype":"Error","options":{"title":"更新失败","message":"id required","cwidth":16,"cheight":9,"timeout":3}}
|
||||
|
||||
db = DBPools()
|
||||
dbname = get_module_dbname('reallife_asset')
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
recs = await sor.R("rl_org_group", {"id": id})
|
||||
if not recs: return {"success": False, "message": "Not found"}
|
||||
if not recs:
|
||||
return {"widgettype":"Error","options":{"title":"更新失败","message":"Not found","cwidth":16,"cheight":9,"timeout":3}}
|
||||
|
||||
upd = {}
|
||||
for k in ['status', 'vendor_group_id', 'local_group_id', 'vendor']:
|
||||
@ -15,4 +17,4 @@ for k in ['status', 'vendor_group_id', 'local_group_id', 'vendor']:
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
await sor.U("rl_org_group", {**upd, "id": id})
|
||||
|
||||
return {"success": True}
|
||||
return {"widgettype":"Message","options":{"title":"更新成功","message":"ok","cwidth":16,"cheight":9,"timeout":3}}
|
||||
|
||||
@ -7,16 +7,15 @@ upappid = params_kw.get('upappid', '')
|
||||
api_mapping = params_kw.get('api_mapping', '{}')
|
||||
|
||||
if not vendor:
|
||||
return {"success": False, "message": "供应商标识不能为空"}
|
||||
return {"widgettype":"Error","options":{"title":"创建失败","message":"供应商标识不能为空","cwidth":16,"cheight":9,"timeout":3}}
|
||||
if not upappid:
|
||||
return {"success": False, "message": "上位系统ID不能为空"}
|
||||
return {"widgettype":"Error","options":{"title":"创建失败","message":"上位系统ID不能为空","cwidth":16,"cheight":9,"timeout":3}}
|
||||
|
||||
# Validate api_mapping is valid JSON
|
||||
try:
|
||||
api_mapping_dict = json.loads(api_mapping) if api_mapping else {}
|
||||
api_mapping = json.dumps(api_mapping_dict, ensure_ascii=False)
|
||||
except json.JSONDecodeError:
|
||||
return {"success": False, "message": "API映射必须是有效的JSON"}
|
||||
return {"widgettype":"Error","options":{"title":"创建失败","message":"API映射必须是有效的JSON","cwidth":16,"cheight":9,"timeout":3}}
|
||||
|
||||
data = {
|
||||
"id": id,
|
||||
@ -36,4 +35,4 @@ dbname = get_module_dbname('reallife_asset')
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
await sor.I("rl_vendor_config", data)
|
||||
|
||||
return {"success": True, "id": id}
|
||||
return {"widgettype":"Message","options":{"title":"创建成功","message":"ok","cwidth":16,"cheight":9,"timeout":3,"user_data": data}}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
id = params_kw.get('id', '')
|
||||
if not id: return {"success": False, "message": "id required"}
|
||||
if not id:
|
||||
return {"widgettype":"Error","options":{"title":"删除失败","message":"id required","cwidth":16,"cheight":9,"timeout":3}}
|
||||
|
||||
db = DBPools()
|
||||
dbname = get_module_dbname('reallife_asset')
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
await sor.D("rl_vendor_config", {"id": id})
|
||||
|
||||
return {"success": True}
|
||||
return {"widgettype":"Message","options":{"title":"删除成功","message":"ok","cwidth":16,"cheight":9,"timeout":3}}
|
||||
|
||||
@ -1,29 +1,30 @@
|
||||
id = params_kw.get('id', '')
|
||||
if not id: return {"success": False, "message": "id required"}
|
||||
if not id:
|
||||
return {"widgettype":"Error","options":{"title":"更新失败","message":"id required","cwidth":16,"cheight":9,"timeout":3}}
|
||||
|
||||
db = DBPools()
|
||||
dbname = get_module_dbname('reallife_asset')
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
recs = await sor.R("rl_vendor_config", {"id": id})
|
||||
if not recs: return {"success": False, "message": "Not found"}
|
||||
if not recs:
|
||||
return {"widgettype":"Error","options":{"title":"更新失败","message":"Not found","cwidth":16,"cheight":9,"timeout":3}}
|
||||
|
||||
upd = {}
|
||||
for k in ['status', 'callback_url', 'vendor', 'vendor_title', 'upappid']:
|
||||
if params_kw.get(k) is not None:
|
||||
upd[k] = params_kw.get(k)
|
||||
|
||||
# Update api_mapping if provided
|
||||
api_mapping = params_kw.get('api_mapping', None)
|
||||
if api_mapping is not None:
|
||||
try:
|
||||
api_mapping_dict = json.loads(api_mapping) if api_mapping else {}
|
||||
upd['api_mapping'] = json.dumps(api_mapping_dict, ensure_ascii=False)
|
||||
except json.JSONDecodeError:
|
||||
return {"success": False, "message": "API映射必须是有效的JSON"}
|
||||
return {"widgettype":"Error","options":{"title":"更新失败","message":"API映射必须是有效的JSON","cwidth":16,"cheight":9,"timeout":3}}
|
||||
|
||||
upd['update_time'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
await sor.U("rl_vendor_config", {**upd, "id": id})
|
||||
|
||||
return {"success": True}
|
||||
return {"widgettype":"Message","options":{"title":"更新成功","message":"ok","cwidth":16,"cheight":9,"timeout":3}}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user