import { httpRequest, commonRequest, getServiceUrl } from '@/services/http'
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 logout(params: TradeParams<Proto.LoginReq, Proto.LoginRsp>) {
    return tradeServerRequest('LogoutReq', 'LogoutRsp', params);
}

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

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

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

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

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

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

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

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

/**
 * 实名认证请求
 */
export function requestAddAuth(params: 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);
}