From 7c811247ecf143e08c576986a884bedadc57dd66 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期五, 05 六月 2020 18:29:41 +0800 Subject: [PATCH] add refresh token to resp --- controllers/fileAnalysis.go | 149 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 141 insertions(+), 8 deletions(-) diff --git a/controllers/fileAnalysis.go b/controllers/fileAnalysis.go index da6c3af..44a6e84 100644 --- a/controllers/fileAnalysis.go +++ b/controllers/fileAnalysis.go @@ -3,6 +3,7 @@ import ( "basic.com/dbapi.git" "github.com/gin-gonic/gin" + "strconv" "webserver/extend/code" "webserver/extend/util" ) @@ -16,15 +17,22 @@ // @Description 鑾峰彇鏈湴鏂囦欢鍒楄〃 // @Produce json // @Tags 鏈湴鏂囦欢 +// @Param fileName query string false "鏍规嵁鏂囦欢鍚嶇О鏌ヨ" +// @Param page query int true "褰撳墠椤�" +// @Param size query int true "姣忛〉鏁伴噺" +// @Param type query int true "0:澶勭悊瀹屾垚锛�1:澶勭悊涓紝2:鏈厤瑙勫垯锛�3:澶勭悊澶辫触" // @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") + page,_ := strconv.Atoi(c.Query("page")) + size,_ := strconv.Atoi(c.Query("size")) + fType,_ := strconv.Atoi(c.Query("type")) var api dbapi.FileAnalysisApi - arr, _ := api.FindAllFile(fileName) - if arr !=nil && len(arr) >0 { - util.ResponseFormat(c,code.Success,arr) + b, d := api.FindAllFile(fileName, fType, page, size) + if b { + util.ResponseFormat(c,code.Success, d) } else { util.ResponseFormat(c,code.Success,[]interface{}{}) } @@ -37,13 +45,19 @@ type SortVo struct { Id string `json:"id" binding:"required"` - Direct int `json:"direct" binding:"required" example:"1:鍚戜笂锛�2锛氬悜涓�"` + Direct int `json:"direct" binding:"required"` } type FileStatusVo struct { Ids []string `json:"ids" binding:"required"` - Status int `json:"status" binding:"required"` + Status int `json:"status"` } + +const ( + File_Img_Id_Pre = "img_" + File_Video_Id_Pre = "video_" + File_Audio_Id_Pre = "audio_" +) // @Security ApiKeyAuth // @Summary 寮�鍚垨鏆傚仠鏂囦欢鍒嗘瀽 @@ -51,7 +65,7 @@ // @Accept json // @Produce json // @Tags 鏈湴鏂囦欢 -// Param reqBody body controllers.FileStatusVo true "寮�鍚殏鍋滃弬鏁�,鏆傚仠status=0锛屽紑鍚痵tatus=1" +// @Param reqBody body controllers.FileStatusVo true "寮�鍚殏鍋滃弬鏁�,鏆傚仠status=0锛屽紑鍚痵tatus=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] @@ -77,7 +91,7 @@ // @Accept json // @Produce json // @Tags 鏈湴鏂囦欢 -// Param reqBody body controllers.IdArrVo true "鍒犻櫎鏂囦欢id鍒楄〃" +// @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] @@ -108,7 +122,7 @@ // @Accept json // @Produce json // @Tags 鏈湴鏂囦欢 -// Param reqBody body controllers.SortVo true "鎺掑簭鍙傛暟,鍚戜笂direct=1锛屽悜涓媎irect=2" +// @Param reqBody body controllers.SortVo true "鎺掑簭鍙傛暟,鍚戜笂direct=1锛屽悜涓媎irect=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] @@ -128,3 +142,122 @@ } } + +// @Security ApiKeyAuth +// @Summary 鎸夋暟鎹爤id鏌ユ壘鏂囦欢 +// @Description 鎸夋暟鎹爤id鏌ユ壘鏂囦欢 +// @Accept json +// @Produce json +// @Tags 鏈湴鏂囦欢 +// @Param stackId query string true "stackId" +// @Param type query int true "type" +// @Param name query string false "鎼滅储鏉′欢" +// @Param page query int true "褰撳墠椤�" +// @Param size query int 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/fileAnalysis/findByStackId [get] +func (fac FileAnalysisController) FindByStackId(c *gin.Context) { + stackId := c.Query("stackId") + if stackId == "" { + util.ResponseFormat(c,code.RequestParamError, "") + return + } + typ,_ := strconv.Atoi(c.Query("type")) + page,_ := strconv.Atoi(c.Query("page")) + size,_ := strconv.Atoi(c.Query("size")) + name := c.Query("name") + if page <= 0 { + page = 1 + } + if size <= 0 { + size = 20 + } + var api dbapi.FileAnalysisApi + b,d := api.FindByStackId(stackId, typ, name, page, size) + if !b { + util.ResponseFormat(c,code.ComError, "") + } else { + util.ResponseFormat(c,code.Success, d) + } +} + +// @Summary 閲嶅懡鍚� +// @Description 閲嶅懡鍚� +// @Accept json +// @Produce json +// @Tags 鏈湴鏂囦欢 +// @Param id formData string true "鏂囦欢id" +// @Param name formData string 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/fileAnalysis/rename [post] +func (fac FileAnalysisController) Rename(c *gin.Context) { + id := c.Request.FormValue("id") + name := c.Request.FormValue("name") + if id == "" || name == "" { + util.ResponseFormat(c,code.RequestParamError,"") + return + } + var api dbapi.FileAnalysisApi + if api.Rename(id, name) { + util.ResponseFormat(c,code.Success, "") + } else { + util.ResponseFormat(c,code.ComError,"") + } +} + +// @Summary 绉诲姩 +// @Description 绉诲姩 +// @Accept json +// @Produce json +// @Tags 鏈湴鏂囦欢 +// @Param id formData string true "鏂囦欢id" +// @Param stackId formData string true "鏁版嵁鏍坕d" +// @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/move [post] +func (fac FileAnalysisController) Move(c *gin.Context) { + id := c.Request.FormValue("id") + stackId := c.Request.FormValue("stackId") + if id == "" || stackId == "" { + util.ResponseFormat(c,code.RequestParamError,"") + return + } + var api dbapi.FileAnalysisApi + if api.Move(id, stackId) { + util.ResponseFormat(c,code.Success, "") + } else { + util.ResponseFormat(c,code.ComError,"") + } +} + +type FileMoveVo struct { + Id string `json:"id" binding:"required"` + StackIds []string `json:"stackIds" binding:"required"` +} + +// @Summary 澶嶅埗 +// @Description 澶嶅埗 +// @Accept json +// @Produce json +// @Tags 鏈湴鏂囦欢 +// @Param reqBody body controllers.FileMoveVo 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/fileAnalysis/copy [post] +func (fac FileAnalysisController) Copy(c *gin.Context) { + var reqBody FileMoveVo + err := c.BindJSON(&reqBody) + if err != nil { + util.ResponseFormat(c,code.RequestParamError,"") + return + } + + var api dbapi.FileAnalysisApi + if api.Copy(reqBody.Id, reqBody.StackIds) { + util.ResponseFormat(c,code.Success, "") + } else { + util.ResponseFormat(c,code.ComError,"") + } +} \ No newline at end of file -- Gitblit v1.8.0