diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/config.yaml b/config.yaml index db23302..d5d282a 100644 --- a/config.yaml +++ b/config.yaml @@ -1,3 +1,22 @@ server: port: 9090 - domain: "http://pay.hexidongkeji.top" \ No newline at end of file + domain: "http://pay.hexidongkeji.top" +storage: + storage-type: "cos" + cos: + bucket-url: "https://elf-1304437394.cos.ap-nanjing.myqcloud.com" + secret-id: "AKIDlRuAEGGE1c6Ys24uWu42oMhsqfIZbWDg" + secret-key: "LVSFoAICrU2NWXLycO4azNYWWTJwRYZW" + domain: + obs: + endpoint: + access-key: + secret-key: + bucket: + domain: + oss: + endpoint: + access-key-id: + access-key-secret: + bucket: + domain: \ No newline at end of file diff --git a/config/config.go b/config/config.go index da58842..117eef7 100644 --- a/config/config.go +++ b/config/config.go @@ -1,9 +1,6 @@ package config type Config struct { - Server Server - StorageType string - Oss *Oss - Obs *Obs - Cos *Cos + Server Server + Storage Storage } diff --git a/config/cos.go b/config/cos.go deleted file mode 100644 index 4542e36..0000000 --- a/config/cos.go +++ /dev/null @@ -1,8 +0,0 @@ -package config - -type Cos struct { - BucketURL string - SecretID string - SecretKey string - Domain string -} diff --git a/config/obs.go b/config/obs.go deleted file mode 100644 index 9bd4450..0000000 --- a/config/obs.go +++ /dev/null @@ -1,9 +0,0 @@ -package config - -type Obs struct { - Endpoint string - AccessKey string - SecretKey string - Bucket string - Domain string -} diff --git a/config/oss.go b/config/oss.go deleted file mode 100644 index b8b64db..0000000 --- a/config/oss.go +++ /dev/null @@ -1,9 +0,0 @@ -package config - -type Oss struct { - Endpoint string - AccessKeyID string - AccessKeySecret string - Bucket string - Domain string -} diff --git a/config/storage.go b/config/storage.go new file mode 100644 index 0000000..920d06e --- /dev/null +++ b/config/storage.go @@ -0,0 +1,31 @@ +package config + +type Storage struct { + StorageType string `yaml:"storage-type"` + Oss *Oss + Obs *Obs + Cos *Cos +} + +type Cos struct { + BucketURL string `yaml:"bucket-url"` + SecretID string `yaml:"secret-id"` + SecretKey string `yaml:"secret-key"` + Domain string `yaml:"domain"` +} + +type Obs struct { + Endpoint string `yaml:"endpoint"` + AccessKey string `yaml:"access-key"` + SecretKey string `yaml:"secret-key"` + Bucket string `yaml:"bucket"` + Domain string `yaml:"domain"` +} + +type Oss struct { + Endpoint string `yaml:"endpoint"` + AccessKeyID string `yaml:"access-key-id"` + AccessKeySecret string `yaml:"access-key-secret"` + Bucket string `yaml:"bucket"` + Domain string `yaml:"domain"` +} diff --git a/initialize/initialize.go b/initialize/initialize.go index 5efc440..d2b2890 100644 --- a/initialize/initialize.go +++ b/initialize/initialize.go @@ -39,10 +39,12 @@ func InitConfig() *config.Config { } func InitStorage() storage.Storage { - if global.Config.StorageType == "oss" { - return storage.NewOssStorage(global.Config.Oss) - } else if global.Config.StorageType == "obs" { - return storage.NewObsStorage(global.Config.Obs) + if global.Config.Storage.StorageType == "oss" { + return storage.NewOssStorage(global.Config.Storage.Oss) + } else if global.Config.Storage.StorageType == "obs" { + return storage.NewObsStorage(global.Config.Storage.Obs) + } else if global.Config.Storage.StorageType == "cos" { + return storage.NewCosStorage(global.Config.Storage.Cos) } else { panic("存储系统不存在") }