sunty
2020-08-20 9d88c7c467f8d93af4aab9ba0b6d6c01c2ffc546
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package controllers
 
import (
    "basic.com/pubsub/esutil.git"
    "basic.com/valib/logger.git"
    "github.com/gin-gonic/gin"
    "strconv"
    "webserver/cache"
    "webserver/extend/code"
    "webserver/extend/config"
    "webserver/extend/util"
)
 
type Buckers struct {
}
 
func (b *Buckers) GetBuckets(c *gin.Context) {
    var info interface{}
    localConf, err := cache.GetServerInfo()
    if err != nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
        logger.Debug("localConfig is wrong!!!")
        util.ResponseFormat(c, code.ComError, "es config err")
        return
    }
    ip := localConf.AlarmIp
    port := strconv.Itoa(int(localConf.AlarmPort))
    c.BindJSON(&info)
    inf := info.(map[string]interface{})
    startTime := inf["startTime"].(string)
    endTime := inf["endTime"].(string)
    cameraId := inf["cameraId"].([]string)
    thresholdTime := inf["thresholdTime"].(float64)
    resDate, err := esutil.GetfaceDataBucketsBycameraIdAndTime(cameraId, startTime, endTime, thresholdTime, ip, port, config.EsInfo.EsIndex.AiOcean.IndexName)
    if err != nil {
        util.ResponseFormat(c, code.FailedQuery, err)
        return
    }
    util.ResponseFormat(c, code.Success, resDate)
}