修改web请求接口

This commit is contained in:
wanyaokun
2024-08-28 17:35:28 +08:00
parent 07a3b2a147
commit a7c79df339
4 changed files with 107 additions and 30 deletions
+18 -4
View File
@@ -20,6 +20,14 @@ class ConversationOrm(Base):
introduction = Column(String)
created_at = Column(Integer)
def update(self,data:Dict[str,Any]):
if 'name' in data:
self.name = data['name']
class UserOrm(Base):
__tablename__ = "user"
@@ -143,14 +151,20 @@ class DBManager:
session.commit()
def update(self,tableName:str,data:Dict[str,Any],**filter):
if not self.exist(tableName):
return
session = self.SessionLocal()
ormCls = self._get_orm(tableName)
if ormCls is None:
return
record = session.query(ormCls).filter_by(**filter).first()
if record is not None:
record.update(data)
session.commit()
if len(filter) > 0:
records = session.query(ormCls).filter_by(**filter).all()
else:
records = session.query(ormCls).all()
for record in records:
if record is not None:
record.update(data)
session.commit()
def query(self,tableName:str,**filter):
session = self.SessionLocal()