liuxiaolong
2020-03-09 7103cd719a4a56b3c407b9b3893b85a750ec1a73
controllers/fileAnalysis.go
@@ -3,6 +3,7 @@
import (
   "basic.com/dbapi.git"
   "github.com/gin-gonic/gin"
   "github.com/satori/go.uuid"
   "strconv"
   "webserver/extend/code"
   "webserver/extend/util"
@@ -181,3 +182,83 @@
      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 "数据栈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/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,"")
   }
}