|
1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package svc
-
- import (
- "applet/app/svc/sys_cfg"
- "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum"
- "fmt"
- "strings"
- "xorm.io/xorm"
- )
-
- // ImageBucket is 获取域名
- func ImageBucket(engine *xorm.Engine) (string, string) {
- sysCfgDb := sys_cfg.NewSysCfgDb(engine)
- res := sysCfgDb.SysCfgFindWithDb(enum.AliyunOssBucketScheme, enum.AliyunOssDomain)
- return res[enum.AliyunOssBucketScheme], res[enum.AliyunOssDomain]
- }
-
- // ImageFormatWithBucket is 格式化成oss 域名
- func ImageFormatWithBucket(scheme, domain, name string) string {
- if strings.Contains(name, "http") || name == "" {
- return name
- }
- return fmt.Sprintf("%s://%s/%s", scheme, domain, name)
- }
-
- // ImageFormatWithBucketNew is 格式化成oss 域名
- func ImageFormatWithBucketNew(scheme, domain, name string) string {
- if strings.Contains(name, "http") {
- return name
- }
-
- name = strings.ReplaceAll(name, "{{tempHost}}", "")
- return fmt.Sprintf("%s://%s/%s", scheme, domain, name)
- }
-
- // ImageFormatWithBucketForDataInfo is 格式化成oss 域名 (只格式化内容中的 url)
- func ImageFormatWithBucketForDataInfo(scheme, domain, name string) string {
- prefix := fmt.Sprintf("%s://%s/", scheme, domain)
- name = strings.ReplaceAll(name, "{{tempHost}}", prefix)
- return name
- }
|