From 9b17a8dcbc1f94eb117a37b3b24ca9dae0d2d588 Mon Sep 17 00:00:00 2001
From: qixiaoning <jony.kee@outlook.com>
Date: 星期三, 29 十月 2025 09:40:54 +0800
Subject: [PATCH] 摄像机相关接口跳转,推送配置修改,系统权限菜单修改
---
camera-common/models/camera.go | 104 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 99 insertions(+), 5 deletions(-)
diff --git a/camera-common/models/camera.go b/camera-common/models/camera.go
index 13294ca..e7ff4b8 100644
--- a/camera-common/models/camera.go
+++ b/camera-common/models/camera.go
@@ -1,14 +1,15 @@
package models
import (
- "basic.com/pubsub/protomsg.git"
- "basic.com/valib/logger.git"
"encoding/json"
"fmt"
"strconv"
"strings"
"vamicro/camera-common/pub"
"vamicro/config"
+
+ "basic.com/pubsub/protomsg.git"
+ "basic.com/valib/logger.git"
)
const (
@@ -28,7 +29,8 @@
)
type Camera struct {
- Id string `gorm:"primary_key;column:id;type:varchar(100);unique;" json:"id"`
+ VideoId int64 `gorm:"-;primaryKey;autoIncrement"` //鎽勫儚鏈篿d
+ Id string `gorm:"column:id;type:varchar(100);unique;" json:"id"`
Name string `gorm:"column:name" json:"name" bind:"required"`
Alias string `gorm:"column:alias" json:"alias"` //鎽勫儚鏈虹殑鍒悕
SnapshotUrl string `gorm:"column:snapshot_url" json:"snapshot_url"` //蹇収鍦板潃
@@ -55,6 +57,39 @@
VoiceEnable bool `gorm:"column:voiceEnable;default:0" json:"voiceEnable"`
VoiceId string `gorm:"column:voiceId" json:"voiceId"`
CoordTransform string `gorm:"column:coordTransform" json:"coordTransform"` //鍧愭爣杞崲,闀挎槬杩借釜reid鐢�
+
+}
+
+type CameraDto struct {
+ VideoId int64 `gorm:"primaryKey;autoIncrement"` //鎽勫儚鏈篿d
+ Id string `gorm:"column:id;type:varchar(100);unique;" json:"id"`
+ Name string `gorm:"column:name" json:"name" bind:"required"`
+ Alias string `gorm:"column:alias" json:"alias"` //鎽勫儚鏈虹殑鍒悕
+ SnapshotUrl string `gorm:"column:snapshot_url" json:"snapshot_url"` //蹇収鍦板潃
+ Type int `gorm:"column:type" json:"type" `
+ Addr string `gorm:"column:addr" json:"addr"`
+ Longitude float32 `gorm:"column:longitude" json:"longitude"`
+ Latitude float32 `gorm:"column:latitude" json:"latitude"`
+ Floor int `gorm:"column:floor" json:"floor"` //妤煎眰
+ Rtsp string `gorm:"column:rtsp" json:"rtsp"`
+ Ip string `gorm:"column:ip" json:"ip"`
+ Port int `gorm:"column:port" json:"port"`
+ Username string `gorm:"column:username" json:"username"`
+ Password string `gorm:"column:password" json:"password"`
+ Brand string `gorm:"column:brand" json:"brand"`
+ Reserved string `gorm:"column:reserved" json:"reserved"`
+ IsRunning bool `gorm:"column:is_running" json:"is_running"` //鏄惁姝e湪瑙g爜
+ RunEnable bool `gorm:"column:run_enable" json:"run_enable"` //鎺у埗瀹炴椂澶勭悊鎴栬疆璇㈠鐞嗙殑寮�鍏�
+ RunType int `gorm:"column:run_type" json:"run_type"` //澶勭悊绫诲瀷锛�0锛氳疆璇紝1锛氬疄鏃�,-1:鏃犱换鍔★紝涓嶅仛鍒嗘瀽鎴栬�呭垎鏋愪换鍔¤鍏充簡
+ RunServerId string `gorm:"column:run_server_id" json:"run_server_id"` //褰撳墠姝e湪澶勭悊鐨勫垎鏋愭湇鍔″櫒id
+
+ ResolutionWidth int `gorm:"column:resolution_width;default:0" json:"resolution_width"` //鍒嗚鲸鐜囧
+ ResolutionHeight int `gorm:"column:resolution_height;default:0" json:"resolution_height"` //鍒嗚鲸鐜囬珮
+
+ VoiceEnable bool `gorm:"column:voiceEnable;default:0" json:"voiceEnable"`
+ VoiceId string `gorm:"column:voiceId" json:"voiceId"`
+ CoordTransform string `gorm:"column:coordTransform" json:"coordTransform"` //鍧愭爣杞崲,闀挎槬杩借釜reid鐢�
+
}
func (Camera) TableName() string {
@@ -86,8 +121,8 @@
return cameraEMap
}
-//cameraType (0:鏌ュ叏閮�,1:鍒嗘瀽鎽勫儚鏈�,2:鐩戞帶鎽勫儚鏈�)
-//cameraName
+// cameraType (0:鏌ュ叏閮�,1:鍒嗘瀽鎽勫儚鏈�,2:鐩戞帶鎽勫儚鏈�)
+// cameraName
func (camera *Camera) Find(cameraType int, cameraName string, camType int, isPlatform int, linkStr string) (camMenus []CameraTreeNode, err error) {
logger.Debug("camType:", camType)
cType := strconv.Itoa(camType)
@@ -296,6 +331,41 @@
return result.RowsAffected > 0
}
+func (camera *Camera) DelLink(id int64) (err error) {
+
+ //鍒犻櫎鍏宠仈妫�娴嬪唴瀹�
+ dbdel1 := db.Exec("delete from mal_task_check_link where task_id=?", id)
+ err = dbdel1.Error
+ if err != nil || dbdel1.RowsAffected == 0 {
+ return err
+ }
+ //鍒犻櫎鍏宠仈棰勮瑙勫垯
+ dbdel2 := db.Exec("delete from mal_task_rule_link where task_id=?", id)
+ err = dbdel2.Error
+ if err != nil || dbdel2.RowsAffected == 0 {
+ return err
+ }
+ //鍒犻櫎鍏宠仈鎽勫儚鏈轰换鍔�
+ dbdel3 := db.Exec("delete from mal_task_video_link where task_id=?", id)
+ err = dbdel3.Error
+ if err != nil || dbdel3.RowsAffected == 0 {
+ return err
+ }
+ //鍒犻櫎鍏宠仈宸ヤ綔鏃堕棿
+ dbdel4 := db.Exec("delete from mal_task_work_time_link where task_id=?", id)
+ err = dbdel4.Error
+ if err != nil || dbdel4.RowsAffected == 0 {
+ return err
+ }
+ //鍒犻櫎鍏宠仈鐭ヨ瘑搴�
+ dbdel5 := db.Exec("delete from mal_knowledge_link where task_id=?", id)
+ err = dbdel5.Error
+ if err != nil || dbdel5.RowsAffected == 0 {
+ return err
+ }
+ return
+}
+
func (camera *Camera) Delete(cid string) (int64, error) {
var err error
tx := GetDB().Begin()
@@ -372,3 +442,27 @@
}
pub.AddDbMessage(&dbMsg)
}
+
+type VideoLink struct {
+ ID int `gorm:"column:id" json:"id"`
+ VideoId string `gorm:"column:video_id" json:"videoId"`
+ TaskId int `gorm:"column:task_id" json:"taskId"`
+}
+
+func GetTasks() map[string][]interface{} {
+
+ var lists []VideoLink
+ sqlStr := `select id,video_id,task_id from mal_task_video_link`
+ if err := db.Raw(sqlStr).Scan(&lists).Error; err != nil {
+ fmt.Println(err.Error())
+ return nil
+ }
+
+ checkMap := make(map[string][]interface{})
+ for _, d2 := range lists {
+ if d2.VideoId != "" {
+ checkMap[d2.VideoId] = append(checkMap[d2.VideoId], d2)
+ }
+ }
+ return checkMap
+}
--
Gitblit v1.8.0