dengbiao há 17 horas
ascendente
cometimento
0d358715ed
4 ficheiros alterados com 40 adições e 20 eliminações
  1. +11
    -1
      app/hdl/comm/hdl_comm.go
  2. +26
    -18
      app/hdl/setCenter/oss/aliyun/hdl_basic.go
  3. +2
    -0
      app/md/setCenter/oss/aliyun/md.basic.go
  4. +1
    -1
      go.mod

+ 11
- 1
app/hdl/comm/hdl_comm.go Ver ficheiro

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

func MenuList(c *gin.Context) {
@@ -157,6 +158,7 @@ func GetOssUrl(c *gin.Context) {
ossBucketScheme := cfgMap[enum2.AliyunOssBucketScheme]
accessKeyID := cfgMap[enum2.AliyunOssAccessKeyID]
accessKeySecret := cfgMap[enum2.AliyunOssAccessKeySecret]
aliyunOptions := cfgMap[enum2.AliyunOptions]

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

signedURL, err := bucket.SignURL(args.FileName, oss.HTTPPut, 60*5)
optionsList := strings.Split(aliyunOptions, ",")

var options []oss.Option

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

signedURL, err := bucket.SignURL(args.FileName, oss.HTTPPut, 60*5, options...)
if err != nil {
e.OutErr(c, e.ERR_AES_ENCODE, err.Error())
return


+ 26
- 18
app/hdl/setCenter/oss/aliyun/hdl_basic.go Ver ficheiro

@@ -32,36 +32,40 @@ func GetBasic(c *gin.Context) {
for _, cfg := range *sysCfg {
cfgMap[cfg.Key] = cfg.Val
}
endpoint, ok := cfgMap[enum2.AliyunOss(enum2.AliyunOssEndpoint).String()]
endpoint, ok := cfgMap[enum2.AliyunOssEndpoint]
if !ok {
sysCfgDb.SysCfgInsert(enum2.AliyunOss(enum2.AliyunOssEndpoint).String(), "", "oss地域节点")
sysCfgDb.SysCfgInsert(enum2.AliyunOssEndpoint, "", enum2.AliyunOss(enum2.AliyunOssEndpoint).String())
endpoint = ""
}
bucketName, ok := cfgMap[enum2.AliyunOss(enum2.AliyunOssBucketName).String()]
bucketName, ok := cfgMap[enum2.AliyunOssBucketName]
if !ok {
sysCfgDb.SysCfgInsert(enum2.AliyunOss(enum2.AliyunOssBucketName).String(), "", "oss存储桶名称")
sysCfgDb.SysCfgInsert(enum2.AliyunOssBucketName, "", enum2.AliyunOss(enum2.AliyunOssBucketName).String())
bucketName = ""
}
bucketScheme, ok := cfgMap[enum2.AliyunOss(enum2.AliyunOssBucketScheme).String()]
bucketScheme, ok := cfgMap[enum2.AliyunOssBucketScheme]
if !ok {
sysCfgDb.SysCfgInsert(enum2.AliyunOss(enum2.AliyunOssBucketScheme).String(), "", "oss上传方式")
sysCfgDb.SysCfgInsert(enum2.AliyunOssBucketScheme, "", enum2.AliyunOss(enum2.AliyunOssBucketScheme).String())
bucketScheme = ""
}
accessKeyID, ok := cfgMap[enum2.AliyunOss(enum2.AliyunOssAccessKeyID).String()]
accessKeyID, ok := cfgMap[enum2.AliyunOssAccessKeyID]
if !ok {
sysCfgDb.SysCfgInsert(enum2.AliyunOss(enum2.AliyunOssAccessKeyID).String(), "", "oss访问秘钥id")
sysCfgDb.SysCfgInsert(enum2.AliyunOssAccessKeyID, "", enum2.AliyunOss(enum2.AliyunOssAccessKeyID).String())
accessKeyID = ""
}
accessKeySecret, ok := cfgMap[enum2.AliyunOss(enum2.AliyunOssAccessKeySecret).String()]
accessKeySecret, ok := cfgMap[enum2.AliyunOssAccessKeySecret]
if !ok {
sysCfgDb.SysCfgInsert(enum2.AliyunOss(enum2.AliyunOssAccessKeySecret).String(), "", "oss访问秘钥")
sysCfgDb.SysCfgInsert(enum2.AliyunOssAccessKeySecret, "", enum2.AliyunOss(enum2.AliyunOssAccessKeySecret).String())
accessKeySecret = ""
}
domain, ok := cfgMap[enum2.AliyunOss(enum2.AliyunOssDomain).String()]
domain, ok := cfgMap[enum2.AliyunOssDomain]
if !ok {
sysCfgDb.SysCfgInsert(enum2.AliyunOss(enum2.AliyunOssDomain).String(), "", "oss域名")
sysCfgDb.SysCfgInsert(enum2.AliyunOssDomain, "", enum2.AliyunOss(enum2.AliyunOssDomain).String())
domain = ""
}
options, ok := cfgMap[enum2.AliyunOptions]
if !ok {
sysCfgDb.SysCfgInsert(enum2.AliyunOptions, "", enum2.AliyunOss(enum2.AliyunOptions).String())
}

resp := md.GetBasicResp{
OssEndpoint: endpoint,
@@ -70,6 +74,7 @@ func GetBasic(c *gin.Context) {
OssAccessKeyId: accessKeyID,
OssAccessKeySecret: accessKeySecret,
OssObjectDomain: domain,
OssOption: options,
}

e.OutSuc(c, resp, nil)
@@ -97,22 +102,25 @@ func SetBasic(c *gin.Context) {
cfgDb := implement.NewSysCfgDb(db.Db, redisConn)

if req.OssAccessKeyId != "" {
cfgDb.SysCfgUpdate(enum2.AliyunOss(enum2.AliyunOssAccessKeyID).String(), req.OssAccessKeyId)
cfgDb.SysCfgUpdate(enum2.AliyunOssAccessKeyID, req.OssAccessKeyId)
}
if req.OssAccessKeySecret != "" {
cfgDb.SysCfgUpdate(enum2.AliyunOss(enum2.AliyunOssAccessKeySecret).String(), req.OssAccessKeySecret)
cfgDb.SysCfgUpdate(enum2.AliyunOssAccessKeySecret, req.OssAccessKeySecret)
}
if req.OssBucketScheme != "" {
cfgDb.SysCfgUpdate(enum2.AliyunOss(enum2.AliyunOssBucketScheme).String(), req.OssBucketScheme)
cfgDb.SysCfgUpdate(enum2.AliyunOssBucketScheme, req.OssBucketScheme)
}
if req.OssObjectDomain != "" {
cfgDb.SysCfgUpdate(enum2.AliyunOss(enum2.AliyunOssDomain).String(), req.OssObjectDomain)
cfgDb.SysCfgUpdate(enum2.AliyunOssDomain, req.OssObjectDomain)
}
if req.OssBucketName != "" {
cfgDb.SysCfgUpdate(enum2.AliyunOss(enum2.AliyunOssBucketName).String(), req.OssBucketName)
cfgDb.SysCfgUpdate(enum2.AliyunOssBucketName, req.OssBucketName)
}
if req.OssEndpoint != "" {
cfgDb.SysCfgUpdate(enum2.AliyunOss(enum2.AliyunOssEndpoint).String(), req.OssEndpoint)
cfgDb.SysCfgUpdate(enum2.AliyunOssEndpoint, req.OssEndpoint)
}
if req.OssOption != "" {
cfgDb.SysCfgUpdate(enum2.AliyunOptions, req.OssEndpoint)
}
e.OutSuc(c, "success", nil)
}

+ 2
- 0
app/md/setCenter/oss/aliyun/md.basic.go Ver ficheiro

@@ -7,6 +7,7 @@ type GetBasicResp struct {
OssAccessKeyId string `json:"oss_access_key_id" example:"oss访问秘钥id"`
OssAccessKeySecret string `json:"oss_access_key_secret" example:"oss访问秘钥"`
OssObjectDomain string `json:"oss_object_domain" example:"oss域名"`
OssOption string `json:"oss_option" example:"oss选项,以逗号分割"`
}

type SetBasicReq struct {
@@ -16,4 +17,5 @@ type SetBasicReq struct {
OssAccessKeyId string `json:"oss_access_key_id" example:"oss访问秘钥id"`
OssAccessKeySecret string `json:"oss_access_key_secret" example:"oss访问秘钥"`
OssObjectDomain string `json:"oss_object_domain" example:"oss域名"`
OssOption string `json:"oss_option" example:"oss选项,以逗号分割"`
}

+ 1
- 1
go.mod Ver ficheiro

@@ -34,7 +34,7 @@ require (

require (
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241126123220-2fadc60eff6f
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241126083327-1b1d0a2602a0
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241126134228-b1047bfb8475
code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5
github.com/360EntSecGroup-Skylar/excelize v1.4.1


Carregando…
Cancelar
Guardar