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
ffc6a497
Commit
ffc6a497
authored
Jul 28, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/4.3_cwj' into 'master'
4.0.5 接口优化 See merge request
!24
parents
c08701f9
6d902bd7
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
176 additions
and
14 deletions
+176
-14
rank.go
cv/cp_cv/rank.go
+6
-6
user.go
cv/user_cv/user.go
+99
-0
rank.go
route/cp_r/rank.go
+8
-8
router.go
route/router.go
+1
-0
user.go
route/user_r/user.go
+62
-0
No files found.
cv/cp_cv/rank.go
View file @
ffc6a497
...
...
@@ -7,8 +7,8 @@ import (
type
CvCpRank
struct
{
CpId
uint64
`json:"cpId"`
// cpId
User1
*
user_cv
.
CvUser
Bas
e
`json:"user1"`
// user1
User2
*
user_cv
.
CvUser
Bas
e
`json:"user2,omitempty"`
// user2
User1
*
user_cv
.
CvUser
Littl
e
`json:"user1"`
// user1
User2
*
user_cv
.
CvUser
Littl
e
`json:"user2,omitempty"`
// user2
Score
uint32
`json:"score"`
// 分值
CpLevel
CvCpLevel
`json:"cpLevel"`
// cp等级
Ranking
string
`json:"ranking"`
// 排名
...
...
cv/user_cv/user.go
View file @
ffc6a497
package
user_cv
import
(
"encoding/json"
"git.hilo.cn/hilo-common/_const/common"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mylogrus"
...
...
@@ -111,6 +112,17 @@ type CvUserBase struct {
GroupRole
common
.
GroupRoleType
`json:"groupRole"`
// 在群组的角色
}
type
CvUserLittle
struct
{
//不会有返回值
Id
*
mysql
.
ID
`json:"id,omitempty"`
//头像,不存在为nil
Avatar
*
string
`json:"avatar"`
//用户对外ID
ExternalId
*
string
`json:"externalId"`
//昵称,不存在为nil
Nick
*
string
`json:"nick"`
}
//批量获取用户基本信息
func
GetUserBases
(
userIds
[]
mysql
.
ID
,
myUserId
mysql
.
ID
)
([]
*
CvUserBase
,
error
)
{
if
len
(
userIds
)
==
0
{
...
...
@@ -482,6 +494,50 @@ type CvUserDetail struct {
Cp
*
CvCp
`json:"cp,omitempty"`
// cp信息
}
//用户详细信息-在房间里面时需要的
type
CvUserDetailRoom
struct
{
//不会有返回值
//不会有返回值
Id
*
mysql
.
ID
`json:"id,omitempty"`
//头像,不存在为nil
Avatar
*
string
`json:"avatar"`
//是否默认头像 true:是 false:不是
DefaultAvatar
*
bool
`json:"defaultAvatar"`
//用户对外ID
ExternalId
*
string
`json:"externalId"`
//昵称,不存在为nil
Nick
*
string
`json:"nick"`
//性别 1:男 2:女,不存在为nil
Sex
*
uint8
`json:"sex"`
//国家,不存在为nil
Country
*
string
`json:"country"`
//国旗图标,不存在为nil
CountryIcon
*
string
`json:"countryIcon"`
//邀请码
Code
*
string
`json:"code"`
IsPrettyCode
bool
`json:"isPrettyCode"`
// 是否靓号
//生日,如果是其它人用户信息,年龄则按照是否展示显示,如果是本人,年龄则按照是否存在展示
Birthday
*
uint64
`json:"birthday"`
//是否展示年龄, 是本人才有数据,看其他用户均为nil
IsShowAge
*
uint8
`json:"isShowAge"`
//是否VIP用户
IsVip
bool
`json:"isVip"`
Svip
rpc
.
CvSvip
`json:"svip"`
// svip结构,等级+权限
Medals
[]
uint32
`json:"medals"`
// 勋章列表
Noble
noble_cv
.
CvNoble
`json:"noble"`
// 当前的
CountryManager
*
CVCountryManager
`json:"countryManager,omitempty"`
// 国家管理员
Headwear
*
headwear_cv
.
CvHeadwear
`json:"headwear"`
// 当前使用的头饰
WealthUserGrade
uint32
`json:"wealthUserGrade"`
//财富等级
CharmUserGrade
uint32
`json:"charmUserGrade"`
//魅力等级
ActivityUserGrade
uint32
`json:"activityUserGrade"`
//活跃等级
GroupPower
rpc
.
CvGroupPowerInfo
`json:"groupPower"`
// 家族
//是否喜欢(本人没有数据,//20210205 已废弃nil,产品说:可以自己喜欢自己)
IsLike
*
bool
`json:"isLike"`
//别人是否喜欢我,自己本人没有数据 (20210205 已废弃nil,产品说:可以自己喜欢自己)
IsLikeMe
*
bool
`json:"isLikeMe"`
Cp
*
CvCpTiny
`json:"cp,omitempty"`
// cp信息
GroupRole
common
.
GroupRoleType
`json:"groupRole"`
// 在群组的角色
}
// cv国家管理人员
type
CVCountryManager
struct
{
Country
string
`json:"country"`
// 国家name
...
...
@@ -497,6 +553,33 @@ type CvCp struct {
CpDays
int
`json:"cpDays"`
// cp天数
}
// cp信息
type
CvCpTiny
struct
{
CpUserInfo
*
CvCpUser
`json:"cpUserInfo"`
// cp用户信息
CpLevel
CvCpLevel
`json:"cpLevel"`
// cp等级
MyPrivilegeList
[]
CvPrivilege
`json:"myPrivilegeList"`
// 等级特权
CreatedUnix
int64
`json:"createdUnix"`
// cp创建时间
CpDays
int
`json:"cpDays"`
// cp天数
}
type
CvCpUser
struct
{
//不会有返回值
Id
*
mysql
.
ID
`json:"id,omitempty"`
//头像,不存在为nil
Avatar
*
string
`json:"avatar"`
//用户对外ID
ExternalId
*
string
`json:"externalId"`
//昵称,不存在为nil
Nick
*
string
`json:"nick"`
//性别 1:男 2:女,不存在为nil
Sex
*
uint8
`json:"sex"`
//邀请码
Code
*
string
`json:"code"`
Headwear
*
headwear_cv
.
CvHeadwear
`json:"headwear"`
// 当前使用的头饰
Svip
rpc
.
CvSvip
`json:"svip"`
// svip结构,等级+权限
Noble
noble_cv
.
CvNoble
`json:"noble"`
// 当前的
}
// cp关系
type
CvCpRelation
struct
{
CpId
uint64
`json:"cpId"`
...
...
@@ -516,3 +599,19 @@ type CvCpLevel struct {
type
CvPrivilege
struct
{
Type
cp_e
.
CpPrivilege
`json:"type"`
// 特权id 1:空间 2:横幅 3:等级勋章 4:证书 5:进场特效 6:头像头饰 7:动态资料卡 8:麦位特效
}
func
UserBaseToUserLittle
(
base
*
CvUserBase
)
*
CvUserLittle
{
return
&
CvUserLittle
{
Id
:
base
.
Id
,
Avatar
:
base
.
Avatar
,
ExternalId
:
base
.
ExternalId
,
Nick
:
base
.
Nick
,
}
}
func
CvUserDetailToCvUserDetailRoom
(
info
*
CvUserDetail
)
*
CvUserDetailRoom
{
res
:=
new
(
CvUserDetailRoom
)
jData
,
_
:=
json
.
Marshal
(
info
)
_
=
json
.
Unmarshal
(
jData
,
&
res
)
return
res
}
route/cp_r/rank.go
View file @
ffc6a497
...
...
@@ -81,8 +81,8 @@ func CpRank(c *gin.Context) (*mycontext.MyContext, error) {
for
i
,
rank
:=
range
ranks
{
response
=
append
(
response
,
cp_cv
.
CvCpRank
{
CpId
:
rank
.
CpId
,
User1
:
user
Base
[
rank
.
UserId1
]
,
User2
:
user
Base
[
rank
.
UserId2
]
,
User1
:
user
_cv
.
UserBaseToUserLittle
(
userBase
[
rank
.
UserId1
])
,
User2
:
user
_cv
.
UserBaseToUserLittle
(
userBase
[
rank
.
UserId2
])
,
Score
:
rank
.
Score
,
Ranking
:
fmt
.
Sprintf
(
"%d"
,
i
+
1
+
offset
),
CpLevel
:
cp_cv
.
CvCpLevel
{
...
...
@@ -143,8 +143,8 @@ func CpTop3(c *gin.Context) (*mycontext.MyContext, error) {
if
queryType
==
"day"
{
response
.
Day
=
append
(
response
.
Day
,
cp_cv
.
CvCpRank
{
CpId
:
rank
.
CpId
,
User1
:
user
Base
[
rank
.
UserId1
]
,
User2
:
user
Base
[
rank
.
UserId2
]
,
User1
:
user
_cv
.
UserBaseToUserLittle
(
userBase
[
rank
.
UserId1
])
,
User2
:
user
_cv
.
UserBaseToUserLittle
(
userBase
[
rank
.
UserId2
])
,
Score
:
rank
.
Score
,
Ranking
:
fmt
.
Sprintf
(
"%d"
,
i
+
1
+
offset
),
CpLevel
:
cp_cv
.
CvCpLevel
{
...
...
@@ -154,8 +154,8 @@ func CpTop3(c *gin.Context) (*mycontext.MyContext, error) {
}
else
{
response
.
Week
=
append
(
response
.
Week
,
cp_cv
.
CvCpRank
{
CpId
:
rank
.
CpId
,
User1
:
user
Base
[
rank
.
UserId1
]
,
User2
:
user
Base
[
rank
.
UserId2
]
,
User1
:
user
_cv
.
UserBaseToUserLittle
(
userBase
[
rank
.
UserId1
])
,
User2
:
user
_cv
.
UserBaseToUserLittle
(
userBase
[
rank
.
UserId2
])
,
Score
:
rank
.
Score
,
Ranking
:
fmt
.
Sprintf
(
"%d"
,
i
+
1
+
offset
),
CpLevel
:
cp_cv
.
CvCpLevel
{
...
...
@@ -224,10 +224,10 @@ func CpMy(c *gin.Context) (*mycontext.MyContext, error) {
Score
:
scores
,
}
if
relation
.
UserId1
>
0
{
response
.
User1
=
user
Bases
[
relation
.
UserId1
]
response
.
User1
=
user
_cv
.
UserBaseToUserLittle
(
userBases
[
relation
.
UserId1
])
}
if
relation
.
UserId2
>
0
{
response
.
User2
=
user
Bases
[
relation
.
UserId2
]
response
.
User2
=
user
_cv
.
UserBaseToUserLittle
(
userBases
[
relation
.
UserId2
])
response
.
Ranking
=
"30+"
ranks
:=
cp_m
.
PageCpDayRank
(
model
,
beginDate
,
endDate
,
0
,
30
)
for
i
,
rank
:=
range
ranks
{
...
...
route/router.go
View file @
ffc6a497
...
...
@@ -65,6 +65,7 @@ func InitRouter() *gin.Engine {
userV2
.
GET
(
"/invite/apply"
,
wrapper
(
invite_r
.
InviteApplyList
))
userV2
.
GET
(
"/invite/platform"
,
wrapper
(
invite_r
.
PromotionPlatform
))
userV2
.
GET
(
"/invite/period"
,
wrapper
(
invite_r
.
AgentPeriod
))
userV2
.
GET
(
"/detail/room"
,
EncryptHandle
,
wrapper
(
user_r
.
GetUserDetailInRoom
))
}
inner
:=
r
.
Group
(
"/inner"
)
inner
.
Use
(
ExceptionHandle
,
LoggerHandle
)
...
...
route/user_r/user.go
View file @
ffc6a497
...
...
@@ -7,6 +7,7 @@ import (
"git.hilo.cn/hilo-common/resource/redisCli"
"github.com/gin-gonic/gin"
"hilo-user/_const/redis_key/user_k"
"hilo-user/cv/user_cv"
"hilo-user/domain/model/group_m"
"hilo-user/domain/model/tim_m"
"hilo-user/domain/service/user_s"
...
...
@@ -106,3 +107,64 @@ func UserDetailByExternalId(c *gin.Context) (*mycontext.MyContext, error) {
resp
.
ResponseOk
(
c
,
cvUserDetail
)
return
myContext
,
nil
}
// @Tags 用户
// @Summary 房间内获取用户信息
// @Param userExternalId query string true "userExternalId"
// @Param groupId query string false "群组id,当传了该id,则返回该用户在该群组的身份"
// @Success 200 {object} user_cv.CvUserDetailRoom
// @Router /v2/user/detail/room [get]
func
GetUserDetailInRoom
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myContext
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
userId
,
lang
,
err
:=
req
.
GetUserIdLang
(
c
,
myContext
)
if
err
!=
nil
{
return
myContext
,
err
}
otherUserId
,
err
:=
req
.
ToUserId
(
myContext
,
c
.
Query
(
"userExternalId"
))
if
err
!=
nil
{
return
nil
,
err
}
model
:=
domain
.
CreateModelContext
(
myContext
)
imGroupId
:=
c
.
Query
(
"groupId"
)
if
imGroupId
!=
""
{
imGroupId
,
err
=
group_m
.
ToImGroupId
(
model
,
imGroupId
)
if
err
!=
nil
{
return
myContext
,
err
}
}
cvUserDetail
,
err
:=
user_s
.
NewUserService
(
myContext
)
.
GetUserDetail
(
otherUserId
,
userId
,
lang
)
if
err
!=
nil
{
return
myContext
,
err
}
if
imGroupId
!=
""
{
cvUserDetail
.
GroupRole
,
err
=
group_m
.
GetGroupRoleById
(
model
,
imGroupId
,
otherUserId
)
if
err
!=
nil
{
return
myContext
,
err
}
}
if
cvUserDetail
!=
nil
{
// 检查是否需要同步
if
n
,
err
:=
redisCli
.
GetRedis
()
.
Exists
(
model
,
user_k
.
GetKeySyncTimHilo
(
userId
))
.
Result
();
err
==
nil
{
if
n
==
0
{
// FIXME:转异步执行
err
=
tim_m
.
FlushHiloInfo
(
*
cvUserDetail
.
ExternalId
,
cvUserDetail
.
IsVip
,
cvUserDetail
.
IsPrettyCode
,
cvUserDetail
.
Medals
,
cvUserDetail
.
MyGroupPowerName
,
cvUserDetail
.
Noble
.
Level
)
if
err
==
nil
{
redisCli
.
GetRedis
()
.
Set
(
model
,
user_k
.
GetKeySyncTimHilo
(
userId
),
"1"
,
time
.
Minute
)
}
else
{
model
.
Log
.
Info
(
"UserBaseByExternalId, FlushHiloInfo failed: "
,
err
)
}
}
else
{
model
.
Log
.
Info
(
"UserDetailByExternalId, no need to sync yet: "
,
userId
)
}
}
else
{
model
.
Log
.
Info
(
"UserDetailByExternalId, check KeySyncTimHilo failed"
,
err
)
}
}
resp
.
ResponseOk
(
c
,
user_cv
.
CvUserDetailToCvUserDetailRoom
(
cvUserDetail
))
return
myContext
,
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