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
ae31a3f6
Commit
ae31a3f6
authored
Feb 20, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:用户背包接口
parent
c1bc2b78
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
160 additions
and
217 deletions
+160
-217
enum.go
_const/enum/match_e/enum.go
+0
-214
enum.go
_const/enum/res_e/enum.go
+6
-3
bag.go
cv/user_cv/bag.go
+17
-0
user_bag.go
domain/model/bag_m/user_bag.go
+34
-0
gift.go
domain/model/res_m/gift.go
+38
-0
router.go
route/router.go
+1
-0
bag.go
route/user_r/bag.go
+64
-0
nameplate.go
route/user_r/nameplate.go
+0
-0
No files found.
_const/enum/match_e/enum.go
deleted
100755 → 0
View file @
c1bc2b78
package
match_e
import
"git.hilo.cn/hilo-common/resource/mysql"
/****************************/
type
MatchDetailDataChange
mysql
.
NumAll
const
(
AddDataChange
MatchDetailDataChange
=
1
ReduceDataChange
MatchDetailDataChange
=
2
ZeroDataChange
MatchDetailDataChange
=
0
)
/******元素分数***************/
/*type EnumCountType mysql.Type
const (
PriorityEnumCountType EnumCountType = 1
ExcellentEnumCountType EnumCountType = 2
RelationEnumCountType EnumCountType = 3
)*/
/*const (
//接收到礼物的数量
ReceiveGiftNumCountType EnumCountType = 1
//接收到礼物的频率
ReceiveGiftFCountType EnumCountType = 2
//被举报
BeReportCountType EnumCountType = 3
//被拉黑
BeBlackCountType EnumCountType = 4
//支付次数
PayCountType EnumCountType = 5
//被喜欢的次数
LikeMeType EnumCountType = 6
//新用户
NewUserType EnumCountType = 7
//连续被拒
AgainRefuse EnumCountType = 8
//每天新登陆用户
DailyUserType EnumCountType = 9
//活跃等级
ActiveGrade EnumCountType = 10
//连续同性
AgainSameSex EnumCountType = 11
//匹配推送次数
MatchSuccessNum EnumCountType = 12
//匹配推送接受次数
MatchConfirmNum EnumCountType = 13
//接通率
MatchConfirmRate EnumCountType = 14
//免费加时
MatchFreeTimeNum EnumCountType = 15
//礼物加时
MatchGiftTimeNum EnumCountType = 16
//加时率
MatchAddTimeRate EnumCountType = 17
//工会成员
TradeUnion EnumCountType = 18
//匹配拒绝
RelationMatchRefuse EnumCountType = 19
//匹配用户
RelationMatchUser EnumCountType = 20
)*/
// 优先度排序
type
PriorityUserFormOriginType
mysql
.
Type
const
(
//钻石余额
PriorityDiamond
PriorityUserFormOriginType
=
1
//首充
PriorityFirstCharge
PriorityUserFormOriginType
=
2
//财富等级
PriorityWealthGrade
PriorityUserFormOriginType
=
3
//被举报
PriorityBeReport
PriorityUserFormOriginType
=
4
//被拉黑
PriorityBeBlack
PriorityUserFormOriginType
=
5
//近期充值
PriorityRecentlyPay
PriorityUserFormOriginType
=
6
//新用户
PriorityNewUserType
PriorityUserFormOriginType
=
7
//连续被拒
PriorityAgainRefuse
PriorityUserFormOriginType
=
8
//每天新登陆用户
PriorityDailyUserType
PriorityUserFormOriginType
=
9
//活跃等级
PriorityActiveGrade
PriorityUserFormOriginType
=
10
//工会
PriorityTradeUnion
PriorityUserFormOriginType
=
11
//多次匹配到同性
PriorityAgainSameSex
PriorityUserFormOriginType
=
12
)
var
PriorityMap
=
map
[
PriorityUserFormOriginType
]
string
{
PriorityDiamond
:
"钻石余额"
,
PriorityFirstCharge
:
"首充"
,
PriorityWealthGrade
:
"财富等级"
,
PriorityBeReport
:
"被举报"
,
PriorityBeBlack
:
"被拉黑"
,
PriorityRecentlyPay
:
"近期充值"
,
PriorityNewUserType
:
"新用户"
,
PriorityAgainRefuse
:
"连续被拒"
,
PriorityDailyUserType
:
"每天新登陆用户"
,
PriorityActiveGrade
:
"活跃等级"
,
PriorityTradeUnion
:
"工会"
,
PriorityAgainSameSex
:
"连续同性"
,
}
// 质量排序
type
ExcellentUserFormOriginType
mysql
.
Type
const
(
//被喜欢的次数
ExcellentLikeMe
ExcellentUserFormOriginType
=
1
//接收礼物数量
ExcellentReceiveGiftNumChange
ExcellentUserFormOriginType
=
2
//接收礼物次数
ExcellentReceiveGiftFChange
ExcellentUserFormOriginType
=
3
//被投诉次数
ExcellentBeReport
ExcellentUserFormOriginType
=
4
//被拉黑的次数
ExcellentBeBlack
ExcellentUserFormOriginType
=
5
//魅力等级
ExcellentCharmGrade
ExcellentUserFormOriginType
=
6
//被付费建立融云会话
ExcellentSessionCreate
ExcellentUserFormOriginType
=
7
//接通率
ExcellentMatchConfirmRate
ExcellentUserFormOriginType
=
8
//加时率(视频通话加时次数(免费加时成功 + 礼物加时成功)/视频通话次数(匹配成功的次数))
ExcellentAddTimeRate
ExcellentUserFormOriginType
=
9
//工会成员
ExcellentTradeUnion
ExcellentUserFormOriginType
=
10
//匹配成功次数
ExcellentMatchSuccessNum
ExcellentUserFormOriginType
=
11
//匹配确认次数
ExcellentMatchConfirmNum
ExcellentUserFormOriginType
=
12
//匹配免费加时的次数
ExcellentMatchFreeTimeNum
ExcellentUserFormOriginType
=
13
//匹配礼物加时次数
ExcellentMatchGiftTimeNum
ExcellentUserFormOriginType
=
14
)
var
ExcellentMap
=
map
[
ExcellentUserFormOriginType
]
string
{
ExcellentLikeMe
:
"喜欢我"
,
ExcellentReceiveGiftNumChange
:
"接收礼物数量"
,
ExcellentReceiveGiftFChange
:
"接收礼物次数"
,
ExcellentBeReport
:
"被投诉次数"
,
ExcellentBeBlack
:
"被拉黑次数"
,
ExcellentCharmGrade
:
"魅力等级"
,
ExcellentSessionCreate
:
"被付费建立融云会话"
,
ExcellentMatchConfirmRate
:
"接通率"
,
ExcellentAddTimeRate
:
"加时率"
,
ExcellentTradeUnion
:
"工会成员"
,
ExcellentMatchSuccessNum
:
"匹配成功次数"
,
ExcellentMatchConfirmNum
:
"匹配确认次数"
,
ExcellentMatchFreeTimeNum
:
"匹配免费加时次数"
,
ExcellentMatchGiftTimeNum
:
"匹配礼物加时次数"
,
}
// 关系排序
type
RelationUserFormOriginType
mysql
.
Type
const
(
//喜欢的用户
RelationUserLike
RelationUserFormOriginType
=
1
//匹配拒绝用户
RelationMatchRefuse
RelationUserFormOriginType
=
2
//匹配过的用户
RelationMatchUser
RelationUserFormOriginType
=
3
//付费发送过消息但没进行过视频聊天
RelationSessionNoMatchConfirm
RelationUserFormOriginType
=
4
//上一次匹配的用户
RelationMatchUserLastTime
RelationUserFormOriginType
=
5
)
var
RelationMap
=
map
[
RelationUserFormOriginType
]
string
{
RelationUserLike
:
"喜欢的用户"
,
RelationMatchRefuse
:
"匹配被拒绝"
,
RelationMatchUser
:
"匹配上的用户"
,
RelationSessionNoMatchConfirm
:
"付费发送过消息但没进行过视频聊天"
,
RelationMatchUserLastTime
:
"上一次匹配的用户"
,
}
/******匹配确认***********************************/
type
MatchConfirmStatus
mysql
.
Type
const
(
Success
MatchConfirmStatus
=
1
Fail
MatchConfirmStatus
=
2
Temp
MatchConfirmStatus
=
3
)
type
MatchConfirmUserAcceptRefuse
mysql
.
Type
const
(
AcceptMatchConfirmUser
MatchConfirmUserAcceptRefuse
=
1
RefuseMatchConfirmUser
MatchConfirmUserAcceptRefuse
=
2
)
type
MatchCharmUserScoreDetailType
=
mysql
.
Type
const
(
GiftReceiveCharmType
MatchCharmUserScoreDetailType
=
1
GiftReceiveVipCharmType
MatchCharmUserScoreDetailType
=
2
)
type
MatchWealthUserScoreDetailType
=
mysql
.
Type
const
(
GiftReceiveWealthType
MatchWealthUserScoreDetailType
=
1
GiftReceiveVipWealthType
MatchWealthUserScoreDetailType
=
2
)
_const/enum/res_e/enum.go
View file @
ae31a3f6
...
...
@@ -6,9 +6,6 @@ type MsgIdType = uint
const
(
DEFAULT_LANG
=
"en"
MSG_ID_GAME_CREATE
MsgIdType
=
1001
MSG_ID_GAME_JOIN
MsgIdType
=
1002
)
type
ResMedalType
=
mysql
.
Type
...
...
@@ -55,3 +52,9 @@ const (
type
ResNameplateType
=
mysql
.
Type
type
ResNameplateObtainType
=
mysql
.
Type
type
ResNameplateScope
=
mysql
.
Type
type
ResUserBag
=
mysql
.
Type
const
(
ResUserBagGift
ResUserBag
=
1
// 背包道具-礼物
)
cv/user_cv/bag.go
0 → 100644
View file @
ae31a3f6
package
user_cv
import
(
"git.hilo.cn/hilo-common/resource/mysql"
"hilo-user/_const/enum/res_e"
)
type
UserBag
struct
{
ResType
res_e
.
ResUserBag
`json:"resType"`
// 道具类型 1:礼物道具
ResId
mysql
.
ID
`json:"resId"`
// 道具资源id
Name
string
`json:"name"`
// 资源名称
DiamondNum
mysql
.
Num
`json:"diamondNum"`
// 钻石数量
IconUrl
string
`json:"iconUrl"`
// icon url
SvgaUrl
string
`json:"svgaUrl"`
// svga url
Count
mysql
.
Num
`json:"count"`
// 拥有数量
RemainDays
int
`json:"remainDays"`
// 有效天数
}
domain/model/bag_m/user_bag.go
0 → 100644
View file @
ae31a3f6
package
bag_m
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"hilo-user/_const/enum/res_e"
"time"
)
type
UserBag
struct
{
mysql
.
Entity
UserId
mysql
.
ID
ResType
mysql
.
Type
ResId
mysql
.
ID
Count
mysql
.
Num
EndTime
time
.
Time
}
// 获取用户有效的背包
// param userId 用户id
// param resType 背包类型 1:礼物
// condition
// 1.获取end_time未到期的
// 2.数量大于0的
func
GetUserValidUserBag
(
model
*
domain
.
Model
,
userId
mysql
.
ID
,
resType
res_e
.
ResUserBag
)
([]
*
UserBag
,
error
)
{
var
res
[]
*
UserBag
if
err
:=
model
.
DB
()
.
Model
(
UserBag
{})
.
Where
(
"end_time > ?"
,
time
.
Now
())
.
Where
(
"count > 0"
)
.
Where
(
"user_id = ?"
,
userId
)
.
Find
(
&
res
)
.
Error
;
err
!=
nil
{
return
nil
,
err
}
return
res
,
nil
}
domain/model/res_m/gift.go
0 → 100644
View file @
ae31a3f6
package
res_m
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
)
type
ResGift
struct
{
mysql
.
Entity
Name
mysql
.
Str
IconUrl
mysql
.
Str
SvagUrl
mysql
.
Str
MusicUrl
mysql
.
Str
Column
uint16
DiamondNum
mysql
.
Num
BeanNum
mysql
.
Num
ReceiveDiamondNum
mysql
.
Num
Second
mysql
.
Num
// obsolete
N
mysql
.
Num
GroupBroadcast
bool
Cp
bool
Together
bool
Status
mysql
.
UserYesNo
GiftType
mysql
.
Type
}
// 获取所有有效的礼物
func
FindValidResGiftsMap
(
model
*
domain
.
Model
)
(
map
[
mysql
.
ID
]
ResGift
,
error
)
{
res
:=
make
(
map
[
mysql
.
ID
]
ResGift
,
0
)
rows
:=
make
([]
ResGift
,
0
)
if
err
:=
model
.
DB
()
.
Model
(
ResGift
{})
.
Where
(
"status = ?"
,
mysql
.
USER
)
.
Find
(
&
rows
)
.
Error
;
err
!=
nil
{
return
nil
,
err
}
for
i
,
v
:=
range
rows
{
res
[
v
.
ID
]
=
rows
[
i
]
}
return
res
,
nil
}
route/router.go
View file @
ae31a3f6
...
...
@@ -19,6 +19,7 @@ func InitRouter() *gin.Engine {
user
:=
v1
.
Group
(
"/user"
)
{
user
.
GET
(
"/nameplate"
,
wrapper
(
user_r
.
UserNameplate
))
user
.
GET
(
"/bag/:resType"
,
wrapper
(
user_r
.
UserBag
))
}
inner
:=
r
.
Group
(
"/inner"
)
inner
.
Use
(
ExceptionHandle
,
LoggerHandle
)
...
...
route/user_r/bag.go
0 → 100644
View file @
ae31a3f6
package
user_r
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mycontext"
"github.com/gin-gonic/gin"
"hilo-user/_const/enum/res_e"
"hilo-user/cv/user_cv"
"hilo-user/domain/model/bag_m"
"hilo-user/domain/model/res_m"
"hilo-user/myerr/bizerr"
"hilo-user/req"
"hilo-user/resp"
"strconv"
"time"
)
// @Tags 用户背包
// @Summary 获取用户的铭牌
// @Param column path int true "分栏:1 礼物"
// @Success 200 {object} []user_cv.UserBag
// @Router /v1/user/bag/{resType} [get]
func
UserBag
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myCtx
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
userId
,
err
:=
req
.
GetUserId
(
c
)
if
err
!=
nil
{
return
myCtx
,
err
}
model
:=
domain
.
CreateModelContext
(
myCtx
)
resType
,
err
:=
strconv
.
Atoi
(
c
.
Param
(
"resType"
))
if
err
!=
nil
{
return
myCtx
,
err
}
var
results
[]
user_cv
.
UserBag
switch
res_e
.
ResUserBag
(
resType
)
{
case
res_e
.
ResUserBagGift
:
userBagGifts
,
err
:=
bag_m
.
GetUserValidUserBag
(
model
,
userId
,
res_e
.
ResUserBagGift
)
if
err
!=
nil
{
return
myCtx
,
err
}
allValidGifts
,
err
:=
res_m
.
FindValidResGiftsMap
(
model
)
if
err
!=
nil
{
return
myCtx
,
err
}
for
_
,
bagGift
:=
range
userBagGifts
{
if
gift
,
ok
:=
allValidGifts
[
bagGift
.
ResId
];
ok
{
results
=
append
(
results
,
user_cv
.
UserBag
{
ResType
:
res_e
.
ResUserBagGift
,
ResId
:
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
),
})
}
}
default
:
return
myCtx
,
bizerr
.
InvalidParameter
}
resp
.
ResponseOk
(
c
,
results
)
return
myCtx
,
nil
}
route/user_r/
user
.go
→
route/user_r/
nameplate
.go
View file @
ae31a3f6
File moved
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