|
|
@@ -12,7 +12,10 @@ import (
|
|
|
"log-server/service/log"
|
|
|
loging2 "log-server/service/log/loging"
|
|
|
"log-server/utils"
|
|
|
+ "net/url"
|
|
|
"strconv"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
type ApiLoging struct {
|
|
|
@@ -681,3 +684,69 @@ func (e *ApiLoging) GetErrDeviceLog(c *gin.Context) {
|
|
|
}, "获取成功", c)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// @Tags loging
|
|
|
+// @Summary 获取无忧token
|
|
|
+// @Security ApiKeyAuth
|
|
|
+// @accept application/json
|
|
|
+// @Produce application/json
|
|
|
+// @Param data body log2.DeviceLog true "设备异常数据接口"
|
|
|
+// @Success 200
|
|
|
+// @Router /loging/getWuYToken [Get]
|
|
|
+func (e *ApiLoging) GetWuYToken(c *gin.Context) {
|
|
|
+ type Data struct {
|
|
|
+ Token string `json:"token"`
|
|
|
+ }
|
|
|
+ var data Data
|
|
|
+ key := fmt.Sprintf("%s:wuYToken", time.Now().Format("2006-01-02"))
|
|
|
+ t, _ := global.GVA_REDIS.Get(c, key).Result()
|
|
|
+ if t != "" {
|
|
|
+ data.Token = t
|
|
|
+ response.OkWithDetailed(data, "获取成功", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ header := map[string]string{"Content-Type": "application/x-www-form-urlencoded"}
|
|
|
+ var (
|
|
|
+ params = url.Values{}
|
|
|
+ )
|
|
|
+ params.Set("username", "18408246387")
|
|
|
+ params.Set("password", "der123456")
|
|
|
+ params.Set("source", "3")
|
|
|
+ params.Set("auth", "none")
|
|
|
+ requestData := params.Encode()
|
|
|
+ reqUrl := "https://user.wuyouip.com/Sign/_In"
|
|
|
+ reqs, err := utils.Request("POST", reqUrl, strings.NewReader(requestData), header, nil)
|
|
|
+ if err != nil {
|
|
|
+ global.GVA_LOG.Error("获取失败!", zap.Error(err))
|
|
|
+ response.FailWithMessage("获取失败", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ token := reqs.Cookies()[1].Value
|
|
|
+ if token != "" {
|
|
|
+ token = "token=" + token
|
|
|
+ global.GVA_REDIS.Set(c, key, token, time.Hour*15)
|
|
|
+ }
|
|
|
+ data.Token = token
|
|
|
+ response.OkWithDetailed(data, "获取成功", c)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// @Tags loging
|
|
|
+// @Summary 中控上报异常信息
|
|
|
+// @Security ApiKeyAuth
|
|
|
+// @accept application/json
|
|
|
+// @Produce application/json
|
|
|
+// @Success 200 {object} response.Response{data=interface{}} "中控上报异常信息"
|
|
|
+// @Router /loging/supConErr [post]
|
|
|
+func (s *ApiLoging) SupConErr(c *gin.Context) {
|
|
|
+ var paramsInfo request.SupConErrRequest
|
|
|
+ _ = c.ShouldBindJSON(¶msInfo)
|
|
|
+ if paramsInfo.PcCode == "" || paramsInfo.Describe == "" {
|
|
|
+ global.GVA_LOG.Error("参数错误!")
|
|
|
+ response.FailWithMessage("参数错误", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ num := ServiceStatisticsLog.SupConErr(paramsInfo.PcCode, paramsInfo.Describe)
|
|
|
+ global.GVA_LOG.Warn(fmt.Sprintf("中控上报异常pc_code=%s 描述=%s", paramsInfo.PcCode, paramsInfo.Describe))
|
|
|
+ response.OkWithDetailed(num, "上报成功", c)
|
|
|
+}
|