|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package svc
-
- import (
- "fmt"
- "github.com/gin-gonic/gin"
- "strconv"
- )
-
- func GetMasterId(c *gin.Context) (masterId string) {
- masterId = c.GetHeader("master_id")
- if masterId != "" {
- return
- }
-
- masterId = c.GetString("master_id")
- if masterId == "" {
- //TODO::通过域名查找masterId
- //host := c.Request.Host
-
- //fmt.Println("not found master_id found MasterId start")
- //masterId = c.GetHeader("MasterId")
- //if masterId == "" && c.GetHeader("Platform") == md.PLATFORM_WAP { // H5 要根据域名去获取mid
- // hostList := strings.Split(c.Request.Host, ".")
- // if isNumeric(hostList[0]) {
- // masterId = hostList[0]
- // } else if isNumeric(hostList[1]) {
- // masterId = hostList[1]
- // } else {
- // // 自定义域名
- // masterId = svc.GetWebSiteDomainMasterId(baseDb, md.PLATFORM_WAP, c.Request.Host)
- // }
- //}
- //if masterId == "" && c.GetHeader("Platform") == md.PLATFORM_PC { // H5 要根据域名去获取mid
- // hostList := strings.Split(c.Request.Host, ".")
- // if isNumeric(hostList[0]) {
- // masterId = hostList[0]
- // } else if isNumeric(hostList[1]) {
- // masterId = hostList[1]
- // } else {
- // // 自定义域名
- // masterId = svc.GetWebSiteDomainMasterId(baseDb, md.PLATFORM_PC, c.Request.Host)
- // }
- //}
- //if masterId == "" && c.GetHeader("Platform") == "" { // 无平台访问
- // hostList := strings.Split(c.Request.Host, ".")
- // if isNumeric(hostList[0]) {
- // masterId = hostList[0]
- // }
- //}
- }
- fmt.Println("master_id:::::::", masterId)
- return
- }
-
- func isNumeric(str string) bool {
- _, err := strconv.ParseFloat(str, 64)
- return err == nil
- }
|