fix dbtable update status when time invalid
| | |
| | | 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 为true才允许开启 |
| | | if !b { |
| | | util.ResponseFormat(c,code.UpdateFail,"当前不允许启用") |
| | | return |
| | | } |
| | | } |
| | | |
| | | b,_ := dtApi.UpdateDbTableStatus(ds.Id, ds.Enable) |
| | | if b { |