广告平台(媒体使用)
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

44 lines
961 B

  1. package svc
  2. import (
  3. "applet/app/e"
  4. "applet/app/utils"
  5. db "code.fnuoos.com/zhimeng/model.git/src"
  6. "code.fnuoos.com/zhimeng/model.git/src/super/implement"
  7. "fmt"
  8. "github.com/gin-gonic/gin"
  9. "strconv"
  10. )
  11. func GetMasterId(c *gin.Context) (masterId string) {
  12. masterId = c.GetHeader("master_id")
  13. if masterId != "" {
  14. return
  15. }
  16. masterId = c.GetString("master_id")
  17. if masterId == "" {
  18. //TODO::通过域名查找masterId
  19. host := c.Request.Host
  20. userAppDomainDb := implement.NewUserAppDomainDb(db.Db)
  21. userAppDomain, err := userAppDomainDb.GetAppDomainByHost(host)
  22. if err != nil {
  23. e.OutErr(c, e.ERR_DB_ORM, err)
  24. return
  25. }
  26. if userAppDomain == nil {
  27. e.OutErr(c, e.ERR_NOT_FAN, "域名不存在")
  28. return
  29. }
  30. masterId = utils.IntToStr(userAppDomain.Uuid)
  31. c.Set("master_id", masterId)
  32. }
  33. fmt.Println("master_id:::::::", masterId)
  34. return
  35. }
  36. func isNumeric(str string) bool {
  37. _, err := strconv.ParseFloat(str, 64)
  38. return err == nil
  39. }