From 761fad17bc80a49087c683c405564f6c6133ddc9 Mon Sep 17 00:00:00 2001 From: csf123321 Date: Thu, 2 Apr 2026 23:41:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=B1=82=E9=99=90=E5=88=B6?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/crud/crud_source.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/app/crud/crud_source.py b/backend/app/crud/crud_source.py index f183c39..9c7aa0a 100644 --- a/backend/app/crud/crud_source.py +++ b/backend/app/crud/crud_source.py @@ -24,6 +24,10 @@ def get_multi(db: Session, skip: int = 0, limit: int = 100) -> List[InfoSource]: def create(db: Session, obj_in: InfoSourceCreate) -> InfoSource: """创建新的信息源""" db_obj = InfoSource(**obj_in.model_dump()) + exits =db.query(InfoSource).filter(InfoSource.source_name == db_obj.source_name).first() + if exits: + db.close() + return db_obj try: db.add(db_obj) db.commit()