def signup( user_schema: UserSchema = Body(..., embed=True, alias="user"), session: Session = Depends(get_session), ) -> ObjectCreate: user_service = UserService(session) if user_service.get_by_email(user_schema.email): raise HTTPException( status_code=HTTP_401_UNAUTHORIZED, detail='Usuário já criado' ) user = user_service.insert(user_schema.dict()) return ObjectCreate( message='Usuário criado com sucesso', object_id=user.id )
back_to_previous() result = __role_service.search_role() for index in range(len(result)): one = result[index] print( Fore.LIGHTBLUE_EX, "\t%d.\t%s" % (index + 1, one[1])) print(Style.RESET_ALL) try: opt = input("\n\t角色编号:").strip() if opt == "Q" or opt == "q": break else: role_id = result[int(opt) - 1][0] __user_service.insert( username, password, email, role_id) print("\n\t用户添加成功!") time.sleep(1) except: print("\n\t输入有误,请重新输入!") time.sleep(1) continue # 继续添加 while True: cls() opt = input("\n\t是否要继续添加?Y/N:").strip() if opt == "Y" or opt == "y": break_flag = 1 elif opt == "N" or opt == "n": break_flag = 2