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
48f22c89
Commit
48f22c89
authored
May 30, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CpLevel CvCpLevel `json:"cpLevel"` // cp等级
parent
0b17c301
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
4 deletions
+28
-4
rank.go
cv/cp_cv/rank.go
+5
-4
level.go
domain/model/cp_m/level.go
+13
-0
rank.go
route/cp_r/rank.go
+10
-0
No files found.
cv/cp_cv/rank.go
View file @
48f22c89
...
@@ -10,6 +10,7 @@ type CvCp struct {
...
@@ -10,6 +10,7 @@ type CvCp struct {
User1
*
user_cv
.
CvUserBase
`json:"user1"`
// user1
User1
*
user_cv
.
CvUserBase
`json:"user1"`
// user1
User2
*
user_cv
.
CvUserBase
`json:"user2"`
// user2
User2
*
user_cv
.
CvUserBase
`json:"user2"`
// user2
Score
uint32
`json:"score"`
// 分值
Score
uint32
`json:"score"`
// 分值
CpLevel
CvCpLevel
`json:"cpLevel"`
// cp等级
//Ranking int `json:"ranking"` // 排名
//Ranking int `json:"ranking"` // 排名
}
}
...
...
domain/model/cp_m/level.go
View file @
48f22c89
...
@@ -53,6 +53,19 @@ func GetCpLevel(model *domain.Model, cpId mysql.ID) CpLevel {
...
@@ -53,6 +53,19 @@ func GetCpLevel(model *domain.Model, cpId mysql.ID) CpLevel {
return
level
return
level
}
}
// 批量获取cp等级
func
MGetCpLevel
(
model
*
domain
.
Model
,
cpIds
[]
mysql
.
ID
)
map
[
mysql
.
ID
]
CpLevel
{
var
res
=
make
(
map
[
mysql
.
ID
]
CpLevel
)
var
level
[]
CpLevel
if
err
:=
model
.
DB
()
.
Model
(
CpLevel
{})
.
Where
(
"cp_id in ?"
,
cpIds
)
.
Find
(
&
level
)
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"MGetCpLevel fail:%v"
,
err
)
}
for
i
,
v
:=
range
level
{
res
[
v
.
CpId
]
=
level
[
i
]
}
return
res
}
// 添加cp等级积分增减明细
// 添加cp等级积分增减明细
func
AddCpLevelDetail
(
model
*
domain
.
Model
,
detail
CpLevelDetail
)
error
{
func
AddCpLevelDetail
(
model
*
domain
.
Model
,
detail
CpLevelDetail
)
error
{
return
model
.
DB
()
.
Create
(
&
detail
)
.
Error
return
model
.
DB
()
.
Create
(
&
detail
)
.
Error
...
...
route/cp_r/rank.go
View file @
48f22c89
...
@@ -59,14 +59,17 @@ func CpRank(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -59,14 +59,17 @@ func CpRank(c *gin.Context) (*mycontext.MyContext, error) {
ranks
:=
cp_m
.
PageCpDayRank
(
model
,
beginDate
,
endDate
,
offset
,
limit
)
ranks
:=
cp_m
.
PageCpDayRank
(
model
,
beginDate
,
endDate
,
offset
,
limit
)
var
response
[]
cp_cv
.
CvCp
var
response
[]
cp_cv
.
CvCp
var
userIds
[]
mysql
.
ID
var
userIds
[]
mysql
.
ID
var
cpIds
[]
mysql
.
ID
for
_
,
rank
:=
range
ranks
{
for
_
,
rank
:=
range
ranks
{
userIds
=
append
(
userIds
,
rank
.
UserId1
)
userIds
=
append
(
userIds
,
rank
.
UserId1
)
userIds
=
append
(
userIds
,
rank
.
UserId2
)
userIds
=
append
(
userIds
,
rank
.
UserId2
)
cpIds
=
append
(
cpIds
,
rank
.
CpId
)
}
}
userBase
,
err
:=
user_cv
.
GetUserBaseMap
(
userIds
,
userId
)
userBase
,
err
:=
user_cv
.
GetUserBaseMap
(
userIds
,
userId
)
if
err
!=
nil
{
if
err
!=
nil
{
return
myCtx
,
err
return
myCtx
,
err
}
}
cpLevels
:=
cp_m
.
MGetCpLevel
(
model
,
cpIds
)
for
_
,
rank
:=
range
ranks
{
for
_
,
rank
:=
range
ranks
{
response
=
append
(
response
,
cp_cv
.
CvCp
{
response
=
append
(
response
,
cp_cv
.
CvCp
{
CpId
:
rank
.
CpId
,
CpId
:
rank
.
CpId
,
...
@@ -74,6 +77,13 @@ func CpRank(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -74,6 +77,13 @@ func CpRank(c *gin.Context) (*mycontext.MyContext, error) {
User2
:
userBase
[
rank
.
UserId2
],
User2
:
userBase
[
rank
.
UserId2
],
Score
:
rank
.
Score
,
Score
:
rank
.
Score
,
//Ranking: i + 1 + offset,
//Ranking: i + 1 + offset,
CpLevel
:
cp_cv
.
CvCpLevel
{
Level
:
cpLevels
[
rank
.
CpId
]
.
Level
,
//Points: cp_e.CpLevelPoints[cpLevel] + curPoints,
//NextPoints: nextPoints,
//RemainPoints: remainPoints,
//ExpireAtUnix: expireAtUnix,
},
})
})
}
}
resp
.
ResponsePageBaseOk
(
c
,
response
,
pageReq
.
PageIndex
+
1
,
len
(
ranks
)
>=
pageReq
.
PageSize
)
resp
.
ResponsePageBaseOk
(
c
,
response
,
pageReq
.
PageIndex
+
1
,
len
(
ranks
)
>=
pageReq
.
PageSize
)
...
...
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