import http from '@/services/http'
import tradeServer from '@/services/socket/trade'

/**
 * 用户登录
 */
export function login(params: Proto.LoginReq) {
    return tradeServer.sendMessage<Proto.LoginRsp>({
        params,
        reqName: 'LoginReq',
        rspName: 'LoginRsp'
    })
}

/**
 * 用户登出
 */
export function logout(params: Proto.LogoutReq) {
    return tradeServer.sendMessage<Proto.LogoutRsp>({
        params,
        reqName: 'LogoutReq',
        rspName: 'LogoutRsp'
    })
}

/**
 * 用户令牌校验
 */
export function tokenCheck(params: Proto.TokenCheckReq) {
    return tradeServer.sendMessage<Proto.TokenCheckRsp>({
        params,
        reqName: 'TokenCheckReq',
        rspName: 'TokenCheckRsp'
    })
}

/**
 * 修改密码
 */
export function modifyPassword(params: Proto.ModifyPwdReq) {
    return tradeServer.sendMessage<Proto.ModifyPwdRsp>({
        params,
        reqName: 'ModifyPwdReq',
        rspName: 'ModifyPwdRsp'
    })
}

/**
 * 查询用户菜单
 */
export function queryAccountMenu() {
    return http.commonRequest<Ermcp.UserRoutes[]>({
        url: '/account/menu',
    })
}

/**
 * 查询登录ID
 */
export function queryLoginId(params: { username: string }) {
    return http.commonRequest<string>({
        url: '/User/GetLoginID',
        params,
    })
}

/**
 * 查询登录账户配置信息
 */
export function queryLoginData(params: Ermcp.LoginQueryReq) {
    return http.commonRequest<Ermcp.LoginQueryRsp>({
        url: '/User/LoginQuery',
        params,
    })
}

/**
 * 查询资金账户信息
 */
export function queryTaAccounts(params: Ermcp.TaAccountsReq) {
    return http.commonRequest<Ermcp.TaAccountsRsp[]>({
        url: '/TaAccount/GetTaAccounts',
        params,
    })
}

/**
 * 查询账户角色
 */
export function queryAccountRole() {
    return http.commonRequest<Ermcp.UserRole[]>({
        url: '/account/role',
    })
}