import { httpRequest, commonRequest, getServiceUrl } from '@/services/http'
import { HttpParams, CommonParams } from '@/services/http/interface'
import { tradeServerRequest } from '@/services/socket/trade'
import { TradeParams } from '@/services/socket/trade/interface'

/**
 * 用户登录
 */
export function login(params: TradeParams<Proto.LoginReq, Proto.LoginRsp>) {
    return tradeServerRequest('LoginReq', 'LoginRsp', params);
}

/**
 * 用户令牌校验
 */
export function tokenCheck(params: TradeParams<Proto.TokenCheckReq, Proto.TokenCheckRsp>) {
    return tradeServerRequest('TokenCheckReq', 'TokenCheckRsp', params);
}

/**
 * 查询账户菜单
 */
export function queryAccountMenu(params: HttpParams<{ rsp: Model.UserMenu[] }>) {
    return httpRequest('/account/menu', 'get', params);
}

/**
 * 查询登录ID
 */
export function queryLoginId(params: HttpParams<{ req: { username: string }, rsp: string }>) {
    return httpRequest('/User/GetLoginID', 'get', params);
}

/**
 * 查询登录账户配置信息
 */
export function queryLoginData(params: HttpParams<{ req: Model.LoginQueryReq, rsp: Model.LoginQueryRsp }>) {
    return httpRequest('/User/LoginQuery', 'get', params);
}

/**
 * 获取用户账号信息
 */
export function queryUserAccount(params: HttpParams<{ req: { userID: number }, rsp: Model.UserAccount }>) {
    return httpRequest('/User/GetUserAccount', 'get', params);
}

/**
 * 查询资金账户信息
 */
export function queryTaAccounts(params: HttpParams<{ req: Model.TaAccountsReq, rsp: Model.TaAccountsRsp[] }>) {
    return httpRequest('/TaAccount/GetTaAccounts', 'get', params);
}

/**
 * 查询账户角色
 */
export function queryAccountRole(params: HttpParams<{ rsp: Model.UserRole[] }>) {
    return httpRequest('/account/role', 'get', params);
}

/**
 * 查询实名认证信息
 */
 export function queryWrDraftUserInfo(params: HttpParams<{ req: Model.WrDraftUserInfoReq, rsp: Model.UserInfo[] }>) {
    return httpRequest('/WrTrade2/QueryWrDraftUserInfo', 'get', params);
}

/**
 * 实名认证请求
 */
 export function requestAddAuth(params: CommonParams<{ req: Model.AddAuthReq }>) {
    return commonRequest(getServiceUrl('openApiUrl') + '/onlineopen/userInfo/addAuth', 'post', params);
}

/**
 * 投资者销户申请
 */
export function investorDel(params: TradeParams<Proto.InvestorDelReq, Proto.InvestorDelRsp>) {
    return tradeServerRequest('InvestorDelReq', 'InvestorDelRsp', params);
}

/**
 * 修改密码
 */
export function modifyPassword(params: TradeParams<Proto.ModifyPwdReq, Proto.ModifyPwdRsp>) {
    return tradeServerRequest('ModifyPwdReq', 'ModifyPwdRsp', params);
}