Browse Source

update

master
shenjiachi 1 month ago
parent
commit
91d4a35ac1
4 changed files with 61 additions and 28 deletions
  1. +32
    -0
      app/enum/enum_aliyun_oss.go
  2. +5
    -5
      app/hdl/comm/hdl_comm.go
  3. +22
    -21
      app/hdl/setCenter/oss/aliyun/hdl_basic.go
  4. +2
    -2
      app/md/setCenter/oss/aliyun/md.basic.go

+ 32
- 0
app/enum/enum_aliyun_oss.go View File

@@ -0,0 +1,32 @@
package enum

type AliyunOss int32

const (
AliyunOssEndpoint = 1
AliyunOssBucketName = 2
AliyunOssBucketScheme = 3
AliyunOssAccessKeyID = 4
AliyunOssAccessKeySecret = 5
AliyunOssDomain = 6
)

func (gt AliyunOss) String() string {
switch gt {
case AliyunOssEndpoint:
return "oss_endpoint"
case AliyunOssBucketName:
return "oss_bucket_name"
case AliyunOssBucketScheme:
return "oss_bucket_scheme"
case AliyunOssAccessKeyID:
return "oss_access_key_id"
case AliyunOssAccessKeySecret:
return "oss_access_key_secret"
case AliyunOssDomain:
return "oss_domain"

default:
return "未知"
}
}

+ 5
- 5
app/hdl/comm/hdl_comm.go View File

@@ -136,11 +136,11 @@ func GetOssUrl(c *gin.Context) {
for _, cfg := range *sysCfgs {
cfgMap[cfg.Key] = cfg.Val
}
endpoint := cfgMap["oss_endpoint"]
bucketName := cfgMap["oss_bucket_name"]
objectName := cfgMap["oss_object_scheme"]
accessKeyID := cfgMap["oss_access_key_id"]
accessKeySecret := cfgMap["oss_access_key_secret"]
endpoint := cfgMap[enum.AliyunOss(enum.AliyunOssEndpoint).String()]
bucketName := cfgMap[enum.AliyunOss(enum.AliyunOssBucketName).String()]
objectName := cfgMap[enum.AliyunOss(enum.AliyunOssBucketScheme).String()]
accessKeyID := cfgMap[enum.AliyunOss(enum.AliyunOssAccessKeyID).String()]
accessKeySecret := cfgMap[enum.AliyunOss(enum.AliyunOssAccessKeySecret).String()]

client, err := oss.New(endpoint, accessKeyID, accessKeySecret)
if err != nil {


+ 22
- 21
app/hdl/setCenter/oss/aliyun/hdl_basic.go View File

@@ -3,6 +3,7 @@ package aliyun
import (
"applet/app/db"
"applet/app/e"
"applet/app/enum"
md "applet/app/md/setCenter/oss/aliyun"
"applet/app/utils/cache"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
@@ -31,41 +32,41 @@ func GetBasic(c *gin.Context) {
for _, cfg := range *sysCfg {
cfgMap[cfg.Key] = cfg.Val
}
endpoint, ok := cfgMap["oss_endpoint"]
endpoint, ok := cfgMap[enum.AliyunOss(enum.AliyunOssEndpoint).String()]
if !ok {
sysCfgDb.SysCfgInsert("oss_endpoint", "", "oss地域节点")
sysCfgDb.SysCfgInsert(enum.AliyunOss(enum.AliyunOssEndpoint).String(), "", "oss地域节点")
endpoint = ""
}
bucketName, ok := cfgMap["oss_bucket_name"]
bucketName, ok := cfgMap[enum.AliyunOss(enum.AliyunOssBucketName).String()]
if !ok {
sysCfgDb.SysCfgInsert("oss_bucket_name", "", "oss存储桶名称")
sysCfgDb.SysCfgInsert(enum.AliyunOss(enum.AliyunOssBucketName).String(), "", "oss存储桶名称")
bucketName = ""
}
objectScheme, ok := cfgMap["oss_object_scheme"]
bucketScheme, ok := cfgMap[enum.AliyunOss(enum.AliyunOssBucketScheme).String()]
if !ok {
sysCfgDb.SysCfgInsert("oss_object_scheme", "", "oss上传方式")
objectScheme = ""
sysCfgDb.SysCfgInsert(enum.AliyunOss(enum.AliyunOssBucketScheme).String(), "", "oss上传方式")
bucketScheme = ""
}
accessKeyID, ok := cfgMap["oss_access_key_id"]
accessKeyID, ok := cfgMap[enum.AliyunOss(enum.AliyunOssAccessKeyID).String()]
if !ok {
sysCfgDb.SysCfgInsert("oss_access_key_id", "", "oss访问秘钥id")
sysCfgDb.SysCfgInsert(enum.AliyunOss(enum.AliyunOssAccessKeyID).String(), "", "oss访问秘钥id")
accessKeyID = ""
}
accessKeySecret, ok := cfgMap["oss_access_key_secret"]
accessKeySecret, ok := cfgMap[enum.AliyunOss(enum.AliyunOssAccessKeySecret).String()]
if !ok {
sysCfgDb.SysCfgInsert("oss_access_key_secret", "", "oss访问秘钥")
sysCfgDb.SysCfgInsert(enum.AliyunOss(enum.AliyunOssAccessKeySecret).String(), "", "oss访问秘钥")
accessKeySecret = ""
}
domain, ok := cfgMap["oss_object_domain"]
domain, ok := cfgMap[enum.AliyunOss(enum.AliyunOssDomain).String()]
if !ok {
sysCfgDb.SysCfgInsert("oss_object_domain", "", "oss域名")
sysCfgDb.SysCfgInsert(enum.AliyunOss(enum.AliyunOssDomain).String(), "", "oss域名")
domain = ""
}

resp := md.GetBasicResp{
OssEndpoint: endpoint,
OssBucketName: bucketName,
OssObjectScheme: objectScheme,
OssBucketScheme: bucketScheme,
OssAccessKeyId: accessKeyID,
OssAccessKeySecret: accessKeySecret,
OssObjectDomain: domain,
@@ -96,22 +97,22 @@ func SetBasic(c *gin.Context) {
cfgDb := implement.NewSysCfgDb(db.Db, redisConn)

if req.OssAccessKeyId != "" {
cfgDb.SysCfgUpdate("oss_access_key_id", req.OssAccessKeyId)
cfgDb.SysCfgUpdate(enum.AliyunOss(enum.AliyunOssAccessKeyID).String(), req.OssAccessKeyId)
}
if req.OssAccessKeySecret != "" {
cfgDb.SysCfgUpdate("oss_access_key_secret", req.OssAccessKeySecret)
cfgDb.SysCfgUpdate(enum.AliyunOss(enum.AliyunOssAccessKeySecret).String(), req.OssAccessKeySecret)
}
if req.OssObjectScheme != "" {
cfgDb.SysCfgUpdate("oss_object_scheme", req.OssObjectScheme)
if req.OssBucketScheme != "" {
cfgDb.SysCfgUpdate(enum.AliyunOss(enum.AliyunOssBucketScheme).String(), req.OssBucketScheme)
}
if req.OssObjectDomain != "" {
cfgDb.SysCfgUpdate("oss_object_domain", req.OssObjectDomain)
cfgDb.SysCfgUpdate(enum.AliyunOss(enum.AliyunOssDomain).String(), req.OssObjectDomain)
}
if req.OssBucketName != "" {
cfgDb.SysCfgUpdate("oss_bucket_name", req.OssBucketName)
cfgDb.SysCfgUpdate(enum.AliyunOss(enum.AliyunOssBucketName).String(), req.OssBucketName)
}
if req.OssEndpoint != "" {
cfgDb.SysCfgUpdate("oss_endpoint", req.OssEndpoint)
cfgDb.SysCfgUpdate(enum.AliyunOss(enum.AliyunOssEndpoint).String(), req.OssEndpoint)
}
e.OutSuc(c, "success", nil)
}

+ 2
- 2
app/md/setCenter/oss/aliyun/md.basic.go View File

@@ -3,7 +3,7 @@ package md
type GetBasicResp struct {
OssEndpoint string `json:"oss_endpoint" example:"oss地域节点"`
OssBucketName string `json:"oss_bucket_name" example:"oss存储桶名称"`
OssObjectScheme string `json:"oss_object_scheme" example:"oss上传方式"`
OssBucketScheme string `json:"oss_bucket_scheme" example:"oss上传方式"`
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域名"`
@@ -12,7 +12,7 @@ type GetBasicResp struct {
type SetBasicReq struct {
OssEndpoint string `json:"oss_endpoint" example:"oss地域节点"`
OssBucketName string `json:"oss_bucket_name" example:"oss存储桶名称"`
OssObjectScheme string `json:"oss_object_scheme" example:"oss上传方式"`
OssBucketScheme string `json:"oss_bucket_scheme" example:"oss上传方式"`
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域名"`


Loading…
Cancel
Save