refactor:修改pydantic数据校验模型名

This commit is contained in:
zhengxinonly
2022-07-04 20:56:24 +08:00
parent 45874b17ee
commit ad0f174996
8 changed files with 14 additions and 57 deletions
+3 -3
View File
@@ -147,7 +147,7 @@ def make_menu_tree():
return sorted(menu_dict.get(0), key=lambda item: item['sort'])
class PowerModel(BaseModel):
class PowerSchema(BaseModel):
icon: str
open_type: Optional[str] = Field(alias='openType')
parent_id: Optional[str] = Field(alias='parentId')
@@ -199,7 +199,7 @@ class RightsApi(MethodView):
class PowerApi(MethodView):
@validate()
def post(self, body: PowerModel):
def post(self, body: PowerSchema):
power = RightModel(
icon=body.icon,
open_type=body.open_type,
@@ -239,7 +239,7 @@ class PowerApi(MethodView):
return fail_api(message="删除失败")
@validate()
def put(self, _id, body: PowerModel):
def put(self, _id, body: PowerSchema):
data = {
"icon": body.icon,
"open_type": body.open_type,