liuxiaolong
2020-07-14 aaa7697d6ec77e03d96ce36ca66abcbbcf2bb7a3
controllers/sdk.go
@@ -47,7 +47,7 @@
// @Description 算法保存
// @Accept json
// @Produce json
// @Tags sdk
// @Tags 算法
// @Param reqMap body controllers.SdkVo true "人脸检测"
// @Success 200 {string} json "{"code":200, msg:"请求处理成功",data:"",success:true}"
// @Failure 500 {string} json "{"code":500, msg:"请求失败",data:"",success:false}"
@@ -73,7 +73,7 @@
// @Summary 查找所有算法
// @Description 查找所有算法
// @Produce json
// @Tags sdk
// @Tags 算法
// @Param sdkName query string false "可选参数"
// @Success 200 {string} json "{"code":200, msg:"请求处理成功",data:"算法列表",success:true}"
// @Failure 500 {string} json "{"code":500, msg:"请求失败",data:"[]",success:false}"
@@ -91,7 +91,7 @@
// @Summary 根据id获取算法信息
// @Description 根据id获取算法信息
// @Produce json
// @Tags sdk
// @Tags 算法
// @Param id query string true "算法id,必填"
// @Success 200 {string} json "{"code":200, msg:"请求处理成功",data:"算法信息",success:true}"
// @Failure 500 {string} json "{"code":500, msg:"请求失败",data:"",success:false}"
@@ -134,7 +134,7 @@
// @Summary 根据taskId获取算法信息
// @Description 根据taskId获取算法信息
// @Produce json
// @Tags sdk
// @Tags 算法
// @Param taskId query string true "taskId,必填"
// @Success 200 {string} json "{"code":200, msg:"请求处理成功",data:"算法信息",success:true}"
// @Failure 500 {string} json "{"code":500, msg:"请求失败",data:"",success:false}"
@@ -158,7 +158,7 @@
// @Description 算法安装包上传(分块检查)
// @Accept multipart/form-data
// @Produce json
// @Tags sdk
// @Tags 算法
// @Param chunkNumber formData int true "当前是第几个分块"
// @Param chunkSize formData int true "每一块的大小"
// @Param currentChunkSize formData int true "当前块的大小"
@@ -210,7 +210,7 @@
// @Description 算法安装包上传
// @Accept multipart/form-data
// @Produce json
// @Tags sysset
// @Tags 算法
// @Param chunkNumber formData int true "当前是第几个分块"
// @Param chunkSize formData int true "每一块的大小"
// @Param currentChunkSize formData int true "当前块的大小"
@@ -257,20 +257,44 @@
      Header:           header,
   }
   var sv service.SysService
   if b,isComplete := sv.PatchUpload(&arg); b {
      if isComplete { //上传完毕需要自动触发安装
         var sv service.SdkInstallService
         if b,err := sv.SdkInstall(identifier, filename);b {
            util.ResponseFormat(c,&code.Code{http.StatusOK, true, "算法安装成功"},"算法安装成功")
            return
         } else {
            util.ResponseFormat(c,&code.Code{http.StatusBadRequest, false, "算法安装失败"},err.Error())
            return
         }
      }
      util.ResponseFormat(c, code.Success, "")
   if b,_ := sv.PatchUpload(&arg); b {
      //if isComplete { //上传完毕需要自动触发安装
      //   var sv service.SdkInstallService
      //   if b,err := sv.SdkInstall(identifier, filename);b {
      //      util.ResponseFormat(c,&code.Code{http.StatusOK, true, "算法安装成功"},"算法安装成功")
      //      return
      //   } else {
      //      util.ResponseFormat(c,&code.Code{http.StatusBadRequest, false, "算法安装失败"},err.Error())
      //      return
      //   }
      //}
      util.ResponseFormat(c, code.Success, "上传完成")
   } else {
      util.ResponseFormat(c, code.ComError, "")
   }
}
// @Security ApiKeyAuth
// @Summary 上传完成开始安装
// @Description 上传完成开始安装
// @Produce json
// @Tags 算法
// @Param identifier formData string true "整个文件的唯一标识,目前是md5"
// @Param filename formData string true "文件名称"
// @Success 200 {string} json "{"code":200, msg:"", success:true}"
// @Failure 500 {string} json "{"code":500, msg:"", success:false}"
// @Router /data/api-v/sdk/install [post]
func (sc SdkController) Install(c *gin.Context) {
   identifier := c.Request.FormValue("identifier")
   filename := c.Request.FormValue("filename")
   var sv service.SdkInstallService
   if b,err := sv.SdkInstall(identifier, filename);b {
      util.ResponseFormat(c,&code.Code{http.StatusOK, true, "算法安装成功"},"算法安装成功")
      return
   } else {
      util.ResponseFormat(c,&code.Code{http.StatusBadRequest, false, "算法安装失败"},err.Error())
      return
   }
}
@@ -278,7 +302,7 @@
// @Summary 从商城下载或升级算法
// @Description 从商城下载或升级算法
// @Produce json
// @Tags sysset
// @Tags 算法
// @Param path query string true "算法id"
// @Success 200 {string} json "{"code":200, msg:"", success:true}"
// @Failure 500 {string} json "{"code":500, msg:"", success:false}"
@@ -296,3 +320,27 @@
      util.ResponseFormat(c, &code.Code{http.StatusBadRequest, false, err.Error()}, err.Error())
   }
}
// @Security ApiKeyAuth
// @Summary 使用激活码激活安装算法
// @Description 使用激活码激活安装算法
// @Produce json
// @Tags 算法
// @Param code query string true "激活码"
// @Success 200 {string} json "{"code":200, msg:"", success:true}"
// @Failure 500 {string} json "{"code":500, msg:"", success:false}"
// @Router /data/api-v/sdk/active [get]
func (sc SdkController) Active(c *gin.Context) {
   cod := c.GetString("code")
   if cod == "" {
      util.ResponseFormat(c, code.RequestParamError, "激活码不能为空")
      return
   }
   var sv service.SdkInstallService
   err := sv.Active(cod)
   if err == nil {
      util.ResponseFormat(c,code.Success,  "激活成功")
   } else {
      util.ResponseFormat(c,code.ComError, err.Error())
   }
}