Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-group
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujiebin
hilo-group
Commits
6f1c0fb2
Commit
6f1c0fb2
authored
May 16, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
url test
parent
6c74420e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
2 deletions
+52
-2
group_info.go
route/group_r/group_info.go
+18
-2
url_test.go
test/url_test.go
+34
-0
No files found.
route/group_r/group_info.go
View file @
6f1c0fb2
...
...
@@ -38,6 +38,7 @@ import (
"hilo-group/myerr/bizerr"
"hilo-group/req"
"hilo-group/resp"
"net/url"
"sort"
"strconv"
"strings"
...
...
@@ -829,12 +830,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"
)
// todo for test
uri
.
RawQuery
=
v
.
Encode
()
actionUrl
=
uri
.
String
()
}
groupBanners
=
append
(
groupBanners
,
GroupBanner
{
H5Url
:
v
.
Url
,
BannerUrl
:
v
.
Image
,
GroupId
:
groupMap
[
v
.
GroupCode
],
ActionUrl
:
v
.
Url
,
ActionUrl
:
action
Url
,
})
}
resp
.
ResponseOk
(
c
,
groupBanners
)
...
...
test/url_test.go
0 → 100644
View file @
6f1c0fb2
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
()))
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment