ソースを参照

新增数据发布时间校验

mxs 1 年間 前
コミット
420385434e

+ 0 - 2
src/util/config.go

@@ -1,7 +1,6 @@
 package util
 
 import (
-	red "github.com/go-redis/redis"
 	"mongodb"
 	qu "qfw/util"
 	"qfw/util/redis"
@@ -34,7 +33,6 @@ var (
 	RedisDelKey5    string
 	RedisSave       string // 新增数据保存信息
 
-	RedisCluster *red.ClusterClient
 )
 
 var (

+ 0 - 25
src/util/redisCluster.go

@@ -1,25 +0,0 @@
-package util
-
-import (
-	"context"
-	"github.com/go-redis/redis"
-	"time"
-)
-
-func NewClusterClient(adds []string) *redis.ClusterClient {
-	client := redis.NewClusterClient(&redis.ClusterOptions{
-		Addrs:        adds,
-		MaxRedirects: 5,
-		PoolSize:     10,
-		MaxRetries:   3,
-	})
-	return client
-}
-
-func Get(rdb *redis.ClusterClient, ctx context.Context, key string) *redis.StringCmd {
-	return rdb.Get(ctx, key)
-}
-
-func RedisClusterPut(rdb *redis.ClusterClient, ctx context.Context, key string, value interface{}, d time.Duration) *redis.StatusCmd {
-	return rdb.Set(ctx, key, value, d)
-}

+ 7 - 0
src/web/templates/repair/jy_create.html

@@ -100,6 +100,13 @@
             showMsg(msg)
             return;
         }
+        //发布时间校验
+        var publishtime = new Date(updata["publishtime"]).getTime();
+        var currentTimestamp = Date.now();
+        if(publishtime > currentTimestamp){
+            showMsg("发布时间过大");
+            return;
+        }
 
         var detail = document.getElementById('jsonDetail').value
         var tmp_detail = ''+detail

+ 4 - 1
src/web/templates/repair/jy_create_new.html

@@ -314,6 +314,10 @@
         if ($('#publishtime').find("input").val() != "") {
             var start = $('#publishtime').find("input").val();
             start = new Date(start).getTime() / 1000;
+            if(start > Date.now() / 1000){
+                alert("发布时间过大");
+                return;
+            }
             dataMap["publishtime"] = start;
         }else {
             dataMap["publishtime"] = ""
@@ -321,7 +325,6 @@
         dataMap["detail"] = $('#jsonDetail').val()
         dataMap["contenthtml"] = $('#jsonContentHtml').val()
         dataMap["summary"] = $('#summary').val()
-        console.log(dataMap)
         if (dataMap["title"] == "" || dataMap["site"] == "" || dataMap["href"] == "" || dataMap["channel"] == "" ||
             dataMap["publishtime"] == "" ||  dataMap["detail"] == "" || dataMap["contenthtml"] == "") {
             alert("请填写必须字段!");