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

svc_master.go 1.6 KiB

4 달 전
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package svc
  2. import (
  3. "fmt"
  4. "github.com/gin-gonic/gin"
  5. "strconv"
  6. )
  7. func GetMasterId(c *gin.Context) (masterId string) {
  8. masterId = c.GetHeader("master_id")
  9. if masterId != "" {
  10. return
  11. }
  12. masterId = c.GetString("master_id")
  13. if masterId == "" {
  14. //TODO::通过域名查找masterId
  15. //host := c.Request.Host
  16. //fmt.Println("not found master_id found MasterId start")
  17. //masterId = c.GetHeader("MasterId")
  18. //if masterId == "" && c.GetHeader("Platform") == md.PLATFORM_WAP { // H5 要根据域名去获取mid
  19. // hostList := strings.Split(c.Request.Host, ".")
  20. // if isNumeric(hostList[0]) {
  21. // masterId = hostList[0]
  22. // } else if isNumeric(hostList[1]) {
  23. // masterId = hostList[1]
  24. // } else {
  25. // // 自定义域名
  26. // masterId = svc.GetWebSiteDomainMasterId(baseDb, md.PLATFORM_WAP, c.Request.Host)
  27. // }
  28. //}
  29. //if masterId == "" && c.GetHeader("Platform") == md.PLATFORM_PC { // H5 要根据域名去获取mid
  30. // hostList := strings.Split(c.Request.Host, ".")
  31. // if isNumeric(hostList[0]) {
  32. // masterId = hostList[0]
  33. // } else if isNumeric(hostList[1]) {
  34. // masterId = hostList[1]
  35. // } else {
  36. // // 自定义域名
  37. // masterId = svc.GetWebSiteDomainMasterId(baseDb, md.PLATFORM_PC, c.Request.Host)
  38. // }
  39. //}
  40. //if masterId == "" && c.GetHeader("Platform") == "" { // 无平台访问
  41. // hostList := strings.Split(c.Request.Host, ".")
  42. // if isNumeric(hostList[0]) {
  43. // masterId = hostList[0]
  44. // }
  45. //}
  46. }
  47. fmt.Println("master_id:::::::", masterId)
  48. return
  49. }
  50. func isNumeric(str string) bool {
  51. _, err := strconv.ParseFloat(str, 64)
  52. return err == nil
  53. }