CoinMapper.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. package top.lvzhiqiang.mapper;
  2. import com.alibaba.fastjson.JSONObject;
  3. import org.apache.ibatis.annotations.Insert;
  4. import org.apache.ibatis.annotations.MapKey;
  5. import org.apache.ibatis.annotations.Select;
  6. import org.apache.ibatis.annotations.Update;
  7. import top.lvzhiqiang.entity.*;
  8. import java.math.BigDecimal;
  9. import java.util.Collection;
  10. import java.util.List;
  11. import java.util.Map;
  12. /**
  13. * coin-Mapper
  14. *
  15. * @author lvzhiqiang
  16. * 2023/9/9 17:37
  17. */
  18. public interface CoinMapper {
  19. @Insert({"<script>" +
  20. "INSERT ignore INTO coin_order_history(symbol,size,orderId,clientOid,filledQty,fee,price,priceAvg,state,side" +
  21. ",timeInForce,totalProfits,posSide,marginCoin,leverage,marginMode,orderType,reduceOnly,enterPointSource,tradeSide" +
  22. ",holdMode,orderSource,cTime,uTime)" +
  23. " VALUES " +
  24. "<foreach collection='list' item='p' index=\"index\" separator=\",\">" +
  25. " ( #{p.symbol}, #{p.size}, #{p.orderId}, #{p.clientOid}, #{p.filledQty}, #{p.fee}, #{p.price}, #{p.priceAvg}, #{p.state}" +
  26. ", #{p.side}, #{p.timeInForce}, #{p.totalProfits}, #{p.posSide}, #{p.marginCoin}, #{p.leverage}, #{p.marginMode}, #{p.orderType}" +
  27. ", #{p.reduceOnly}, #{p.enterPointSource}, #{p.tradeSide}, #{p.holdMode}, #{p.orderSource}, #{p.cTime}, #{p.uTime})" +
  28. "</foreach>" +
  29. "</script>"})
  30. int insertHistoryOrderList(List<CoinHistoryOrder> historyOrderList);
  31. @Select({"<script>" +
  32. "select * from coin_order_history WHERE 1 = 1" +
  33. "<if test=\"keyword != null and keyword != ''\">" +
  34. " and symbol like concat('%',#{keyword},'%')" +
  35. "</if>" +
  36. "<if test=\"side != null and side != ''\">" +
  37. " and side = #{side}" +
  38. "</if>" +
  39. " order by ${sortField} ${sort}" +
  40. "</script>"})
  41. List<CoinHistoryOrder> findHistoryOrderList(Map<String, Object> params);
  42. @Select("select symbol,type,category,sort from coin_monitor_currency where delete_flag = 1 order by sort")
  43. List<CoinMonitorCurrency> findMonitorCurrencyList();
  44. @Select("select * from coin_public_params where 1=1")
  45. @MapKey("codeKey")
  46. List<CoinPubilcParams> findPublicParams();
  47. @Insert({"<script>" +
  48. "INSERT INTO coin_trader(traderUid,traderNickName,maxFollowCount,followCount,totalFollowers,profitOrderCount,lossOrderCount," +
  49. "totalTradeCount,dailyProfitRate,dailyProfit,copyTradeDays,roi,totalProfit,totalFollowersProfit,aum,maxCallbackRate,last3wWinRate," +
  50. "averageWinRate,traderHeadPic,canTrace,tradingPairsAvailable,profile,lastTradeTime,modify_time)" +
  51. " VALUES " +
  52. "<foreach collection='list' item='mt' index=\"index\" separator=\",\">" +
  53. " (#{mt.traderUid},#{mt.traderNickName},#{mt.maxFollowCount},#{mt.followCount},#{mt.totalFollowers},#{mt.profitOrderCount},#{mt.lossOrderCount}," +
  54. "#{mt.totalTradeCount},#{mt.dailyProfitRate},#{mt.dailyProfit},#{mt.copyTradeDays},#{mt.roi},#{mt.totalProfit},#{mt.totalFollowersProfit},#{mt.aum}," +
  55. "#{mt.maxCallbackRate},#{mt.last3wWinRate},#{mt.averageWinRate},#{mt.traderHeadPic},#{mt.canTrace},#{mt.tradingPairsAvailable},#{mt.profile},#{mt.lastTradeTime}, now())" +
  56. " </foreach>" +
  57. " ON DUPLICATE KEY UPDATE traderNickName=values(traderNickName),maxFollowCount=values(maxFollowCount),followCount=values(followCount),totalFollowers=values(totalFollowers)," +
  58. "profitOrderCount=values(profitOrderCount),lossOrderCount=values(lossOrderCount),totalTradeCount=values(totalTradeCount),dailyProfitRate=values(dailyProfitRate)," +
  59. "dailyProfit=values(dailyProfit),copyTradeDays=values(copyTradeDays),roi=values(roi),totalProfit=values(totalProfit),totalFollowersProfit=values(totalFollowersProfit)," +
  60. "aum=values(aum),maxCallbackRate=values(maxCallbackRate),last3wWinRate=values(last3wWinRate),averageWinRate=values(averageWinRate),traderHeadPic=values(traderHeadPic)," +
  61. "canTrace=values(canTrace),tradingPairsAvailable=values(tradingPairsAvailable),profile=values(profile),lastTradeTime=values(lastTradeTime),modify_time=now()" +
  62. "</script>"})
  63. void insertMixTradeList(List<CoinTrader> parseMixTradeList);
  64. @Select({"<script>" +
  65. "select * from coin_trader WHERE 1 = 1" +
  66. "<if test=\"keyword != null and keyword != ''\">" +
  67. " and traderNickName like concat('%',#{keyword},'%')" +
  68. "</if>" +
  69. "<if test=\"canTrace != null and canTrace != ''\">" +
  70. " and canTrace = #{canTrace}" +
  71. "</if>" +
  72. " order by ${sortField} ${sort}" +
  73. "</script>"})
  74. List<CoinTrader> findMixTraderList(Map<String, Object> params);
  75. @Select("select concat(traderUid, '|', traderNickName) from coin_monitor_trader where delete_flag = '1'")
  76. List<String> findMonitorTraderList();
  77. @Select({"<script>" +
  78. "select * from coin_watchlist WHERE delete_flag = 1" +
  79. "<if test=\"keyword != null and keyword != ''\">" +
  80. " and symbol like concat('%',#{keyword},'%')" +
  81. "</if>" +
  82. "<if test=\"symbol != null and symbol != ''\">" +
  83. " and symbol = #{symbol}" +
  84. "</if>" +
  85. "<if test=\"filterField != null and filterField != ''\">" +
  86. " and filter_flag = #{filterField}" +
  87. "</if>" +
  88. "<if test=\"trackCategoryField != null and trackCategoryField != ''\">" +
  89. " and track_category like concat('%',#{trackCategoryField},'%')" +
  90. "</if>" +
  91. " order by " +
  92. "<foreach collection='sortField' item='sf' index=\"index\" separator=\",\">" +
  93. " ${sf} ${sort}" +
  94. " </foreach>" +
  95. "</script>"})
  96. List<CoinWatchlist> findWatchlistList(Map<String, Object> params);
  97. @Select({"<script>" +
  98. "select cw.* from coin_watchlist cw left join coin_watchlist_other cwo on cw.symbol=cwo.symbol WHERE cw.delete_flag = 1" +
  99. "<if test=\"keyword != null and keyword != ''\">" +
  100. " and cw.symbol like concat('%',#{keyword},'%')" +
  101. "</if>" +
  102. "<if test=\"symbol != null and symbol != ''\">" +
  103. " and cw.symbol = #{symbol}" +
  104. "</if>" +
  105. "<if test=\"filterField != null and filterField != ''\">" +
  106. " and cw.filter_flag = #{filterField}" +
  107. "</if>" +
  108. "<if test=\"trackCategoryField != null and trackCategoryField != ''\">" +
  109. " and cw.track_category like concat('%',#{trackCategoryField},'%')" +
  110. "</if>" +
  111. "<if test=\"trackCategory2Field != null and trackCategory2Field != ''\">" +
  112. " and cw.track_category2 like concat('%',#{trackCategory2Field},'%')" +
  113. "</if>" +
  114. "<if test=\"cexFilterField != null and cexFilterField != ''\">" +
  115. " <choose>" +
  116. " <when test=\" cexFilterName == 'cwo.cex_spot' \">" +
  117. " and substring(cwo.cex_spot,#{cexFilterIndex},1) = '1'" +
  118. " </when>" +
  119. " <otherwise>" +
  120. " and substring(cwo.cex_perpetual,#{cexFilterIndex},1) = '1'" +
  121. " </otherwise>" +
  122. " </choose>" +
  123. "</if>" +
  124. " order by " +
  125. "<foreach collection='sortField' item='sf' index=\"index\" separator=\",\">" +
  126. " ${sf} ${sort}" +
  127. " </foreach>" +
  128. "</script>"})
  129. List<CoinWatchlist> findWatchlistList2(Map<String, Object> params);
  130. @Select({"<script>" +
  131. "select cwu.id,cw.cmc_id,cwu.symbol,cw.mark_price,cw.price_change_percentage_24h,cw.total_market_value," +
  132. "cw.total_market_ranking,cwu.track_category,cwu.track_category2,cw.highest_historical_price,cw.ath_change_percentage," +
  133. "cw.lowest_historical_price,cw.atl_change_percentage,cw.highest_historical_date,cw.lowest_historical_date,cw.increase_multiple," +
  134. "cwu.issuing_date,cwu.issuing_days,cw.coingecko_id,cw.coingecko_url,cw.cmc_url,cw.feixiaohao_url,cwu.score,cwu.sort," +
  135. "cwu.remark,cwu.filter_flag,cwu.create_time,cw.modify_time,cwu.delete_flag" +
  136. " from coin_watchlist_user cwu "+
  137. "left join coin_watchlist cw on cwu.symbol=cw.symbol " +
  138. "left join coin_watchlist_other cwo on cwu.symbol=cwo.symbol WHERE cwu.user_id = #{userId} and cwu.delete_flag = 1" +
  139. "<if test=\"keyword != null and keyword != ''\">" +
  140. " and cwu.symbol like concat('%',#{keyword},'%')" +
  141. "</if>" +
  142. "<if test=\"symbol != null and symbol != ''\">" +
  143. " and cwu.symbol = #{symbol}" +
  144. "</if>" +
  145. "<if test=\"filterField != null and filterField != ''\">" +
  146. " and cwu.filter_flag = #{filterField}" +
  147. "</if>" +
  148. "<if test=\"trackCategoryField != null and trackCategoryField != ''\">" +
  149. " and cwu.track_category like concat('%',#{trackCategoryField},'%')" +
  150. "</if>" +
  151. "<if test=\"trackCategory2Field != null and trackCategory2Field != ''\">" +
  152. " and cwu.track_category2 like concat('%',#{trackCategory2Field},'%')" +
  153. "</if>" +
  154. "<if test=\"cexFilterField != null and cexFilterField != ''\">" +
  155. " <choose>" +
  156. " <when test=\" cexFilterName == 'cwo.cex_spot' \">" +
  157. " and substring(cwo.cex_spot,#{cexFilterIndex},1) = '1'" +
  158. " </when>" +
  159. " <otherwise>" +
  160. " and substring(cwo.cex_perpetual,#{cexFilterIndex},1) = '1'" +
  161. " </otherwise>" +
  162. " </choose>" +
  163. "</if>" +
  164. " order by " +
  165. "<foreach collection='sortField' item='sf' index=\"index\" separator=\",\">" +
  166. " ${sf} ${sort}" +
  167. " </foreach>" +
  168. "</script>"})
  169. List<CoinWatchlist> findWatchlistList2ByUserId(Map<String, Object> params);
  170. @Update("update coin_watchlist set cmc_id=#{cmcId},total_market_ranking=#{totalMarketRanking},total_market_value=#{totalMarketValue}," +
  171. "mark_price=#{markPrice},price_change_percentage_24h=#{priceChangePercentage24h},highest_historical_price=#{highestHistoricalPrice},ath_change_percentage=#{athChangePercentage},atl_change_percentage=#{atlChangePercentage},lowest_historical_price=#{lowestHistoricalPrice}," +
  172. "highest_historical_date=#{highestHistoricalDate},lowest_historical_date=#{lowestHistoricalDate},increase_multiple=#{increaseMultiple}," +
  173. "coingecko_url=#{coingeckoUrl},cmc_url=#{cmcUrl},feixiaohao_url=#{feixiaohaoUrl},modify_time=now() where id = #{id}")
  174. int updateCoinWatchlist(CoinWatchlist coinWatchlist);
  175. @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) " +
  176. "VALUES (#{symbol}, #{maxSupply}, #{circulatingSupply}, #{circulatingRate}, #{totalSupply}, #{marketCap}, #{fullyDilutedMarketCap}, now(), now())" +
  177. " ON DUPLICATE KEY UPDATE max_supply=values(max_supply),circulating_supply=values(circulating_supply),circulating_rate=values(circulating_rate),total_supply=values(total_supply)" +
  178. ",market_cap=values(market_cap),fully_diluted_market_cap=values(fully_diluted_market_cap),modify_time=now()")
  179. int insertOrUpdateCoinWatchlistOther(CoinWatchlistOther coinWatchlistOther);
  180. @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')")
  181. List<CoinWatchlistOther> findAllCoinWatchlistOther();
  182. @Select("select * from coin_watchlist_other where symbol = #{symbol} and delete_flag = 1")
  183. CoinWatchlistOther findWatchlistOtherBySymbol(String symbol);
  184. @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")
  185. CoinWatchlistOther findWatchlistOtherBySymbol2(String symbol);
  186. @Insert({"<script>" +
  187. "INSERT INTO coin_watchlist_other(symbol,cex_spot,cex_perpetual,create_time,modify_time)" +
  188. " VALUES " +
  189. "<foreach collection='collection' item='cwo' index=\"index\" separator=\",\">" +
  190. " (#{cwo.symbol},#{cwo.cexSpot},#{cwo.cexPerpetual},now(),now())" +
  191. " </foreach>" +
  192. " ON DUPLICATE KEY UPDATE cex_spot=values(cex_spot),cex_perpetual=values(cex_perpetual),modify_time=now()" +
  193. "</script>"})
  194. int insertOrUpdateCoinWatchlistOtherList(Collection<CoinWatchlistOther> coinWatchlistOtherList);
  195. @Update({"<script>" +
  196. "update coin_watchlist_user " +
  197. "<set>" +
  198. "<if test=\"score != null and score != ''\">" +
  199. " score = #{score}," +
  200. "</if>" +
  201. "<if test=\"remark != null and remark != ''\">" +
  202. " remark = #{remark}," +
  203. "</if>" +
  204. "modify_time=now()" +
  205. "</set>" +
  206. "where user_id = #{userId} and symbol = #{symbol}" +
  207. "</script>"})
  208. int updateCoinWatchlistRemarkAndScore(CoinWatchlist coinWatchlist);
  209. @Select("select * from coin_watchlist where symbol = #{symbol} and delete_flag = 1")
  210. CoinWatchlist findWatchlistBySymbol(String symbol);
  211. @Select("select cwu.*,cw.cmc_id,cw.cmc_url,cw.coingecko_id,cw.coingecko_url,cw.feixiaohao_url" +
  212. " from coin_watchlist_user cwu left join coin_watchlist cw on cwu.symbol=cw.symbol where cwu.user_id = #{userId} and cwu.symbol = #{symbol} and cwu.delete_flag = 1")
  213. CoinWatchlist findWatchlistUserBySymbolAndUserId(String symbol, Integer userId);
  214. @Insert({"<script>" +
  215. "INSERT INTO coin_cmc_map(cmc_id,cmc_rank,name,symbol,slug,is_active,status," +
  216. "first_historical_data,last_historical_data,platform,modify_time)" +
  217. " VALUES " +
  218. "<foreach collection='list' item='mt' index=\"index\" separator=\",\">" +
  219. " (#{mt.cmcId},#{mt.cmcRank},#{mt.name},#{mt.symbol},#{mt.slug},#{mt.isActive},#{mt.status}," +
  220. "#{mt.firstHistoricalData},#{mt.lastHistoricalData},#{mt.platform},now())" +
  221. " </foreach>" +
  222. " ON DUPLICATE KEY UPDATE cmc_rank=values(cmc_rank),name=values(name),symbol=values(symbol),slug=values(slug)," +
  223. "is_active=values(is_active),status=values(status),first_historical_data=values(first_historical_data),last_historical_data=values(last_historical_data),modify_time=now()" +
  224. "</script>"})
  225. void insertCmcMapList(List<CoinCmcMap> cmcMapList);
  226. @Select({"<script>" +
  227. "select * from coin_cmc_map WHERE 1 = 1" +
  228. "<if test=\"keyword != null and keyword != ''\">" +
  229. " and (name like concat('%',#{keyword},'%') or symbol like concat('%',#{keyword},'%') or slug like concat('%',#{keyword},'%'))" +
  230. "</if>" +
  231. "<if test=\"filterField != null and filterField != ''\">" +
  232. " and status = #{filterField}" +
  233. "</if>" +
  234. " order by ${sortField} ${sort}" +
  235. "</script>"})
  236. List<CoinCmcMap> findCmcMapList(Map<String, Object> params);
  237. @Select("SELECT * FROM coin_monitor_job WHERE delete_flag = 1")
  238. @MapKey("job_name")
  239. Map<String, JSONObject> findMonitorJobConfig();
  240. @Insert("INSERT INTO coin_watchlist(cmc_id, symbol, coingecko_id, coingecko_url, cmc_url, feixiaohao_url, create_time, modify_time, delete_flag) " +
  241. "VALUES (#{cmcId}, #{symbol}, #{coingeckoId}, #{coingeckoUrl}, #{cmcUrl}, #{feixiaohaoUrl}, now(), now(), 1)" +
  242. " ON DUPLICATE KEY UPDATE cmc_id=values(cmc_id),coingecko_id=values(coingecko_id)" +
  243. ",coingecko_url=values(coingecko_url),cmc_url=values(cmc_url),feixiaohao_url=values(feixiaohao_url),modify_time=now(),delete_flag=1")
  244. int insertOrUpdateWatchlist(CoinWatchlist coinWatchlist);
  245. @Insert("INSERT INTO coin_watchlist_user(symbol, user_id, track_category, track_category2, issuing_date, issuing_days, filter_flag, create_time, modify_time, delete_flag) " +
  246. "VALUES (#{symbol}, #{userId}, #{trackCategory}, #{trackCategory2}, #{issuingDate}, #{issuingDays}, #{filterFlag}, now(), now(), 1)" +
  247. " ON DUPLICATE KEY UPDATE track_category=values(track_category),track_category2=values(track_category2),issuing_date=values(issuing_date)," +
  248. "issuing_days=values(issuing_days),filter_flag=values(filter_flag),modify_time=now(),delete_flag=1")
  249. int insertOrUpdateWatchlistUser(CoinWatchlist coinWatchlist);
  250. @Insert({"<script>" +
  251. "INSERT INTO coin_binance_symbol(symbol,status,baseAsset,marginAsset,baseAssetPrecision,contractType,underlyingSubType," +
  252. "filters,orderTypes,timeInForce,liquidationFee,marketTakeBound,deliveryDate,onboardDate,modify_time)" +
  253. " VALUES " +
  254. "<foreach collection='list' item='cbs' index=\"index\" separator=\",\">" +
  255. " (#{cbs.symbol},#{cbs.status},#{cbs.baseAsset},#{cbs.marginAsset},#{cbs.baseAssetPrecision},#{cbs.contractType},#{cbs.underlyingSubType}," +
  256. "#{cbs.filters},#{cbs.orderTypes},#{cbs.timeInForce},#{cbs.liquidationFee},#{cbs.marketTakeBound},#{cbs.deliveryDate},#{cbs.onboardDate},now())" +
  257. " </foreach>" +
  258. " ON DUPLICATE KEY UPDATE status=values(status),baseAsset=values(baseAsset),marginAsset=values(marginAsset),baseAssetPrecision=values(baseAssetPrecision)," +
  259. "contractType=values(contractType),underlyingSubType=values(underlyingSubType),filters=values(filters),orderTypes=values(orderTypes)," +
  260. "timeInForce=values(timeInForce),liquidationFee=values(liquidationFee),marketTakeBound=values(marketTakeBound),deliveryDate=values(deliveryDate),onboardDate=values(onboardDate),modify_time=now()" +
  261. "</script>"})
  262. void insertCoinBinanceSymbolList(List<CoinBinanceSymbol> coinBinanceSymbolList);
  263. @Select({"<script>" +
  264. "select * from coin_binance_symbol WHERE 1 = 1" +
  265. "<if test=\"keyword != null and keyword != ''\">" +
  266. " and symbol like concat('%',#{keyword},'%')" +
  267. "</if>" +
  268. "<if test=\"status != null and status != ''\">" +
  269. " and status = #{status}" +
  270. "</if>" +
  271. "<if test=\"marginAsset != null and marginAsset != ''\">" +
  272. " and marginAsset = #{marginAsset}" +
  273. "</if>" +
  274. "<if test=\"contractType != null and contractType != ''\">" +
  275. " and contractType = #{contractType}" +
  276. "</if>" +
  277. " order by ${sortField} ${sort}" +
  278. "</script>"})
  279. List<CoinBinanceSymbol> findCoinBinanceSymbolListByParams(Map<String, Object> params);
  280. @Select("select orderId from coin_binance_order_history")
  281. List<String> findAllCoinBinanceOrderIdList();
  282. @Insert({"<script>" +
  283. "INSERT ignore INTO coin_binance_order_history(orderId,symbol,status,price,avgPrice,origQty,executedQty,cumQuote,timeInForce,type" +
  284. ",side,positionSide,stopPrice,workingType,origType,time,updateTime,commission,realizedPnl,modify_time)" +
  285. " VALUES " +
  286. "<foreach collection='list' item='p' index=\"index\" separator=\",\">" +
  287. " ( #{p.orderId}, #{p.symbol}, #{p.status}, #{p.price}, #{p.avgPrice}, #{p.origQty}, #{p.executedQty}, #{p.cumQuote}, #{p.timeInForce}, #{p.type}" +
  288. ", #{p.side}, #{p.positionSide}, #{p.stopPrice}, #{p.workingType}, #{p.origType}, #{p.time}, #{p.updateTime}, #{p.commission}, #{p.realizedPnl}, now())" +
  289. "</foreach>" +
  290. "</script>"})
  291. void insertOrUpdateBinanceOrderHistoryList(List<CoinBinanceOrderHistory> coinBinanceOrderHistoryList);
  292. @Select({"<script>" +
  293. "select cch.*,cec.category_name exchangeCategory from coin_currency_holding cch left join coin_exchange_category cec on cch.exchange_category_id=cec.id WHERE cch.delete_flag = 1" +
  294. "<if test=\"keyword != null and keyword != ''\">" +
  295. " and cch.symbol like concat('%',#{keyword},'%')" +
  296. "</if>" +
  297. "<if test=\"symbol != null and symbol != ''\">" +
  298. " and cch.symbol = #{symbol}" +
  299. "</if>" +
  300. "<if test=\"status != null and status != ''\">" +
  301. " and cch.status = #{status}" +
  302. "</if>" +
  303. "<if test=\"categoryField != null and categoryField != ''\">" +
  304. " and cch.exchange_category_id = #{categoryField}" +
  305. "</if>" +
  306. " order by " +
  307. "<foreach collection='sortField' item='sf' index=\"index\" separator=\",\">" +
  308. " ${sf} ${sort}" +
  309. " </foreach>" +
  310. "</script>"})
  311. List<CoinCurrencyHolding> findCurrentHoldingList(Map<String, Object> params);
  312. @Update("update coin_currency_holding set symbol=#{symbol},buy_price=#{buyPrice},current_price=#{currentPrice},change_percentage=#{changePercentage},buy_quantity=#{buyQuantity}," +
  313. "current_quantity=#{currentQuantity},buy_amount=#{buyAmount},current_amount=#{currentAmount},exchange_category_id=#{exchangeCategoryId},coingecko_id=#{coingeckoId},status=#{status}," +
  314. "remark=#{remark},buy_time=#{buyTime},modify_time=now() where id = #{id}")
  315. int updateCurrentHolding(CoinCurrencyHolding coinCurrencyHolding);
  316. @Select({"<script>" +
  317. "select sum(current_amount) from coin_currency_holding cch WHERE cch.delete_flag = 1" +
  318. "<if test=\"keyword != null and keyword != ''\">" +
  319. " and cch.symbol like concat('%',#{keyword},'%')" +
  320. "</if>" +
  321. "<if test=\"symbol != null and symbol != ''\">" +
  322. " and cch.symbol = #{symbol}" +
  323. "</if>" +
  324. "<if test=\"status != null and status != ''\">" +
  325. " and cch.status = #{status}" +
  326. "</if>" +
  327. "<if test=\"categoryField != null and categoryField != ''\">" +
  328. " and cch.exchange_category_id = #{categoryField}" +
  329. "</if>" +
  330. "</script>"})
  331. BigDecimal getCurrentHoldingTotalAmout(Map<String, Object> params);
  332. @Select({"<script>" +
  333. "select bi.*,bc.name categoryName from bookmark_info bi left join bookmark_category bc on bi.category_id=bc.id WHERE bi.delete_flag = 1 and bc.delete_flag = 1" +
  334. "<if test=\"keyword != null and keyword != ''\">" +
  335. " and (bi.title like concat('%',#{keyword},'%') or bi.remark like concat('%',#{keyword},'%') or bi.tags like concat('%',#{keyword},'%'))" +
  336. "</if>" +
  337. "<if test=\"categoryField != null and categoryField != ''\">" +
  338. " and bi.category_id = #{categoryField}" +
  339. "</if>" +
  340. "<if test=\"accountId != null and accountId != ''\">" +
  341. " and bi.account_id = #{accountId}" +
  342. "</if>" +
  343. "<if test=\"isFavorite != null and isFavorite != ''\">" +
  344. " and bi.is_favorite = #{isFavorite}" +
  345. "</if>" +
  346. "<if test=\"status != null and status != ''\">" +
  347. " and bi.status = #{status}" +
  348. "</if>" +
  349. " order by " +
  350. "<foreach collection='sortField' item='sf' index=\"index\" separator=\",\">" +
  351. " ${sf} ${sort}" +
  352. " </foreach>" +
  353. "</script>"})
  354. List<BookmarkInfo> findBookmarkList(Map<String, Object> params);
  355. @Select("select 1 from coin_users where username = #{username} and password = #{password} and delete_flag = 1")
  356. Integer existUserByUsernameAndPassword(String username, String password);
  357. @Select("select 1 from coin_users where username = #{userName} and delete_flag = 1")
  358. Integer existUserByUsername(String userName);
  359. @Select("select * from coin_users where username = #{userName} and delete_flag = 1")
  360. JSONObject findUserByUsername(String userName);
  361. }