新增获取oss签名
This commit is contained in:
parent
f18c3ec306
commit
81a3f45817
@ -10,6 +10,7 @@ import (
|
||||
"hepa-calc-admin-api/api/requests"
|
||||
"hepa-calc-admin-api/api/responses"
|
||||
"hepa-calc-admin-api/config"
|
||||
"hepa-calc-admin-api/extend/aliyun"
|
||||
"hepa-calc-admin-api/global"
|
||||
"hepa-calc-admin-api/utils"
|
||||
"sort"
|
||||
@ -337,3 +338,31 @@ func (b *Public) GetIndexData(c *gin.Context) {
|
||||
|
||||
responses.OkWithData(g, c)
|
||||
}
|
||||
|
||||
// GetOssSign 获取oss签名
|
||||
func (b *Public) GetOssSign(c *gin.Context) {
|
||||
publicRequest := requests.PublicRequest{}
|
||||
req := publicRequest.GetOssSign
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取oss签名
|
||||
dir := "base/class/"
|
||||
|
||||
// 生成签名
|
||||
ossSign, err := aliyun.GetOssSign(dir)
|
||||
if err != nil {
|
||||
responses.FailWithMessage("获取签名失败", c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(ossSign, c)
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package requests
|
||||
type PublicRequest struct {
|
||||
Login // 登陆
|
||||
GetIndexData // 首页动态统计数据
|
||||
GetOssSign // 获取oss签名
|
||||
}
|
||||
|
||||
// Login 登陆
|
||||
@ -19,3 +20,8 @@ type GetIndexData struct {
|
||||
StartTime string `json:"start_time" form:"start_time" validate:"required" label:"开始时间"`
|
||||
EndTime string `json:"end_time" form:"end_time" validate:"required" label:"结束时间"`
|
||||
}
|
||||
|
||||
// GetOssSign 获取oss签名
|
||||
type GetOssSign struct {
|
||||
Scene int `json:"scene" form:"scene" validate:"required,oneof=1 2" label:"场景"` // (1:分类图标)
|
||||
}
|
||||
|
||||
@ -105,6 +105,13 @@ func adminRouter(r *gin.Engine, api controller.Api) {
|
||||
// 首页动态统计数据
|
||||
indexGroup.GET("/data", api.Public.GetIndexData)
|
||||
}
|
||||
|
||||
// 签名
|
||||
signGroup := adminGroup.Group("/sign")
|
||||
{
|
||||
// 获取oss签名
|
||||
signGroup.GET("/oss", api.Public.GetOssSign)
|
||||
}
|
||||
}
|
||||
|
||||
// basicRouter 基础数据-验证权限
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user