Эх сурвалжийг харах

add:增加insertOrUpdateWatchlist v1

tujidelv 1 жил өмнө
parent
commit
1598dd4851

+ 59 - 0
src/main/java/top/lvzhiqiang/controller/CoinController.java

@@ -6,6 +6,7 @@ import org.springframework.web.multipart.MultipartFile;
 import top.lvzhiqiang.config.InitRunner;
 import top.lvzhiqiang.dto.R;
 import top.lvzhiqiang.entity.CoinApiConfig;
+import top.lvzhiqiang.entity.CoinWatchlist;
 import top.lvzhiqiang.entity.FileImage;
 import top.lvzhiqiang.enumeration.ResultCodeEnum;
 import top.lvzhiqiang.exception.BusinessException;
@@ -244,4 +245,62 @@ public class CoinController {
             return R.error().message(e.getMessage());
         }
     }
+
+    /**
+     * insertOrUpdateWatchlist
+     *
+     * @author lvzhiqiang
+     * 2024/1/20 15:42
+     */
+    @RequestMapping("/insertOrUpdateWatchlist")
+    @ResponseBody
+    public R insertOrUpdateWatchlist(String symbol, String trackCategory, String issuingDate, Long cmcId, String coingeckoId, Integer filterFlag, String crudType) {
+        if (StringUtils.isEmpty(crudType)) {
+            throw new ParameterException("crudType为空!");
+        }
+
+        if (StringUtils.isEmpty(symbol)) {
+            throw new ParameterException("symbol为空!");
+
+        }
+
+        if ("1".equals(crudType)) {
+            // 新增
+            if (StringUtils.isEmpty(trackCategory) || StringUtils.isEmpty(issuingDate) || null == cmcId || StringUtils.isEmpty(coingeckoId) || null == filterFlag) {
+                throw new ParameterException("参数为空!");
+            }
+
+            CoinWatchlist coinWatchlist = new CoinWatchlist();
+            coinWatchlist.setSymbol(symbol);
+            coinWatchlist.setTrackCategory(trackCategory);
+            coinWatchlist.setIssuingDate(LocalDate.parse(issuingDate, DateUtils.dateFormatter));
+            coinWatchlist.setCmcId(cmcId);
+            coinWatchlist.setCoingeckoId(coingeckoId);
+            coinWatchlist.setFilterFlag(filterFlag);
+
+            coinMapper.insertOrUpdateWatchlist(coinWatchlist);
+        } else if ("2".equals(crudType)) {
+            // 修改
+            CoinWatchlist coinWatchlist = coinMapper.findWatchlistBySymbol(symbol);
+            if (coinWatchlist == null) {
+                throw new BusinessException(ResultCodeEnum.UNKNOWN_ERROR.getCode(), "symbol 不存在!");
+            }
+
+            if (StringUtils.isNotEmpty(trackCategory)) {
+                coinWatchlist.setTrackCategory(trackCategory);
+            }
+            if (StringUtils.isNotEmpty(issuingDate)) {
+                coinWatchlist.setIssuingDate(LocalDate.parse(issuingDate, DateUtils.dateFormatter));
+            }
+            if (null != cmcId) {
+                coinWatchlist.setCmcId(cmcId);
+            }
+            if (null != filterFlag) {
+                coinWatchlist.setFilterFlag(filterFlag);
+            }
+            coinMapper.insertOrUpdateWatchlist(coinWatchlist);
+        }
+
+        return R.ok().data("success");
+    }
 }

+ 2 - 0
src/main/java/top/lvzhiqiang/entity/CoinWatchlist.java

@@ -130,4 +130,6 @@ public class CoinWatchlist implements Serializable {
      * 删除标志(1:正常,2:已删除)
      */
     private Integer deleteFlag;
+
+    private Integer filterFlag;
 }

+ 6 - 1
src/main/java/top/lvzhiqiang/mapper/CoinMapper.java

@@ -107,7 +107,7 @@ public interface CoinMapper {
     @Update("update coin_watchlist set remark=#{remark},modify_time=now() where symbol = #{symbol}")
     int updateCoinWatchlistRemark(CoinWatchlist coinWatchlist);
 
-    @Select("select * from coin_watchlist where symbol = #{symbol}")
+    @Select("select * from coin_watchlist where symbol = #{symbol} and delete_flag = 1")
     CoinWatchlist findWatchlistBySymbol(String symbol);
 
 
@@ -164,4 +164,9 @@ public interface CoinMapper {
     @Select("SELECT * FROM coin_monitor_job WHERE delete_flag = 1")
     @MapKey("job_name")
     Map<String, JSONObject> findMonitorJobConfig();
+
+    @Insert("INSERT INTO coin_watchlist(cmc_id, symbol, track_category, issuing_date, coingecko_id, filter_flag, create_time, modify_time) " +
+            "VALUES (#{cmcId}, #{symbol}, #{trackCategory}, #{issuingDate}, #{coingeckoId}, #{filterFlag}, now(), now())" +
+            " ON DUPLICATE KEY UPDATE cmc_id=values(cmc_id),track_category=values(track_category),issuing_date=values(issuing_date),coingecko_id=values(coingecko_id),filter_flag=values(filter_flag),modify_time=now()")
+    int insertOrUpdateWatchlist(CoinWatchlist coinWatchlist);
 }

+ 35 - 4
src/main/resources/static/coin.html

@@ -85,7 +85,7 @@
         white-space: nowrap;
     }
 
-    .quiet-loading, .uploadImgs-loading {
+    .quiet-loading, .uploadImgs-loading, .watchlist-loading {
         display: none;
         position: absolute;
         z-index: 999;
@@ -223,18 +223,18 @@
             <input type="text" style="width: 100px;padding-top: 3px;" id="apis-quiet-div-watchlist-pages" disabled="disabled" value="999999">
             <input type="text" style="width: 100px;padding-top: 3px;" id="apis-quiet-div-watchlist-keyword" placeholder="名称关键词">
             <select id="apis-quiet-div-watchlist-filterField" style="height: 24px;">
-                <option value="">--</option>
-                <option value="1">未过滤</option>
                 <option value="2">已过滤</option>
+                <option value="1">未过滤</option>
                 <option value="3">哈哈哈</option>
+                <option value="">--</option>
             </select>
             <select id="apis-quiet-div-watchlist-trackCategoryField" style="height: 24px;">
                 <option value="">--</option>
             </select>
             <select id="apis-quiet-div-watchlist-sortField" style="height: 24px;">
+                <option value="price_change_percentage_24h">24H涨跌幅</option>
                 <option value="total_market_value">流通市值</option>
                 <option value="total_market_ranking">市值排名</option>
-                <option value="price_change_percentage_24h">24H涨跌幅</option>
                 <option value="increase_multiple">涨幅倍数</option>
                 <option value="issuing_days">发行天数</option>
             </select>
@@ -381,6 +381,37 @@
             </form>
         </div>
     </div>
+    <div style="display: flex;">
+        <div style="margin-right:20px;">
+            <div class="watchlist-loading"><img src='cover/loading.gif'></div>
+            <span class="font">InsertOrUpdateWatchlist</span>
+            <span id="insertOrUpdateWatchlistAlert" style="margin-left: 10px;font-size: 13px;"></span>
+            <form method="post" action="coin/insertOrUpdateWatchlistAlert" onsubmit="return false;" id="insertOrUpdateWatchlist">
+                <span>名称</span>
+                <input type="text" name="symbol" placeholder="不可为空"/>
+                <span>赛道分类</span>
+                <input type="text" name="trackCategory" placeholder="可为空"/>
+                <span>发行日期</span>
+                <input type="text" name="issuingDate" placeholder="可为空"/>
+                <span>cmcId</span>
+                <input type="text" name="cmcId" placeholder="可为空"/>
+                <span>coingeckoId</span>
+                <input type="text" name="coingeckoId" placeholder="可为空"/>
+                <span>filterFlag</span>
+                <select id="apis-quiet-div-watchlist-filterFlagField" style="height: 24px;" name="filterFlag">
+                    <option value="2">已过滤</option>
+                    <option value="1">未过滤</option>
+                    <option value="3">哈哈哈</option>
+                </select>
+                <select id="apis-quiet-div-watchlist-crudType" style="height: 24px;" name="crudType">
+                    <option value="1">insert</option>
+                    <option value="2">update</option>
+                </select>
+                <input type="button" value="提交" onclick="insertOrUpdateWatchlistSubmit()">
+                <input type="reset" value="重置">
+            </form>
+        </div>
+    </div>
 </div>
 
 <div id="watchlistpreview">

+ 273 - 22
src/main/resources/static/css/my-av.css

@@ -21,6 +21,33 @@
     animation: savOpenAnim 0.15s;
 }
 
+.savCloseAnim {
+    animation: savCloseAnim 0.15s;
+}
+
+@keyframes savOpenAnim {
+    0% {
+        transform: scale(0.5);
+        background: rgba(255, 255, 255, .1);
+    }
+    100% {
+        transform: scale(1);
+        background: rgba(255, 255, 255, .8);
+    }
+}
+
+@keyframes savCloseAnim {
+    0% {
+        opacity: 1;
+        transform: scale(1);
+    }
+    100% {
+        opacity: 0;
+        transform: scale(0.5);
+    }
+}
+
+/* 链接相关 */
 .savlink {
     margin: 4px 4px 4px 4px;
     border-radius: 4px;
@@ -34,12 +61,43 @@
     user-select: none;
 }
 
+.savlink:not(.RPdisabled):hover {
+    background: aliceblue;
+    box-shadow: -2px -2px 6px rgb(255 255 255 / 50%), 1px 1px 2px rgb(70 70 70 / 50%), inset -2px -2px 6px rgb(255 255 255 / 50%), inset 2px 2px 6px rgb(100 100 100 / 50%);
+}
+
 .sav-menu .savlink a {
     color: #459df5;
     text-decoration: none;
     transition: 0.4s;
 }
 
+.sav-menu .savlink:not(.RPdisabled):hover a {
+    color: #039cff;
+    text-shadow: 0 0 #7cfb80;
+}
+
+avdivsinfo a, avdivsinfo a:visited, avdivsinfo a:link {
+    color: #000;
+    transition: 0.2s;
+}
+
+avdivsinfo a:hover {
+    color: #850000;
+}
+
+/* 相关页面按钮 */
+.relatedPage.RPdisabled {
+    cursor: default;
+}
+
+.relatedPage.RPdisabled a {
+    cursor: default;
+    pointer-events: none;
+    text-decoration: line-through;
+    color: #333;
+}
+
 avdivsinfo {
     text-indent: -2.5em;
     line-height: normal;
@@ -53,16 +111,22 @@ avdivsinfo avdiv {
     padding-left: 2.5em;
 }
 
-avdivsinfo a, avdivsinfo a:visited, avdivsinfo a:link {
-    color: #000;
-    transition: 0.2s;
+avdivsinfo .avInfoTags, avdivsinfo .avInfoSeries {
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
 }
 
-avdivimg {
-    position: relative;
+avdiverror {
     display: block;
-    text-indent: initial;
-    user-select: none;
+    margin-top: 10px;
+    padding-left: 10px;
+}
+
+avdiverror avdiv {
+    display: block;
+    margin-bottom: 5px;
+    transition: 0.2s;
 }
 
 avdiv .avimg {
@@ -79,8 +143,65 @@ avdiv .avimg {
     transition-timing-function: ease-out;
 }
 
-.savCloseAnim {
-    animation: savCloseAnim 0.15s;
+avdiv .imageBig {
+    max-height: 600px;
+    transform: scale(1.3);
+    border-radius: 10px;
+    border-top: 2px solid #fff;
+    border-left: 2px solid #fff;
+    box-shadow: -2px -2px 4px rgb(160 160 160), 4px 4px 4px rgb(70 70 70 / 60%);
+}
+
+avdiv .imageBig:hover {
+    box-shadow: -4px -4px 8px rgb(160 160 160), 6px 6px 8px rgb(70 70 70 / 60%);
+}
+
+savdiv.sav-id {
+    transition: 0.5s;
+}
+
+savdiv.sav-id, savmagnet {
+    cursor: pointer;
+}
+
+u:has(savdiv) {
+    text-decoration: none;
+}
+
+.yesJellyfin {
+    color: #459df5
+}
+
+.noJellyfin {
+    text-decoration: line-through;
+}
+
+avspan svg {
+    height: 14px;
+    position: relative;
+    top: 0.1em;
+    opacity: 0.8;
+    transition: 0.2s;
+    display: inline-block;
+    vertical-align: baseline;
+}
+
+avspan svg:hover {
+    opacity: 1;
+}
+
+avdiv.sav-menu .avimg.savImgError {
+    height: 200px;
+}
+
+/* 动画: 横线加载时的动画 */
+@keyframes sav-loading-animation {
+    from {
+        transform: translate(0, 0);
+    }
+    to {
+        transform: translate(50%, 0);
+    }
 }
 
 .savLoadingContainer {
@@ -109,6 +230,10 @@ avdiv .avimg {
     position: absolute;
 }
 
+.savLoading svg:last-child {
+    left: -50%;
+}
+
 .stop1, .stop3 {
     stop-color: #fff0;
 }
@@ -118,23 +243,149 @@ avdiv .avimg {
     transition: 1s;
 }
 
-.savLoading svg:last-child {
-    left: -50%;
-}
-
 .stop2.javbusloading {
     stop-color: #71d99b;
 }
 
-avdiv .imageBig {
-    max-height: 600px;
-    transform: scale(1.3);
-    border-radius: 10px;
-    border-top: 2px solid #fff;
-    border-left: 2px solid #fff;
-    box-shadow: -2px -2px 4px rgb(160 160 160), 4px 4px 4px rgb(70 70 70 / 60%);
+.stop2.javdbloading {
+    stop-color: #cccc00;
 }
 
-avdiv .imageBig:hover {
-    box-shadow: -4px -4px 8px rgb(160 160 160), 6px 6px 8px rgb(70 70 70 / 60%);
+.stop2.fc2loading {
+    stop-color: #F8A01C;
+}
+
+/* 预览视频 */
+avdivimg {
+    position: relative;
+    display: block;
+    text-indent: initial;
+    user-select: none;
+}
+
+.avimg-preview-button {
+    width: 40px;
+    height: 40px;
+    border-radius: 40px;
+    background: #00e7ff00;
+    opacity: 0.8;
+    position: absolute;
+    top: 0;
+    bottom: 0;
+    left: 0;
+    right: 0;
+    margin: auto;
+    z-index: 1;
+    transition: 0.4s;
+    animation: savOpenAnim2 0.15s;
+
+}
+
+@keyframes huerotate {
+    0% {
+        filter: hue-rotate(0deg);
+    }
+    100% {
+        filter: hue-rotate(360deg);
+    }
+}
+
+.avimg-preview-button:hover {
+    opacity: 1;
+    background: #00e7ff;
+}
+
+.avimg-preview-button:after {
+    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'  viewBox='0 0 512 512'%3E%3Cpath d='M448 255c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' fill=''  fill-opacity='0.8' stroke='none'/%3E%3Cpath fill='white' d='M216.32  334.44l114.45-69.14a10.89 10.89 0 000-18.6l-114.45-69.14a10.78 10.78 0 00-16.32 9.31v138.26a10.78 10.78 0 0016.32 9.31z'/%3E%3C/svg%3E");
+    background-repeat: no-repeat;
+    background-position: 50%;
+    background-size: 48px 48px;
+    content: "";
+    display: block;
+    position: absolute;
+    top: 0;
+    bottom: 0;
+    left: 0;
+    right: 0;
+    /* border: 2px solid;
+    border-image:linear-gradient(45deg,gold,deeppink)1; */
+}
+
+.savCloseAnim2, avdivimg:has(avdivVideo) .avimg-preview-button, avdivimg:has(.imageBig) .avimg-preview-button {
+    animation: savCloseAnim2 0.15s;
+    animation-fill-mode: forwards;
+}
+
+avdivVideo {
+    position: absolute;
+    top: 0;
+    bottom: 0;
+    left: 0;
+    right: 0;
+    animation: savOpenAnim2 0.15s;
+}
+
+avdivimg video {
+    width: 100%;
+    height: 100%;
+    object-fit: contain;
+    background: #fff9;
+    backdrop-filter: blur(5px);
+    border-radius: 4px;
+}
+
+.savVideoClose {
+    position: absolute;
+    right: 0;
+    top: 0;
+    padding: 7px 10px 7px 97%;
+    border-radius: 4px;
+    cursor: pointer;
+    transition: 0.4s;
+}
+
+iframe + .savVideoClose {
+    color: #fff;
+}
+
+.savVideoClose:hover {
+    color: red;
+    background: #fff8;
+}
+
+avdivvideo iframe {
+    width: 100%;
+    height: 100%;
+    border: none;
+}
+
+@keyframes savOpenAnim2 {
+    0% {
+        opacity: 0;
+        transform: scale(0);
+    }
+    100% {
+        opacity: 1;
+        transform: scale(1);
+    }
+}
+
+@keyframes savCloseAnim2 {
+    0% {
+        opacity: 1;
+        transform: scale(1);
+    }
+    100% {
+        opacity: 0;
+        transform: scale(0);
+    }
+}
+
+/* 对其他网站的一些更改 */
+.fc2-embed-video-player.opt_logo .fc2-video-player .fc2-video-metadata {
+    display: none !important;
+}
+
+.fc2-video-player-logo {
+    display: none !important;
 }

+ 35 - 0
src/main/resources/static/js/my-coin.js

@@ -615,4 +615,39 @@ function uploadImgsSubmit(){
             console.log("uploadImgs-submit error," + data);
         }
     });
+}
+
+function insertOrUpdateWatchlistSubmit(){
+    var fromData = new FormData($("#insertOrUpdateWatchlist")[0]);
+    $.ajax({
+        url: "coin/insertOrUpdateWatchlist", //请求的url地址
+        dataType: "json", //返回格式为json
+        data: fromData, //参数值
+        type: "post", //请求方式
+        processData: false,// 告诉jQuery不要去处理发送的数据
+        contentType: false,// 告诉jQuery不要去设置Content-Type请求头
+        async: true, //请求是否异步,默认为异步,这也是ajax重要特性
+        success: function (data) {
+            $(".watchlist-loading").css("display", "none");
+            //请求成功时处理
+            if (data != null && $.trim(data) != "" && data.success) {
+                $("#insertOrUpdateWatchlistAlert").html(JSON.stringify(data.data));
+                var quietSelectOption = $("#apis-quiet-select option:selected");
+                if ($(quietSelectOption).attr("nameen") === 'watchlist') {
+                    $(".apis-quiet-div-button2").click();
+                }
+            } else {
+                $("#insertOrUpdateWatchlistAlert").html(data.message);
+            }
+        },
+        beforeSend: function () {
+            $(".watchlist-loading").css("display", "block");
+        },
+        complete: function () {
+        },
+        error: function (data) {
+            //请求出错处理
+            console.log("insertOrUpdateWatchlist-submit error," + data);
+        }
+    });
 }