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
e3429dc5
Commit
e3429dc5
authored
Apr 20, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取上个月开始时间
parent
97beeb3a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
15 deletions
+47
-15
group_rank.go
cv/group_power_cv/group_rank.go
+8
-0
group_star.go
domain/model/groupPower_m/group_star.go
+2
-2
group_power.go
domain/service/group_power_s/group_power.go
+3
-3
group_rank.go
route/group_power_r/group_rank.go
+34
-10
No files found.
cv/group_power_cv/group_rank.go
View file @
e3429dc5
...
...
@@ -40,6 +40,14 @@ type CvGroupPowerRank struct {
Items
[]
CvGroupPowerRankData
`json:"items"`
// 列表
}
// 家族月度排行活动榜单
type
CvGroupPowerRankMontAct
struct
{
MyGroupPower
*
CvGroupPowerRankData
`json:"myGroupPower,omitempty"`
// 我的家族排名
Items
[]
CvGroupPowerRankData
`json:"items"`
// 列表
MyGroupPowerLast
*
CvGroupPowerRankData
`json:"myGroupPowerLast"`
// 我的家族排名(上月)
ItemsLast
[]
CvGroupPowerRankData
`json:"itemsLast"`
// 列表(上月)
}
type
CvGroupPowerRankData
struct
{
CvGroupPowerBase
`json:",inline"`
CvGroupPowerGrade
`json:",inline"`
...
...
domain/model/groupPower_m/group_star.go
View file @
e3429dc5
...
...
@@ -104,9 +104,9 @@ func GetGroupPowerMonthStar(model *domain.Model, groupPowerId, userId mysql.ID,
}
// 获取家族之星排行
func
GetGroupPowerMonthStarRank
(
model
*
domain
.
Model
,
groupPowerId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
,
offset
,
limit
int
)
([]
*
GroupPowerMonthStar
,
error
)
{
func
GetGroupPowerMonthStarRank
(
model
*
domain
.
Model
,
groupPowerId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
,
offset
,
limit
int
,
month
string
)
([]
*
GroupPowerMonthStar
,
error
)
{
var
res
[]
*
GroupPowerMonthStar
month
:=
time
.
Now
()
.
Format
(
"200601"
)
//
month := time.Now().Format("200601")
if
err
:=
model
.
DB
()
.
Model
(
GroupPowerMonthStar
{})
.
Where
(
"month = ? AND group_power_id = ? AND `type` = ?"
,
month
,
groupPowerId
,
_type
)
.
Order
(
"score desc"
)
.
Offset
(
offset
)
.
Limit
(
limit
)
.
Find
(
&
res
)
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetGroupPowerMonthStarRank fail:%v"
,
err
)
...
...
domain/service/group_power_s/group_power.go
View file @
e3429dc5
...
...
@@ -149,8 +149,8 @@ func GetGroupPowerRankResp(model *domain.Model, beginDate, endDate string, userI
return
response
,
nil
}
func
GetGroupPowerStar
(
model
*
domain
.
Model
,
groupPowerId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
,
offset
,
limit
int
)
([]
*
group_power_cv
.
CvGroupPowerStarData
,
error
)
{
rank
,
err
:=
groupPower_m
.
GetGroupPowerMonthStarRank
(
model
,
groupPowerId
,
_type
,
offset
,
limit
)
func
GetGroupPowerStar
(
model
*
domain
.
Model
,
groupPowerId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
,
offset
,
limit
int
,
month
string
)
([]
*
group_power_cv
.
CvGroupPowerStarData
,
error
)
{
rank
,
err
:=
groupPower_m
.
GetGroupPowerMonthStarRank
(
model
,
groupPowerId
,
_type
,
offset
,
limit
,
month
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -201,7 +201,7 @@ func DoCalcGroupPowerMonthRankAct(model *domain.Model, calcMonth, beginDate, end
powerIds
:=
make
([]
uint64
,
0
,
len
(
response
.
Items
))
for
i
,
v
:=
range
response
.
Items
{
powerIds
=
append
(
powerIds
,
v
.
Id
)
response
.
Items
[
i
]
.
StarList
,
err
=
GetGroupPowerStar
(
model
,
v
.
Id
,
groupPower_e
.
GroupPowerStarTypeFamous
,
0
,
10
)
response
.
Items
[
i
]
.
StarList
,
err
=
GetGroupPowerStar
(
model
,
v
.
Id
,
groupPower_e
.
GroupPowerStarTypeFamous
,
0
,
10
,
time
.
Now
()
.
Format
(
utils
.
COMPACT_MONTH_FORMAT
)
)
if
err
!=
nil
{
return
err
}
...
...
route/group_power_r/group_rank.go
View file @
e3429dc5
...
...
@@ -57,7 +57,7 @@ func GroupPowerRank(c *gin.Context) (*mycontext.MyContext, error) {
// @Tags 国家势力
// @Summary 家族榜单-活动
// @Success 200 {object}
[]group_power_cv.CvGroupPowerRank
// @Success 200 {object}
group_power_cv.CvGroupPowerRankMontAct
// @Router /v1/h5/groupPower/rank/month [get]
func
GroupPowerMonthRankAct
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myContext
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
...
...
@@ -65,26 +65,50 @@ func GroupPowerMonthRankAct(c *gin.Context) (*mycontext.MyContext, error) {
if
err
!=
nil
{
return
myContext
,
err
}
beginDate
,
endDate
:=
now
.
BeginningOfMonth
()
.
Format
(
"2006-01-02"
),
now
.
EndOfMonth
()
.
Format
(
"2006-01-02"
)
var
model
=
domain
.
CreateModelContext
(
myContext
)
response
,
err
:=
group_power_s
.
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
userId
)
// 这个月
beginDate
,
endDate
:=
now
.
BeginningOfMonth
()
.
Format
(
utils
.
DATE_FORMAT
),
now
.
EndOfMonth
()
.
Format
(
utils
.
DATE_FORMAT
)
response
,
err
:=
GroupPowerMonthRankActByMonth
(
model
,
userId
,
beginDate
,
endDate
,
time
.
Now
()
.
Format
(
utils
.
COMPACT_MONTH_FORMAT
))
if
err
!=
nil
{
return
myContext
,
err
}
// 上月
lastMonthStart
:=
utils
.
GetLastMonthStart
(
time
.
Now
())
lastTime
:=
now
.
New
(
lastMonthStart
)
beginDateLast
,
endDateLast
:=
lastTime
.
BeginningOfMonth
()
.
Format
(
utils
.
DATE_FORMAT
),
lastTime
.
EndOfMonth
()
.
Format
(
utils
.
DATE_FORMAT
)
responseLast
,
err
:=
GroupPowerMonthRankActByMonth
(
model
,
userId
,
beginDateLast
,
endDateLast
,
lastMonthStart
.
Format
(
utils
.
COMPACT_MONTH_FORMAT
))
if
err
!=
nil
{
return
myContext
,
err
}
res
:=
&
group_power_cv
.
CvGroupPowerRankMontAct
{
MyGroupPower
:
response
.
MyGroupPower
,
Items
:
response
.
Items
,
MyGroupPowerLast
:
responseLast
.
MyGroupPower
,
ItemsLast
:
responseLast
.
Items
,
}
resp
.
ResponseOk
(
c
,
res
)
return
myContext
,
nil
}
func
GroupPowerMonthRankActByMonth
(
model
*
domain
.
Model
,
userId
uint64
,
beginDate
,
endDate
,
month
string
)
(
response
group_power_cv
.
CvGroupPowerRank
,
err
error
)
{
response
,
err
=
group_power_s
.
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
userId
)
if
err
!=
nil
{
return
response
,
err
}
if
response
.
MyGroupPower
!=
nil
{
response
.
MyGroupPower
.
StarList
,
err
=
group_power_s
.
GetGroupPowerStar
(
model
,
response
.
MyGroupPower
.
Id
,
groupPower_e
.
GroupPowerStarTypeFamous
,
0
,
10
)
response
.
MyGroupPower
.
StarList
,
err
=
group_power_s
.
GetGroupPowerStar
(
model
,
response
.
MyGroupPower
.
Id
,
groupPower_e
.
GroupPowerStarTypeFamous
,
0
,
10
,
month
)
}
if
err
!=
nil
{
return
myContext
,
err
return
response
,
err
}
for
i
,
v
:=
range
response
.
Items
{
response
.
Items
[
i
]
.
StarList
,
err
=
group_power_s
.
GetGroupPowerStar
(
model
,
v
.
Id
,
groupPower_e
.
GroupPowerStarTypeFamous
,
0
,
10
)
response
.
Items
[
i
]
.
StarList
,
err
=
group_power_s
.
GetGroupPowerStar
(
model
,
v
.
Id
,
groupPower_e
.
GroupPowerStarTypeFamous
,
0
,
10
,
month
)
if
err
!=
nil
{
return
myContext
,
err
return
response
,
err
}
}
resp
.
ResponseOk
(
c
,
response
)
return
myContext
,
nil
return
response
,
nil
}
// @Tags 国家势力
...
...
@@ -176,7 +200,7 @@ func GroupPowerStar(c *gin.Context) (*mycontext.MyContext, error) {
}
offset
,
limit
:=
(
param
.
PageIndex
-
1
)
*
param
.
PageSize
,
param
.
PageSize
var
model
=
domain
.
CreateModelContext
(
myContext
)
response
,
err
:=
group_power_s
.
GetGroupPowerStar
(
model
,
param
.
GroupPowerId
,
param
.
Type
,
offset
,
limit
)
response
,
err
:=
group_power_s
.
GetGroupPowerStar
(
model
,
param
.
GroupPowerId
,
param
.
Type
,
offset
,
limit
,
time
.
Now
()
.
Format
(
utils
.
COMPACT_MONTH_FORMAT
)
)
if
err
!=
nil
{
return
myContext
,
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