| | |
| | | import ( |
| | | "basic.com/pubsub/esutil.git" |
| | | "basic.com/valib/logger.git" |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "strconv" |
| | | "webserver/cache" |
| | |
| | | "webserver/extend/util" |
| | | ) |
| | | |
| | | type ClearDataController struct{} |
| | | type DeleteDataController struct{} |
| | | |
| | | type clearParams struct { |
| | | type deleteParams struct { |
| | | StartTime string `json:"startTime"` |
| | | EndTime string `json:"endTime"` |
| | | } |
| | | |
| | | func (cdc *ClearDataController) ClearEsData(c *gin.Context) { |
| | | var cp clearParams |
| | | func (cdc *DeleteDataController) DeleteEsData(c *gin.Context) { |
| | | var cp deleteParams |
| | | localConf, err := cache.GetServerInfo() |
| | | if err != nil || localConf.AlarmIp == "" || localConf.ServerId == "" { |
| | | logger.Debug("localConfig is wrong!!!") |
| | |
| | | util.ResponseFormat(c, code.InvalidRequest, "数据已删除或该时间段无数据") |
| | | return |
| | | } |
| | | fmt.Println("asgdasgdjhas: ", ip, port, config.BasicFS.IndexName, startTime, endTime, analyServerId) |
| | | addRes, addErr := esutil.AddDelTask(ip, port, config.BasicFS.IndexName, startTime, endTime, analyServerId) |
| | | if addErr != nil { |
| | | util.ResponseFormat(c, code.InvalidRequest, "追加任务失败") |
| | | fmt.Println("错误为u: ", addErr) |
| | | util.ResponseFormat(c, code.InvalidRequest, "追加任务出错") |
| | | return |
| | | } |
| | | if addRes != true { |
| | | util.ResponseFormat(c, code.InvalidRequest, "追加任务失败") |
| | | return |
| | | } |
| | | deleteRes, deleteErr := esutil.DeleteAnalyServerData(ip, port, config.BasicFS.IndexName, startTime, endTime, analyServerId) |
| | | deleteRes, deleteErr := esutil.DeleteAnalyServerData(ip, port, config.EsInfo.EsIndex.AiOcean.IndexName, startTime, endTime, analyServerId) |
| | | if deleteErr != nil { |
| | | util.ResponseFormat(c, code.InvalidRequest, "数据删除失败") |
| | | util.ResponseFormat(c, code.InvalidRequest, "数据删除出错") |
| | | return |
| | | } |
| | | if deleteRes != true { |