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
aa5389e0
Commit
aa5389e0
authored
Jul 21, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix/top_group_area' into 'master'
群组置顶分区 See merge request
!50
parents
5253543a
9f18413f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
+15
-11
groupTop.go
domain/model/group_m/groupTop.go
+6
-2
group_list.go
route/group_r/group_list.go
+9
-9
No files found.
domain/model/group_m/groupTop.go
View file @
aa5389e0
...
@@ -23,9 +23,13 @@ func (g *GroupTop) Delete(model *domain.Model) error {
...
@@ -23,9 +23,13 @@ func (g *GroupTop) Delete(model *domain.Model) error {
return
model
.
Db
.
Where
(
g
)
.
Delete
(
&
GroupTop
{})
.
Error
return
model
.
Db
.
Where
(
g
)
.
Delete
(
&
GroupTop
{})
.
Error
}
}
func
GroupTopGetAll
(
model
*
domain
.
Model
)
([]
string
,
error
)
{
func
GroupTopGetAll
(
model
*
domain
.
Model
,
area
int
)
([]
string
,
error
)
{
rows
:=
make
([]
GroupTop
,
0
)
rows
:=
make
([]
GroupTop
,
0
)
err
:=
model
.
Db
.
Order
(
"id"
)
.
Find
(
&
rows
)
.
Error
err
:=
model
.
DB
()
.
Table
(
"group_top"
)
.
Joins
(
"left join group_info gi on group_top.im_group_id = gi.im_group_id "
+
"left join res_country rc on gi.country = rc.name"
)
.
Where
(
"rc.area = ?"
,
area
)
.
Order
(
"group_top.id"
)
.
Find
(
&
rows
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
route/group_r/group_list.go
View file @
aa5389e0
...
@@ -72,6 +72,12 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -72,6 +72,12 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
}
}
model
:=
domain
.
CreateModelContext
(
myContext
)
model
:=
domain
.
CreateModelContext
(
myContext
)
// 获取国家信息
_
,
area
,
err
:=
user_m
.
GetUserCountryArea
(
model
,
myUserId
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetUserCountryArea 获取国家资源错误 userId:%d, err:%v"
,
myUserId
,
err
)
return
myContext
,
err
}
/* 2022-06-30 老板说先不分区
/* 2022-06-30 老板说先不分区
regions, err := res_m.GetAllLangRegion(model)
regions, err := res_m.GetAllLangRegion(model)
if err != nil {
if err != nil {
...
@@ -120,7 +126,7 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -120,7 +126,7 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
model
.
Log
.
Infof
(
"GetPopularGroups, micGroupNum: %v, banned %d, hidden %d,cost:%v"
,
micGroupNum
,
banCount
,
hiddenCount
,
time
.
Now
()
.
Sub
(
start
))
model
.
Log
.
Infof
(
"GetPopularGroups, micGroupNum: %v, banned %d, hidden %d,cost:%v"
,
micGroupNum
,
banCount
,
hiddenCount
,
time
.
Now
()
.
Sub
(
start
))
// 3. 处理置顶群
// 3. 处理置顶群
topGroupIds
,
err
:=
getTopGroups
(
model
,
bannedGroups
,
hiddenGroups
)
topGroupIds
,
err
:=
getTopGroups
(
model
,
bannedGroups
,
hiddenGroups
,
area
)
if
err
!=
nil
{
if
err
!=
nil
{
return
myContext
,
err
return
myContext
,
err
}
}
...
@@ -165,12 +171,6 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -165,12 +171,6 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
//}
//}
//logstr += " |"
//logstr += " |"
// 获取国家信息
_
,
area
,
err
:=
user_m
.
GetUserCountryArea
(
model
,
myUserId
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetUserCountryArea 获取国家资源错误 userId:%d, err:%v"
,
myUserId
,
err
)
return
myContext
,
err
}
myArea
:=
fmt
.
Sprintf
(
"%d"
,
area
)
myArea
:=
fmt
.
Sprintf
(
"%d"
,
area
)
// 国家区域信息
// 国家区域信息
resAreaMap
,
err
:=
res_c
.
GetCountryAreaMap
(
model
)
resAreaMap
,
err
:=
res_c
.
GetCountryAreaMap
(
model
)
...
@@ -402,8 +402,8 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -402,8 +402,8 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
return
myContext
,
nil
return
myContext
,
nil
}
}
func
getTopGroups
(
model
*
domain
.
Model
,
bannedGroups
map
[
string
]
uint64
,
hiddenGroups
map
[
string
]
struct
{})
([]
string
,
error
)
{
func
getTopGroups
(
model
*
domain
.
Model
,
bannedGroups
map
[
string
]
uint64
,
hiddenGroups
map
[
string
]
struct
{}
,
area
int
)
([]
string
,
error
)
{
topGroups
,
err
:=
group_m
.
GroupTopGetAll
(
model
)
topGroups
,
err
:=
group_m
.
GroupTopGetAll
(
model
,
area
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
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