Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-common
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
hujiebin
hilo-common
Commits
28880473
Commit
28880473
authored
Jun 14, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update user.go
parent
ec5be060
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
173 additions
and
33 deletions
+173
-33
user.go
rpc/user.go
+173
-33
No files found.
rpc/user.go
View file @
28880473
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"encoding/json"
"encoding/json"
"errors"
"errors"
"fmt"
"fmt"
"git.hilo.cn/hilo-common/_const/common"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mylogrus"
"git.hilo.cn/hilo-common/mylogrus"
"git.hilo.cn/hilo-common/resource/consul"
"git.hilo.cn/hilo-common/resource/consul"
...
@@ -241,39 +242,6 @@ func SendUserRide(model *domain.Model, userId mysql.ID, rideId mysql.ID, day mys
...
@@ -241,39 +242,6 @@ func SendUserRide(model *domain.Model, userId mysql.ID, rideId mysql.ID, day mys
return
nil
return
nil
}
}
// cp关系
type
CvCpRelation
struct
{
CpId
uint64
`json:"cpId"`
UserId
uint64
`json:"userId"`
CpUserId
uint64
`json:"cpUserId"`
}
// 获取用户cp关系
func
GetUserCpRelation
(
model
*
domain
.
Model
,
userId
mysql
.
ID
)
(
*
CvCpRelation
,
error
)
{
type
Response
struct
{
Code
int
`json:"code"`
Message
string
`json:"message"`
Data
*
CvCpRelation
`json:"data"`
}
_url
:=
fmt
.
Sprintf
(
"%v://%v/inner/user/cpRelation"
,
defaultUserServerScheme
,
getUserHost
())
resp
,
err
:=
HttpGet
(
model
,
_url
,
nil
,
map
[
string
][]
string
{
"id"
:
{
fmt
.
Sprintf
(
"%d"
,
userId
)},
})
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetUserCpRelation fail:%v"
,
err
)
return
nil
,
err
}
response
:=
new
(
Response
)
if
err
=
json
.
Unmarshal
(
resp
,
response
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetUserCpRelation json fail:%v"
,
err
)
return
nil
,
err
}
if
response
.
Data
!=
nil
&&
response
.
Data
.
CpUserId
>
0
{
return
response
.
Data
,
nil
}
return
nil
,
nil
}
// 获取指定cp对
// 获取指定cp对
func
MGetUserCpPairs
(
model
*
domain
.
Model
,
userIds
[]
mysql
.
ID
)
([][
2
]
mysql
.
ID
,
error
)
{
func
MGetUserCpPairs
(
model
*
domain
.
Model
,
userIds
[]
mysql
.
ID
)
([][
2
]
mysql
.
ID
,
error
)
{
type
Response
struct
{
type
Response
struct
{
...
@@ -313,3 +281,175 @@ func getUserHost() string {
...
@@ -313,3 +281,175 @@ func getUserHost() string {
mylogrus
.
MyLog
.
Infof
(
"getHostUser:%v---%v"
,
r
,
UserServerHost
[
r
])
mylogrus
.
MyLog
.
Infof
(
"getHostUser:%v---%v"
,
r
,
UserServerHost
[
r
])
return
UserServerHost
[
r
]
return
UserServerHost
[
r
]
}
}
// cp关系
type
CvCpRelation
struct
{
CpId
uint64
`json:"cpId"`
UserId
uint64
`json:"userId"`
CpUserId
uint64
`json:"cpUserId"`
CpUserAvatar
string
`json:"cpUserAvatar"`
}
// 批量获取用户cpRelation
func
MGetUserCpRelations
(
model
*
domain
.
Model
,
userIds
[]
mysql
.
ID
)
(
map
[
mysql
.
ID
]
CvCpRelation
,
error
)
{
type
Response
struct
{
Code
int
`json:"code"`
Message
string
`json:"message"`
Data
map
[
mysql
.
ID
]
CvCpRelation
}
var
res
=
make
(
map
[
mysql
.
ID
]
CvCpRelation
)
if
len
(
userIds
)
<=
0
{
return
res
,
nil
}
var
userIdsStr
[]
string
for
_
,
userId
:=
range
userIds
{
userIdsStr
=
append
(
userIdsStr
,
fmt
.
Sprintf
(
"%d"
,
userId
))
}
_url
:=
fmt
.
Sprintf
(
"%v://%v/inner/user/cpRelations"
,
defaultUserServerScheme
,
getUserHost
())
resp
,
err
:=
HttpGet
(
model
,
_url
,
nil
,
map
[
string
][]
string
{
"ids"
:
userIdsStr
,
})
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"MGetUserSvip fail:%v"
,
err
)
return
res
,
err
}
response
:=
new
(
Response
)
if
err
=
json
.
Unmarshal
(
resp
,
response
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"MGetUserSvip json fail:%v"
,
err
)
return
res
,
err
}
return
res
,
nil
}
// 获取用户cpRelation
func
GetUserCpRelation
(
model
*
domain
.
Model
,
userId
mysql
.
ID
)
(
CvCpRelation
,
error
)
{
res
,
err
:=
MGetUserCpRelations
(
model
,
[]
uint64
{
userId
})
if
err
!=
nil
{
return
CvCpRelation
{},
err
}
return
res
[
userId
],
nil
}
type
CvCp
struct
{
CpUserInfo
*
CvUserBase
`json:"cpUserInfo"`
// cp用户信息
CpLevel
CvCpLevel
`json:"cpLevel"`
// cp等级
MyPrivilegeList
[]
CvPrivilege
`json:"myPrivilegeList"`
// 等级特权
CreatedUnix
int64
`json:"createdUnix"`
// cp创建时间
CpDays
int
`json:"cpDays"`
// cp天数
}
// cp等级
type
CvCpLevel
struct
{
Level
int
`json:"level"`
// 等级 0:无称号 1:恋爱CP 2:甜蜜CP 3:忠诚CP 4:炽热CP 5:荣耀CP
Points
uint32
`json:"points"`
// CP值
Title
string
`json:"title"`
}
// 特权信息
type
CvPrivilege
struct
{
Type
int
`json:"type"`
// 特权id 1:空间 2:横幅 3:等级勋章 4:证书 5:进场特效 6:头像头饰 7:动态资料卡 8:麦位特效
}
//用户基本信息
type
CvUserBase
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"`
//签名,不存在为nil
Description
*
string
`json:"description"`
//性别 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"`
// 是否靓号
IsLogout
bool
`json:"isLogout"`
//是否注销
//生日,如果是其它人用户信息,年龄则按照是否展示显示,如果是本人,年龄则按照是否存在展示
Birthday
*
uint64
`json:"birthday"`
//是否展示年龄, 是本人才有数据,看其他用户均为nil
IsShowAge
*
uint8
`json:"isShowAge"`
//是否工会成员, 只有是自己查自己,这个才有值,其它全为nil, 20220329 数据开放:原因:产品1对1视频聊天中,公会用户视频需要送礼物。改为: 全部人可以知道是否是公会用户。
IsTradeUnion
*
bool
`json:"isTradeUnion"`
//是否代理管理员, 只有自己查自己的时候才有值,其他情况为nil
IsAgentMgr
*
bool
`json:"isAgentMgr"`
//工会成员,是否开启了,匹配通知,只有 isTradeUnion值为true,这里才有值,
IsTradeUnionMatchNotification
*
bool
`json:"isTradeUnionMatchNotification"`
//是否VIP用户
IsVip
bool
`json:"isVip"`
//是否是官方人员
IsOfficialStaff
bool
`json:"isOfficialStaff"`
//VIP用户过期时间(只有自己查询自己,才返回)
VipExpireTime
*
int64
`json:"vipExpireTime"`
Svip
CvSvip
`json:"svip"`
// svip结构,等级+权限
Medals
[]
uint32
`json:"medals"`
// 勋章列表 TODO: 删除
MedalInfo
[]
CvMedal
`json:"medalInfo"`
// 勋章列表
Headwear
*
CvHeadwear
`json:"headwear"`
// 当前使用的头饰
Ride
CvProperty
`json:"ride"`
// 当前使用的座驾
Noble
CvNoble
`json:"noble"`
// 当前的
GroupRole
common
.
GroupRoleType
`json:"groupRole"`
// 在群组的角色
}
type
CvMedal
struct
{
Id
uint32
`json:"id"`
PicUrl
mysql
.
Str
`json:"picUrl"`
EffectUrl
mysql
.
Str
`json:"effectUrl"`
}
type
CvHeadwear
struct
{
Id
uint64
`json:"id"`
Using
bool
`json:"using"`
PicUrl
mysql
.
Str
`json:"picUrl"`
EffectUrl
mysql
.
Str
`json:"effectUrl"`
TimeLeft
int64
`json:"timeLeft"`
// 离到期还有多少秒(过期则是负数)
}
type
CvProperty
struct
{
Id
uint64
`json:"id"`
PicUrl
mysql
.
Str
`json:"picUrl"`
EffectUrl
mysql
.
Str
`json:"effectUrl"`
Using
bool
`json:"using"`
TimeLeft
int64
`json:"timeLeft"`
// 离到期还有多少秒(过期则是负数)
SenderAvatar
string
`json:"senderAvatar"`
ReceiverAvatar
string
`json:"receiverAvatar"`
}
type
CvNoble
struct
{
Level
uint16
`json:"level"`
EndTime
int64
`json:"endTime"`
}
// 获取用户cp
func
GetUserCp
(
model
*
domain
.
Model
,
userId
mysql
.
ID
)
(
*
CvCp
,
error
)
{
type
Response
struct
{
Code
int
`json:"code"`
Message
string
`json:"message"`
Data
*
CvCp
`json:"data"`
}
_url
:=
fmt
.
Sprintf
(
"%v://%v/inner/user/cp"
,
defaultUserServerScheme
,
getUserHost
())
resp
,
err
:=
HttpGet
(
model
,
_url
,
nil
,
map
[
string
][]
string
{
"id"
:
{
fmt
.
Sprintf
(
"%d"
,
userId
)},
})
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetUserCp fail:%v"
,
err
)
return
nil
,
err
}
response
:=
new
(
Response
)
if
err
=
json
.
Unmarshal
(
resp
,
response
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetUserCp json fail:%v"
,
err
)
return
nil
,
err
}
if
response
.
Data
!=
nil
&&
response
.
Data
.
CpUserInfo
!=
nil
{
return
response
.
Data
,
nil
}
return
nil
,
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