From 057f034d4cd728c1bd0284e7c6b4a47739d5220d Mon Sep 17 00:00:00 2001 From: zhaoqingang <zhaoqg0118@163.com> Date: 星期四, 12 十二月 2024 19:57:41 +0800 Subject: [PATCH] yonghu --- app/api/group.py | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/api/group.py b/app/api/group.py index 745afe5..5498eb1 100644 --- a/app/api/group.py +++ b/app/api/group.py @@ -7,7 +7,7 @@ from app.models.user import PageParameter from app.models.user_model import UserModel from app.service.group import create_group, group_list, edit_group_data, delete_group_data, get_group_users, \ - save_user_to_group + save_user_to_group, save_group_resource group_router = APIRouter() @@ -36,7 +36,7 @@ if not group.group_name: return Response(code=400, msg="The group_name cannot be empty!") db_group = db.query(GroupModel).filter(GroupModel.group_name == group.group_name).first() - if db_group: + if db_group and db_group.id != group.id: return Response(code=200, msg="group_name already created") is_edit = await edit_group_data(db, group.id, {"group_name": group.group_name, "group_description": group.group_description, @@ -65,6 +65,8 @@ db_group = db.query(GroupModel).filter(GroupModel.id == groupId).first() if not db_group: return Response(code=200, msg="group does not exist") + if db_group.group_type ==2: + return Response(code=400, msg="榛樿缁勬棤娉曞垹闄わ紒") is_edit = await delete_group_data(db, groupId) if not is_edit: return Response(code=200, msg="group delete failure", data={}) @@ -91,13 +93,13 @@ return Response(code=200, msg="success", data={}) -@group_router.post("/group_resource", response_model=Response) +@group_router.put("/group_resource", response_model=Response) async def group_resource(group_resource: GroupResource, current_user: UserModel = Depends(get_current_user), db=Depends(get_db)): db_group = db.query(GroupModel).filter(GroupModel.id == group_resource.id).first() if not db_group: return Response(code=200, msg="group does not exist") - # is_success = await save_group_resource(db, current_user.id, group_resource.id, group_resource.agents, group_resource.dialogs, group_resource.knowledges) - # if not is_success: - # return Response(code=500, msg="save user to group failure", data={}) + is_success = await save_group_resource(db, current_user.id, group_resource.id, group_resource.agents, group_resource.dialogs, group_resource.knowledges) + if not is_success: + return Response(code=500, msg="save user to group failure", data={}) return Response(code=200, msg="success", data={}) -- Gitblit v1.8.0