main
elf 7 months ago
parent 715fca9196
commit f147b11d6a

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@ -1,3 +1,22 @@
server: server:
port: 9090 port: 9090
domain: "http://pay.hexidongkeji.top" 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:

@ -1,9 +1,6 @@
package config package config
type Config struct { type Config struct {
Server Server Server Server
StorageType string Storage Storage
Oss *Oss
Obs *Obs
Cos *Cos
} }

@ -1,8 +0,0 @@
package config
type Cos struct {
BucketURL string
SecretID string
SecretKey string
Domain string
}

@ -1,9 +0,0 @@
package config
type Obs struct {
Endpoint string
AccessKey string
SecretKey string
Bucket string
Domain string
}

@ -1,9 +0,0 @@
package config
type Oss struct {
Endpoint string
AccessKeyID string
AccessKeySecret string
Bucket string
Domain string
}

@ -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"`
}

@ -39,10 +39,12 @@ func InitConfig() *config.Config {
} }
func InitStorage() storage.Storage { func InitStorage() storage.Storage {
if global.Config.StorageType == "oss" { if global.Config.Storage.StorageType == "oss" {
return storage.NewOssStorage(global.Config.Oss) return storage.NewOssStorage(global.Config.Storage.Oss)
} else if global.Config.StorageType == "obs" { } else if global.Config.Storage.StorageType == "obs" {
return storage.NewObsStorage(global.Config.Obs) return storage.NewObsStorage(global.Config.Storage.Obs)
} else if global.Config.Storage.StorageType == "cos" {
return storage.NewCosStorage(global.Config.Storage.Cos)
} else { } else {
panic("存储系统不存在") panic("存储系统不存在")
} }

Loading…
Cancel
Save