From 7430cab6725d09759460d66270800b1698e76374 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Thu, 17 Jul 2025 09:52:57 +0800 Subject: [PATCH 1/4] perf: Config user api --- backend/apps/system/api/workspace.py | 18 ++++++++++++------ backend/apps/system/schemas/system_schema.py | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/backend/apps/system/api/workspace.py b/backend/apps/system/api/workspace.py index 8725cffc..926a46a8 100644 --- a/backend/apps/system/api/workspace.py +++ b/backend/apps/system/api/workspace.py @@ -1,5 +1,5 @@ from typing import Optional -from fastapi import APIRouter, Query +from fastapi import APIRouter, HTTPException, Query from sqlmodel import exists, or_, select from apps.system.models.system_model import UserWsModel, WorkspaceBase, WorkspaceEditor, WorkspaceModel from apps.system.models.user import UserModel @@ -105,11 +105,14 @@ async def pager( @router.post("/uws") -async def create(session: SessionDep, creator: UserWsDTO): +async def create(session: SessionDep, current_user: CurrentUser, creator: UserWsDTO): + if not current_user.isAdmin and current_user.weight == 0: + raise HTTPException("no permission to execute") + oid: int = creator.oid if current_user.isAdmin else current_user.oid # 判断uid_list以及oid合法性 db_model_list = [ UserWsModel.model_validate({ - "oid": creator.oid, + "oid": oid, "uid": uid, "weight": creator.weight }) @@ -133,10 +136,13 @@ async def edit(session: SessionDep, editor: UserWsEditor): session.commit() @router.delete("/uws") -async def delete(session: SessionDep, dto: UserWsBase): - db_model_list: list[UserWsModel] = session.exec(select(UserWsModel).where(UserWsModel.uid.in_(dto.uid_list), UserWsModel.oid == dto.oid)).all() +async def delete(session: SessionDep, current_user: CurrentUser, dto: UserWsBase): + if not current_user.isAdmin and current_user.weight == 0: + raise HTTPException("no permission to execute") + oid: int = dto.oid if current_user.isAdmin else current_user.oid + db_model_list: list[UserWsModel] = session.exec(select(UserWsModel).where(UserWsModel.uid.in_(dto.uid_list), UserWsModel.oid == oid)).all() if not db_model_list: - raise ValueError(f"UserWsModel not found") + raise HTTPException(f"UserWsModel not found") for db_model in db_model_list: session.delete(db_model) session.commit() diff --git a/backend/apps/system/schemas/system_schema.py b/backend/apps/system/schemas/system_schema.py index 388bca15..feaa3c83 100644 --- a/backend/apps/system/schemas/system_schema.py +++ b/backend/apps/system/schemas/system_schema.py @@ -48,7 +48,7 @@ class PwdEditor(BaseModel): class UserWsBase(BaseModel): uid_list: list[int] - oid: int + oid: Optional[int] = None class UserWsDTO(UserWsBase): weight: int = 0 From fe415511bcc636508465e62c13d33064efd7ef7e Mon Sep 17 00:00:00 2001 From: junjun Date: Thu, 17 Jul 2025 10:03:07 +0800 Subject: [PATCH 2/4] feat: prompt --- backend/template.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/template.yaml b/backend/template.yaml index 975649c6..036de9ae 100644 --- a/backend/template.yaml +++ b/backend/template.yaml @@ -5,7 +5,7 @@ template: 根据表结构和问题生成符合{engine}数据库引擎规范的sql语句,以及sql中所用到的表名(不要包含schema和database,用数组返回)。 你必须遵守以下规则: - 生成的SQL必须符合{engine}的规范。 - - 根据表结构生成SQL语句。 + - 根据表结构生成SQL语句,需给每个表名生成一个别名。 - SQL查询中不能使用星号(*),必须明确指定字段名. - SQL查询的字段名不要自动翻译,别名必须为英文。 - 计算占比,百分比类型字段,保留两位小数,以%结尾。 @@ -174,6 +174,7 @@ template: - 生成的SQL必须符合{engine}的规范。 - 不要替换原来SQL中的过滤条件,将新过滤条件添加到SQL中,生成一个新的sql。 - 如果存在冗余的过滤条件则进行去重后再生成新SQL。 + - 给过滤条件中的字段前加上表别名(如果没有表别名则加表名),如:table.field。 - 生成SQL时,必须避免关键字冲突: - 如数据库引擎是 PostgreSQL、Oracle,则在schema、表名、字段名、别名外层加双引号; - 如数据库引擎是 MySQL,则在表名、字段名、别名外层加反引号; From ba757e28fb7e1326257d2e08eac6040c63ccb930 Mon Sep 17 00:00:00 2001 From: junjun Date: Thu, 17 Jul 2025 12:01:08 +0800 Subject: [PATCH 3/4] feat: prompt --- backend/template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/template.yaml b/backend/template.yaml index 036de9ae..a801d88c 100644 --- a/backend/template.yaml +++ b/backend/template.yaml @@ -5,7 +5,7 @@ template: 根据表结构和问题生成符合{engine}数据库引擎规范的sql语句,以及sql中所用到的表名(不要包含schema和database,用数组返回)。 你必须遵守以下规则: - 生成的SQL必须符合{engine}的规范。 - - 根据表结构生成SQL语句,需给每个表名生成一个别名。 + - 根据表结构生成SQL语句,需给每个表名生成一个别名(不要加AS)。 - SQL查询中不能使用星号(*),必须明确指定字段名. - SQL查询的字段名不要自动翻译,别名必须为英文。 - 计算占比,百分比类型字段,保留两位小数,以%结尾。 From 89171a975877c65c5ce419ee872da5e98b2cf847 Mon Sep 17 00:00:00 2001 From: ulleo Date: Thu, 17 Jul 2025 13:07:42 +0800 Subject: [PATCH 4/4] feat: chat greeting css --- frontend/src/views/chat/index.vue | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/src/views/chat/index.vue b/frontend/src/views/chat/index.vue index 3bfac12f..8f28cb59 100644 --- a/frontend/src/views/chat/index.vue +++ b/frontend/src/views/chat/index.vue @@ -47,7 +47,7 @@ /> - + @@ -73,7 +73,7 @@ size="large" type="primary" class="greeting-btn" - @click="createNewChat" + @click="createNewChatSimple" > @@ -299,6 +299,12 @@ const goEmpty = () => { inputMessage.value = '' } +const createNewChatSimple = async () => { + currentChat.value = new ChatInfo() + currentChatId.value = undefined + await createNewChat() +} + const createNewChat = async () => { goEmpty() if (isAssistant.value) { @@ -760,9 +766,7 @@ defineExpose({ align-items: center; .welcome-content { - padding: 12px; - - width: fit-content; + width: 100%; max-width: 800px; display: flex; gap: 16px;