Commit 6e504653 authored by hujiebin's avatar hujiebin

Merge branch 'feature/gem-game' into 'master'

粉钻大厅

See merge request !41
parents f08e5a90 6de8d11e
......@@ -154,6 +154,7 @@ type SimpleRoleInfo struct {
type BannerElement struct {
H5Url string `json:"h5Url"` // h5链接
BannerUrl string `json:"bannerUrl"` // 图片地址
ActionUrl string `json:"actionUrl"` // 统跳地址
}
type RoomInfo struct {
......
......@@ -38,6 +38,7 @@ import (
"hilo-group/myerr/bizerr"
"hilo-group/req"
"hilo-group/resp"
"net/url"
"sort"
"strconv"
"strings"
......@@ -592,6 +593,7 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) {
result.Banners = append(result.Banners, group_cv.BannerElement{
H5Url: i.Url,
BannerUrl: i.Image,
ActionUrl: i.Url, // 支持direction=1横屏
})
}
} else {
......@@ -751,6 +753,8 @@ type GroupBanner struct {
BannerUrl string `json:"bannerUrl"`
//群主Id
GroupId string `json:"groupId"`
//统跳地址 http开头:web页面,query参数direction(0:竖屏 1:横屏); hilo开头:原生页面
ActionUrl string `json:"actionUrl"`
}
// @Tags 群组
......@@ -827,11 +831,27 @@ func GroupBannerList(c *gin.Context) (*mycontext.MyContext, error) {
if v.Area == 3 && !utils.IsInStringList(country, v.CountryList) {
continue
}
actionUrl := v.Url
if uri, err := url.Parse(actionUrl); err == nil {
query := uri.RawQuery
queryArr := strings.Split(query, "&")
v := url.Values{}
if len(queryArr) > 0 {
for _, q := range queryArr {
if arr := strings.Split(q, "="); len(arr) == 2 {
v.Add(arr[0], arr[1])
}
}
}
//v.Add("direction", "1") // 横屏的需要这样
uri.RawQuery = v.Encode()
actionUrl = uri.String()
}
groupBanners = append(groupBanners, GroupBanner{
H5Url: v.Url,
BannerUrl: v.Image,
GroupId: groupMap[v.GroupCode],
ActionUrl: actionUrl,
})
}
resp.ResponseOk(c, groupBanners)
......@@ -841,6 +861,7 @@ func GroupBannerList(c *gin.Context) (*mycontext.MyContext, error) {
type RoomBanner struct {
H5Url string `json:"h5Url"` // h5链接
BannerUrl string `json:"bannerUrl"` // 图片地址
ActionUrl string `json:"actionUrl"` // 统跳地址 http开头:web页面,query参数direction(0:竖屏 1:横屏); hilo开头:原生页面
}
// @Tags 群组
......@@ -893,6 +914,7 @@ func RoomBannerList(c *gin.Context) (*mycontext.MyContext, error) {
result = append(result, RoomBanner{
H5Url: i.Url,
BannerUrl: i.Image,
ActionUrl: i.Url,
})
}
resp.ResponseOk(c, result)
......
package test
import (
"fmt"
"net/url"
"path"
"strings"
"testing"
)
func TestUrlParse(t *testing.T) {
//rawUrl := "https://pkg.go.dev/net/url?a=b&c=d#example-ParseQuery"
rawUrl := "https://pkg.go.dev/net/url"
uri, err := url.Parse(rawUrl)
if err != nil {
return
}
query := uri.RawQuery
queryArr := strings.Split(query, "&")
v := url.Values{}
if len(queryArr) > 0 {
for _, q := range queryArr {
if arr := strings.Split(q, "="); len(arr) == 2 {
v.Add(arr[0], arr[1])
}
}
}
v.Add("v1", "v1")
v.Add("v2", "v2")
uri.RawQuery = v.Encode()
uri.Path = path.Join(uri.Path, "/ccc/ddd")
fmt.Println(fmt.Sprintf("修改后的URL是:%s", uri.String()))
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment