This commit is contained in:
王思川 2022-11-09 16:45:01 +08:00
parent ad7be5c782
commit 0862b664d9
2 changed files with 13 additions and 2 deletions

View File

@ -73,6 +73,18 @@ def func03(uid: str, schema: UserSchemas.EditReqBody, db: Session = Depends(get_
if not data: if not data:
raise HTTPException(status_code=202, detail="User Not found") raise HTTPException(status_code=202, detail="User Not found")
# 检查角色是否存在
if schema.role_id:
role_obj = RoleCrud.get_role_by_id(db=db, role_id=schema.role_id)
if not role_obj:
raise HTTPException(status_code=202, detail="Role Not Existed")
# 检查部门是否存在
if schema.role_id:
department_obj = DepartmentCrud.get_department_by_id(db=db, department_id=schema.department_id)
if not department_obj:
raise HTTPException(status_code=202, detail="Department Not Existed")
# 编辑用户 # 编辑用户
result = UserCrud.edit_user(db=db, schema=schema, uid=uid) result = UserCrud.edit_user(db=db, schema=schema, uid=uid)
if not result: if not result:

View File

@ -16,7 +16,6 @@ class CreateReqBody(BaseModel):
class FullUserResBody(BaseModel): class FullUserResBody(BaseModel):
id: str id: str
email: EMailRegex = "xxxx@fecr.com.cn" email: EMailRegex = "xxxx@fecr.com.cn"
name: str = "用户" name: str = "用户"
@ -35,7 +34,7 @@ class EditReqBody(BaseModel):
def del_null_value(self): def del_null_value(self):
_dict = self.dict() _dict = self.dict()
for key in list(_dict.keys()): for key in list(_dict.keys()):
if not _dict.get(key): if _dict.get(key) is None:
del _dict[key] del _dict[key]
return _dict return _dict