|
@@ -541,7 +541,7 @@ func (c *DeviceController) DeviceWarning_Post() {
|
|
|
T_Text := c.GetString("T_Text")
|
|
|
T_time := c.GetString("T_time")
|
|
|
T_history, _ := c.GetInt("T_history") // TODO 后期废弃
|
|
|
- if len(T_time) == 0 && conf.UseNewWarningQuery {
|
|
|
+ if len(T_time) == 0 {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "时间格式错误"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
@@ -560,8 +560,8 @@ func (c *DeviceController) DeviceWarning_Post() {
|
|
|
T_year, T_month = date.Format("2006"), date.Format("01")
|
|
|
Wtab += "_" + T_year + "_" + T_month
|
|
|
warning, err = Warning.Read_Warning_ById_Backups(id, T_year, T_month)
|
|
|
- if err != nil && err.Error() != "<QuerySeter> no row found"{
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
+ if err != nil && err.Error() != "<QuerySeter> no row found" {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -574,20 +574,18 @@ func (c *DeviceController) DeviceWarning_Post() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
warning = Warning.Read_Warning_ById(int64(id))
|
|
|
if warning.Id > 0 {
|
|
|
warning.T_Text = T_Text
|
|
|
warning.T_State = 2
|
|
|
warning.UpdateTime = time.Now()
|
|
|
if is := Warning.Update_Warning(warning, "T_Text", "T_State", "UpdateTime"); !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
} else {
|
|
|
// 使用新的查询方式后 warning表不做更新
|
|
|
|
|
@@ -609,7 +607,7 @@ func (c *DeviceController) DeviceWarning_Post() {
|
|
|
Wtab += "_" + T_year + "_" + T_month
|
|
|
warningBackups, err := Warning.Read_Warning_ById_Backups(id, T_year, T_month)
|
|
|
if err != nil && err.Error() != "<QuerySeter> no row found" {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -640,7 +638,7 @@ func (c *DeviceController) DeviceWarning_Del() {
|
|
|
id, _ := c.GetInt("T_id")
|
|
|
T_time := c.GetString("T_time")
|
|
|
T_history, _ := c.GetInt("T_history") // TODO 后期废弃
|
|
|
- if len(T_time) == 0 && conf.UseNewWarningQuery {
|
|
|
+ if len(T_time) == 0 {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "时间格式错误"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
@@ -658,19 +656,22 @@ func (c *DeviceController) DeviceWarning_Del() {
|
|
|
T_year, T_month = date.Format("2006"), date.Format("01")
|
|
|
Wtab += "_" + T_year + "_" + T_month
|
|
|
|
|
|
- warning, err = Warning.Read_Warning_ById_Backups(id, T_year, T_month)
|
|
|
- if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
+ warningBackups, err := Warning.Read_Warning_ById_Backups(id, T_year, T_month)
|
|
|
+ if err != nil && err.Error() != "<QuerySeter> no row found" {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- warning.T_State = 0
|
|
|
- warning.UpdateTime = time.Now()
|
|
|
- if is := Warning.Update_Warning_Backups(warning, T_year, T_month); !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
|
|
|
- c.ServeJSON()
|
|
|
- return
|
|
|
+ if warningBackups.Id > 0 {
|
|
|
+ warning.T_State = 0
|
|
|
+ warning.UpdateTime = time.Now()
|
|
|
+ if is := Warning.Update_Warning_Backups(warning, T_year, T_month); !is {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
warning = Warning.Read_Warning_ById(int64(id))
|
|
|
if warning.Id > 0 {
|
|
|
warning.T_State = 0
|
|
@@ -681,25 +682,24 @@ func (c *DeviceController) DeviceWarning_Del() {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
+ // 删除主表
|
|
|
warning = Warning.Read_Warning_ById(int64(id))
|
|
|
if warning.Id > 0 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
- c.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
- warning.T_State = 0
|
|
|
- if is := Warning.Update_Warning(warning, "T_State"); !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
|
|
|
- c.ServeJSON()
|
|
|
- return
|
|
|
+ warning.T_State = 0
|
|
|
+ if is := Warning.Update_Warning(warning, "T_State"); !is {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- date := warning.T_Ut
|
|
|
+ // 删除分表
|
|
|
+ date, err := time.Parse("2006-01-02 15:04:05", T_time)
|
|
|
T_year, T_month = date.Format("2006"), date.Format("01")
|
|
|
Wtab += "_" + T_year + "_" + T_month
|
|
|
warningBackups, err := Warning.Read_Warning_ById_Backups(id, T_year, T_month)
|
|
|
if err != nil && err.Error() != "<QuerySeter> no row found" {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -707,7 +707,7 @@ func (c *DeviceController) DeviceWarning_Del() {
|
|
|
warningBackups.T_State = 0
|
|
|
warningBackups.UpdateTime = time.Now()
|
|
|
if is := Warning.Update_Warning_Backups(warningBackups, T_year, T_month); !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|