蛋蛋星球-客户端
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.
 
 
 
 
 

45 lines
1.3 KiB

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