蛋蛋星球 后台端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

svc_file_img_format.go 1.2 KiB

1 semana atrás
1234567891011121314151617181920212223242526272829303132333435363738394041
  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. }