From 00f81bcd59dc409c36951333f09d64117a504138 Mon Sep 17 00:00:00 2001 From: ymq Date: Sat, 22 Aug 2026 18:55:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(sdlc):=20=E6=A8=A1=E5=9E=8B=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=20get/add/update=20=E5=BC=BA=E5=88=B6=E7=94=A8?= =?UTF-8?q?=E4=BC=9A=E8=AF=9D=E5=BD=93=E5=89=8D=E9=A1=B9=E7=9B=AE=20projec?= =?UTF-8?q?t=5Fid=EF=BC=8C=E5=B7=A5=E4=BD=9C=E7=A9=BA=E9=97=B4=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E6=96=87=E6=A1=88=E7=BB=9F=E4=B8=80=E4=B8=BA=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/api/workspace_popup.dspy | 2 +- .../add_sd_project_role_models.dspy | 15 +++++++++++++-- .../get_sd_project_role_models.dspy | 18 +++++++++++++++++- .../update_sd_project_role_models.dspy | 13 +++++++++++++ 4 files changed, 44 insertions(+), 4 deletions(-) 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 {