controllers/fileAnalysis.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
controllers/fileAnalysisSetting.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
go.mod | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
go.sum | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
router/router.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
controllers/fileAnalysis.go
New file @@ -0,0 +1,130 @@ package controllers import ( "basic.com/dbapi.git" "github.com/gin-gonic/gin" "webserver/extend/code" "webserver/extend/util" ) type FileAnalysisController struct { } // @Security ApiKeyAuth // @Summary 获取本地文件列表 // @Description 获取本地文件列表 // @Produce json // @Tags 本地文件 // @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}" // @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}" // @Router /data/api-v/fileAnalysis/findAllFile [get] func (fac FileAnalysisController) FindAllFile(c *gin.Context) { fileName := c.Query("fileName") var api dbapi.FileAnalysisApi arr, _ := api.FindAllFile(fileName) if arr !=nil && len(arr) >0 { util.ResponseFormat(c,code.Success,arr) } else { util.ResponseFormat(c,code.Success,[]interface{}{}) } } type IdArrVo struct { Ids []string `json:"ids" binding:"required"` } type SortVo struct { Id string `json:"id" binding:"required"` Direct int `json:"direct" binding:"required" example:"1:向上,2:向下"` } type FileStatusVo struct { Ids []string `json:"ids" binding:"required"` Status int `json:"status" binding:"required"` } // @Security ApiKeyAuth // @Summary 开启或暂停文件分析 // @Description 开启或暂停文件分析 // @Accept json // @Produce json // @Tags 本地文件 // Param reqBody body controllers.FileStatusVo true "开启暂停参数,暂停status=0,开启status=1" // @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}" // @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}" // @Router /data/api-v/fileAnalysis/updateStatus [post] func (fac FileAnalysisController) UpdateStatus(c *gin.Context) { var reqBody FileStatusVo err := c.BindJSON(&reqBody) if err !=nil { util.ResponseFormat(c,code.RequestParamError,"参数有误") return } var api dbapi.FileAnalysisApi if api.UpdateStatus(reqBody.Ids, reqBody.Status) { util.ResponseFormat(c,code.Success,"") } else { util.ResponseFormat(c,code.ComError,"") } } // @Security ApiKeyAuth // @Summary 删除本地文件 // @Description 删除本地文件 // @Accept json // @Produce json // @Tags 本地文件 // Param reqBody body controllers.IdArrVo true "删除文件id列表" // @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}" // @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}" // @Router /data/api-v/fileAnalysis/delete [post] func (fac FileAnalysisController) Delete(c *gin.Context) { var reqBody IdArrVo err := c.BindJSON(&reqBody) if err !=nil { util.ResponseFormat(c,code.RequestParamError,"参数有误") return } var api dbapi.FileAnalysisApi if api.Delete(reqBody.Ids) { util.ResponseFormat(c,code.DelSuccess,"") } else { util.ResponseFormat(c,code.ComError,"") } } const ( Sort_Up = 1 Sort_Down = 2 ) // @Security ApiKeyAuth // @Summary 本地文件排序 // @Description 本地文件排序 // @Accept json // @Produce json // @Tags 本地文件 // Param reqBody body controllers.SortVo true "排序参数,向上direct=1,向下direct=2" // @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}" // @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}" // @Router /data/api-v/fileAnalysis/sortFile [post] func (fac FileAnalysisController) SortFile(c *gin.Context) { var reqBody SortVo err := c.BindJSON(&reqBody) if err !=nil || (reqBody.Direct !=Sort_Up && reqBody.Direct !=Sort_Down) { util.ResponseFormat(c,code.RequestParamError,"参数有误") return } var api dbapi.FileAnalysisApi if api.SortFile(reqBody.Id,reqBody.Direct) { util.ResponseFormat(c,code.UpdateSuccess,"更新成功") } else { util.ResponseFormat(c,code.UpdateFail,"更新失败") } } controllers/fileAnalysisSetting.go
New file @@ -0,0 +1,38 @@ package controllers import ( "basic.com/dbapi.git" "github.com/gin-gonic/gin" "webserver/extend/code" "webserver/extend/util" ) type FileAnalysisSettingController struct { } func (fsc FileAnalysisSettingController) Show(c *gin.Context) { var api dbapi.FileAnalysisApi setting, err := api.GetFileAnalysisSet() if err == nil { util.ResponseFormat(c,code.Success, setting) } else { util.ResponseFormat(c,code.ComError, setting) } } type EnableSet struct { Enable bool `json:"enable"` } func (fsc FileAnalysisSettingController) ChangeEnable(c *gin.Context) { var reqBody EnableSet c.BindJSON(&reqBody) var api dbapi.FileAnalysisApi if api.ChangeEnable(reqBody.Enable) { util.ResponseFormat(c,code.UpdateSuccess,"更新成功") } else { util.ResponseFormat(c,code.UpdateFail,"更新失败") } } go.mod
@@ -3,12 +3,12 @@ go 1.12 require ( basic.com/dbapi.git v0.0.0-20191122064621-1675117bdb57 // indirect basic.com/dbapi.git v0.0.0-20191202091445-8ddb48697708 // 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-20191120125514-865efa73a9ae // indirect basic.com/pubsub/protomsg.git v0.0.0-20191120124614-c1105ad8821c // indirect basic.com/pubsub/protomsg.git v0.0.0-20191202120753-f20294c1ff90 // indirect basic.com/valib/capture.git v0.0.0-20191126081138-bf954c0fa627 // indirect basic.com/valib/deliver.git v0.0.0-20190531095353-25d8c3b20051 basic.com/valib/godraw.git v0.0.0-20191122082247-26e9987cd183 // indirect go.sum
@@ -1,5 +1,5 @@ basic.com/dbapi.git v0.0.0-20191122064621-1675117bdb57 h1:RHd4ZKtKR9oEJ0zNUwz/hHSpqPS63LFe7CxRqRJWFWc= basic.com/dbapi.git v0.0.0-20191122064621-1675117bdb57/go.mod h1:eDXPnxaz6jZPDvBSk7ya7oSASWPCuUEgRTJCjsfKt/Q= basic.com/dbapi.git v0.0.0-20191202091445-8ddb48697708 h1:8lk1xOxDhlOftb7xaFSaB554zP97Y2m2oW4dJrHZnNM= basic.com/dbapi.git v0.0.0-20191202091445-8ddb48697708/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= @@ -8,8 +8,8 @@ basic.com/pubsub/cache.git v0.0.0-20190718093725-6a413e1d7d48/go.mod h1:gHLJZz2ee1cGL0X0ae69fs56bAxkDgEQwDhhXZJNUcY= basic.com/pubsub/esutil.git v0.0.0-20191120125514-865efa73a9ae h1:/j1dIDLxzEp51N+ZHZIq1xeYVK9zz8epWEAfw01uWe8= basic.com/pubsub/esutil.git v0.0.0-20191120125514-865efa73a9ae/go.mod h1:yIvppFPFGC61DOdm71ujnsxZBMFUu2yKjr5O43bMWCw= basic.com/pubsub/protomsg.git v0.0.0-20191120124614-c1105ad8821c h1:iVBONjMIxCXKJ/kWFgw0kTws9/ZWdTQqJC3otzRGLyo= basic.com/pubsub/protomsg.git v0.0.0-20191120124614-c1105ad8821c/go.mod h1:un5NV5VWQoblVLZfx1Rt5vyLgwR0jI92d3VJhfrJhWU= basic.com/pubsub/protomsg.git v0.0.0-20191202120753-f20294c1ff90 h1:bQiuJTp4+7KvCfDmVQPDUwk3n/sqHD6/YyO/akh94Ek= basic.com/pubsub/protomsg.git v0.0.0-20191202120753-f20294c1ff90/go.mod h1:un5NV5VWQoblVLZfx1Rt5vyLgwR0jI92d3VJhfrJhWU= basic.com/valib/capture.git v0.0.0-20191126081138-bf954c0fa627 h1:26J3wU05U/v72SvUvtFc6Ymgvlill9SXbRn/cMGE5k0= basic.com/valib/capture.git v0.0.0-20191126081138-bf954c0fa627/go.mod h1:y+h7VUnoSQ3jOtf2K3twXNA8fYDfyUsifSswcyKLgNw= basic.com/valib/deliver.git v0.0.0-20190531095353-25d8c3b20051/go.mod h1:bkYiTUGzckyNOjAgn9rB/DOjFzwoSHJlruuWQ6hu6IY= router/router.go
@@ -45,6 +45,8 @@ sysRoleController := new(controllers.RoleController) ptzController := new(controllers.PanTiltZoomController) licenseController := new(controllers.LicenseController) fileAnalysisC := new(controllers.FileAnalysisController) fileSettingC := new(controllers.FileAnalysisSettingController) urlPrefix := "/data/api-v" // wp 添加 路径 前缀 @@ -287,6 +289,18 @@ clusterApi.POST("/updateClusterName", clusterController.UpdateClusterName) clusterApi.POST("/leave", clusterController.Leave) } fileAnalyApi := r.Group(urlPrefix + "/fileAnalysis") { fileAnalyApi.GET("/findAllFile", fileAnalysisC.FindAllFile) fileAnalyApi.POST("/updateStatus",fileAnalysisC.UpdateStatus) fileAnalyApi.POST("/delete",fileAnalysisC.Delete) fileAnalyApi.POST("/sortFile",fileAnalysisC.SortFile) } fileSettingApi := r.Group(urlPrefix + "/fileSetting") { fileSettingApi.GET("/show",fileSettingC.Show) fileSettingApi.POST("/changeEnable", fileSettingC.ChangeEnable) } // 文件 上传 r.Static("static", "./static") // 静态文件