sunty
2020-08-20 9d88c7c467f8d93af4aab9ba0b6d6c01c2ffc546
controllers/ruleTemplate.go
@@ -2,9 +2,6 @@
import (
   "basic.com/dbapi.git"
   "basic.com/pubsub/protomsg.git"
   "bytes"
   "encoding/json"
   "github.com/gin-gonic/gin"
   "github.com/gogo/protobuf/jsonpb"
   "webserver/extend/code"
@@ -21,12 +18,20 @@
   OrigName: true,
}
type RuleTemplateVo struct {
   Id             string             `json:"id"` //场景模板id
   Name           string             `json:"name"`                                           //模板名称
   Desc           string             `json:"desc"`                                           //场景描述
   Txt            string             `json:"txt"`                                             //场景策略规则组合文字
   Rules          string             `json:"rules"`                                   //具体的小规则集合
}
// @Summary 保存场景模板
// @Description 保存场景模板
// @Accept json
// @Produce json
// @Tags 场景模板
// @Param reqBody body models.RuleTemplate true "模板保存参数"
// @Param reqBody body controllers.RuleTemplateVo true "模板保存参数"
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
// @Router /data/api-v/template/rule/save [post]
@@ -100,20 +105,7 @@
   var api dbapi.RuleTemplateApi
   b, templates := api.FindAll()
   if b {
      var result protomsg.RuleTemplateList
      for _,r := range templates {
         result.List = append(result.List, &r)
      }
      var _buffer bytes.Buffer
      err := jsonpbMarshaler.Marshal(&_buffer, &result)
      if err == nil {
         jsonB := _buffer.Bytes()
         var m map[string]interface{}
         json.Unmarshal(jsonB, &m)
         util.ResponseFormat(c,code.Success, m)
         return
      }
      util.ResponseFormat(c,code.Success, templates)
   } else {
      util.ResponseFormat(c, code.ComError, "")
   }