面包店
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 

59 satır
1.5 KiB

  1. package svc
  2. import (
  3. "applet/app/db"
  4. "applet/app/db/model"
  5. "applet/app/utils"
  6. "applet/app/utils/logx"
  7. "github.com/gin-gonic/gin"
  8. "github.com/tidwall/gjson"
  9. "strings"
  10. )
  11. // 获取指定类型的域名:admin、wap、api
  12. func GetWebSiteDomainInfo(c *gin.Context, domainType string) string {
  13. if domainType == "" {
  14. domainType = "wap"
  15. }
  16. domainSetting := SysCfgGet(c, "domain_setting")
  17. domainTypePath := domainType + ".type"
  18. domainSslPath := domainType + ".isOpenHttps"
  19. domainPath := domainType + ".domain"
  20. domainTypeValue := gjson.Get(domainSetting, domainTypePath).String()
  21. domainSslValue := gjson.Get(domainSetting, domainSslPath).String()
  22. domain := gjson.Get(domainSetting, domainPath).String()
  23. scheme := "http://"
  24. if domainSslValue == "1" {
  25. scheme = "https://"
  26. }
  27. // 有自定义域名 返回自定义的
  28. if domainTypeValue == "own" && domain != "" {
  29. return scheme + domain
  30. }
  31. // 否则返回官方的
  32. official, err := db.GetOfficialDomainInfoByType(db.Db, c.GetString("mid"), domainType)
  33. if err != nil {
  34. _ = logx.Errorf("Get Official Domain Fail! %s", err)
  35. return ""
  36. }
  37. if strings.Contains(official, "http") {
  38. return official
  39. }
  40. return scheme + official
  41. }
  42. // 获取指定类型的域名对应的masterId:admin、wap、api
  43. func GetWebSiteDomainMasterId(domainType string, host string) string {
  44. obj := new(model.UserAppDomain)
  45. has, err := db.Db.Where("domain=? and type=?", host, domainType).Get(obj)
  46. if err != nil || !has {
  47. return ""
  48. }
  49. return utils.AnyToString(obj.Uuid)
  50. }