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()