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
3c6346df
Commit
3c6346df
authored
Apr 26, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/sheep' into 'master'
Feature/sheep See merge request
!3
parents
a4e2ee30
47ebd317
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
8 deletions
+47
-8
level.go
cv/user_cv/level.go
+4
-2
userNoble.go
domain/model/noble_m/userNoble.go
+7
-6
matchActive.go
domain/model/user_m/matchActive.go
+31
-0
inner.go
route/user_r/inner.go
+5
-0
No files found.
cv/user_cv/level.go
View file @
3c6346df
...
@@ -6,6 +6,8 @@ type MGetUserLevelData map[mysql.ID]CvUserLevel
...
@@ -6,6 +6,8 @@ type MGetUserLevelData map[mysql.ID]CvUserLevel
type
CvUserLevel
struct
{
type
CvUserLevel
struct
{
UserId
mysql
.
ID
`json:"userId"`
// 用户id
UserId
mysql
.
ID
`json:"userId"`
// 用户id
WealthUserGrade
uint32
`json:"wealthUserGrade"`
//财富等级
WealthUserGrade
uint32
`json:"wealthUserGrade"`
// 财富等级
CharmUserGrade
uint32
`json:"charmUserGrade"`
//魅力等级
CharmUserGrade
uint32
`json:"charmUserGrade"`
// 魅力等级
ActiveUserGrade
uint32
`json:"activeUserGrade"`
// 活跃等级
NobleLevel
uint16
`json:"nobleLevel"`
// 贵族等级
}
}
domain/model/noble_m/userNoble.go
View file @
3c6346df
package
noble_m
package
noble_m
import
(
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/resource/mysql"
"gorm.io/gorm"
"gorm.io/gorm"
"time"
"time"
...
@@ -78,8 +79,8 @@ func GetNobleLevel(db *gorm.DB, userId uint64) (uint16, error) {
...
@@ -78,8 +79,8 @@ func GetNobleLevel(db *gorm.DB, userId uint64) (uint16, error) {
}
}
}
}
func
BatchGetNobleLevel
(
db
*
gorm
.
DB
,
userIds
[]
uint64
)
(
map
[
uint64
]
uint16
,
error
)
{
func
BatchGetNobleLevel
(
model
*
domain
.
Model
,
userIds
[]
uint64
)
(
map
[
uint64
]
uint16
,
error
)
{
m
,
err
:=
BatchGetActiveNoble
(
db
,
userIds
)
m
,
err
:=
BatchGetActiveNoble
(
model
,
userIds
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -90,10 +91,10 @@ func BatchGetNobleLevel(db *gorm.DB, userIds []uint64) (map[uint64]uint16, error
...
@@ -90,10 +91,10 @@ func BatchGetNobleLevel(db *gorm.DB, userIds []uint64) (map[uint64]uint16, error
return
result
,
nil
return
result
,
nil
}
}
func
BatchGetActiveNoble
(
db
*
gorm
.
DB
,
userIds
[]
uint64
)
(
map
[
uint64
]
UserNoble
,
error
)
{
func
BatchGetActiveNoble
(
model
*
domain
.
Model
,
userIds
[]
uint64
)
(
map
[
uint64
]
UserNoble
,
error
)
{
ub
:=
UserNoble
{}
ub
:=
UserNoble
{}
records
,
err
:=
ub
.
batchGet
(
db
,
userIds
)
records
,
err
:=
ub
.
batchGet
(
model
,
userIds
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -110,9 +111,9 @@ func BatchGetActiveNoble(db *gorm.DB, userIds []uint64) (map[uint64]UserNoble, e
...
@@ -110,9 +111,9 @@ func BatchGetActiveNoble(db *gorm.DB, userIds []uint64) (map[uint64]UserNoble, e
}
}
// 查询用户未过期的贵族
// 查询用户未过期的贵族
func
(
ub
*
UserNoble
)
batchGet
(
db
*
gorm
.
DB
,
userIds
[]
uint64
)
(
map
[
uint64
][]
UserNoble
,
error
)
{
func
(
ub
*
UserNoble
)
batchGet
(
model
*
domain
.
Model
,
userIds
[]
uint64
)
(
map
[
uint64
][]
UserNoble
,
error
)
{
rows
:=
make
([]
UserNoble
,
0
)
rows
:=
make
([]
UserNoble
,
0
)
if
err
:=
db
.
Model
(
ub
)
.
Where
(
"end_time>=NOW() AND user_id IN ?"
,
userIds
)
.
Order
(
"level DESC"
)
.
Find
(
&
rows
)
.
Error
;
err
!=
nil
{
if
err
:=
model
.
DB
()
.
Model
(
ub
)
.
Where
(
"end_time>=NOW() AND user_id IN ?"
,
userIds
)
.
Order
(
"level DESC"
)
.
Find
(
&
rows
)
.
Error
;
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
result
:=
make
(
map
[
uint64
][]
UserNoble
,
0
)
result
:=
make
(
map
[
uint64
][]
UserNoble
,
0
)
...
...
domain/model/user_m/matchActive.go
0 → 100644
View file @
3c6346df
package
user_m
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
)
/**
* 用户活跃分数
**/
type
MatchActityUserScore
struct
{
mysql
.
Entity
*
domain
.
Model
`gorm:"-"`
UserId
mysql
.
ID
Score
mysql
.
Num
Grade
mysql
.
Num
}
// 获取活跃等级
func
MGetActiveGrade
(
model
*
domain
.
Model
,
userIds
[]
mysql
.
ID
)
(
map
[
mysql
.
ID
]
mysql
.
Num
,
error
)
{
res
:=
make
(
map
[
mysql
.
ID
]
mysql
.
Num
)
var
rows
[]
MatchActityUserScore
if
err
:=
mysql
.
Db
.
Model
(
&
MatchActityUserScore
{})
.
Where
(
"user_id in ?"
,
userIds
)
.
Find
(
&
rows
)
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"MGetActiveGrade fail:%v"
,
err
)
return
res
,
err
}
for
_
,
r
:=
range
rows
{
res
[
r
.
UserId
]
=
r
.
Grade
}
return
res
,
nil
}
route/user_r/inner.go
View file @
3c6346df
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"hilo-user/cv/user_cv"
"hilo-user/cv/user_cv"
"hilo-user/domain/model/bag_m"
"hilo-user/domain/model/bag_m"
"hilo-user/domain/model/noble_m"
"hilo-user/domain/model/res_m"
"hilo-user/domain/model/res_m"
"hilo-user/domain/model/user_m"
"hilo-user/domain/model/user_m"
"hilo-user/resp"
"hilo-user/resp"
...
@@ -34,12 +35,16 @@ func MGetUserLevels(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -34,12 +35,16 @@ func MGetUserLevels(c *gin.Context) (*mycontext.MyContext, error) {
return
myCtx
,
err
return
myCtx
,
err
}
}
charmGrade
,
err
:=
user_m
.
MGetCharmGrade
(
model
,
req
.
Ids
)
charmGrade
,
err
:=
user_m
.
MGetCharmGrade
(
model
,
req
.
Ids
)
activeGrade
,
err
:=
user_m
.
MGetActiveGrade
(
model
,
req
.
Ids
)
nobleLevel
,
err
:=
noble_m
.
BatchGetNobleLevel
(
model
,
req
.
Ids
)
response
:=
user_cv
.
MGetUserLevelData
{}
response
:=
user_cv
.
MGetUserLevelData
{}
for
_
,
userId
:=
range
req
.
Ids
{
for
_
,
userId
:=
range
req
.
Ids
{
response
[
userId
]
=
user_cv
.
CvUserLevel
{
response
[
userId
]
=
user_cv
.
CvUserLevel
{
UserId
:
userId
,
UserId
:
userId
,
WealthUserGrade
:
wealthGrade
[
userId
],
WealthUserGrade
:
wealthGrade
[
userId
],
CharmUserGrade
:
charmGrade
[
userId
],
CharmUserGrade
:
charmGrade
[
userId
],
ActiveUserGrade
:
activeGrade
[
userId
],
NobleLevel
:
nobleLevel
[
userId
],
}
}
}
}
...
...
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