diff --git a/wwwroot/api/workspace_popup.dspy b/wwwroot/api/workspace_popup.dspy index 191ac05..617eb11 100644 --- a/wwwroot/api/workspace_popup.dspy +++ b/wwwroot/api/workspace_popup.dspy @@ -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: diff --git a/wwwroot/sd_project_role_models/add_sd_project_role_models.dspy b/wwwroot/sd_project_role_models/add_sd_project_role_models.dspy index 9bb54a6..ce482d0 100644 --- a/wwwroot/sd_project_role_models/add_sd_project_role_models.dspy +++ b/wwwroot/sd_project_role_models/add_sd_project_role_models.dspy @@ -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"}} +# 会话当前项目强制(auto):project_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"}} diff --git a/wwwroot/sd_project_role_models/get_sd_project_role_models.dspy b/wwwroot/sd_project_role_models/get_sd_project_role_models.dspy index 7f5bdb9..ff1d7b8 100644 --- a/wwwroot/sd_project_role_models/get_sd_project_role_models.dspy +++ b/wwwroot/sd_project_role_models/get_sd_project_role_models.dspy @@ -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') diff --git a/wwwroot/sd_project_role_models/update_sd_project_role_models.dspy b/wwwroot/sd_project_role_models/update_sd_project_role_models.dspy index f3e3066..0c638f9 100644 --- a/wwwroot/sd_project_role_models/update_sd_project_role_models.dspy +++ b/wwwroot/sd_project_role_models/update_sd_project_role_models.dspy @@ -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"}} +# 会话当前项目强制(auto):project_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 {