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
b9aeabdc
Commit
b9aeabdc
authored
Jun 06, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:成就yefix
parent
d0121190
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
28 deletions
+28
-28
achievement.go
domain/model/cp_m/achievement.go
+4
-3
cp_level.go
domain/service/event_s/cp_level.go
+2
-2
rank.go
route/cp_r/rank.go
+22
-23
No files found.
domain/model/cp_m/achievement.go
View file @
b9aeabdc
...
@@ -41,10 +41,11 @@ func UpdateCpAchievement(model *domain.Model, cpId, userId1, userId2 mysql.ID, T
...
@@ -41,10 +41,11 @@ func UpdateCpAchievement(model *domain.Model, cpId, userId1, userId2 mysql.ID, T
return
model
.
DB
()
.
Model
(
CpAchievement
{})
.
Where
(
"cp_id = ? AND `type` = ?"
,
cpId
,
Type
)
.
Where
(
"score < ?"
,
score
)
.
UpdateColumn
(
"score"
,
score
)
.
Error
return
model
.
DB
()
.
Model
(
CpAchievement
{})
.
Where
(
"cp_id = ? AND `type` = ?"
,
cpId
,
Type
)
.
Where
(
"score < ?"
,
score
)
.
UpdateColumn
(
"score"
,
score
)
.
Error
}
}
// 获取
用户
cp成就
// 获取cp成就
func
GetCpAchievements
(
model
*
domain
.
Model
,
cpId
mysql
.
ID
)
[]
CpAchievement
{
func
GetCpAchievements
(
model
*
domain
.
Model
)
[]
CpAchievement
{
var
achievements
[]
CpAchievement
var
achievements
[]
CpAchievement
if
err
:=
model
.
DB
()
.
Model
(
CpAchievement
{})
.
Where
(
"cp_id = ?"
,
cpId
)
.
Find
(
&
achievements
)
.
Error
;
err
!=
nil
{
subQuery
:=
model
.
DB
()
.
Table
(
"cp_achievement a"
)
.
Joins
(
"JOIN cp_relation r ON a.cp_id = r.id"
)
.
Select
(
"type,MAX(score) AS max_score"
)
.
Group
(
"type"
)
if
err
:=
model
.
DB
()
.
Model
(
CpAchievement
{})
.
Where
(
"(type, score) IN (?)"
,
subQuery
)
.
Find
(
&
achievements
)
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetAchievements fail:%v"
,
err
)
model
.
Log
.
Errorf
(
"GetAchievements fail:%v"
,
err
)
}
}
return
achievements
return
achievements
...
...
domain/service/event_s/cp_level.go
View file @
b9aeabdc
...
@@ -2,7 +2,6 @@ package event_s
...
@@ -2,7 +2,6 @@ package event_s
import
(
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"github.com/jinzhu/now"
"github.com/jinzhu/now"
"hilo-user/_const/enum/cp_e"
"hilo-user/_const/enum/cp_e"
"hilo-user/domain/event/gift_ev"
"hilo-user/domain/event/gift_ev"
...
@@ -31,7 +30,8 @@ func CpGiftEvent() {
...
@@ -31,7 +30,8 @@ func CpGiftEvent() {
}
}
// 检查最新的等级
// 检查最新的等级
if
cpLevel
:=
cp_m
.
GetCpLevel
(
model
,
cpRelation
.
ID
);
cpLevel
.
CpId
>=
0
{
if
cpLevel
:=
cp_m
.
GetCpLevel
(
model
,
cpRelation
.
ID
);
cpLevel
.
CpId
>=
0
{
if
err
:=
cp_m
.
UpdateCpAchievement
(
model
,
cpLevel
.
CpId
,
cpRelation
.
UserId1
,
cpRelation
.
UserId2
,
cp_e
.
CpAchievementLevel
,
mysql
.
Num
(
cpLevel
.
Level
));
err
!=
nil
{
points
:=
cpLevel
.
Points
+
cp_e
.
CpLevelPoints
[
cpLevel
.
Level
]
if
err
:=
cp_m
.
UpdateCpAchievement
(
model
,
cpLevel
.
CpId
,
cpRelation
.
UserId1
,
cpRelation
.
UserId2
,
cp_e
.
CpAchievementLevel
,
points
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"UpdateCpAchievement fail:%v"
,
err
)
model
.
Log
.
Errorf
(
"UpdateCpAchievement fail:%v"
,
err
)
}
}
}
}
...
...
route/cp_r/rank.go
View file @
b9aeabdc
...
@@ -231,16 +231,13 @@ func CpMy(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -231,16 +231,13 @@ func CpMy(c *gin.Context) (*mycontext.MyContext, error) {
// @Summary 成就页
// @Summary 成就页
// @Param token header string true "token"
// @Param token header string true "token"
// @Param nonce header string true "随机数字"
// @Param nonce header string true "随机数字"
// @Param pageIndex query int true "偏移值 默认:1" default(1)
// @Param pageSize query int true "请求数量 默认:10" default(10)
// @Success 200 {object} []cp_cv.CvCpAchievement
// @Success 200 {object} []cp_cv.CvCpAchievement
// @Router /v2/cp/achievement [get]
// @Router /v2/cp/achievement [get]
func
CpAchievement
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
func
CpAchievement
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myCtx
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
myCtx
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
userId
,
err
:=
req
.
GetUserId
(
c
)
if
err
!=
nil
{
return
myCtx
,
err
}
model
:=
domain
.
CreateModelContext
(
myCtx
)
model
:=
domain
.
CreateModelContext
(
myCtx
)
relation
,
exits
:=
cp_m
.
GetCpRelation
(
model
,
userId
)
var
response
=
make
([]
cp_cv
.
CvCpAchievement
,
0
)
var
response
=
make
([]
cp_cv
.
CvCpAchievement
,
0
)
TypeDescMap
:=
map
[
cp_e
.
CpAchievement
]
string
{
// todo 翻译
TypeDescMap
:=
map
[
cp_e
.
CpAchievement
]
string
{
// todo 翻译
cp_e
.
CpAchievementLevel
:
"等级分值最高"
,
cp_e
.
CpAchievementLevel
:
"等级分值最高"
,
...
@@ -249,12 +246,16 @@ func CpAchievement(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -249,12 +246,16 @@ func CpAchievement(c *gin.Context) (*mycontext.MyContext, error) {
cp_e
.
CpAchievementWeekRank
:
"周榜最高"
,
cp_e
.
CpAchievementWeekRank
:
"周榜最高"
,
cp_e
.
CpAchievementDayRank
:
"天榜最高"
,
cp_e
.
CpAchievementDayRank
:
"天榜最高"
,
}
}
if
exits
{
achievements
:=
cp_m
.
GetCpAchievements
(
model
)
users
,
err
:=
user_m
.
GetUserMapByIds
(
model
,
[]
mysql
.
ID
{
relation
.
UserId1
,
relation
.
UserId2
})
var
userIds
[]
uint64
for
_
,
v
:=
range
achievements
{
userIds
=
append
(
userIds
,
v
.
UserId1
)
userIds
=
append
(
userIds
,
v
.
UserId2
)
}
users
,
err
:=
user_m
.
GetUserMapByIds
(
model
,
userIds
)
if
err
!=
nil
{
if
err
!=
nil
{
return
myCtx
,
err
return
myCtx
,
err
}
}
achievements
:=
cp_m
.
GetCpAchievements
(
model
,
relation
.
ID
)
for
_
,
a
:=
range
achievements
{
for
_
,
a
:=
range
achievements
{
response
=
append
(
response
,
cp_cv
.
CvCpAchievement
{
response
=
append
(
response
,
cp_cv
.
CvCpAchievement
{
CpId
:
a
.
CpId
,
CpId
:
a
.
CpId
,
...
@@ -266,8 +267,6 @@ func CpAchievement(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -266,8 +267,6 @@ func CpAchievement(c *gin.Context) (*mycontext.MyContext, error) {
TimeUnix
:
a
.
UpdatedTime
.
Unix
(),
TimeUnix
:
a
.
UpdatedTime
.
Unix
(),
})
})
}
}
}
else
{
}
resp
.
ResponsePageBaseOk
(
c
,
response
,
0
,
false
)
resp
.
ResponsePageBaseOk
(
c
,
response
,
0
,
false
)
return
myCtx
,
nil
return
myCtx
,
nil
}
}
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