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
Compare Revisions
master...fix/top_group_area
Source
fix/top_group_area
Select Git revision
...
Target
master
Select Git revision
Compare
Commits (3)
群组指定分区
· 4546d9fe
chenweijian
authored
Jul 21, 2023
4546d9fe
群组指定分区
· 74c1f6d3
chenweijian
authored
Jul 21, 2023
74c1f6d3
群组指定分区
· 51f731d7
chenweijian
authored
Jul 21, 2023
51f731d7
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 @
51f731d7
...
...
@@ -23,9 +23,13 @@ func (g *GroupTop) Delete(model *domain.Model) 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
)
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
{
return
nil
,
err
}
...
...
route/group_r/group_list.go
View file @
51f731d7
...
...
@@ -72,6 +72,12 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
}
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 老板说先不分区
regions, err := res_m.GetAllLangRegion(model)
if err != nil {
...
...
@@ -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
))
// 3. 处理置顶群
topGroupIds
,
err
:=
getTopGroups
(
model
,
bannedGroups
,
hiddenGroups
)
topGroupIds
,
err
:=
getTopGroups
(
model
,
bannedGroups
,
hiddenGroups
,
area
)
if
err
!=
nil
{
return
myContext
,
err
}
...
...
@@ -165,12 +171,6 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
//}
//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
)
// 国家区域信息
resAreaMap
,
err
:=
res_c
.
GetCountryAreaMap
(
model
)
...
...
@@ -402,8 +402,8 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
return
myContext
,
nil
}
func
getTopGroups
(
model
*
domain
.
Model
,
bannedGroups
map
[
string
]
uint64
,
hiddenGroups
map
[
string
]
struct
{})
([]
string
,
error
)
{
topGroups
,
err
:=
group_m
.
GroupTopGetAll
(
model
)
func
getTopGroups
(
model
*
domain
.
Model
,
bannedGroups
map
[
string
]
uint64
,
hiddenGroups
map
[
string
]
struct
{}
,
area
int
)
([]
string
,
error
)
{
topGroups
,
err
:=
group_m
.
GroupTopGetAll
(
model
,
area
)
if
err
!=
nil
{
return
nil
,
err
}
...
...