Browse Source

update

master
shenjiachi 21 hours ago
parent
commit
e82398a53c
6 changed files with 145 additions and 136 deletions
  1. +3
    -9
      app/hdl/comm/hdl_comm.go
  2. +2
    -1
      app/md/comm/hdl_comm.go
  3. +1
    -1
      app/router/router.go
  4. +52
    -47
      docs/docs.go
  5. +52
    -47
      docs/swagger.json
  6. +35
    -31
      docs/swagger.yaml

+ 3
- 9
app/hdl/comm/hdl_comm.go View File

@@ -11,7 +11,6 @@ import (
enum2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" enum2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum"
"github.com/aliyun/aliyun-oss-go-sdk/oss" "github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"strings"
"time" "time"
) )


@@ -25,7 +24,7 @@ import (
// @Param req body comm.ImgReqUploadReq true "签名上传url" // @Param req body comm.ImgReqUploadReq true "签名上传url"
// @Success 200 {string} "许可链接" // @Success 200 {string} "许可链接"
// @Failure 400 {object} md.Response "具体错误" // @Failure 400 {object} md.Response "具体错误"
// @Router /api/comm/getOssUrl [get]
// @Router /api/v1/comm/getOssUrl [POST]
func GetOssUrl(c *gin.Context) { func GetOssUrl(c *gin.Context) {
var args comm.ImgReqUploadReq var args comm.ImgReqUploadReq
err := c.ShouldBindJSON(&args) err := c.ShouldBindJSON(&args)
@@ -56,7 +55,6 @@ func GetOssUrl(c *gin.Context) {
ossBucketScheme := cfgMap[enum2.AliyunOssBucketScheme] ossBucketScheme := cfgMap[enum2.AliyunOssBucketScheme]
accessKeyID := cfgMap[enum2.AliyunOssAccessKeyID] accessKeyID := cfgMap[enum2.AliyunOssAccessKeyID]
accessKeySecret := cfgMap[enum2.AliyunOssAccessKeySecret] accessKeySecret := cfgMap[enum2.AliyunOssAccessKeySecret]
aliyunOptions := cfgMap[enum2.AliyunOptions]


// 创建OSSClient实例。 // 创建OSSClient实例。
client, err := oss.New(ossBucketScheme+"://"+endpoint, accessKeyID, accessKeySecret) client, err := oss.New(ossBucketScheme+"://"+endpoint, accessKeyID, accessKeySecret)
@@ -72,12 +70,8 @@ func GetOssUrl(c *gin.Context) {
return return
} }


optionsList := strings.Split(aliyunOptions, ",")

var options []oss.Option

for _, option := range optionsList {
options = append(options, oss.ContentType(option))
options := []oss.Option{
oss.ContentType(args.ContentType),
} }


signedURL, err := bucket.SignURL(args.FileName, oss.HTTPPut, 60*5, options...) signedURL, err := bucket.SignURL(args.FileName, oss.HTTPPut, 60*5, options...)


+ 2
- 1
app/md/comm/hdl_comm.go View File

@@ -5,7 +5,8 @@ type AccessRecordsReq struct {
} }


type ImgReqUploadReq struct { type ImgReqUploadReq struct {
FileName string `json:"file_name" binding:"required" example:"文件名"`
FileName string `json:"file_name,required" binding:"required" example:"文件名"`
ContentType string `json:"content_type,required" binding:"required" example:"image/jpeg"`
} }


type UploadReq struct { type UploadReq struct {


+ 1
- 1
app/router/router.go View File

@@ -144,6 +144,6 @@ func route(r *gin.RouterGroup) {
} }


func rComm(r *gin.RouterGroup) { func rComm(r *gin.RouterGroup) {
r.GET("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL
r.POST("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL
r.GET("/accessRecords", comm.AccessRecords) // 访问记录 r.GET("/accessRecords", comm.AccessRecords) // 访问记录
} }

+ 52
- 47
docs/docs.go View File

@@ -24,53 +24,6 @@ const docTemplate = `{
"host": "{{.Host}}", "host": "{{.Host}}",
"basePath": "{{.BasePath}}", "basePath": "{{.BasePath}}",
"paths": { "paths": {
"/api/comm/getOssUrl": {
"get": {
"description": "上传许可链接(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"对象存储"
],
"summary": "通用请求-对象存储-上传许可链接(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "签名上传url",
"name": "req",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/comm.ImgReqUploadReq"
}
}
],
"responses": {
"200": {
"description": "许可链接",
"schema": {
"type": "string"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/addFriend/basalRate": { "/api/v1/addFriend/basalRate": {
"get": { "get": {
"description": "基础速率(获取)", "description": "基础速率(获取)",
@@ -727,6 +680,53 @@ const docTemplate = `{
} }
} }
}, },
"/api/v1/comm/getOssUrl": {
"post": {
"description": "上传许可链接(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"对象存储"
],
"summary": "通用请求-对象存储-上传许可链接(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "签名上传url",
"name": "req",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/comm.ImgReqUploadReq"
}
}
],
"responses": {
"200": {
"description": "许可链接",
"schema": {
"type": "string"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/config": { "/api/v1/config": {
"get": { "get": {
"description": "基本配置", "description": "基本配置",
@@ -2361,9 +2361,14 @@ const docTemplate = `{
"comm.ImgReqUploadReq": { "comm.ImgReqUploadReq": {
"type": "object", "type": "object",
"required": [ "required": [
"content_type",
"file_name" "file_name"
], ],
"properties": { "properties": {
"content_type": {
"type": "string",
"example": "image/jpeg"
},
"file_name": { "file_name": {
"type": "string", "type": "string",
"example": "文件名" "example": "文件名"


+ 52
- 47
docs/swagger.json View File

@@ -18,53 +18,6 @@
"host": "ddxq.izhim.com", "host": "ddxq.izhim.com",
"basePath": "/api/v1", "basePath": "/api/v1",
"paths": { "paths": {
"/api/comm/getOssUrl": {
"get": {
"description": "上传许可链接(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"对象存储"
],
"summary": "通用请求-对象存储-上传许可链接(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "签名上传url",
"name": "req",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/comm.ImgReqUploadReq"
}
}
],
"responses": {
"200": {
"description": "许可链接",
"schema": {
"type": "string"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/addFriend/basalRate": { "/api/v1/addFriend/basalRate": {
"get": { "get": {
"description": "基础速率(获取)", "description": "基础速率(获取)",
@@ -721,6 +674,53 @@
} }
} }
}, },
"/api/v1/comm/getOssUrl": {
"post": {
"description": "上传许可链接(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"对象存储"
],
"summary": "通用请求-对象存储-上传许可链接(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "签名上传url",
"name": "req",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/comm.ImgReqUploadReq"
}
}
],
"responses": {
"200": {
"description": "许可链接",
"schema": {
"type": "string"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/config": { "/api/v1/config": {
"get": { "get": {
"description": "基本配置", "description": "基本配置",
@@ -2355,9 +2355,14 @@
"comm.ImgReqUploadReq": { "comm.ImgReqUploadReq": {
"type": "object", "type": "object",
"required": [ "required": [
"content_type",
"file_name" "file_name"
], ],
"properties": { "properties": {
"content_type": {
"type": "string",
"example": "image/jpeg"
},
"file_name": { "file_name": {
"type": "string", "type": "string",
"example": "文件名" "example": "文件名"


+ 35
- 31
docs/swagger.yaml View File

@@ -20,10 +20,14 @@ definitions:
type: object type: object
comm.ImgReqUploadReq: comm.ImgReqUploadReq:
properties: properties:
content_type:
example: image/jpeg
type: string
file_name: file_name:
example: 文件名 example: 文件名
type: string type: string
required: required:
- content_type
- file_name - file_name
type: object type: object
md.AdvertisingBasic: md.AdvertisingBasic:
@@ -1246,37 +1250,6 @@ info:
title: 蛋蛋星球-APP客户端 title: 蛋蛋星球-APP客户端
version: "1.0" version: "1.0"
paths: paths:
/api/comm/getOssUrl:
get:
consumes:
- application/json
description: 上传许可链接(获取)
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
name: Authorization
required: true
type: string
- description: 签名上传url
in: body
name: req
required: true
schema:
$ref: '#/definitions/comm.ImgReqUploadReq'
produces:
- application/json
responses:
"200":
description: 许可链接
schema:
type: string
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 通用请求-对象存储-上传许可链接(获取)
tags:
- 对象存储
/api/v1/addFriend/basalRate: /api/v1/addFriend/basalRate:
get: get:
consumes: consumes:
@@ -1710,6 +1683,37 @@ paths:
summary: 蛋蛋学院-文章-分享后调用统计数量 summary: 蛋蛋学院-文章-分享后调用统计数量
tags: tags:
- 蛋蛋学院 - 蛋蛋学院
/api/v1/comm/getOssUrl:
post:
consumes:
- application/json
description: 上传许可链接(获取)
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
name: Authorization
required: true
type: string
- description: 签名上传url
in: body
name: req
required: true
schema:
$ref: '#/definitions/comm.ImgReqUploadReq'
produces:
- application/json
responses:
"200":
description: 许可链接
schema:
type: string
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 通用请求-对象存储-上传许可链接(获取)
tags:
- 对象存储
/api/v1/config: /api/v1/config:
get: get:
consumes: consumes:


Loading…
Cancel
Save