蛋蛋星球-制度模式
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.

51 lines
1.6 KiB

  1. package svc
  2. import (
  3. "code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
  4. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  5. "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum"
  6. zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/logx"
  7. "fmt"
  8. "github.com/gomodule/redigo/redis"
  9. "strings"
  10. "xorm.io/xorm"
  11. )
  12. // ImageBucket is 获取域名
  13. func ImageBucket(engine *xorm.Engine, conn redis.Conn) (string, string) {
  14. sysCfgDb := implement.NewSysCfgDb(engine, conn)
  15. defer func(sysCfgDb dao.SysCfgDao) {
  16. err := sysCfgDb.Close()
  17. if err != nil {
  18. zhios_order_relate_logx.Error("redis close err:" + err.Error()) // 记录错误信息
  19. }
  20. }(sysCfgDb)
  21. res := sysCfgDb.SysCfgFindWithDb(enum.AliyunOssBucketScheme, enum.AliyunOssDomain)
  22. return res[enum.AliyunOssBucketScheme], res[enum.AliyunOssDomain]
  23. }
  24. // ImageFormatWithBucket is 格式化成oss 域名
  25. func ImageFormatWithBucket(scheme, domain, name string) string {
  26. if strings.Contains(name, "http") || name == "" {
  27. return name
  28. }
  29. return fmt.Sprintf("%s://%s/%s", scheme, domain, name)
  30. }
  31. // ImageFormatWithBucketNew is 格式化成oss 域名
  32. func ImageFormatWithBucketNew(scheme, domain, name string) string {
  33. if strings.Contains(name, "http") {
  34. return name
  35. }
  36. name = strings.ReplaceAll(name, "{{tempHost}}", "")
  37. return fmt.Sprintf("%s://%s/%s", scheme, domain, name)
  38. }
  39. // ImageFormatWithBucketForDataInfo is 格式化成oss 域名 (只格式化内容中的 url)
  40. func ImageFormatWithBucketForDataInfo(scheme, domain, name string) string {
  41. prefix := fmt.Sprintf("%s://%s/", scheme, domain)
  42. name = strings.ReplaceAll(name, "{{tempHost}}", prefix)
  43. return name
  44. }