zhangqian
2024-05-21 111676bec43d0698c3f605993fe5b09bf4c93008
音频下载接口
6个文件已修改
134 ■■■■■ 已修改文件
conf/config.yaml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/audio.go 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/router.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
conf/config.yaml
@@ -17,6 +17,6 @@
  MaxBackups: 2  # 保留的旧日志文件个数
  RotateDays: 5  # 日志文件的最大保留天数
local:
  storePath: uploads/
  storePath: uploads
analysis:
  url: http://192.168.20.116:5000/recognition
controllers/audio.go
@@ -241,6 +241,37 @@
    util.ResponseFormat(c, code.UpdateSuccess, audio)
}
// AudioDownload
// @Tags      音频
// @Summary   音频下载
// @Produce   application/json
// @Param     object  query request.ProcessAudio true  "参数"
// @Success   200 {object} util.Response{data=models.Audio} "成功"
// @Router    /api-sa/v1/audio/download [get]
func (slf AudioCtl) AudioDownload(c *gin.Context) {
    var params request.ProcessAudio
    if err := c.ShouldBindQuery(&params); err != nil {
        util.ResponseFormat(c, code.RequestParamError, err.Error())
        return
    }
    audio, err := models.NewAudioSearch().SetID(params.ID).First()
    if err != nil {
        util.ResponseFormat(c, code.InternalError, "查询失败")
        return
    }
    if audio.FilePath == "" {
        util.ResponseFormat(c, code.InternalError, "查询失败")
        return
    }
    c.Header("Content-Description", "File Transfer")
    c.Header("Content-Disposition", "attachment; filename="+audio.Name)
    c.Header("Content-Type", "application/octet-stream")
    c.File(audio.FilePath)
}
// BatchProcess
// @Tags      音频
// @Summary   批量处理音频
docs/docs.go
@@ -106,6 +106,45 @@
                }
            }
        },
        "/api-sa/v1/audio/download": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "音频"
                ],
                "summary": "音频下载",
                "parameters": [
                    {
                        "type": "integer",
                        "name": "id",
                        "in": "query",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/util.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/models.Audio"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api-sa/v1/audio/follow": {
            "post": {
                "produces": [
docs/swagger.json
@@ -94,6 +94,45 @@
                }
            }
        },
        "/api-sa/v1/audio/download": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "音频"
                ],
                "summary": "音频下载",
                "parameters": [
                    {
                        "type": "integer",
                        "name": "id",
                        "in": "query",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/util.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/models.Audio"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api-sa/v1/audio/follow": {
            "post": {
                "produces": [
docs/swagger.yaml
@@ -264,6 +264,28 @@
      summary: 删除音频
      tags:
      - 音频
  /api-sa/v1/audio/download:
    get:
      parameters:
      - in: query
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            allOf:
            - $ref: '#/definitions/util.Response'
            - properties:
                data:
                  $ref: '#/definitions/models.Audio'
              type: object
      summary: 音频下载
      tags:
      - 音频
  /api-sa/v1/audio/follow:
    post:
      parameters:
router/router.go
@@ -28,6 +28,7 @@
        audioAPi.POST("upload", audioCtl.Upload)              // 上传音频
        audioAPi.GET("list", audioCtl.List)                   // 音频检索
        audioAPi.GET("info", audioCtl.AudioInfo)              // 音频详情
        audioAPi.GET("download", audioCtl.AudioDownload)      // 音频下载
        audioAPi.GET("trainInfoList", audioCtl.TrainInfoList) // 火车信息列表
        audioAPi.POST("process", audioCtl.Process)            // 音频处理
        audioAPi.POST("batchProcess", audioCtl.BatchProcess)  // 音频批量处理