From 01b491e465e6bcba4abc5b0b9d3d56c1549006e8 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期六, 31 八月 2019 16:34:03 +0800
Subject: [PATCH] fix dbtable update status when time invalid

---
 controllers/dbtablesCon.go |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/controllers/dbtablesCon.go b/controllers/dbtablesCon.go
index 9746d1d..e1e75bf 100644
--- a/controllers/dbtablesCon.go
+++ b/controllers/dbtablesCon.go
@@ -129,7 +129,35 @@
 		util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎")
 		return
 	}
+
 	var dtApi dbapi.DbTableApi
+	dts, err := dtApi.DbtablesById([]string{ds.Id})
+	if err !=nil || dts == nil {
+		util.ResponseFormat(c,code.RequestParamError,"搴曞簱涓嶅瓨鍦�")
+		return
+	}
+	if ds.Enable == 1 {
+		str := dts[0].StartTime
+		etr := dts[0].EndTime
+		ct := time.Now()
+		st, _ := time.ParseInLocation("2006-01-02 15:04:05", str, time.Local)
+		b := false
+		if etr != "" {
+			et,_ := time.ParseInLocation("2006-01-02 15:04:05", etr, time.Local)
+			if et.After(ct) && st.Before(ct) {
+				b = true
+			}
+		} else {
+			if st.Before(ct) {
+				b = true
+			}
+		}
+		//b 涓簍rue鎵嶅厑璁稿紑鍚�
+		if !b {
+			util.ResponseFormat(c,code.UpdateFail,"褰撳墠涓嶅厑璁稿惎鐢�")
+			return
+		}
+	}
 
 	b,_ := dtApi.UpdateDbTableStatus(ds.Id, ds.Enable)
 	if b {

--
Gitblit v1.8.0