蛋蛋星球 后台端
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.
 
 
 
 

42 lines
1.2 KiB

  1. package svc
  2. import (
  3. "applet/app/svc/sys_cfg"
  4. "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum"
  5. "fmt"
  6. "strings"
  7. "xorm.io/xorm"
  8. )
  9. // ImageBucket is 获取域名
  10. func ImageBucket(engine *xorm.Engine) (string, string) {
  11. sysCfgDb := sys_cfg.NewSysCfgDb(engine)
  12. res := sysCfgDb.SysCfgFindWithDb(enum.AliyunOssBucketScheme, enum.AliyunOssDomain)
  13. return res[enum.AliyunOssBucketScheme], res[enum.AliyunOssDomain]
  14. }
  15. // ImageFormatWithBucket is 格式化成oss 域名
  16. func ImageFormatWithBucket(scheme, domain, name string) string {
  17. if strings.Contains(name, "http") || name == "" {
  18. return name
  19. }
  20. return fmt.Sprintf("%s://%s/%s", scheme, domain, name)
  21. }
  22. // ImageFormatWithBucketNew is 格式化成oss 域名
  23. func ImageFormatWithBucketNew(scheme, domain, name string) string {
  24. if strings.Contains(name, "http") {
  25. return name
  26. }
  27. name = strings.ReplaceAll(name, "{{tempHost}}", "")
  28. return fmt.Sprintf("%s://%s/%s", scheme, domain, name)
  29. }
  30. // ImageFormatWithBucketForDataInfo is 格式化成oss 域名 (只格式化内容中的 url)
  31. func ImageFormatWithBucketForDataInfo(scheme, domain, name string) string {
  32. prefix := fmt.Sprintf("%s://%s/", scheme, domain)
  33. name = strings.ReplaceAll(name, "{{tempHost}}", prefix)
  34. return name
  35. }