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
ef0d3aed
Commit
ef0d3aed
authored
Mar 20, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
家族月排名
parent
5935a3fb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
0 deletions
+28
-0
groupPower.go
cv/group_power_cv/groupPower.go
+1
-0
group_rank.go
domain/model/groupPower_m/group_rank.go
+20
-0
group_power.go
route/group_power_r/group_power.go
+7
-0
No files found.
cv/group_power_cv/groupPower.go
View file @
ef0d3aed
...
...
@@ -671,6 +671,7 @@ type GroupPower struct {
MemberMax
mysql
.
Num
`json:"memberMax" gorm:"-"`
// 最大人数
Role
int
`json:"role" gorm:"-"`
// 我在此家族中的角色 0.路人 1.成员 2.家族长 3.管理员
IsApply
bool
`json:"isApply" gorm:"-"`
// 最大人数
MonthRank
int
`json:"monthRank" gorm:"-"`
// 家族月排名
}
type
GroupPowerUser
struct
{
...
...
domain/model/groupPower_m/group_rank.go
View file @
ef0d3aed
...
...
@@ -25,3 +25,23 @@ func GetGroupPowerExpRank(model *domain.Model, beginDate, endDate string, limit
}
return
res
,
nil
}
// 获取我的家族月排名是多少,超过30则返回31
func
GetGroupPowerExpRankById
(
model
*
domain
.
Model
,
beginDate
,
endDate
string
,
limit
int
,
groupPowerId
uint64
)
(
int
,
error
)
{
var
res
[]
GroupPowerExpRank
if
err
:=
model
.
DB
()
.
Table
(
"group_power_day_exp"
)
.
Select
(
"group_power_id,SUM(exp) as exp"
)
.
Where
(
"date BETWEEN ? AND ?"
,
beginDate
,
endDate
)
.
Group
(
"group_power_id"
)
.
Order
(
"exp DESC"
)
.
Limit
(
limit
)
.
Find
(
&
res
)
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetMyGroupPowerExpRank fail:%v"
,
err
)
return
0
,
err
}
for
i
:=
range
res
{
res
[
i
]
.
Rank
=
i
+
1
}
myRank
:=
31
for
_
,
v
:=
range
res
{
if
v
.
GroupPowerId
==
groupPowerId
{
myRank
=
v
.
Rank
}
}
return
myRank
,
nil
}
route/group_power_r/group_power.go
View file @
ef0d3aed
...
...
@@ -9,6 +9,7 @@ import (
"git.hilo.cn/hilo-common/resource/redisCli"
"git.hilo.cn/hilo-common/utils"
"github.com/gin-gonic/gin"
"github.com/jinzhu/now"
"hilo-group/_const/enum/groupPower_e"
"hilo-group/_const/enum/group_e"
"hilo-group/_const/enum/msg_e"
...
...
@@ -760,6 +761,12 @@ func GroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) {
info
.
Nameplate
=
groupInfo
.
Name
}
}
// 家族月排名
beginDate
,
endDate
:=
now
.
BeginningOfMonth
()
.
Format
(
"2006-01-02"
),
now
.
EndOfMonth
()
.
Format
(
"2006-01-02"
)
info
.
MonthRank
,
err
=
groupPower_m
.
GetGroupPowerExpRankById
(
model
,
beginDate
,
endDate
,
30
,
info
.
Id
)
if
err
!=
nil
{
return
myContext
,
err
}
// 我在该家族中的角色
myPU
:=
groupPower_m
.
GroupPowerUser
{
UserId
:
myUserId
}
myGroupPUser
,
err
:=
myPU
.
GetGroupPowerUser
(
model
)
...
...
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