package com.m2pool.pool.mapper;

import com.m2pool.common.datasource.annotation.UserDB;
import com.m2pool.pool.dto.*;
import com.m2pool.pool.entity.*;
import com.m2pool.pool.vo.AccountBalanceAddVo;
import com.m2pool.pool.vo.ApiKeyUpdateVo;
import com.m2pool.pool.vo.ReadOnlyHtmlChangeVo;
import com.m2pool.system.api.model.OpenApiKeyInfo;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @Description 用户网站账号和挖矿账号相关sql
 * @Date 2022/8/30 17:47
 * @Author 杜懿
 */
@UserDB
public interface UserAccountMapper {

        /**
         * 添加挖矿账号
         * @param vo
         * @return
         */
        public boolean userAddMinerAccount(@Param("vo") UserMinerAccount vo);

        /**
         * 修改挖矿账号 备注等
         * @param accountId
         * @param vo
         * @return
         */
        public boolean updateMinerAccountRemark(@Param("accountId") long accountId,@Param("vo") AccountBalanceAddVo vo);

        /**
         * 挖矿账户绑定钱包
         * @param accountId
         * @param vo
         * @return
         */
        public boolean accountAddBalance(@Param("accountId") long accountId, @Param("vo") AccountBalanceAddVo vo);

        /** 停止使用地址 */
        public boolean accountStopBalance(@Param("id") long id, @Param("vo") AccountBalanceAddVo vo);

        /**
         * 修改挖矿账户绑定的钱包地址
         * @param id
         * @param vo
         * @return
         */
        public boolean updateBalance(@Param("id") long id, @Param("vo") AccountBalanceAddVo vo);

        //public List<UserAccountDto> getAccountByUser(@Param("user") String user, @Param("vo") AccountVo vo);

        public UserAccountDto getAccountByUserAccountAndCoin(@Param("user") String user, @Param("account") String account, @Param("coin") String coin);

        public boolean checkAccountIfExist(@Param("account") String account, @Param("coin") String coin);

        public UserAccountDto getAccountByUserAccountId(@Param("user") String user,@Param("id") long id);


        public int getAccountNumberByUserAccountAndCoin(@Param("user") String user, @Param("coin") String coin);

        public List<UserAccountListDto> getAccountByUserAndCoin(@Param("user") String user);

        public UserAccountDto getAccountByUserAndMinerAccount(@Param("user") String user,@Param("ma") String ma);

        public MinerAccountBalanceDto getBalanceByMinerAccount(@Param("maId") long maId);

        boolean batchDelAccount(@Param("ids") List<Long> ids);

        public List<BalanceListDto> getBalanceByCoin(@Param("coin") String coin);

        public boolean checkKeyIfExist(@Param("key") String key);

        public boolean createReadOnlyPage(@Param("vo") UserReadOnlyPage vo);

        public List<UserReadOnlyPageInfo> getPageListByUser(@Param("user") String user);

        public UserReadOnlyPageInfo getPageInfoByKey(@Param("key") String key);

        public boolean changeReadOnlyPage(@Param("vo") ReadOnlyHtmlChangeVo vo);

        public boolean batchDeletePageByKeyAndUser(@Param("keys") List<String> keys,@Param("user") String user);

        public int getApiKeyCountByUser(@Param("user") String user);
        /**
         * 用户绑定apiKey
         * @param vo
         * @return
         */
        public boolean userCreateApiKey(@Param("vo") OpenApiKey vo);

        public List<UserApi> getAPIListByUser(@Param("user") String user);

        public UserApi getAPIInfoByUserAndId(@Param("id") long id,@Param("user") String user);

        public boolean updateApiKey(@Param("vo") ApiKeyUpdateVo vo,@Param("user") String user);

        public boolean batchDeleteAPIByIdsAndUser(@Param("ids") List<String> ids,@Param("user") String user);

        /**
         * 删除挖矿账户对应的只读页面
         * @param list
         * @return
         */
        int deleteBatchReadOnlyPage(@Param("list")List<UserAccountDto> list);


        List<UserAccountDto> getUserMinerByUserEmail(@Param("email") String email);
}
