From 8b5501c71df968cdc422001f7caea712aa59a02d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=9D=E5=B7=9D?= Date: Thu, 10 Nov 2022 01:05:35 +0800 Subject: [PATCH] changes --- AppIndicators/Router.py | 24 ++++++++++++------------ Utils/AccessControl/model.conf | 15 --------------- 2 files changed, 12 insertions(+), 27 deletions(-) delete mode 100644 Utils/AccessControl/model.conf diff --git a/AppIndicators/Router.py b/AppIndicators/Router.py index 1a19b66..6417841 100644 --- a/AppIndicators/Router.py +++ b/AppIndicators/Router.py @@ -24,7 +24,7 @@ def func01(schema: Schemas.CreateIndicatorReqBody, db: Session = Depends(get_db) category_obj = Crud.get_category_by_id(db=db, category_id=schema.category_id) if not category_obj: - raise HTTPException(status_code=202, detail="Category Not Found") + raise HTTPException(status_code=404, detail="Category Not Found") index_obj = Crud.create_indicator(db=db, schema=schema) @@ -40,7 +40,7 @@ def func01(schema: Schemas.CreateIndicatorReqBody, db: Session = Depends(get_db) def func02(iid: str, db: Session = Depends(get_db)): index_obj = Crud.get_indicator_by_iid(db=db, iid=iid) if not index_obj: - raise HTTPException(status_code=400, detail="Indicator Not Existed") + raise HTTPException(status_code=404, detail="Indicator Not Existed") Crud.delete_indicator(db=db, iid=iid) @@ -52,11 +52,11 @@ def func02(iid: str, db: Session = Depends(get_db)): def func03(iid: str, schema: Schemas.EditIndicatorReqBody, db: Session = Depends(get_db)): index_obj = Crud.get_indicator_by_iid(db=db, iid=iid) if not index_obj: - raise HTTPException(status_code=202, detail="Indicator Not Found") + raise HTTPException(status_code=404, detail="Indicator Not Found") category_obj = Crud.get_category_by_id(db=db, category_id=schema.category_id) if not category_obj: - raise HTTPException(status_code=202, detail="Category Not Found") + raise HTTPException(status_code=404, detail="Category Not Found") Crud.edit_indicator(db=db, schema=schema, iid=iid) @@ -68,7 +68,7 @@ def func03(iid: str, schema: Schemas.EditIndicatorReqBody, db: Session = Depends def func04(iid: str, db: Session = Depends(get_db)): index_obj = Crud.get_indicator_by_iid(db, iid=iid) if index_obj is None: - raise HTTPException(status_code=202, detail="Indicator Not Found") + raise HTTPException(status_code=404, detail="Indicator Not Found") return index_obj.to_dict() @@ -78,7 +78,7 @@ def func04(iid: str, db: Session = Depends(get_db)): def func05(iid: str, db: Session = Depends(get_db)): index_obj = Crud.get_indicator_by_iid(db, iid=iid) if not index_obj: - raise HTTPException(status_code=400, detail="Indicator Not Found") + raise HTTPException(status_code=404, detail="Indicator Not Found") return index_obj.to_dict() @@ -99,7 +99,7 @@ def func07(schema: Schemas.RegisterIndicatorReqBody, db: Session = Depends(get_d category_obj = Crud.get_category_by_name(db=db, title=schema.category) if not category_obj: - raise HTTPException(status_code=202, detail="Category Not Found") + raise HTTPException(status_code=404, detail="Category Not Found") real_schema = schema.dict() real_schema.pop("category") @@ -120,7 +120,7 @@ def func07(schema: Schemas.RegisterIndicatorReqBody, db: Session = Depends(get_d def func08(iid: str, body: Schemas.EditParamReqBody, db: Session = Depends(get_db)): index_obj = Crud.get_indicator_by_iid(db=db, iid=iid) if not index_obj: - raise HTTPException(status_code=400, detail="Indicator Not Found") + raise HTTPException(status_code=404, detail="Indicator Not Found") Crud.create_parameter(db=db, schema=body, _iid=iid) @@ -131,7 +131,7 @@ def func08(iid: str, body: Schemas.EditParamReqBody, db: Session = Depends(get_d def func09(pid: str, schema: Schemas.EditParamReqBody, db: Session = Depends(get_db)): data = Crud.get_parameter_by_pid(db=db, pid=pid) if not data: - raise HTTPException(status_code=202, detail="Parameter Not Existed") + raise HTTPException(status_code=404, detail="Parameter Not Existed") Crud.edit_parameter(db=db, pid=pid, schema=schema) @@ -143,7 +143,7 @@ def func09(pid: str, schema: Schemas.EditParamReqBody, db: Session = Depends(get def func10(pid: str, db: Session = Depends(get_db)): data = Crud.get_parameter_by_pid(db=db, pid=pid) if not data: - raise HTTPException(status_code=202, detail="Parameter Not Existed") + raise HTTPException(status_code=404, detail="Parameter Not Existed") Crud.delete_parameter(db=db, pid=pid) @@ -165,12 +165,12 @@ def func11(schema: Schemas.CreateCategoryReqBody, db: Session = Depends(get_db)) def func12(schema: Schemas.DeleteCategoryReqBody, db: Session = Depends(get_db)): data = Crud.get_category_by_id(db=db, category_id=schema.category_id) if not data: - raise HTTPException(status_code=202, detail="Category Not Existed") + raise HTTPException(status_code=404, detail="Category Not Found") try: Crud.delete_category(db=db, category_id=schema.category_id) except IntegrityError: - raise HTTPException(status_code=400, detail="Cannot Delete Category") + raise HTTPException(status_code=202, detail="Category Is Being Used") return {"info": "Success"} diff --git a/Utils/AccessControl/model.conf b/Utils/AccessControl/model.conf deleted file mode 100644 index b0665ab..0000000 --- a/Utils/AccessControl/model.conf +++ /dev/null @@ -1,15 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[role_definition] -g = _, _ -g2 = _, _ - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = g(r.sub, p.sub) && g2(r.obj, p.obj) && r.act == p.act || r.sub == "管理员" \ No newline at end of file