应用层限制同步

This commit is contained in:
2026-04-02 23:41:06 +08:00
parent 0cab5c1cda
commit 761fad17bc
+4
View File
@@ -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: def create(db: Session, obj_in: InfoSourceCreate) -> InfoSource:
"""创建新的信息源""" """创建新的信息源"""
db_obj = InfoSource(**obj_in.model_dump()) 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: try:
db.add(db_obj) db.add(db_obj)
db.commit() db.commit()