蛋蛋星球-制度模式
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

svc_file_img_format.go 1.0 KiB

4 天之前
1234567891011121314151617181920212223242526272829303132333435
  1. package svc
  2. import (
  3. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  4. "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum"
  5. "fmt"
  6. "github.com/gomodule/redigo/redis"
  7. "strings"
  8. "xorm.io/xorm"
  9. )
  10. // ImageBucket is 获取域名
  11. func ImageBucket(engine *xorm.Engine, conn redis.Conn) (string, string) {
  12. sysCfgDb := implement.NewSysCfgDb(engine, conn)
  13. res := sysCfgDb.SysCfgFindWithDb(enum.AliyunOssBucketScheme, enum.AliyunOssDomain)
  14. return res[enum.AliyunOssBucketScheme], res[enum.AliyunOssDomain]
  15. }
  16. // ImageFormatWithBucket is 格式化成oss 域名
  17. func ImageFormatWithBucket(scheme, domain, name string) string {
  18. if strings.Contains(name, "http") || name == "" {
  19. return name
  20. }
  21. return fmt.Sprintf("%s://%s/%s", scheme, domain, name)
  22. }
  23. // ImageFormatWithBucketNew is 格式化成oss 域名
  24. func ImageFormatWithBucketNew(scheme, domain, name string) string {
  25. if strings.Contains(name, "http") {
  26. return name
  27. }
  28. name = strings.ReplaceAll(name, "{{host}}", "")
  29. return fmt.Sprintf("%s://%s/%s", scheme, domain, name)
  30. }