Visual_Novel_iOS/crush/Crush/Src/ViewModel/UserOperator.swift

38 lines
1.1 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// UserOperator.swift
// Crush
//
// Created by Leon on 2025/8/11.
//
struct UserOperator{
private init(){}
/// uid: aiIduserId
static func checkname(name:String?, uid : Int? = nil, block:((_ nicknameOK: Bool) -> Void)?){
let validname = name ?? ""
var exUserId : Int? = nil
if let paramsUid = uid{
exUserId = paramsUid
}else if let userId = UserCore.shared.user?.userId{
exUserId = userId
}
UserProvider.request(.userNicknameCheck(nickname: validname, exUserId: exUserId), modelType: Bool?.self) {result in
switch result {
case .success(let success):
if let checkResult = success, checkResult == false{
block?(true)
}else{
Hud.toast(str: "该昵称已存在")
block?(false)
}
case .failure:
block?(false)
break
}
}
}
}