jwt&dbの操作 実装
This commit is contained in:
@@ -67,3 +67,52 @@ def edit_user(
|
||||
db.commit()
|
||||
db.refresh(db_user)
|
||||
return db_user
|
||||
|
||||
|
||||
def get_appsetting(db: Session, id: int):
|
||||
app = db.query(models.AppSetting).get(id)
|
||||
if not app:
|
||||
raise HTTPException(status_code=404, detail="App not found")
|
||||
return app
|
||||
|
||||
def create_appsetting(db: Session, app: schemas.AppBase):
|
||||
db_app = models.AppSetting(
|
||||
appid=app.appid,
|
||||
setting=app.setting,
|
||||
)
|
||||
db.add(db_app)
|
||||
db.commit()
|
||||
db.refresh(db_app)
|
||||
return db_app
|
||||
|
||||
def delete_appsetting(db: Session, id: int):
|
||||
app = get_appsetting(db, id)
|
||||
if not app:
|
||||
raise HTTPException(status.HTTP_404_NOT_FOUND, detail="App not found")
|
||||
db.delete(app)
|
||||
db.commit()
|
||||
return app
|
||||
|
||||
|
||||
def edit_appsetting(
|
||||
db: Session, id: int, app: schemas.AppBase
|
||||
) -> schemas.App:
|
||||
db_app = get_appsetting(db, id)
|
||||
if not db_app:
|
||||
raise HTTPException(status.HTTP_404_NOT_FOUND, detail="App not found")
|
||||
update_data = app.dict(exclude_unset=True)
|
||||
|
||||
for key, value in update_data.items():
|
||||
setattr(db_app, key, value)
|
||||
|
||||
db.add(db_app)
|
||||
db.commit()
|
||||
db.refresh(db_app)
|
||||
return db_app
|
||||
|
||||
|
||||
def get_kintones(db: Session, type: int):
|
||||
kintones = db.query(models.Kintone).filter(models.Kintone.type == type).all()
|
||||
if not kintones:
|
||||
raise HTTPException(status_code=404, detail="Data not found")
|
||||
return kintones
|
||||
Reference in New Issue
Block a user