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
823b8882
Commit
823b8882
authored
Jul 10, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Plain Diff
merge master
parents
536911b7
2c323d3c
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
78 additions
and
25 deletions
+78
-25
bag.go
cv/user_cv/bag.go
+1
-0
user.go
cv/user_cv/user.go
+9
-4
gift.go
domain/model/res_m/gift.go
+1
-0
user.go
domain/model/user_m/user.go
+18
-0
user.go
domain/service/user_s/user.go
+2
-2
response.go
resp/response.go
+19
-6
middleHandle.go
route/middleHandle.go
+13
-0
router.go
route/router.go
+2
-2
bag.go
route/user_r/bag.go
+13
-11
No files found.
cv/user_cv/bag.go
View file @
823b8882
...
...
@@ -16,6 +16,7 @@ type UserBag struct {
Count
mysql
.
Num
`json:"count"`
// 拥有数量
RemainDays
int
`json:"remainDays"`
// 有效天数
TextStyleList
[]
*
TextStyle
`json:"textStyleList"`
// 文本样式
HasGiftText
bool
`json:"hasGiftText"`
// 是否有礼物文字
}
type
TextStyle
struct
{
...
...
cv/user_cv/user.go
View file @
823b8882
...
...
@@ -151,11 +151,15 @@ func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error)
//rp := res_m.ResProperty{}
//properties, err := rp.GetAll(mysql.Db)
_
,
myArea
,
err
:=
user_m
.
GetUserCountryArea
(
domain
.
CreateModelNil
(),
myUserId
)
if
err
!=
nil
{
return
nil
,
err
propertiesArea
:=
make
(
map
[
int
]
map
[
uint64
]
property_cv
.
CvProperty
)
for
_
,
v
:=
range
[]
int
{
1
,
2
}
{
properties
,
err
:=
GetPropertyAll
(
mysql
.
Db
,
v
)
if
err
!=
nil
{
return
nil
,
err
}
propertiesArea
[
v
]
=
properties
}
properties
,
err
:=
GetPropertyAll
(
mysql
.
Db
,
myArea
)
areaMap
,
err
:=
user_m
.
GetUserAreaMap
(
domain
.
CreateModelNil
(),
userIds
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -173,6 +177,7 @@ func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error)
cvUserBases
:=
[]
*
CvUserBase
{}
for
i
:=
0
;
i
<
len
(
users
);
i
++
{
user
:=
users
[
i
]
properties
:=
propertiesArea
[
areaMap
[
user
.
ID
]]
invisible
:=
IfLogout
(
user
.
LogoutTime
)
invisibleAvatar
:=
""
invisibleNick
:=
user
.
Code
...
...
domain/model/res_m/gift.go
View file @
823b8882
...
...
@@ -22,6 +22,7 @@ type ResGift struct {
Together
bool
Status
mysql
.
UserYesNo
GiftType
mysql
.
Type
HasGiftText
bool
}
// 获取所有的礼物
...
...
domain/model/user_m/user.go
View file @
823b8882
...
...
@@ -157,3 +157,21 @@ func GetUserCountryArea(model *domain.Model, userId mysql.ID) (string, int, erro
}
return
res
.
Name
,
res
.
Area
,
nil
}
//获取用户的国家所属的区域(是否阿语区)
func
GetUserAreaMap
(
model
*
domain
.
Model
,
userIds
[]
mysql
.
ID
)
(
map
[
mysql
.
ID
]
int
,
error
)
{
type
info
struct
{
Id
mysql
.
ID
Area
int
}
rows
:=
make
([]
*
info
,
0
)
sql
:=
"select user.id, rc.area from user left join res_country rc on user.country = rc.name where user.id in (?);"
if
err
:=
model
.
DB
()
.
Raw
(
sql
,
userIds
)
.
Scan
(
&
rows
)
.
Error
;
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
}
res
:=
make
(
map
[
mysql
.
ID
]
int
)
for
_
,
v
:=
range
rows
{
res
[
v
.
Id
]
=
v
.
Area
}
return
res
,
nil
}
domain/service/user_s/user.go
View file @
823b8882
...
...
@@ -172,11 +172,11 @@ func (s *UserService) GetUserDetail(userId mysql.ID, myUserId mysql.ID, lang str
//rp := res_m.ResProperty{}
//properties, err := rp.GetAll(mysql.Db)
_
,
myArea
,
err
:=
user_m
.
GetUserCountryArea
(
model
,
myU
serId
)
_
,
area
,
err
:=
user_m
.
GetUserCountryArea
(
model
,
u
serId
)
if
err
!=
nil
{
return
nil
,
err
}
properties
,
err
:=
property_cv
.
GetPropertyAll
(
mysql
.
Db
,
myA
rea
)
properties
,
err
:=
property_cv
.
GetPropertyAll
(
mysql
.
Db
,
a
rea
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
resp/response.go
View file @
823b8882
...
...
@@ -3,6 +3,7 @@ package resp
import
(
"encoding/json"
"git.hilo.cn/hilo-common/mycontext"
"git.hilo.cn/hilo-common/utils"
"github.com/gin-gonic/gin"
"hilo-user/myerr"
"hilo-user/req"
...
...
@@ -15,6 +16,7 @@ type Response struct {
MessageData
interface
{}
`json:"messageData"`
// 消息详情
OperationMessage
interface
{}
`json:"operationMessage"`
// 操作消息
Data
interface
{}
`json:"data"`
// 数据
Edata
interface
{}
`json:"edata"`
// 加密数据
}
type
GameResponse
struct
{
...
...
@@ -36,7 +38,12 @@ func ResponseOk(c *gin.Context, data interface{}) {
Code
:
myerr
.
GetSuccessCode
(),
Message
:
myerr
.
GetSuccessMsg
(),
OperationMessage
:
myerr
.
GetSuccessMsg
(),
Data
:
data
,
}
if
_
,
ok
:=
c
.
Get
(
mycontext
.
InnerEncrypt
);
ok
{
//response.Edata = utils.EncryptionData(data, []byte("484194d4d0f968a7"))
response
.
Edata
=
utils
.
EncryptionData
(
data
,
[]
byte
(
"hilo!@#$%^&*()_+"
))
}
else
{
response
.
Data
=
data
}
printResponseBody
(
c
,
&
response
)
...
...
@@ -50,15 +57,21 @@ func ResponsePageBaseOk(c *gin.Context, data interface{}, nextPageIndex int, has
if
data
==
nil
{
data
=
make
([]
interface
{},
0
)
}
pageData
:=
req
.
PageRespBase
{
NextPageIndex
:
nextPageIndex
,
HasNextPage
:
hasNextPage
,
Data
:
data
,
}
response
:=
Response
{
Code
:
myerr
.
GetSuccessCode
(),
Message
:
myerr
.
GetSuccessMsg
(),
OperationMessage
:
myerr
.
GetSuccessMsg
(),
Data
:
req
.
PageRespBase
{
NextPageIndex
:
nextPageIndex
,
HasNextPage
:
hasNextPage
,
Data
:
data
,
},
}
if
_
,
ok
:=
c
.
Get
(
mycontext
.
InnerEncrypt
);
ok
{
//response.Edata = utils.EncryptionData(data, []byte("484194d4d0f968a7"))
response
.
Edata
=
utils
.
EncryptionData
(
pageData
,
[]
byte
(
"hilo!@#$%^&*()_+"
))
}
else
{
response
.
Data
=
pageData
}
c
.
JSON
(
http
.
StatusOK
,
response
)
}
...
...
route/middleHandle.go
View file @
823b8882
...
...
@@ -7,6 +7,7 @@ import (
"git.hilo.cn/hilo-common/mycontext"
"git.hilo.cn/hilo-common/mylogrus"
"git.hilo.cn/hilo-common/resource/config"
"git.hilo.cn/hilo-common/utils"
"github.com/gin-gonic/gin"
"hilo-user/myerr/bizerr"
"hilo-user/req"
...
...
@@ -137,6 +138,18 @@ func LoggerHandle(c *gin.Context) {
mycontext
.
CreateMyContext
(
c
.
Keys
)
.
Log
.
Infof
(
"request end fullPath:%v,url:%v, method: %v, traceId:%v, latency:%v userId:%v"
,
c
.
FullPath
(),
reqUri
,
method
,
traceId
,
latency
,
userId
)
}
// 加密Handle
func
EncryptHandle
(
c
*
gin
.
Context
)
{
header
:=
c
.
Request
.
Header
appVersion
:=
header
.
Get
(
"Appversion"
)
if
len
(
appVersion
)
>
0
{
if
high
,
_
:=
utils
.
CompareVersion
(
appVersion
,
"> 3.9.0"
);
high
{
c
.
Set
(
mycontext
.
InnerEncrypt
,
true
)
}
}
c
.
Next
()
}
//http信息解密(web)
func
HttpWebSecretHandle
(
c
*
gin
.
Context
)
{
traceId
,
_
:=
c
.
Keys
[
mycontext
.
TRACEID
]
...
...
route/router.go
View file @
823b8882
...
...
@@ -29,8 +29,8 @@ func InitRouter() *gin.Engine {
{
user
.
GET
(
"/nameplate"
,
wrapper
(
user_r
.
UserNameplate
))
user
.
GET
(
"/bag/:resType"
,
wrapper
(
user_r
.
UserBag
))
user
.
GET
(
"/detail"
,
wrapper
(
user_r
.
UserDetail
))
user
.
GET
(
"/detail/:userExternalId"
,
wrapper
(
user_r
.
UserDetailByExternalId
))
user
.
GET
(
"/detail"
,
EncryptHandle
,
wrapper
(
user_r
.
UserDetail
))
user
.
GET
(
"/detail/:userExternalId"
,
EncryptHandle
,
wrapper
(
user_r
.
UserDetailByExternalId
))
}
cp
:=
v2
.
Group
(
"/cp"
)
{
...
...
route/user_r/bag.go
View file @
823b8882
...
...
@@ -46,22 +46,24 @@ func UserBag(c *gin.Context) (*mycontext.MyContext, error) {
for
_
,
bagGift
:=
range
userBagGifts
{
if
gift
,
ok
:=
allGifts
[
bagGift
.
ResId
];
ok
{
info
:=
user_cv
.
UserBag
{
BagId
:
bagGift
.
ID
,
ResType
:
res_e
.
ResUserBagGift
,
ResId
:
gift
.
ID
,
GiftId
:
gift
.
ID
,
Name
:
gift
.
Name
,
DiamondNum
:
gift
.
DiamondNum
,
IconUrl
:
gift
.
IconUrl
,
SvgaUrl
:
gift
.
SvagUrl
,
Count
:
bagGift
.
Count
,
RemainDays
:
int
(
bagGift
.
EndTime
.
Sub
(
time
.
Now
())
.
Hours
()
/
24
),
BagId
:
bagGift
.
ID
,
ResType
:
res_e
.
ResUserBagGift
,
ResId
:
gift
.
ID
,
GiftId
:
gift
.
ID
,
Name
:
gift
.
Name
,
DiamondNum
:
gift
.
DiamondNum
,
IconUrl
:
gift
.
IconUrl
,
SvgaUrl
:
gift
.
SvagUrl
,
Count
:
bagGift
.
Count
,
RemainDays
:
int
(
bagGift
.
EndTime
.
Sub
(
time
.
Now
())
.
Hours
()
/
24
),
HasGiftText
:
gift
.
HasGiftText
,
}
if
gift
.
ID
==
cp_e
.
CpConfessionGiftId
{
// 如果是cp告白礼物
if
gift
.
ID
==
cp_e
.
CpConfessionGiftId
||
gift
.
HasGiftText
{
// 如果是cp告白礼物
info
.
TextStyleList
=
make
([]
*
user_cv
.
TextStyle
,
0
,
2
)
info
.
TextStyleList
=
append
(
info
.
TextStyleList
,
&
user_cv
.
TextStyle
{
TextColor
:
"#ce0083"
,
TextSize
:
20
,
TextKey
:
"sender_name"
},
&
user_cv
.
TextStyle
{
TextColor
:
"#ce0083"
,
TextSize
:
20
,
TextKey
:
"receiver_name"
},
&
user_cv
.
TextStyle
{
TextColor
:
"#FFFFFF"
,
TextSize
:
40
,
TextKey
:
"gift_text"
},
)
}
...
...
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