| | |
| | | TaskName string `db:"task_name" json:"taskName"` |
| | | } |
| | | |
| | | type TaskAggregate struct { |
| | | ID int64 `gorm:"column:task_id" json:"id"` |
| | | Name string `gorm:"column:task_name" json:"name"` |
| | | IsDelete int8 `json:"isDelete"` |
| | | } |
| | | |
| | | type TaskM struct { |
| | | TaskId int64 `db:"task_id" json:"taskId"` |
| | | TaskName string `db:"task_name" json:"taskName"` |
| | |
| | | } |
| | | |
| | | // 查询列表数据 |
| | | func GetAllTask() (items []Task, err error) { |
| | | func GetAllTask() (items []TaskAggregate, err error) { |
| | | // 主查询SQL |
| | | sqlStr := fmt.Sprintf(` |
| | | SELECT task_id, task_name |
| | |
| | | func (cc CameraController) GetAllTasks(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply { |
| | | //绑定json和结构体 |
| | | |
| | | var tasks []models.Task |
| | | var tasks []models.TaskAggregate |
| | | tasks, _ = models.GetAllTask() |
| | | |
| | | return &bhomeclient.Reply{Success: true, Msg: "获取成功", Data: tasks} |
| | |
| | | package controllers |
| | | |
| | | import ( |
| | | "basic.com/valib/bhomeclient.git" |
| | | "basic.com/valib/logger.git" |
| | | "vamicro/push-service/service" |
| | | "vamicro/push-service/vo" |
| | | |
| | | "basic.com/valib/bhomeclient.git" |
| | | "basic.com/valib/logger.git" |
| | | ) |
| | | |
| | | type EventPushController struct { |
| | | |
| | | } |
| | | |
| | | |
| | | // @Summary 事件推送保存 |
| | | // @Description 事件推送保存 |
| | |
| | | Checked: true, |
| | | Children: []vo.PushSetMenu{ |
| | | {Checked: true, Id: "id", Name: "主键ID", Alias: "id"}, |
| | | {Checked: true, Id: "isDelete", Name: "是否删除", Alias: "isDelete"}, |
| | | {Checked: true, Id: "likeDate", Name: "比对时间", Alias: "likeDate"}, |
| | | {Checked: true, Id: "picDate", Name: "抓拍时间", Alias: "picDate"}, |
| | | {Checked: true, Id: "updateTime", Name: "更新时间", Alias: "updateTime"}, |
| | | {Checked: true, Id: "picMaxUrl", Name: "告警全景图地址", Alias: "picMaxUrl"}, |
| | | {Checked: true, Id: "picSrcUrl", Name: "原始全景图地址", Alias: "picSrcUrl"}, |
| | | {Checked: true, Id: "picId", Name: "图片ID", Alias: "picId"}, |
| | | {Checked: true, Id: "picWH.picH", Name: "图片高", Alias: "picH"}, |
| | | {Checked: true, Id: "picWH.picW", Name: "图片宽", Alias: "picW"}, |
| | | {Checked: true, Id: "sdkName", Name: "sdk类型", Alias: "sdkName"}, |
| | | {Checked: true, Id: "videoUrl", Name: "录像地址", Alias: "videoUrl"}, |
| | | {Checked: true, Id: "content", Name: "场景名称", Alias: "content"}, |
| | | {Checked: true, Id: "linkTag", Name: "联动任务标志", Alias: "linkTag"}, |
| | | {Checked: true, Id: "otherLabels", Name: "其他标签", Alias: "otherLebels"}, |
| | | {Checked: true, Id: "showLabels", Name: "算法标签", Alias: "showLabels"}, |
| | | {Checked: true, Id: "version", Name: "索引版本", Alias: "version"}, |
| | | {Checked: true, Id: "isAlarm", Name: "是否报警", Alias: "isAlarm"}, |
| | | {Checked: true, Id: "detect_time", Name: "创建时间", Alias: "detect_time"}, |
| | | {Checked: true, Id: "zh_desc_class", Name: "中文描述", Alias: "zh_desc_class"}, |
| | | {Checked: true, Id: "image_path", Name: "图像地址", Alias: "image_path"}, |
| | | {Checked: true, Id: "video_path", Name: "录像地址", Alias: "video_path"}, |
| | | {Checked: true, Id: "event_level_name", Name: "事件等级", Alias: "event_level_name"}, |
| | | {Checked: true, Id: "suggestion", Name: "处理建议", Alias: "suggestion"}, |
| | | {Checked: true, Id: "risk_description", Name: "隐患描述", Alias: "risk_description"}, |
| | | {Checked: true, Id: "is_warning", Name: "是否预警", Alias: "is_warning"}, |
| | | }, |
| | | } |
| | | // detectAreaSet := vo.PushSetMenu{ |
| | |
| | | "basic.com/pubsub/protomsg.git" |
| | | "basic.com/valib/bhomeclient.git" |
| | | "basic.com/valib/bhomedbapi.git" |
| | | "basic.com/valib/logger.git" |
| | | uuid "github.com/satori/go.uuid" |
| | | ) |
| | | |
| | |
| | | } else { //新增 |
| | | if er > 0 { |
| | | err = errors.New("名称不允许重复") |
| | | logger.Debug(err) |
| | | return false |
| | | } |
| | | eventPushE.Id = uuid.NewV4().String() |
| | | if err = tx.Table("event_push").Create(&eventPushE).Error; err != nil { |
| | | logger.Debug(err) |
| | | return false |
| | | } |
| | | } |
| | |
| | | EventPushId: eventPushE.Id, |
| | | } |
| | | if err = tx.Table("event_push_server").Create(&ipPortE).Error; err != nil { |
| | | logger.Debug(err) |
| | | return false |
| | | } |
| | | } |
| | |
| | | Id: uuid.NewV4().String(), |
| | | Enable: urlVo.Enable, |
| | | Url: urlVo.Url, |
| | | ServerIp: urlVo.ServerIp, |
| | | Port: urlVo.Port, |
| | | Type: models.PUSH_URL_TYPE, |
| | | EventPushId: eventPushE.Id, |
| | | } |
| | | if err = tx.Table("event_push_server").Create(&urlE).Error; err != nil { |
| | | logger.Debug(err) |
| | | return false |
| | | } |
| | | } |
| | | |
| | | logger.Debug("hhhhhhh") |
| | | |
| | | for _, rule := range body.Rules { |
| | | rule.Id = uuid.NewV4().String() |
| | | rule.EventPushId = eventPushE.Id |
| | | if err = tx.Table("event_push_rule").Create(&rule).Error; err != nil { |
| | | logger.Debug(err) |
| | | return false |
| | | } |
| | | } |
| | |
| | | |
| | | type EventUrlVo struct { |
| | | Url string `json:"url"` |
| | | ServerIp string `json:"server_ip"` |
| | | Port int `json:"port"` |
| | | Enable bool `json:"enable"` |
| | | } |
| | | |