| | |
| | | async def add_user(user: UserInfo, current_user: UserModel = Depends(get_current_user), db=Depends(get_db)): |
| | | if not user.userName: |
| | | return Response(code=400, msg="The userName cannot be empty!") |
| | | if "@" in user.username: |
| | | if "@" in user.userName: |
| | | return Response(code=400, msg="Username cannot contain @") |
| | | if user.pwd: |
| | | if not is_valid_password(user.pwd): |
| | | return Response(code=400, msg="The password must be at least 8 and contain both numbers and letters") |
| | | db_user = db.query(UserModel).filter(UserModel.username == user.userName, UserModel.status != USER_STATSU_DELETE).first() |
| | | if db_user: |
| | | return Response(code=200, msg="user already created") |
| | | return Response(code=400, msg="user already created") |
| | | pwd = user.pwd |
| | | if not pwd: |
| | | pwd = "basic123456" |
| | |
| | | is_edit = await edit_user_dept(db, user.userId, user.depts) |
| | | if not is_edit: |
| | | return Response(code=500, msg="user edit failure", data={}) |
| | | return Response(code=200, msg="user edit successfully", data={}) |
| | | return Response(code=200, msg="user edit successfully", data={}) |
| | | |
| | | |
| | | @user_router.get("/ping", response_model=Response) |
| | | async def user_ping(current_user: UserModel = Depends(get_current_user)): |
| | | return Response(code=200, msg="", data={}) |