From 712ef81c6b8813a498a66cf61ffcd37e5c502c8c Mon Sep 17 00:00:00 2001 From: sunty <1172534965@qq.com> Date: 星期五, 01 十一月 2019 13:45:30 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- controllers/cameraTimerule.go | 5 controllers/es.go | 18 controllers/gb28181Cloud.go | 18 + go.mod | 7 controllers/cameraTaskArgs.go | 6 controllers/dbtableperson.go | 77 ++++++ controllers/task.go | 31 ++ controllers/cameraPolygon.go | 4 controllers/syssetcont.go | 70 +++++ controllers/camera.go | 30 ++ controllers/monitoring.go | 1 config/test.yaml | 9 controllers/pollConfig.go | 4 extend/sys/system.go | 55 +++- controllers/tasklist.go | 2 controllers/taglist.go | 1 extend/config/config.go | 3 controllers/cluster.go | 10 controllers/sysRole.go | 1 controllers/user.go | 4 middlewares/auth/auth.go | 2 controllers/capture.go | 1 controllers/cameraTask.go | 9 controllers/area.go | 7 controllers/esSearch.go | 1 controllers/dictionary.go | 2 controllers/sdk.go | 4 router/router.go | 11 controllers/dbtablesCon.go | 28 - controllers/fileController.go | 65 ++++- /dev/null | 32 -- go.sum | 14 controllers/cameraPTZ.go | 71 ++++++ controllers/eventPush.go | 6 controllers/initForData.go | 2 controllers/sysMenu.go | 2 36 files changed, 485 insertions(+), 128 deletions(-) diff --git a/config/test.yaml b/config/test.yaml index 4c84f61..655231c 100644 --- a/config/test.yaml +++ b/config/test.yaml @@ -24,16 +24,17 @@ sysThresholds: - value: 60 - color: #13ce66 + color: '#13ce66' - value: 80 - color: #FF9C4A + color: '#FF9C4A' - value: 95 - color: #f53d3d + color: '#f53d3d' - value: 100 - color: #5d0000 + color: '#5d0000' + ptzSpeed: 50 database: driver: sqlite name: sqlite3 diff --git a/controllers/area.go b/controllers/area.go index 626bec6..705c05c 100644 --- a/controllers/area.go +++ b/controllers/area.go @@ -19,6 +19,7 @@ // @Summary 鏄剧ず鏍戝舰缁撴瀯 // @Description 鏄剧ず宸︿晶鎵�鏈夊尯鍩熷拰鎽勫儚鏈� +// @Security ApiKeyAuth // @Produce json // @Tags menu // @Param parentid query string true "鍖哄煙鐨刬d" @@ -39,6 +40,7 @@ // @Summary 鏄剧ずGb28181鏍戝舰缁撴瀯 // @Description 鏄剧ずGb28181鏍戝舰缁撴瀯 +// @Security ApiKeyAuth // @Produce json // @Tags menu // @Param parentid query string true "鍖哄煙鐨刬d" @@ -59,6 +61,7 @@ // @Summary 鍒锋柊Gb28181骞冲彴鏍� // @Description 鍒锋柊Gb28181骞冲彴鏍� +// @Security ApiKeyAuth // @Produce json // @Tags menu // @Param id formData string false "鍥芥爣骞冲彴id" @@ -76,6 +79,7 @@ } } +// @Security ApiKeyAuth // @Summary 鍒犻櫎Gb28181骞冲彴 // @Description 鍒犻櫎Gb28181骞冲彴 // @Produce json @@ -92,6 +96,7 @@ } } +// @Security ApiKeyAuth // @Summary 娣诲姞menu鐨勫尯鍩� // @Description 娣诲姞鐩綍涓婂尯鍩� // @Produce json @@ -119,6 +124,7 @@ } } +// @Security ApiKeyAuth // @Summary 淇敼鍚嶅瓧 // @Description 淇敼鍖哄煙鍚嶅瓧 // @Accept json @@ -159,6 +165,7 @@ } } +// @Security ApiKeyAuth // @Summary 鍒犻櫎涓�涓尯鍩� // @Description 鐐瑰嚮鍒犻櫎鎸夐挳鏃跺垹闄や竴涓尯鍩� // @Produce json diff --git a/controllers/camera.go b/controllers/camera.go index 9be77eb..0afa253 100644 --- a/controllers/camera.go +++ b/controllers/camera.go @@ -42,6 +42,7 @@ // @Summary 娣诲姞鎽勫儚鏈� // @Description "浼犲叆鍖哄煙鐨刬d锛坅reaid锛夊拰鎽勫儚鏈哄悕瀛�(name) 蹇呴』锛� 鍏朵粬鍙傛暟鍙互鍦ㄦ憚鍍忔満閰嶇疆鐐瑰嚮淇濆瓨杩涜娣诲姞" +// @Security ApiKeyAuth // @Accept json // @Produce json // @Tags camera @@ -70,6 +71,7 @@ // @Summary 鏇存柊鎽勫儚鏈� // @Description "鐢ㄤ簬鏇存柊鎽勫儚鏈烘搷浣�" +// @Security ApiKeyAuth // @Accept json // @Produce json // @Tags camera @@ -97,6 +99,7 @@ // @Summary "鍒犻櫎鎽勫儚鏈�" // @Description "鏍规嵁鎽勫儚鏈篿d鍒犻櫎鎽勫儚鏈�" +// @Security ApiKeyAuth // @Produce json // @Tags camera // @Param cid path string true "鎽勫儚鏈篿d example: cid0" @@ -116,6 +119,7 @@ // @Summary 鏄剧ず鎽勫儚鏈� // @Description "鏄剧ず鎽勫儚鏈�" +// @Security ApiKeyAuth // @Produce json // @Tags camera // @Param cid path string true "鎽勫儚鏈篿d" @@ -166,6 +170,7 @@ return json.Marshal(test) } +// @Security ApiKeyAuth // @Summary 灏嗘憚鍍忔満鎸傚埌鎸囧畾鐨勭洰褰曟爲涓� // @Description 灏嗘憚鍍忔満鎸傚埌鎸囧畾鐨勭洰褰曟爲涓� // @Produce json @@ -182,6 +187,7 @@ fmt.Println(areaId) } +// @Security ApiKeyAuth // @Summary 鍒犻櫎鏌愪竴涓洰褰曟爲涓嬬殑鎸囧畾鎽勫儚鏈� // @Description 鍒犻櫎鏌愪竴涓洰褰曟爲涓嬬殑鎸囧畾鎽勫儚鏈� // @Produce json @@ -198,9 +204,9 @@ fmt.Println(areaId) } +// @Security ApiKeyAuth // @Summary 鏍规嵁server鑾峰彇鎵�鏈夋憚鍍忔満鍒楄〃鍙婁俊鎭� // @Description 鏍规嵁server鑾峰彇鎵�鏈夋憚鍍忔満鍒楄〃鍙婁俊鎭� -// @Security ApiKeyAuth // @Produce json // @Tags camera // @Param cameraName query string false "鎽勫儚鏈哄悕绉�" @@ -224,6 +230,7 @@ } } +// @Security ApiKeyAuth // @Summary 鑾峰彇杩愯绫诲瀷鑾峰彇鎽勫儚鏈哄垪琛� // @Description 鑾峰彇杩愯绫诲瀷鑾峰彇鎽勫儚鏈哄垪琛� // @Produce json @@ -256,6 +263,7 @@ } } +// @Security ApiKeyAuth // @Summary 鍒囨崲鎽勫儚鏈鸿繍琛屽疄鏃舵垨杞鐨勫紑鍏� // @Description 鍒囨崲鎽勫儚鏈鸿繍琛屽疄鏃舵垨杞鐨勫紑鍏� // @Produce json @@ -284,6 +292,7 @@ } } +// @Security ApiKeyAuth // @Summary 鏇存柊搴曞浘 // @Description 鍒锋柊搴曞浘 // @Produce json @@ -309,6 +318,7 @@ RunType int `json:"run_type"` } +// @Security ApiKeyAuth // @Summary 鎽勫儚鏈鸿疆璇㈠拰瀹炴椂鐘舵�佸垏鎹� // @Description 鎽勫儚鏈鸿疆璇㈠拰瀹炴椂鐘舵�佸垏鎹� // @Produce json @@ -333,4 +343,22 @@ } } +// @Security ApiKeyAuth +// @Summary 缁熻瀹炴椂鍜岃疆璇㈢殑杩愯璺暟鎯呭喌 +// @Description 缁熻瀹炴椂鍜岃疆璇㈢殑杩愯璺暟鎯呭喌 +// @Produce json +// @Tags camera +// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}" +// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}" +// @Router /data/api-v/camera/statisticRunInfo [get] +func (cc CameraController) StatisticRunInfo(c *gin.Context) { + var api dbapi.CameraApi + b, d := api.StatisticRunInfo() + if b { + util.ResponseFormat(c,code.Success,d) + } else { + util.ResponseFormat(c,code.ComError,"") + } +} + diff --git a/controllers/cameraPTZ.go b/controllers/cameraPTZ.go new file mode 100644 index 0000000..2cb0af2 --- /dev/null +++ b/controllers/cameraPTZ.go @@ -0,0 +1,71 @@ +package controllers + +import ( + "basic.com/dbapi.git" + "basic.com/gb28181api.git" + + "webserver/extend/code" + "webserver/extend/config" + "webserver/extend/util" + + "github.com/gin-gonic/gin" +) + +type PanTiltZoomController struct { +} + +type PTZInstruct struct { + CameraId string `json:"cameraId"` //鎽勫儚鏈篿d + CameraType int `json:"cameraType"` //鎽勫儚鏈虹被鍨� + PTZType string `json:"ptzType"` //鎺у埗绫诲瀷 left right top ... stop +} + +// @Summary 浜戝彴 +// @Description 鎽勫儚鏈轰簯鍙版帶鍒� +// @Security ApiKeyAuth +// @Produce json +// @Tags camera +// @Param ptzBody body controllers.PTZInstruct true "鎺у埗绫诲瀷锛歶p,down,left,right,zoomin,zoomout,stop" +// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}" +// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}" +// @Router /data/api-v/camera/ptzControl [post] +func (ptz PanTiltZoomController) Move(c *gin.Context) { + var param PTZInstruct + if err := c.BindJSON(¶m); err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎") + return + } + + ptzSpeed := config.Server.PTZSpeed + if ptzSpeed == 0 { + ptzSpeed = 50 + } + + if param.CameraType == 1 { + var api dbapi.SysSetApi + r, gb28182Config := api.Gb28181ConfigShow() + + if r { + conf, ok := gb28182Config.(map[string]interface{}) + if ok { + gb28181api.Init(conf["ServerIp"].(string), int(conf["ServerPort"].(float64))) + } else { + util.ResponseFormat(c, code.ComError, "鍥芥爣閰嶇疆璇诲彇澶辫触") + return + } + + } else { + util.ResponseFormat(c, code.ComError, "鍥芥爣鎺ュ彛鏌ヨ澶辫触") + return + } + + var gbApi gb28181api.Gb28181Api + if r := gbApi.SetCameraPtz(param.CameraId, param.PTZType, ptzSpeed); r { + util.ResponseFormat(c, code.Success, "") + } else { + util.ResponseFormat(c, code.Success, "鍥芥爣鎺ュ彛鎿嶄綔澶辫触") + } + } else { + util.ResponseFormat(c, code.Success, "涓嶆敮鎸佺殑鎽勫儚鏈虹被鍨�") + } +} diff --git a/controllers/cameraPolygon.go b/controllers/cameraPolygon.go index 4408523..e71a471 100644 --- a/controllers/cameraPolygon.go +++ b/controllers/cameraPolygon.go @@ -33,6 +33,7 @@ Y float64 `json:"y"` } +// @Security ApiKeyAuth // @Summary 淇濆瓨鎽勫儚鏈哄杈瑰舰 // @Description 淇濆瓨鎽勫儚鏈哄杈瑰舰 // @Accept json @@ -54,7 +55,7 @@ util.ResponseFormat(c,code.ComError,"淇濆瓨澶辫触") } - +// @Security ApiKeyAuth // @Summary 鍒犻櫎鎽勫儚鏈哄尯鍩� // @Description 鍒犻櫎鎽勫儚鏈哄尯鍩� // @Accept json @@ -80,6 +81,7 @@ util.ResponseFormat(c,code.ComError,"鍒犻櫎") } +// @Security ApiKeyAuth // @Summary 鏌ユ壘鎽勫儚鏈哄尯鍩� // @Description 鏌ユ壘鎽勫儚鏈哄尯鍩� // @Accept json diff --git a/controllers/cameraTask.go b/controllers/cameraTask.go index 7a686c5..9d49181 100644 --- a/controllers/cameraTask.go +++ b/controllers/cameraTask.go @@ -74,6 +74,7 @@ Polygon CameraPolygonVo `json:"polygon"` } +// @Security ApiKeyAuth // @Summary 鏌ヨ鎵�鏈変换鍔� // @Description "鏌ヨ鎵�鏈変换鍔�" // @Accept json @@ -95,6 +96,7 @@ } } +// @Security ApiKeyAuth // @Summary 鎽勫儚鏈烘坊鍔犱竴涓换鍔� // @Description 鎽勫儚鏈烘坊鍔犱竴涓换鍔� // @Produce json @@ -123,6 +125,7 @@ } } +// @Security ApiKeyAuth // @Summary 鏌ヨ鎵�鏈変换鍔� // @Description "鏌ヨ鎵�鏈変换鍔�" // @Produce json @@ -146,7 +149,7 @@ } } - +// @Security ApiKeyAuth // @Summary 鎽勫儚鏈轰繚瀛樹换鍔� // @Description 鎽勫儚鏈轰繚瀛樹换鍔� // @Accept json @@ -175,6 +178,7 @@ } } +// @Security ApiKeyAuth // @Summary 鍒犻櫎鎽勫儚鏈虹殑浠诲姟 // @Description 鍒犻櫎鎽勫儚鏈虹殑浠诲姟 // @Produce json @@ -211,6 +215,7 @@ AlarmLevel int `json:"alarm_level"` } +// @Security ApiKeyAuth // @Summary 淇濆瓨浠诲姟鏄惁涓嬩紶鏁版嵁 // @Description 淇濆瓨浠诲姟鏄惁涓嬩紶鏁版嵁 // @Accept json @@ -237,6 +242,7 @@ } } +// @Security ApiKeyAuth // @Summary 淇濆瓨瑙勫垯缁勬姤璀︾瓑绾� // @Description 淇濆瓨瑙勫垯缁勬姤璀︾瓑绾� // @Produce json @@ -267,6 +273,7 @@ Status int `json:"status"` } +// @Security ApiKeyAuth // @Summary 鏇存柊浠诲姟鐘舵�� // @Description 鏇存柊浠诲姟鐘舵�� // @Produce json diff --git a/controllers/cameraTaskArgs.go b/controllers/cameraTaskArgs.go index e402cb4..f7549ea 100644 --- a/controllers/cameraTaskArgs.go +++ b/controllers/cameraTaskArgs.go @@ -13,7 +13,7 @@ } - +// @Security ApiKeyAuth // @Summary 鏍规嵁鎽勫儚鏈篿d鍜屼换鍔d鏌ヨ绠楁硶閰嶇疆璇︽儏 // @Description 鏍规嵁鎽勫儚鏈篿d鍜屼换鍔d鏌ヨ绠楁硶閰嶇疆璇︽儏 // @Produce json @@ -42,6 +42,7 @@ } } +// @Security ApiKeyAuth // @Summary 鏍规嵁澶氫釜鎽勫儚鏈篿d鏌ヨ鑱斿姩浠诲姟瑙勫垯璁剧疆 // @Description 鏍规嵁澶氫釜鎽勫儚鏈篿d鏌ヨ鑱斿姩浠诲姟瑙勫垯璁剧疆 // @Accept json @@ -67,6 +68,7 @@ } } +// @Security ApiKeyAuth // @Summary 鏍规嵁鍒嗙粍id鍒囨崲甯冮槻鎴栨挙闃� // @Description 鏍规嵁鍒嗙粍id鍒囨崲甯冮槻鎴栨挙闃� // @Produce json @@ -93,6 +95,7 @@ } } +// @Security ApiKeyAuth // @SUmmary 鏍规嵁鍒嗙粍id鍒犻櫎鎽勫儚鏈虹畻娉曡鍒� // @Description 鏍规嵁鍒嗙粍id鍒犻櫎鎽勫儚鏈虹畻娉曡鍒� // @Produce json @@ -144,6 +147,7 @@ GroupId string `json:"group_id"`//鍒嗙粍id } +// @Security ApiKeyAuth // @Summary 淇濆瓨鑱斿姩浠诲姟瑙勫垯鍙傛暟 // @Description 淇濆瓨鑱斿姩浠诲姟瑙勫垯鍙傛暟 // @Accept json diff --git a/controllers/cameraTimerule.go b/controllers/cameraTimerule.go index a4a249e..e8c1d4d 100644 --- a/controllers/cameraTimerule.go +++ b/controllers/cameraTimerule.go @@ -29,7 +29,8 @@ Start string `json:"start"`//寮�濮� End string `json:"end"`//缁撴潫 } -// + +// @Security ApiKeyAuth // @Summary 鏃堕棿瑙勫垯淇濆瓨 // @Description 鏃堕棿瑙勫垯淇濆瓨 // @Accept json @@ -62,6 +63,7 @@ util.ResponseFormat(c,code.ComError,"淇濆瓨澶辫触") } +// @Security ApiKeyAuth // @Summary 鍒犻櫎鏃堕棿瑙勫垯 // @Description 鍒犻櫎鏃堕棿瑙勫垯 // @Accept json @@ -85,6 +87,7 @@ util.ResponseFormat(c, code.ComError, "鍒犻櫎澶辫触") } +// @Security ApiKeyAuth // @Summary 鏌ユ壘鎵�鏈夋椂闂磋鍒� // @Description 鏌ユ壘鎵�鏈夋椂闂磋鍒� // @Accept json diff --git a/controllers/capture.go b/controllers/capture.go index f263e1b..94abac1 100644 --- a/controllers/capture.go +++ b/controllers/capture.go @@ -19,6 +19,7 @@ TreeNodes []string `json:"treeNodes"` } +// @Security ApiKeyAuth // @Summary 瀹炴椂鎶撴媿 // @Description 瀹炴椂鎶撴媿鏁版嵁 // @Accept json diff --git a/controllers/cluster.go b/controllers/cluster.go index 749d249..f81dade 100644 --- a/controllers/cluster.go +++ b/controllers/cluster.go @@ -54,6 +54,7 @@ NodeIps []string `json:"nodeIps"` } +// @Security ApiKeyAuth // @Summary 鍒涘缓闆嗙兢 // @Description 鍒涘缓闆嗙兢 // @Accept json @@ -79,6 +80,7 @@ } } +// @Security ApiKeyAuth // @Summary 鐢熸垚闆嗙兢6浣嶉殢鏈哄瘑鐮� // @Description 鐢熸垚闆嗙兢6浣嶉殢鏈哄瘑鐮� // @Produce json @@ -91,6 +93,7 @@ util.ResponseFormat(c,code.Success,pwd) } +// @Security ApiKeyAuth // @Summary 鏌ヨ鏈湴闆嗙兢 // @Description 鏌ヨ鏈湴闆嗙兢 // @Produce json @@ -108,6 +111,7 @@ } } +// @Security ApiKeyAuth // @Summary 鎼滅储闆嗙兢 // @Description 鎼滅储闆嗙兢 // @Accept json @@ -133,6 +137,7 @@ } } +// @Security ApiKeyAuth // @Summary 閫氳繃searchNum寮傛鑾峰彇闆嗙兢鑺傜偣淇℃伅 // @Description 閫氳繃searchNum寮傛鑾峰彇闆嗙兢鑺傜偣淇℃伅 // @Accept json @@ -151,6 +156,7 @@ } } +// @Security ApiKeyAuth // @Summary 閫氳繃searchNum鍋滄鎼滅储 // @Description 閫氳繃searchNum鍋滄鎼滅储 // @Produce json @@ -168,7 +174,7 @@ } } - +// @Security ApiKeyAuth // @Summary 鍔犲叆闆嗙兢 // @Description 鍔犲叆闆嗙兢 // @Accept json @@ -195,6 +201,7 @@ } } +// @Security ApiKeyAuth // @Summary 淇濆瓨闆嗙兢鍚嶇О // @Description 淇濆瓨闆嗙兢鍚嶇О // @Produce json @@ -220,6 +227,7 @@ } } +// @Security ApiKeyAuth // @Summary 閫�鍑洪泦缇� // @Description 閫�鍑洪泦缇� // @Produce json diff --git a/controllers/dbtableperson.go b/controllers/dbtableperson.go index baa0257..91c3550 100644 --- a/controllers/dbtableperson.go +++ b/controllers/dbtableperson.go @@ -28,6 +28,7 @@ type DbPersonController struct { } +// @Security ApiKeyAuth // @Summary 娣诲姞搴曞簱浜哄憳 // @Description 娣诲姞搴曞簱浜哄憳 // @Accept json @@ -81,6 +82,7 @@ return result } +// @Security ApiKeyAuth // @Summary 淇敼搴曞簱浜哄憳 // @Description 淇敼搴曞簱浜哄憳 // @Accept json @@ -108,6 +110,7 @@ } } +// @Security ApiKeyAuth // @Summary 搴曞簱浜哄憳浠ュ浘鎼滃浘 // @Description 搴曞簱浜哄憳浠ュ浘鎼滃浘 // @Accept json @@ -240,6 +243,7 @@ return resultList } +// @Security ApiKeyAuth // @Summary 鏇存柊搴曞簱浜鸿劯鐓х墖 // @Description 鏇存柊搴曞簱浜鸿劯鐓х墖 // @Accept json @@ -366,6 +370,7 @@ return message } +// @Security ApiKeyAuth // @Summary 鍒犻櫎搴曞簱浜哄憳 // @Description 鍒犻櫎搴撲汉鍛� // @Accept x-www-form-urlencoded @@ -393,6 +398,7 @@ type DelMultiPerson []string +// @Security ApiKeyAuth // @Summary 鍒犻櫎搴曞簱浜哄憳 // @Description 鍒犻櫎搴撲汉鍛� // @Accept json @@ -422,6 +428,7 @@ } } +// @Security ApiKeyAuth // @Summary 鏌ヨ搴曞簱浜哄憳鍒楄〃 // @Description 鏌ヨ搴撲汉鍛樺垪琛� // @Accept json @@ -491,6 +498,7 @@ TableIds []string `json:"tableIds"` } +// @Security ApiKeyAuth // @Summary 鎶撴媿浜哄憳鍔犲叆搴曞簱 // @Description 鎶撴媿浜哄憳鍔犲叆搴曞簱 // @Accept json @@ -500,7 +508,7 @@ // @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}" // @Failure 500 {string} json "{"code":500, msg:"杩斿洖閿欒淇℃伅", success:false}" // @Router /data/api-v/dbperson/joinDbTable [POST] -func (sc *DbPersonController) JoinDbTable(c *gin.Context) { +func (dbc *DbPersonController) JoinDbTable(c *gin.Context) { var reqBody JoinDbTVo c.BindJSON(&reqBody) if reqBody.CaptureId == "" || len(reqBody.TableIds) ==0 { @@ -539,10 +547,67 @@ } type DbtSearch struct { - TableId string `json:"tableId"` - OrderName string `json:"orderName"` - OrderType string `json:"orderType"` + TableId string `json:"tableId"` + OrderName string `json:"orderName"` + OrderType string `json:"orderType"` ContentValue string `json:"contentValue"` - Page int `json:"page"` - Size int `json:"size"` + Page int `json:"page"` + Size int `json:"size"` } + +type DbPersonMove struct { + PersonId string `json:"personId"` + TableIds []string `json:"tableIds"` +} + +// @Security ApiKeyAuth +// @Summary 浜哄憳绉诲姩 +// @Description 浜哄憳绉诲姩 +// @Accept json +// @Produce json +// @Tags dbperson 搴曞簱浜哄憳 +// @Param obj body controllers.DbPersonMove true "绉诲姩鍙傛暟" +// @Success 200 {string} json "{"code":200, msg:"", success:true}" +// @Failure 500 {string} json "{"code":500, msg:"", success:false}" +// @Router /data/api-v/dbperson/move [POST] +func (dbc *DbPersonController) Move(c *gin.Context) { + var reqBody DbPersonMove + c.BindJSON(&reqBody) + if reqBody.PersonId == "" || len(reqBody.TableIds) == 0 { + util.ResponseFormat(c,code.RequestParamError, "鍙傛暟鏈夎") + return + } + var dbpApi dbapi.DbPersonApi + b,d := dbpApi.Move(reqBody.PersonId, reqBody.TableIds) + if b { + util.ResponseFormat(c,code.Success,d) + } else { + util.ResponseFormat(c,code.ComError,"") + } +} + +// @Security ApiKeyAuth +// @Summary 浜哄憳澶嶅埗 +// @Description 浜哄憳澶嶅埗 +// @Accept json +// @Produce json +// @Tags dbperson 搴曞簱浜哄憳 +// @Param obj body controllers.DbPersonMove true "澶嶅埗鍙傛暟" +// @Success 200 {string} json "{"code":200, msg:"", success:true}" +// @Failure 500 {string} json "{"code":500, msg:"", success:false}" +// @Router /data/api-v/dbperson/copy [POST] +func (dbc *DbPersonController) Copy(c *gin.Context) { + var reqBody DbPersonMove + c.BindJSON(&reqBody) + if reqBody.PersonId == "" || len(reqBody.TableIds) == 0 { + util.ResponseFormat(c,code.RequestParamError, "鍙傛暟鏈夎") + return + } + var dbpApi dbapi.DbPersonApi + b,d := dbpApi.Copy(reqBody.PersonId, reqBody.TableIds) + if b { + util.ResponseFormat(c,code.Success,d) + } else { + util.ResponseFormat(c,code.ComError,"") + } +} \ No newline at end of file diff --git a/controllers/dbtablesCon.go b/controllers/dbtablesCon.go index 7b588a9..30c1625 100644 --- a/controllers/dbtablesCon.go +++ b/controllers/dbtablesCon.go @@ -20,6 +20,7 @@ type DbTableController struct { } +// @Security ApiKeyAuth // @Summary 鏄剧ず搴曞簱鍒楄〃 // @Description 鏄剧ず鍚屾鎴栨湰鍦板簱鍒楄〃 // @Accept x-www-form-urlencoded @@ -40,6 +41,7 @@ } } +// @Security ApiKeyAuth // @Summary 鏌ヨ鏈満鎵�鏈夊簳搴撳垪琛� // @Description 鏌ヨ鏈満鎵�鏈夊簳搴撳垪琛� // @Accept x-www-form-urlencoded @@ -77,6 +79,7 @@ return data } +// @Security ApiKeyAuth // @Summary 淇敼搴曞簱 // @Description 淇敼鍚屾鎴栨湰鍦板簱 // @Accept json @@ -89,29 +92,11 @@ func (dbt DbTableController) UpdateDbTables(c *gin.Context) { dbtable := new(models.Dbtables) err := c.BindJSON(&dbtable) - if err !=nil || dbtable.Id == "" || dbtable.TableName == "" { + if err !=nil || dbtable.Id == "" || dbtable.TableName == "" || (dbtable.Enable !=0 && dbtable.Enable !=1) { util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎") return } - currentTime := time.Now() - startTime := dbtable.StartTime - endTime := "" - if dbtable.EndTime != "" { - endTime = dbtable.EndTime - } - st, _ := time.ParseInLocation("2006-01-02 15:04:05", startTime, time.Local) - if endTime != "" { - et, _ := time.ParseInLocation("2006-01-02 15:04:05", endTime, time.Local) - if et.After(currentTime) && st.Before(currentTime) { - dbtable.Enable = 1 - } else { - dbtable.Enable = 0 - } - } else if st.Before(currentTime) && endTime == "" { - dbtable.Enable = 1 - } else { - dbtable.Enable = 0 - } + paramBody := util.Struct2Map(dbtable) var tApi dbapi.DbTableApi b, data := tApi.UpdateDbTables(paramBody) @@ -143,6 +128,7 @@ Enable int `json:"enable"` } +// @Security ApiKeyAuth // @Summary 淇敼搴曞簱鐘舵�� // @Description 淇敼鍚屾鎴栨湰鍦板簱搴曞簱鐘舵�� // @Accept json @@ -230,6 +216,7 @@ return flag } +// @Security ApiKeyAuth // @Summary 娣诲姞搴曞簱 // @Description 娣诲姞鍚屾鎴栨湰鍦板簱 // @Accept json @@ -296,6 +283,7 @@ } } +// @Security ApiKeyAuth // @Summary 鍒犻櫎搴曞簱 // @Description 鍒犻櫎鍚屾鎴栨湰鍦板簱 // @Accept x-www-form-urlencoded diff --git a/controllers/dictionary.go b/controllers/dictionary.go index a68bc28..a71ecce 100644 --- a/controllers/dictionary.go +++ b/controllers/dictionary.go @@ -10,6 +10,7 @@ type DictionaryController struct { } +// @Security ApiKeyAuth // @Summary 鏍规嵁绫诲瀷鏌ユ壘瀛楀吀 // @Description 鏍规嵁绫诲瀷鏌ユ壘瀛楀吀 // @Produce json @@ -28,6 +29,7 @@ } } +// @Security ApiKeyAuth // @Summary 鏍规嵁鐖禝D鏌ユ壘瀛楀吀 // @Description 鏍规嵁鐖禝D鏌ユ壘瀛楀吀 // @Produce json diff --git a/controllers/es.go b/controllers/es.go index 412d64f..ae95a3a 100644 --- a/controllers/es.go +++ b/controllers/es.go @@ -26,7 +26,7 @@ type EsClusterInfo struct { Ip string `json:"ip"` } - +// @Security ApiKeyAuth // @Summary 姣斿鏁版嵁鏌ヨ // @Description 姣斿鏁版嵁鏌ヨ // @Accept json @@ -43,28 +43,28 @@ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎") return } - if searchBody.CompareNum != "" { + if searchBody.CompareNum !="" { //浜屾鎼滅储锛屼笉闇�瑕佸啀姣斿浜� co := service.GetCompResultByNum(searchBody.CompareNum) if co != nil { //浜屾鎼滅储鍜屾帓搴� - twiceM := GetCompareDataTwice(co, searchBody) - util.ResponseFormat(c, code.Success, twiceM) + twiceM := GetCompareDataTwice(co,searchBody) + util.ResponseFormat(c,code.Success,twiceM) return } else { - m := make(map[string]interface{}, 0) + m :=make(map[string]interface{},0) m["compareNum"] = searchBody.CompareNum m["total"] = 0 m["totalList"] = []CompareResult{} - util.ResponseFormat(c, code.CompareResultGone, m) + util.ResponseFormat(c,code.CompareResultGone,m) return } } - m := make(map[string]interface{}, 0) + m :=make(map[string]interface{},0) m["compareNum"] = searchBody.CompareNum m["total"] = 0 m["totalList"] = []CompareResult{} - util.ResponseFormat(c, code.CompareResultGone, m) + util.ResponseFormat(c,code.CompareResultGone,m) } func searchEsData(searchBody models.EsSearch) map[string]interface{} { @@ -114,7 +114,7 @@ //浣跨敤es搴曞眰鏈哄埗澶勭悊鍒嗛〉 //璇锋眰澶� localConf, err2 := cache.GetServerInfo() - if err2 != nil || localConf.AlarmIp == "" || localConf.ServerId == "" { + if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" { logger.Debug("localConfig is wrong!!!") return nil } diff --git a/controllers/esSearch.go b/controllers/esSearch.go index 9fd0f95..bd08e48 100644 --- a/controllers/esSearch.go +++ b/controllers/esSearch.go @@ -17,6 +17,7 @@ type EsSearchController struct{} +// @Security ApiKeyAuth // @Summary 妫�绱� // @Description 淇℃伅妫�绱㈠拰姣斿妫�绱� // @Accept json diff --git a/controllers/eventPush.go b/controllers/eventPush.go index 02d0881..a203f40 100644 --- a/controllers/eventPush.go +++ b/controllers/eventPush.go @@ -47,6 +47,7 @@ Enable bool `json:"enable"` } +// @Security ApiKeyAuth // @Summary 浜嬩欢鎺ㄩ�佷繚瀛� // @Description 浜嬩欢鎺ㄩ�佷繚瀛� // @Tags 浜嬩欢鎺ㄩ�� @@ -70,6 +71,7 @@ } } +// @Security ApiKeyAuth // @Summary 鏍规嵁浜嬩欢鎺ㄩ�佷富棰樼殑涓�绾у拰浜岀骇閫夐」鑾峰彇鏈�鍚庝笅鎷夎彍鍗曞垪琛� // @Description 鏍规嵁浜嬩欢鎺ㄩ�佷富棰樼殑涓�绾у拰浜岀骇閫夐」鑾峰彇鏈�鍚庝笅鎷夎彍鍗曞垪琛� // @Produce json @@ -95,6 +97,7 @@ } } +// @Security ApiKeyAuth // @Summary 鏌ュ叏閮� // @Description 鏌ュ叏閮� // @Produce json @@ -114,6 +117,7 @@ } } +// @Security ApiKeyAuth // @Summary 浜嬩欢鎺ㄩ�佺紪杈� // @Description 浜嬩欢鎺ㄩ�佺紪杈� // @Produce json @@ -142,6 +146,7 @@ Enable bool `json:"enable"` } +// @Security ApiKeyAuth // @Summary 鏀瑰彉enable鐘舵�� // @Description 鏀瑰彉enable鐘舵�� // @Produce json @@ -166,6 +171,7 @@ } } +// @Security ApiKeyAuth // @Summary 鏍规嵁id鍒犻櫎 // @Description 鏍规嵁id鍒犻櫎 // @Accept x-www-form-urlencoded diff --git a/controllers/fileController.go b/controllers/fileController.go index ecdc766..4e596a1 100644 --- a/controllers/fileController.go +++ b/controllers/fileController.go @@ -50,6 +50,7 @@ //var weedfsUri = "http://192.168.1.182:9500/submit" +// @Security ApiKeyAuth // @Summary 渚濇嵁鍥剧墖娣诲姞搴曞簱浜哄憳 // @Description 渚濇嵁鍥剧墖娣诲姞搴曞簱杩斿洖鏁版嵁浜哄憳 // @Accept mpfd @@ -110,6 +111,7 @@ } var faceExtractedMap = make(map[string]FaceExtract,0) +// @Security ApiKeyAuth // @Summary 浜鸿劯鎻愬彇 // @Description 浜鸿劯鎻愬彇 // @Produce json @@ -196,6 +198,7 @@ BaseInfo []DbPersonVo `json:"baseInfo"` VideoUrl string `json:"videoUrl"` SdkName string `json:"sdkName"` + AlarmRules []AlarmRuleVo `json:"alarmRules"` } type DbPersonVo struct { BwType string `json:"bwType"` @@ -215,6 +218,15 @@ type ScoreIndex struct { CompareScore float32 Index int +} + +type AlarmRuleVo struct { + GroupId string `json:"groupId"` + AlarmLevel string `json:"alarmLevel"` + RuleText string `json:"ruleText"` + DefenceState bool `json:"defenceState"` + IsLink bool `json:"isLink"` + LinkInfo string `json:"linkInfo"` } //濉厖鍚戝墠绔繑鍥炵殑鏁版嵁 @@ -286,7 +298,7 @@ logger.Debug("comp videoPersons.len:",len(videopersons)) for _,vp :=range videopersons { isAlarmInt, _ := strconv.Atoi(vp.IsAlarm) - bi := make([]DbPersonVo,0) + var bi []DbPersonVo for _,p :=range vp.BaseInfo { bi = append(bi, DbPersonVo{ PersonId: p.PersonId, @@ -298,9 +310,22 @@ PhoneNum: p.PhoneNum, Sex: p.Sex, TableId: p.TableId, - BwType: strconv.Itoa(int(p.BwType)), + BwType: p.BwType, TableName: p.TableName, }) + } + var alarmRules []AlarmRuleVo + if vp.AlarmRules !=nil && len(vp.AlarmRules) >0 { + for _,ar :=range vp.AlarmRules { + alarmRules = append(alarmRules, AlarmRuleVo{ + GroupId: ar.GroupId, + AlarmLevel: ar.AlarmLevel, + RuleText: ar.RuleText, + DefenceState: ar.DefenceState, + IsLink: ar.IsLink, + LinkInfo: ar.LinkInfo, + }) + } } vpE := CompareResult{ Id: vp.Id, @@ -319,6 +344,7 @@ VideoUrl: vp.VideoUrl, BaseInfo: bi, SdkName: "浜鸿劯", + AlarmRules: alarmRules, } resultList[captureM[vp.Id].Index] = vpE } @@ -369,6 +395,7 @@ } } +// @Security ApiKeyAuth // @Summary 浠ュ浘鎼滃浘 // @Description 浠ュ浘鎼滃浘 // @Accept json @@ -566,7 +593,7 @@ logger.Debug("searchPhoto first Result.len:",len(*co.CompareData),"twice len(captureIds):",len(captureIds)) if captureIds !=nil { var aResult protomsg.SdkCompareResult - aList := getTwiceSearchResult(co, &captureIds) + aList := getTwiceSearchResult(co, &captureIds, searchBody) aTotal := aList.Len() if aTotal <= to { aResult.CompareResult = (*aList)[from:aTotal] @@ -599,7 +626,7 @@ personIdArr = append(personIdArr, pid.Id) } var aResult protomsg.SdkCompareResult - aList := getTwiceSearchResult(co, &personIdArr) + aList := getTwiceSearchResult(co, &personIdArr, searchBody) aTotal := aList.Len() if aTotal <= to { aResult.CompareResult = (*aList)[from:aTotal] @@ -639,14 +666,14 @@ return m } -func getTwiceSearchResult(co *service.CompareOnce, scopeIds *[]string) *service.CompareList{ +func getTwiceSearchResult(co *service.CompareOnce, scopeIds *[]string, searchBody *models.EsSearch) *service.CompareList{ m := make(map[string]string) for _,capId :=range *scopeIds { m[capId] = capId } var totalData service.CompareList for _,each :=range *co.CompareData { - if _,ok :=m[each.Id];ok{ + if _,ok :=m[each.Id];ok && each.CompareScore >= searchBody.Threshold { totalData = append(totalData, each) } } @@ -777,6 +804,7 @@ /**涓婁紶鏂规硶**/ +// @Security ApiKeyAuth // @Summary 鎵归噺娣诲姞搴曞簱浜哄憳 // @Description 渚濇嵁鍥剧墖鎵归噺娣诲姞搴曞簱浜哄憳 // @Accept mpfd @@ -799,8 +827,10 @@ } extNames := make([]string, 0) addResult := make(map[string]interface{}, 0) - successList := make([]string, 0) - failList := make([]string,0) + var successList []string + var failList []string + var noFaceList []string + var multiFaceList []string tAllStart := time.Now() var wg sync.WaitGroup var lock sync.Mutex @@ -828,7 +858,13 @@ field, _, err1 := uploadFileReturnAddr(file, filename, tableId) lock.Lock() if err1 != nil || field == "" { - failList = append(failList, filename) + if err1 !=nil && err1.Error() == "NotFeatureFindError" { + noFaceList = append(noFaceList, filename) + } else if err1 !=nil && err1.Error() == "TooManyFaces" { + multiFaceList = append(multiFaceList, filename) + } else { + failList = append(failList, filename) + } } else { successList = append(successList, filename) } @@ -840,13 +876,15 @@ logger.Debug("鍒�",len(fileHeaders),"寮犱汉鑴哥敤鏃讹細", time.Since(tAllStart)) addResult["successList"] = successList addResult["failList"] = failList + addResult["noFaceList"] = noFaceList + addResult["multiFaceList"] = multiFaceList addResult["fields"] = extNames - //if len(successList)>0 { + if len(successList)>0 { util.ResponseFormat(c, code.DbPersonUploadSuccess, addResult) - //} else { - // util.ResponseFormat(c, code.DbPersonUploadFail, addResult) - //} + } else { + util.ResponseFormat(c, code.DbPersonUploadFail, addResult) + } } type EsPersonSave struct { @@ -857,6 +895,7 @@ IdCard string `json:"idCard"` } +// @Security ApiKeyAuth // @Summary 涓婁紶鍥剧墖 骞跺垏鍥� // @Description 涓婁紶鍥剧墖 骞跺垏鍥� // @Accept mpfd diff --git a/controllers/gb28181Cloud.go b/controllers/gb28181Cloud.go new file mode 100644 index 0000000..48b0f3c --- /dev/null +++ b/controllers/gb28181Cloud.go @@ -0,0 +1,18 @@ +package controllers + +import ( + "basic.com/gb28181api.git" + "github.com/gin-gonic/gin" +) + +type Gb28181CloudController struct { + +} + +func (gb *Gb28181CloudController) Left(c *gin.Context) { + cameraId := c.Query("cameraId") + + var gbApi gb28181api.Gb28181Api + gbApi.SetCameraPtz(cameraId,"",3) + +} diff --git a/controllers/initForData.go b/controllers/initForData.go index 2dcb218..1bd75ab 100644 --- a/controllers/initForData.go +++ b/controllers/initForData.go @@ -16,6 +16,7 @@ type InitForData struct { } +// @Security ApiKeyAuth // @Summary 鎶撴媿瀹炴椂鍥炬暟鎹垵濮嬪寲 // @Description 瀹炴椂鑾峰彇鏁版嵁 // @Accept json @@ -66,6 +67,7 @@ Tasks []string `json:"tasks"` } +// @Security ApiKeyAuth // @Summary 瀹炴椂浠诲姟鐩戞帶鏁版嵁鍒濆鍖� // @Description 瀹炴椂鐩戞帶姣斿鏁版嵁 // @Accept json diff --git a/controllers/monitoring.go b/controllers/monitoring.go index 8586698..ccb3519 100644 --- a/controllers/monitoring.go +++ b/controllers/monitoring.go @@ -14,6 +14,7 @@ "webserver/extend/util" ) +// @Security ApiKeyAuth // @Summary 瀹炴椂鐩戞帶 // @Description 瀹炴椂鐩戞帶姣斿鏁版嵁 // @Accept json diff --git a/controllers/panTilt.go b/controllers/panTilt.go deleted file mode 100644 index 5dd318c..0000000 --- a/controllers/panTilt.go +++ /dev/null @@ -1,32 +0,0 @@ -package controllers - -import ( - "webserver/extend/code" - "webserver/extend/util" - - "github.com/gin-gonic/gin" -) - -type PanTiltController struct { -} - -type PTInstruct struct { - ChannelId string `json:"channelId"` //鏈嶅姟鍣╥d - PTZType string `json:"ptzType"` //杞鍛ㄦ湡 - PTZParam int32 `json:"ptzParam"` //寤舵椂鏃堕棿 -} - -func (controller PanTiltController) Controlling(c *gin.Context) { - var param PTInstruct - if err := c.BindJSON(¶m); err != nil { - util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎") - return - } - - b := true - if b { - util.ResponseFormat(c, code.Success, "") - } else { - util.ResponseFormat(c, code.ComError, "淇濆瓨澶辫触") - } -} diff --git a/controllers/pollConfig.go b/controllers/pollConfig.go index 389c713..445168d 100644 --- a/controllers/pollConfig.go +++ b/controllers/pollConfig.go @@ -18,6 +18,7 @@ Enable bool `json:"enable"` //鏄惁鍚敤杞 } +// @Security ApiKeyAuth // @Summary 淇濆瓨杞鍛ㄦ湡 // @Description 淇濆瓨杞鍛ㄦ湡 // @Produce json @@ -42,6 +43,7 @@ } } +// @Security ApiKeyAuth // @Summary 淇濆瓨杞寤舵椂 // @Description 淇濆瓨杞寤舵椂 // @Produce json @@ -66,6 +68,7 @@ } } +// @Security ApiKeyAuth // @Summary 鑾峰彇鏈満杞閰嶇疆 // @Description 鑾峰彇鏈満杞閰嶇疆 // @Produce json @@ -87,6 +90,7 @@ Enable bool `json:"enable"` } +// @Security ApiKeyAuth // @Summary 鍒囨崲杞寮�鍏� // @Description 鍒囨崲杞寮�鍏� // @Produce json diff --git a/controllers/sdk.go b/controllers/sdk.go index a9ba8a3..cc76c7b 100644 --- a/controllers/sdk.go +++ b/controllers/sdk.go @@ -40,6 +40,7 @@ Sort int `json:"sort"` //鍙傛暟椤哄簭 } +// @Security ApiKeyAuth // @Summary 绠楁硶淇濆瓨 // @Description 绠楁硶淇濆瓨 // @Produce json @@ -65,6 +66,7 @@ } } +// @Security ApiKeyAuth // @Summary 鏌ユ壘鎵�鏈夌畻娉� // @Description 鏌ユ壘鎵�鏈夌畻娉� // @Produce json @@ -81,6 +83,7 @@ util.ResponseFormat(c, code.Success, sdks) } +// @Security ApiKeyAuth // @Summary 鏍规嵁id鑾峰彇绠楁硶淇℃伅 // @Description 鏍规嵁id鑾峰彇绠楁硶淇℃伅 // @Produce json @@ -123,6 +126,7 @@ } } +// @Security ApiKeyAuth // @Summary 鏍规嵁taskId鑾峰彇绠楁硶淇℃伅 // @Description 鏍规嵁taskId鑾峰彇绠楁硶淇℃伅 // @Produce json diff --git a/controllers/sysMenu.go b/controllers/sysMenu.go index a7486a3..e83cb9a 100644 --- a/controllers/sysMenu.go +++ b/controllers/sysMenu.go @@ -13,6 +13,7 @@ } +// @Security ApiKeyAuth // @Summary 褰撳墠鐢ㄦ埛鐨勭郴缁熻彍鍗� // @Description 褰撳墠鐢ㄦ埛鐨勭郴缁熻彍鍗� // @Accept json @@ -35,6 +36,7 @@ } } +// @Security ApiKeyAuth // @Summary 鏌ユ壘褰撳墠鐢ㄦ埛鍙鐨勭郴缁熻彍鍗� // @Description 鏌ユ壘褰撳墠鐢ㄦ埛鍙鐨勭郴缁熻彍鍗� // @Accept json diff --git a/controllers/sysRole.go b/controllers/sysRole.go index 90a7bf7..6413473 100644 --- a/controllers/sysRole.go +++ b/controllers/sysRole.go @@ -11,6 +11,7 @@ } +// @Security ApiKeyAuth // @Summary 鏌ユ壘瑙掕壊鍒楄〃 // @Description 鏌ユ壘瑙掕壊鍒楄〃 // @Tags 绯荤粺瑙掕壊 diff --git a/controllers/syssetcont.go b/controllers/syssetcont.go index 8034844..96705e3 100644 --- a/controllers/syssetcont.go +++ b/controllers/syssetcont.go @@ -1,6 +1,7 @@ package controllers import ( + "regexp" "webserver/extend/code" "webserver/extend/config" "webserver/extend/sys" @@ -51,6 +52,7 @@ NewTime string `json:"newTime" example:"鎵嬪姩鎸囧畾鏃堕棿"` } +// @Security ApiKeyAuth // @Summary 瀛樺偍淇℃伅鏌ヨ // @Description 瀛樺偍淇℃伅鏌ヨ // @Accept json @@ -69,6 +71,7 @@ } } +// @Security ApiKeyAuth // @Summary 瀛樺偍淇℃伅淇敼 // @Description 瀛樺偍淇℃伅淇敼 // @Accept json @@ -95,6 +98,7 @@ } } +// @Security ApiKeyAuth // @Summary 瀛樺偍淇℃伅淇敼 // @Description 瀛樺偍淇℃伅淇敼 // @Accept json @@ -117,6 +121,7 @@ } } +// @Security ApiKeyAuth // @Summary 瑙嗛鎴彇鏃堕暱淇敼 // @Description 瑙嗛鎴彇鏃堕暱淇℃伅 // @Accept x-www-form-urlencoded @@ -142,6 +147,7 @@ } } +// @Security ApiKeyAuth // @Summary 鑾峰彇鍒嗘瀽璁惧淇℃伅 // @Description 鍒嗘瀽璁惧淇℃伅 // @Accept json @@ -179,6 +185,7 @@ } } +// @Security ApiKeyAuth // saveDevInfo dev_id dev_name // @Summary 淇濆瓨瑙嗛鍒嗘瀽璁惧淇℃伅 // @Description 鍒嗘瀽璁惧淇℃伅 @@ -190,7 +197,6 @@ // @Failure 500 {string} json "{"code":500, msg:"杩斿洖閿欒淇℃伅", success:false}" // @Router /data/api-v/sysset/saveDevInfo [POST] func (sset SysSetController) SaveDevInfo(c *gin.Context) { - dev_name := c.PostForm("server_name") var api dbapi.SysSetApi paramBody := make(map[string]interface{}, 0) @@ -211,6 +217,7 @@ } } +// @Security ApiKeyAuth // @Summary GB28181璁剧疆鏌ヨ // @Description GB28181璁剧疆淇℃伅鏌ヨ // @Accept json @@ -229,6 +236,7 @@ } } +// @Security ApiKeyAuth // @Summary GB28181璁剧疆淇℃伅淇敼 // @Description GB28181璁剧疆淇敼 // @Accept json @@ -255,6 +263,7 @@ } } +// @Security ApiKeyAuth // @Summary 鑾峰彇鏃堕棿閰嶇疆 // @Description 绯荤粺鏃堕棿閰嶇疆淇℃伅 // @Accept json @@ -271,6 +280,7 @@ util.ResponseFormat(c, code.Success, resData) } +// @Security ApiKeyAuth // @Summary 娴嬭瘯鍚屾鏃堕棿 // @Description 娴嬭瘯鍚屾鏃堕棿鏈嶅姟鍣ㄦ槸鍚﹀彲鐢� // @Accept json @@ -288,19 +298,17 @@ return } - isIP, err := sys.RunNTPDate(ntpServer) - if !isIP { - util.ResponseFormat(c, code.RequestParamError, "鎸囧畾鐨勬湇鍔″櫒鍦板潃閿欒") + isConn := sys.RunNTPDate(ntpServer) + if !isConn { + util.ResponseFormat(c, code.RequestParamError, "NTP鏈嶅姟鍣ㄤ笉鍙敤") return } - if err == nil { - util.ResponseFormat(c, code.Success, "") - } else { - util.ResponseFormat(c, code.TaskStoped, "") - } + util.ResponseFormat(c, code.Success, "") + } +// @Security ApiKeyAuth // @Summary 璁剧疆绯荤粺鏃堕棿 // @Description 鏍℃绯荤粺鏃堕棿 // @Accept json @@ -340,6 +348,7 @@ util.ResponseFormat(c, code.UpdateSuccess, "閰嶇疆鎴愬姛") } +// @Security ApiKeyAuth // @Summary 鏌ヨ绯荤粺杩愯淇℃伅 // @Description 鑾峰彇褰撳墠绯荤粺鐨勮繍琛岀姸鎬侊紝CPU, GPU, 鍐呭瓨绛� // @Produce json @@ -352,6 +361,7 @@ util.ResponseFormat(c, code.UpdateSuccess, info) } +// @Security ApiKeyAuth // @Summary 鏌ヨ绯荤粺鐘舵�侀槇鍊艰缃� // @Description 鑾峰彇褰撳墠绯荤粺鐨勮繍琛岀姸鎬侊紝CPU, GPU, 鍐呭瓨鐨勯槇鍊奸厤缃� // @Produce json @@ -363,6 +373,7 @@ util.ResponseFormat(c, code.UpdateSuccess, config.Server.SysThresholds) } +// @Security ApiKeyAuth // @Summary 閲嶅惎绯荤粺 // @Description 閲嶅惎鎿嶄綔绯荤粺 // @Produce json @@ -378,3 +389,44 @@ util.ResponseFormat(c, code.Success, "姝e湪閲嶅惎") } + +// @Summary 鑾峰彇瀹氭椂閲嶅惎 +// @Description 鑾峰彇瀹氭椂閲嶅惎浠诲姟鐨勯厤缃鍒� +// @Produce json +// @Tags sysset +// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}" +// @Failure 500 {string} json "{"code":500, msg:"杩斿洖閿欒淇℃伅", success:false}" +// @Router /data/api-v/sysset/rebootTask [GET] +func (sset SysSetController) GetRebootTask(c *gin.Context) { + _, msg := sys.ReadRebootTaskInCrontab() + util.ResponseFormat(c, code.Success, msg) +} + +// @Summary 璁剧疆瀹氭椂閲嶅惎 +// @Description 璁剧疆瀹氭椂閲嶅惎浠诲姟鐨勯厤缃鍒� +// @Produce json +// @Tags sysset +// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}" +// @Failure 500 {string} json "{"code":500, msg:"杩斿洖閿欒淇℃伅", success:false}" +// @Router /data/api-v/sysset/rebootTask [POST] +func (sset SysSetController) SetRebootTask(c *gin.Context) { + task := c.PostForm("task") + if len(task) < 1 { + sys.CleanRebootTask() + util.ResponseFormat(c, code.Success, "閰嶇疆鎴愬姛") + return + } + + regEx := `^([0-9*]+\s){4}[0-9*]+$` + if r, _ := regexp.MatchString(regEx, task); !r { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟閿欒") + return + } + + if r := sys.UpdateRebootTask(task); !r { + util.ResponseFormat(c, code.UpdateFail, "閰嶇疆澶辫触") + return + } + + util.ResponseFormat(c, code.Success, "閰嶇疆鎴愬姛") +} diff --git a/controllers/taglist.go b/controllers/taglist.go index 519fbea..2f3c5d9 100644 --- a/controllers/taglist.go +++ b/controllers/taglist.go @@ -15,6 +15,7 @@ "github.com/gin-gonic/gin" ) +// @Security ApiKeyAuth // @Summary 鏍囩鍒楄〃 // @Description 杩斿洖搴曞簱鏍囩 // @Accept json diff --git a/controllers/task.go b/controllers/task.go index dbb8761..57f9414 100644 --- a/controllers/task.go +++ b/controllers/task.go @@ -38,6 +38,7 @@ FaceExtract_VirtualSdkId = "virtual-faceextract-sdk-pull"//缁撴灉杈撳嚭鐨勭畻娉昳d ) +// @Security ApiKeyAuth // @Summary 鏌ユ壘鎵�鏈変换鍔★紝鍖呭惈浠诲姟淇℃伅鍜屽搴旂殑绠楁硶淇℃伅 // @Description 鏌ユ壘鎵�鏈変换鍔� // @Produce json @@ -69,6 +70,7 @@ } } +// @Security ApiKeyAuth // @Summary 妫�绱㈤〉闈㈣幏鍙栨墍鏈変换鍔″垪琛紙鍖呭惈宸插垹闄ょ殑浠诲姟锛� // @Description 妫�绱㈤〉闈㈣幏鍙栨墍鏈変换鍔″垪琛紙鍖呭惈宸插垹闄ょ殑浠诲姟锛� // @Produce json @@ -125,6 +127,7 @@ } } +// @Security ApiKeyAuth // @Summary 娣诲姞浠诲姟 // @Description 鏌ユ壘鎵�鏈変换鍔� // @Accept json @@ -161,6 +164,7 @@ Sort int `json:"sort"` } +// @Security ApiKeyAuth // @Summary 缁欎换鍔℃坊鍔犵畻娉� // @Description 浠诲姟娣诲姞绠楁硶 // @Produce json @@ -186,6 +190,7 @@ } } +// @Security ApiKeyAuth // @Summary 浠诲姟鍒犻櫎绠楁硶 // @Description 鏍规嵁taskid鍜宻dkid鍒犻櫎 // @Produce json @@ -211,6 +216,7 @@ } } +// @Security ApiKeyAuth // @Summary 鏇存柊浠诲姟鍚嶇О // @Description 鏇存柊浠诲姟鍚嶇О // @Produce json @@ -241,6 +247,7 @@ Enable bool `json:"enable"` } +// @Security ApiKeyAuth // @Summary 鏇存柊浠诲姟鐘舵�� // @Description 锛堢畻娉曚笉鍙�,鍙洿鏂颁换鍔$姸鎬侊級 // @Produce json @@ -266,7 +273,7 @@ } } - +// @Security ApiKeyAuth // @Summary 鍒犻櫎浠诲姟 // @Description 鏍规嵁浠诲姟id鍒犻櫎浠诲姟 // @Produce json @@ -304,6 +311,7 @@ SdkArgValue string `json:"sdk_arg_value"` } +// @Security ApiKeyAuth // @Summary 淇濆瓨绠楁硶瑙勫垯 // @Description 淇濆瓨绠楁硶瑙勫垯 // @Accept json @@ -330,6 +338,7 @@ } } +// @Security ApiKeyAuth // @Summary 鍒犻櫎绠楁硶瑙勫垯 // @Description 鍒犻櫎绠楁硶瑙勫垯 // @Produce json @@ -354,7 +363,7 @@ } } - +// @Security ApiKeyAuth // @Summary 鏌ヨ绠楁硶瑙勫垯 // @Description 鏌ヨ绠楁硶瑙勫垯 // @Produce json @@ -379,3 +388,21 @@ util.ResponseFormat(c,code.ComError,"鏌ヨ澶辫触") } } + +// @Security ApiKeyAuth +// @Summary 缁熻姣忎釜浠诲姟鐨勬憚鍍忔満鏁伴噺 +// @Description 缁熻姣忎釜浠诲姟鐨勬憚鍍忔満鏁伴噺 +// @Produce json +// @Tags task +// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}" +// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}" +// @Router /data/api-v/task/statisticTaskCamera [get] +func (tc TaskController) StatisticTaskCamera(c *gin.Context) { + var taskApi dbapi.TaskApi + b,d := taskApi.StatisticTaskCamera() + if b { + util.ResponseFormat(c,code.Success, d) + } else { + util.ResponseFormat(c,code.ComError, "") + } +} diff --git a/controllers/tasklist.go b/controllers/tasklist.go index c616f1c..13653a6 100644 --- a/controllers/tasklist.go +++ b/controllers/tasklist.go @@ -13,7 +13,7 @@ "webserver/extend/util" ) -//浠诲姟鍒楄〃 +// @Security ApiKeyAuth // @Summary 浠诲姟鍒楄〃 // @Description 杩斿洖浠诲姟鍒楄〃 // @Accept json diff --git a/controllers/user.go b/controllers/user.go index 56b5c8c..a78d271 100644 --- a/controllers/user.go +++ b/controllers/user.go @@ -65,6 +65,7 @@ } } +// @Security ApiKeyAuth // @Summary 鑾峰彇褰撳墠鐢ㄦ埛淇℃伅 // @Description 鑾峰彇褰撳墠鐢ㄦ埛淇℃伅 // @Accept json @@ -92,6 +93,7 @@ c.JSON(http.StatusOK,"閫�鍑烘垚鍔�") } +// @Security ApiKeyAuth // @Summary 鏌ユ壘鎵�鏈夌敤鎴� // @Description 鏌ユ壘鎵�鏈夌敤鎴� // @Accept json @@ -122,6 +124,7 @@ MenuIds []string `json:"menuIds"` } +// @Security ApiKeyAuth // @Summary 缂栬緫姝ょ敤鎴凤紝杩斿洖姝ょ敤鎴风殑鏉冮檺鑿滃崟 // @Description 缂栬緫姝ょ敤鎴凤紝杩斿洖姝ょ敤鎴风殑鏉冮檺鑿滃崟 // @Accept json @@ -146,6 +149,7 @@ } } +// @Security ApiKeyAuth // @Summary 鏇存柊鐢ㄦ埛鍚嶏紝瀵嗙爜鍜岃彍鍗曟潈闄� // @Description 鏇存柊鐢ㄦ埛鍚嶏紝瀵嗙爜鍜岃彍鍗曟潈闄� // @Accept json diff --git a/extend/config/config.go b/extend/config/config.go index c775712..2ab67ab 100644 --- a/extend/config/config.go +++ b/extend/config/config.go @@ -26,8 +26,9 @@ ChannelCount string `mapstructure: "channelCount"` //閫氶亾涓暟 DiskCount string `mapstructure: "diskCount"` //纭洏涓暟 - SudoPassword string `mapstructure: "sudoPassword"` + SudoPassword string `mapstructure: "sudoPassword"` //绯荤粺瀵嗙爜 SysThresholds []threshold `mapstructure: "sysThresholds"` + PTZSpeed int `mapstructure: "ptzSpeed"` // 浜戝彴绉诲姩閫熷害 } var Server = &server{} diff --git a/extend/sys/system.go b/extend/sys/system.go index cccba7e..647917d 100644 --- a/extend/sys/system.go +++ b/extend/sys/system.go @@ -119,8 +119,7 @@ func NTPConfig() (bool, string, string) { status, server, interval := false, "", "" - cmd := exec.Command("/bin/sh", "-c", "crontab -l | grep ntpdate | tr -d '\n'") - cron, _ := cmd.Output() + cron, _ := execRootCommand("crontab -l | grep ntpdate | tr -d '\n'") if task := string(cron); task != "" { status = true slice := strings.Split(task, " ") @@ -160,8 +159,6 @@ return false } - // args := []string{"-s", newTime} - // exec.Command("date", args...).Run() dateCMD := fmt.Sprintf("date -s \"%s\"", newTime) execRootCommand(dateCMD) stopNTPCron() @@ -169,7 +166,7 @@ return true } -const NTPCRONTABFILE = "~/.webServer.crontab" +const NTPCRONTABFILE = "/tmp/.webServer.crontab" func EnableNTPCron(server string, interval int) bool { stopNTPCron() @@ -178,24 +175,32 @@ return false } - addTask := fmt.Sprintf("echo \"*/%d * * * * /usr/sbin/ntpdate %s\" >> %s; crontab %s", interval, server, NTPCRONTABFILE, NTPCRONTABFILE) - exec.Command("/bin/sh", "-c", addTask).Run() + update := fmt.Sprintf("echo \"*/%d * * * * /usr/sbin/ntpdate %s\" >> %s", interval, server, NTPCRONTABFILE) + execRootCommand(update) + + addNTPTask := fmt.Sprintf("crontab %s", NTPCRONTABFILE) + execRootCommand(addNTPTask) return true } func stopNTPCron() { - cleanTask := fmt.Sprintf("crontab -l | grep -v /usr/sbin/ntpdate > %s; crontab %s", NTPCRONTABFILE, NTPCRONTABFILE) - exec.Command("/bin/sh", "-c", cleanTask).Run() + update := fmt.Sprintf("crontab -l | grep -v /usr/sbin/ntpdate > %s", NTPCRONTABFILE) + execRootCommand(update) + + cleanNTPTask := fmt.Sprintf("crontab %s", NTPCRONTABFILE) + execRootCommand(cleanNTPTask) } -func RunNTPDate(server string) (bool, error) { +func RunNTPDate(server string) bool { if ip := net.ParseIP(server); ip == nil { - return false, errors.New("鍙傛暟閿欒") + return false } ntpdate := fmt.Sprintf("/usr/sbin/ntpdate %s", server) - return true, exec.Command("/bin/sh", "-c", ntpdate).Run() + _, err := execRootCommand(ntpdate) + + return err == nil } func Reboot() (bool, string) { @@ -203,3 +208,29 @@ return err == nil, string(stdout) } + +// * * * * * /bin/echo "$(date) Perform basic-reboot-task" >> /tmp/webserver.crontab.log;/sbin/reboot & >> /tmp/webserver.crontab.log +func ReadRebootTaskInCrontab() (bool, string) { + stdout, err := execRootCommand("crontab -l | grep basic-reboot-task | sed -z -r 's/([^0-9* ]+)(.+)//g'") + return err == nil, string(stdout) +} + +func CleanRebootTask() { + update := fmt.Sprintf("crontab -l | grep -v basic-reboot-task > %s", NTPCRONTABFILE) + execRootCommand(update) + + crontab := fmt.Sprintf("crontab %s", NTPCRONTABFILE) + execRootCommand(crontab) +} + +func UpdateRebootTask(task string) bool { + CleanRebootTask() + + tasks := fmt.Sprintf("%s /bin/echo \"$(date) Perform basic-reboot-task\" >> /tmp/webserver.crontab.log;/sbin/reboot & >> /tmp/webserver.crontab.log", task) + update := fmt.Sprintf("echo '%s' >> %s", tasks, NTPCRONTABFILE) + execRootCommand(update) + addNTPTask := fmt.Sprintf("crontab %s", NTPCRONTABFILE) + _, err := execRootCommand(addNTPTask) + + return err == nil +} diff --git a/go.mod b/go.mod index ee4e5ce..3e53878 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,12 @@ go 1.12 require ( - basic.com/dbapi.git v0.0.0-20191029073251-acc3826d096d // indirect + basic.com/dbapi.git v0.0.0-20191031093340-2802ead93fa6 // indirect basic.com/fileServer/WeedFSClient.git v0.0.0-20190919054037-0182b6c3f5cb // indirect + basic.com/gb28181api.git v0.0.0-20191028082253-472438a8407b // indirect basic.com/pubsub/cache.git v0.0.0-20190718093725-6a413e1d7d48 // indirect - basic.com/pubsub/esutil.git v0.0.0-20191029091908-d43f2d92ecb6 // indirect - basic.com/pubsub/protomsg.git v0.0.0-20190829113947-eb5a5f99a745 + basic.com/pubsub/esutil.git v0.0.0-20191031110806-0712822ce390 // indirect + basic.com/pubsub/protomsg.git v0.0.0-20191031110456-1a84b09fbcd1 // indirect basic.com/valib/capture.git v0.0.0-20190924061718-7e98d8c98b3c // indirect basic.com/valib/deliver.git v0.0.0-20190531095353-25d8c3b20051 basic.com/valib/goffmpeg.git v0.0.0-20191024085028-080acae08ec8 // indirect diff --git a/go.sum b/go.sum index 159f81f..551026b 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,15 @@ -basic.com/dbapi.git v0.0.0-20191029073251-acc3826d096d h1:DhbWFpg4/KLeYbMpaLJUlY/z5mSyCx+kPh9JY7OMd2k= -basic.com/dbapi.git v0.0.0-20191029073251-acc3826d096d/go.mod h1:eDXPnxaz6jZPDvBSk7ya7oSASWPCuUEgRTJCjsfKt/Q= +basic.com/dbapi.git v0.0.0-20191031093340-2802ead93fa6 h1:ZSRZQ031oGUT8zT9shvoX9hvFIVbLnNCpJ48SLZKVec= +basic.com/dbapi.git v0.0.0-20191031093340-2802ead93fa6/go.mod h1:eDXPnxaz6jZPDvBSk7ya7oSASWPCuUEgRTJCjsfKt/Q= basic.com/fileServer/WeedFSClient.git v0.0.0-20190919054037-0182b6c3f5cb h1:fM6DojeInFSCFO+wkba1jtyPiSDqw0jYKi4Tk+e+ka4= basic.com/fileServer/WeedFSClient.git v0.0.0-20190919054037-0182b6c3f5cb/go.mod h1:FTryK8BsVLfUplx8a3+l8hJWub6VbAWZCUH7sPRZaso= +basic.com/gb28181api.git v0.0.0-20191028082253-472438a8407b h1:Qh7x2PY3HA9B404Llq+olY5/YlGYrM58bpOHa2CGcro= +basic.com/gb28181api.git v0.0.0-20191028082253-472438a8407b/go.mod h1:iKnzuRRqUEgt17894pX3oYcOG2fLYFVcXiZbPoMK7+4= basic.com/pubsub/cache.git v0.0.0-20190718093725-6a413e1d7d48 h1:BBA30Rgljn6MRieC4gUncETJDyna3ObyubTo9HEQ2M0= basic.com/pubsub/cache.git v0.0.0-20190718093725-6a413e1d7d48/go.mod h1:gHLJZz2ee1cGL0X0ae69fs56bAxkDgEQwDhhXZJNUcY= -basic.com/pubsub/esutil.git v0.0.0-20191029091908-d43f2d92ecb6 h1:HNdnjoaOpLJvyNzUPD2Yx9tLsS7unR19O+0ZYviW2II= -basic.com/pubsub/esutil.git v0.0.0-20191029091908-d43f2d92ecb6/go.mod h1:yIvppFPFGC61DOdm71ujnsxZBMFUu2yKjr5O43bMWCw= -basic.com/pubsub/protomsg.git v0.0.0-20190829113947-eb5a5f99a745 h1:NQ/172pylwH5BnVwt4vlrXVN+UDn8YJc+5V2ZPaC4P0= -basic.com/pubsub/protomsg.git v0.0.0-20190829113947-eb5a5f99a745/go.mod h1:un5NV5VWQoblVLZfx1Rt5vyLgwR0jI92d3VJhfrJhWU= +basic.com/pubsub/esutil.git v0.0.0-20191031110806-0712822ce390 h1:uM/D7VJ41pg1XXpoe73QqCCnQTE08VhXQ2JAAOnN6ao= +basic.com/pubsub/esutil.git v0.0.0-20191031110806-0712822ce390/go.mod h1:yIvppFPFGC61DOdm71ujnsxZBMFUu2yKjr5O43bMWCw= +basic.com/pubsub/protomsg.git v0.0.0-20191031110456-1a84b09fbcd1 h1:w/hlV2znPkwQxusqH8IIeg8+O3DPkCbRhsVKi6GdckU= +basic.com/pubsub/protomsg.git v0.0.0-20191031110456-1a84b09fbcd1/go.mod h1:un5NV5VWQoblVLZfx1Rt5vyLgwR0jI92d3VJhfrJhWU= basic.com/valib/capture.git v0.0.0-20190924061718-7e98d8c98b3c h1:aNujtcGxq0cNLSK08cCamAiUYiQ2/ZsUMNXbX2w8Clc= basic.com/valib/capture.git v0.0.0-20190924061718-7e98d8c98b3c/go.mod h1:y+h7VUnoSQ3jOtf2K3twXNA8fYDfyUsifSswcyKLgNw= basic.com/valib/deliver.git v0.0.0-20190531095353-25d8c3b20051/go.mod h1:bkYiTUGzckyNOjAgn9rB/DOjFzwoSHJlruuWQ6hu6IY= diff --git a/middlewares/auth/auth.go b/middlewares/auth/auth.go index 2de927d..7df2c82 100644 --- a/middlewares/auth/auth.go +++ b/middlewares/auth/auth.go @@ -1,7 +1,6 @@ package auth import ( - "fmt" "github.com/gin-gonic/gin" "net/http" "strings" @@ -64,7 +63,6 @@ c.Abort() } user := (*jwtDriver).User(c) - fmt.Println("AuthHandler user:",user) if user == nil { util.ResponseFormat(c,code.TokenNotFound,"灏氭湭鐧诲綍锛岃鐧诲綍") c.Abort() diff --git a/router/router.go b/router/router.go index 5234b24..3d42f1c 100644 --- a/router/router.go +++ b/router/router.go @@ -43,7 +43,7 @@ sysMenuController := new(controllers.SysMenuController) clusterController := new(controllers.ClusterController) sysRoleController := new(controllers.RoleController) - ptController := new(controllers.PanTiltController) + ptzController := new(controllers.PanTiltZoomController) sysApi := r.Group("/data/api-u/sys") { @@ -102,7 +102,8 @@ camera.POST("/changeRunType", cameraController.ChangeRunType) camera.GET("/getAllCamerasByServer", cameraController.GetAllCamerasByServer) - camera.POST("/ptControl", ptController.Controlling) + camera.POST("/ptzControl", ptzController.Move) + camera.GET("/statisticRunInfo", cameraController.StatisticRunInfo) } cameraTaskArgsApi := r.Group(urlPrefix + "/cameraTaskArgs") @@ -144,6 +145,8 @@ task.GET("/getRulesByTaskSdk", taskController.GetRulesByTaskSdk) task.POST("/deleteTaskSdkRule", taskController.DeleteTaskSdkRule) task.POST("/saveTaskSdkRule", taskController.SaveTaskSdkRule) + + task.GET("/statisticTaskCamera", taskController.StatisticTaskCamera) } // 妫�绱� 鏌ヨ 鑺傜偣鎿嶄綔 @@ -193,6 +196,8 @@ vdbperson.POST("/updateFace", dbPersonCont.UpdateFace) vdbperson.POST("/joinDbTable", dbPersonCont.JoinDbTable) + vdbperson.POST("/move", dbPersonCont.Move) + vdbperson.POST("/copy", dbPersonCont.Copy) } // 绯荤粺璁剧疆 鎿嶄綔 @@ -213,6 +218,8 @@ vsset.GET("/sysThresholds", ssController.GetSysThresholds) vsset.GET("/reboot", ssController.RebootOS) + vsset.GET("/rebootTask", ssController.GetRebootTask) + vsset.POST("/rebootTask", ssController.SetRebootTask) } //绠楁硶搴撴搷浣� -- Gitblit v1.8.0