liuxiaolong
2019-08-23 9dbf52d751cd6b347210550eb5217c3eb2c0306d
controllers/dbtablesCon.go
@@ -63,6 +63,25 @@
      util.ResponseFormat(c,code.RequestParamError,"参数有误")
      return
   }
   currentTime := time.Now()
   startTime := dbtable.StartTime
   endTime := ""
   if dbtable.EndTime != "" {
      endTime = dbtable.EndTime
   }
   st, _ := time.ParseInLocation("2006-01-02 15:04:05", startTime, time.Local)
   if endTime != "" {
      et, _ := time.ParseInLocation("2006-01-02 15:04:05", endTime, time.Local)
      if et.After(currentTime) && st.Before(currentTime) {
         dbtable.Enable = 1
      } else {
         dbtable.Enable = 0
      }
   } else if st.Before(currentTime) && endTime == "" {
      dbtable.Enable = 1
   } else {
      dbtable.Enable = 0
   }
   paramBody := util.Struct2Map(dbtable)
   var tApi dbapi.DbTableApi
   b, data := tApi.UpdateDbTables(paramBody)
@@ -89,6 +108,37 @@
   //}
}
type DbTStatusVo struct {
   Id string `json:"id"`
   Enable int `json:"enable"`
}
// @Summary 修改底库状态
// @Description 修改同步或本地库底库状态
// @Accept  json
// @Produce json
// @Tags dbtable
// @Param obj body controllers.DbTStatusVo true "底库状态修改参数"
// @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true}"
// @Failure 500 {string} json "{"code":500,  msg:"返回错误信息", success:false}"
// @Router /data/api-v/dbtable/updateDbTableStatus [POST]
func (dbt DbTableController) UpdateDbTableStatus(c *gin.Context) {
   var ds DbTStatusVo
   err := c.BindJSON(&ds)
   if err !=nil || ds.Id == "" || (ds.Enable !=0 && ds.Enable !=1)  {
      util.ResponseFormat(c,code.RequestParamError,"参数有误")
      return
   }
   var dtApi dbapi.DbTableApi
   b,_ := dtApi.UpdateDbTableStatus(ds.Id, ds.Enable)
   if b {
      util.ResponseFormat(c,code.UpdateSuccess,"更新成功")
   } else {
      util.ResponseFormat(c,code.ComError,"更新失败")
   }
}
func UpdateEndTime(id string) (flag bool) {
   flag = false
   url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport +