package top.lvzhiqiang.mapper; import com.alibaba.fastjson.JSONObject; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.MapKey; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; import top.lvzhiqiang.entity.*; import java.math.BigDecimal; import java.util.Collection; import java.util.List; import java.util.Map; /** * coin-Mapper * * @author lvzhiqiang * 2023/9/9 17:37 */ public interface CoinMapper { @Insert({""}) int insertHistoryOrderList(List historyOrderList); @Select({""}) List findHistoryOrderList(Map params); @Select("select symbol,type,category,sort from coin_monitor_currency where delete_flag = 1 order by sort") List findMonitorCurrencyList(); @Select("select * from coin_public_params where 1=1") @MapKey("codeKey") List findPublicParams(); @Insert({""}) void insertMixTradeList(List parseMixTradeList); @Select({""}) List findMixTraderList(Map params); @Select("select concat(traderUid, '|', traderNickName) from coin_monitor_trader where delete_flag = '1'") List findMonitorTraderList(); @Select({""}) List findWatchlistList(Map params); @Select({""}) List findWatchlistList2(Map params); @Update("update coin_watchlist set cmc_id=#{cmcId},total_market_ranking=#{totalMarketRanking},total_market_value=#{totalMarketValue}," + "mark_price=#{markPrice},price_change_percentage_24h=#{priceChangePercentage24h},highest_historical_price=#{highestHistoricalPrice},ath_change_percentage=#{athChangePercentage},atl_change_percentage=#{atlChangePercentage},lowest_historical_price=#{lowestHistoricalPrice}," + "highest_historical_date=#{highestHistoricalDate},lowest_historical_date=#{lowestHistoricalDate},increase_multiple=#{increaseMultiple}," + "issuing_days=#{issuingDays},coingecko_url=#{coingeckoUrl},cmc_url=#{cmcUrl},feixiaohao_url=#{feixiaohaoUrl},modify_time=now() where id = #{id}") int updateCoinWatchlist(CoinWatchlist coinWatchlist); @Insert("INSERT INTO coin_watchlist_other(symbol, max_supply, circulating_supply, circulating_rate, total_supply, market_cap, fully_diluted_market_cap, create_time, modify_time) " + "VALUES (#{symbol}, #{maxSupply}, #{circulatingSupply}, #{circulatingRate}, #{totalSupply}, #{marketCap}, #{fullyDilutedMarketCap}, now(), now())" + " ON DUPLICATE KEY UPDATE max_supply=values(max_supply),circulating_supply=values(circulating_supply),circulating_rate=values(circulating_rate),total_supply=values(total_supply)" + ",market_cap=values(market_cap),fully_diluted_market_cap=values(fully_diluted_market_cap),modify_time=now()") int insertOrUpdateCoinWatchlistOther(CoinWatchlistOther coinWatchlistOther); @Select("select a.*,b.coingecko_id from coin_watchlist_other a left join coin_watchlist b on a.symbol=b.symbol where a.delete_flag = 1 and a.symbol not in ('BTC','ETH')") List findAllCoinWatchlistOther(); @Select("select * from coin_watchlist_other where symbol = #{symbol} and delete_flag = 1") CoinWatchlistOther findWatchlistOtherBySymbol(String symbol); @Select("select a.*,b.coingecko_id from coin_watchlist_other a left join coin_watchlist b on a.symbol=b.symbol where a.symbol = #{symbol} and a.delete_flag = 1") CoinWatchlistOther findWatchlistOtherBySymbol2(String symbol); @Insert({""}) int insertOrUpdateCoinWatchlistOtherList(Collection coinWatchlistOtherList); @Update({""}) int updateCoinWatchlistRemark(CoinWatchlist coinWatchlist); @Select("select * from coin_watchlist where symbol = #{symbol} and delete_flag = 1") CoinWatchlist findWatchlistBySymbol(String symbol); @Insert({""}) void insertCmcMapList(List cmcMapList); @Select({""}) List findCmcMapList(Map params); @Select("SELECT * FROM coin_monitor_job WHERE delete_flag = 1") @MapKey("job_name") Map findMonitorJobConfig(); @Insert("INSERT INTO coin_watchlist(cmc_id, symbol, track_category, track_category2, issuing_date, coingecko_id, coingecko_url, cmc_url, feixiaohao_url, filter_flag, create_time, modify_time) " + "VALUES (#{cmcId}, #{symbol}, #{trackCategory}, #{trackCategory2}, #{issuingDate}, #{coingeckoId}, #{coingeckoUrl}, #{cmcUrl}, #{feixiaohaoUrl}, #{filterFlag}, now(), now())" + " ON DUPLICATE KEY UPDATE cmc_id=values(cmc_id),track_category=values(track_category),track_category2=values(track_category2),issuing_date=values(issuing_date),coingecko_id=values(coingecko_id)" + ",coingecko_url=values(coingecko_url),cmc_url=values(cmc_url),feixiaohao_url=values(feixiaohao_url),filter_flag=values(filter_flag),modify_time=now()") int insertOrUpdateWatchlist(CoinWatchlist coinWatchlist); @Insert({""}) void insertCoinBinanceSymbolList(List coinBinanceSymbolList); @Select({""}) List findCoinBinanceSymbolListByParams(Map params); @Select("select orderId from coin_binance_order_history") List findAllCoinBinanceOrderIdList(); @Insert({""}) void insertOrUpdateBinanceOrderHistoryList(List coinBinanceOrderHistoryList); @Select({""}) List findCurrentHoldingList(Map params); @Update("update coin_currency_holding set symbol=#{symbol},buy_price=#{buyPrice},current_price=#{currentPrice},change_percentage=#{changePercentage},buy_quantity=#{buyQuantity}," + "current_quantity=#{currentQuantity},buy_amount=#{buyAmount},current_amount=#{currentAmount},exchange_category_id=#{exchangeCategoryId},coingecko_id=#{coingeckoId},status=#{status}," + "remark=#{remark},buy_time=#{buyTime},modify_time=now() where id = #{id}") int updateCurrentHolding(CoinCurrencyHolding coinCurrencyHolding); @Select({""}) BigDecimal getCurrentHoldingTotalAmout(Map params); @Select({""}) List findBookmarkList(Map params); }