Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-user
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
chenweijian
hilo-user
Commits
f2613d0e
Commit
f2613d0e
authored
Jun 02, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CP,Top3
parent
d2202b7d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
0 deletions
+77
-0
rank.go
cv/cp_cv/rank.go
+5
-0
rank.go
route/cp_r/rank.go
+71
-0
router.go
route/router.go
+1
-0
No files found.
cv/cp_cv/rank.go
View file @
f2613d0e
...
...
@@ -30,3 +30,8 @@ type CvCpAnniversary struct {
Date
string
`json:"date"`
// 纪念日日期
IsRemind
bool
`json:"isRemind"`
// 是否提醒
}
type
CpTops
struct
{
Day
[]
CvCp
`json:"day"`
Week
[]
CvCp
`json:"week"`
}
route/cp_r/rank.go
View file @
f2613d0e
...
...
@@ -91,6 +91,77 @@ func CpRank(c *gin.Context) (*mycontext.MyContext, error) {
return
myCtx
,
nil
}
// @Tags CP v2
// @Summary CP,Top3
// @Param token header string true "token"
// @Param nonce header string true "随机数字"
// @Success 200 {object} cp_cv.CpTops
// @Router /v2/cp/top3 [get]
func
CpTop3
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myCtx
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
userId
,
err
:=
req
.
GetUserId
(
c
)
if
err
!=
nil
{
return
myCtx
,
err
}
var
response
=
cp_cv
.
CpTops
{
Day
:
make
([]
cp_cv
.
CvCp
,
0
),
Week
:
make
([]
cp_cv
.
CvCp
,
0
),
}
queryTypes
:=
[]
string
{
"day"
,
"week"
}
for
_
,
queryType
:=
range
queryTypes
{
var
beginDate
,
endDate
string
switch
queryType
{
case
"day"
:
beginDate
,
endDate
=
time
.
Now
()
.
Format
(
"2006-01-02"
),
time
.
Now
()
.
Format
(
"2006-01-02"
)
case
"week"
:
beginDate
=
now
.
BeginningOfWeek
()
.
Format
(
"2006-01-02"
)
endDate
=
now
.
EndOfWeek
()
.
Format
(
"2006-01-02"
)
}
offset
,
limit
:=
0
,
3
model
:=
domain
.
CreateModelContext
(
myCtx
)
ranks
:=
cp_m
.
PageCpDayRank
(
model
,
beginDate
,
endDate
,
offset
,
limit
)
var
userIds
[]
mysql
.
ID
var
cpIds
[]
mysql
.
ID
for
_
,
rank
:=
range
ranks
{
userIds
=
append
(
userIds
,
rank
.
UserId1
)
userIds
=
append
(
userIds
,
rank
.
UserId2
)
cpIds
=
append
(
cpIds
,
rank
.
CpId
)
}
userBase
,
err
:=
user_cv
.
GetUserBaseMap
(
userIds
,
userId
)
if
err
!=
nil
{
return
myCtx
,
err
}
cpLevels
:=
cp_m
.
MGetCpLevel
(
model
,
cpIds
)
for
i
,
rank
:=
range
ranks
{
if
queryType
==
"day"
{
response
.
Day
=
append
(
response
.
Day
,
cp_cv
.
CvCp
{
CpId
:
rank
.
CpId
,
User1
:
userBase
[
rank
.
UserId1
],
User2
:
userBase
[
rank
.
UserId2
],
Score
:
rank
.
Score
,
Ranking
:
fmt
.
Sprintf
(
"%d"
,
i
+
1
+
offset
),
CpLevel
:
cp_cv
.
CvCpLevel
{
Level
:
cpLevels
[
rank
.
CpId
]
.
Level
,
},
})
}
else
{
response
.
Week
=
append
(
response
.
Week
,
cp_cv
.
CvCp
{
CpId
:
rank
.
CpId
,
User1
:
userBase
[
rank
.
UserId1
],
User2
:
userBase
[
rank
.
UserId2
],
Score
:
rank
.
Score
,
Ranking
:
fmt
.
Sprintf
(
"%d"
,
i
+
1
+
offset
),
CpLevel
:
cp_cv
.
CvCpLevel
{
Level
:
cpLevels
[
rank
.
CpId
]
.
Level
,
},
})
}
}
}
resp
.
ResponseOk
(
c
,
response
)
return
myCtx
,
nil
}
// @Tags CP v2
// @Summary 我的cp
// @Param token header string true "token"
...
...
route/router.go
View file @
f2613d0e
...
...
@@ -36,6 +36,7 @@ func InitRouter() *gin.Engine {
cp
.
GET
(
"/rank/:queryType"
,
wrapper
(
cp_r
.
CpRank
))
cp
.
GET
(
"/my/:queryType"
,
wrapper
(
cp_r
.
CpMy
))
cp
.
GET
(
"/achievement"
,
wrapper
(
cp_r
.
CpAchievement
))
cp
.
GET
(
"/top3"
,
wrapper
(
cp_r
.
CpTop3
))
cp
.
POST
(
"/anniversary"
,
wrapper
(
cp_r
.
PostAnniversary
))
cp
.
PUT
(
"/anniversary/:id"
,
wrapper
(
cp_r
.
PutAnniversary
))
...
...
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