import { httpRequest } from '@/services/http'
import { HttpRequest } from '@/services/http/interface'
import { tradeServerRequest } from '@/services/socket/trade'
import { TradeRequest } from '@/services/socket/trade/interface'

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

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

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

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

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

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

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

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