feat(sdlc): 模型配置 get/add/update 强制用会话当前项目 project_id,工作空间报错文案统一为切换项目

This commit is contained in:
ymq 2026-08-22 18:55:05 +08:00
parent bebb8b2a87
commit 00f81bcd59
4 changed files with 44 additions and 4 deletions

View File

@ -20,7 +20,7 @@ async with DBPools().sqlorContext(dbname) as sor:
"options": {"title": "提示", "cwidth": 30, "cheight": 8, "auto_open": True},
"subwidgets": [{
"widgettype": "Text",
"options": {"text": "请先选择项目", "cfontsize": 1, "color": "#64748b", "padding": "20px"}
"options": {"text": "请先在会话中切换项目", "cfontsize": 1, "color": "#64748b", "padding": "20px"}
}]
}
else:

View File

@ -8,8 +8,19 @@ if not id or len(id) > 32:
id = uuid()
ns['id'] = id
if not ns.get('project_id'):
return {"widgettype":"Error","options":{"title":"Error","timeout":3,"cwidth":16,"cheight":9,"message":"需要 project_id"}}
# 会话当前项目强制autoproject_id 用当前项目,忽略前端传值
_uid = await get_user()
if not _uid:
_uid = 'user-01'
_dbname = get_module_dbname('pipeline_sdlc')
async with DBPools().sqlorContext(_dbname) as _sor:
_prec = await _sor.sqlExe("SELECT current_project_id FROM pipeline_agent_settings WHERE user_id=${u}$", {"u": _uid})
await _sor.sqlExe("COMMIT", {})
_cur_pid = getattr(_prec[0], 'current_project_id', '') if _prec else ''
if not _cur_pid:
return {"widgettype":"Error","options":{"title":"错误","timeout":3,"cwidth":20,"cheight":9,"message":"请先在会话中切换项目"}}
ns['project_id'] = _cur_pid
if not ns.get('role'):
return {"widgettype":"Error","options":{"title":"Error","timeout":3,"cwidth":16,"cheight":9,"message":"需要 role"}}

View File

@ -1,6 +1,22 @@
ns = params_kw.copy()
# 会话当前项目强制过滤auto读 current_project_id无项目报错
_uid = await get_user()
if not _uid:
_uid = 'user-01'
_cur_pid = ''
_dbname = get_module_dbname('pipeline_sdlc')
async with DBPools().sqlorContext(_dbname) as _sor:
_prec = await _sor.sqlExe(
"SELECT current_project_id FROM pipeline_agent_settings WHERE user_id=${u}$",
{"u": _uid})
await _sor.sqlExe("COMMIT", {})
_cur_pid = getattr(_prec[0], 'current_project_id', '') if _prec else ''
if not _cur_pid:
return {"widgettype":"Error","options":{"title":"错误","timeout":3,"cwidth":20,"cheight":9,"message":"请先在会话中切换项目"}}
ns['_cur_pid'] = _cur_pid
userorgid = await get_userorgid()
if not userorgid:
return {
@ -31,7 +47,7 @@ case a.role
when 'agent.deploy_prod' then '生产部署工程师'
when 'agent.qc' then 'QC 质量控制'
else a.role end as role_text
from (select * from sd_project_role_models where 1=1 [[filterstr]]) a
from (select * from sd_project_role_models where project_id = ${_cur_pid}$ [[filterstr]]) a
left join sd_projects b on a.project_id = b.id'''
filterjson = params_kw.get('data_filter')

View File

@ -7,6 +7,19 @@ id = params_kw.id
if not id:
return {"widgettype":"Error","options":{"title":"Error","timeout":3,"cwidth":16,"cheight":9,"message":"需要 id"}}
# 会话当前项目强制autoproject_id 用当前项目,忽略前端传值
_uid = await get_user()
if not _uid:
_uid = 'user-01'
_dbname = get_module_dbname('pipeline_sdlc')
async with DBPools().sqlorContext(_dbname) as _sor:
_prec = await _sor.sqlExe("SELECT current_project_id FROM pipeline_agent_settings WHERE user_id=${u}$", {"u": _uid})
await _sor.sqlExe("COMMIT", {})
_cur_pid = getattr(_prec[0], 'current_project_id', '') if _prec else ''
if not _cur_pid:
return {"widgettype":"Error","options":{"title":"错误","timeout":3,"cwidth":20,"cheight":9,"message":"请先在会话中切换项目"}}
ns['project_id'] = _cur_pid
userorgid = await get_userorgid()
if not userorgid:
return {