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
4546d9fe
Commit
4546d9fe
authored
Jul 21, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
群组指定分区
parent
5253543a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
11 deletions
+14
-11
groupTop.go
domain/model/group_m/groupTop.go
+5
-2
group_list.go
route/group_r/group_list.go
+9
-9
No files found.
domain/model/group_m/groupTop.go
View file @
4546d9fe
...
...
@@ -23,9 +23,12 @@ 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 gt"
)
.
Joins
(
"left join group_info gi on gt.im_group_id = gi.im_group_id left join res_country rc on gi.country = rc.name"
)
.
Where
(
"rc.area = ?"
,
area
)
.
Order
(
"id"
)
.
Find
(
&
rows
)
.
Error
if
err
!=
nil
{
return
nil
,
err
}
...
...
route/group_r/group_list.go
View file @
4546d9fe
...
...
@@ -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
}
...
...
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