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
45c8b1a8
Commit
45c8b1a8
authored
Feb 21, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取背包
parent
9dee630a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
0 deletions
+61
-0
user_bag.go
domain/model/bag_m/user_bag.go
+10
-0
gift.go
domain/model/res_m/gift.go
+9
-0
router.go
route/router.go
+1
-0
inner.go
route/user_r/inner.go
+41
-0
No files found.
domain/model/bag_m/user_bag.go
View file @
45c8b1a8
...
...
@@ -34,3 +34,13 @@ func GetUserValidUserBag(model *domain.Model, userId mysql.ID, resType res_e.Res
}
return
res
,
nil
}
// 获取指定背包
func
GetUserBag
(
model
*
domain
.
Model
,
bagId
mysql
.
ID
)
(
*
UserBag
,
error
)
{
res
:=
new
(
UserBag
)
if
err
:=
model
.
DB
()
.
Model
(
UserBag
{})
.
Where
(
"id = ?"
,
bagId
)
.
First
(
res
)
.
Error
;
err
!=
nil
{
return
nil
,
err
}
return
res
,
nil
}
domain/model/res_m/gift.go
View file @
45c8b1a8
...
...
@@ -36,3 +36,12 @@ func FindValidResGiftsMap(model *domain.Model) (map[mysql.ID]ResGift, error) {
}
return
res
,
nil
}
// 获取礼物
func
FindResGift
(
model
*
domain
.
Model
,
giftId
mysql
.
ID
)
(
*
ResGift
,
error
)
{
res
:=
new
(
ResGift
)
if
err
:=
model
.
DB
()
.
Model
(
ResGift
{})
.
Where
(
"id = ?"
,
giftId
)
.
First
(
res
)
.
Error
;
err
!=
nil
{
return
nil
,
err
}
return
res
,
nil
}
route/router.go
View file @
45c8b1a8
...
...
@@ -26,6 +26,7 @@ func InitRouter() *gin.Engine {
innerUser
:=
inner
.
Group
(
"/user"
)
{
innerUser
.
GET
(
"/levels"
,
wrapper
(
user_r
.
MGetUserLevels
))
innerUser
.
GET
(
"/bag"
,
wrapper
(
user_r
.
GetUserBag
))
}
return
r
}
route/user_r/inner.go
View file @
45c8b1a8
...
...
@@ -6,8 +6,11 @@ import (
"git.hilo.cn/hilo-common/resource/mysql"
"github.com/gin-gonic/gin"
"hilo-user/cv/user_cv"
"hilo-user/domain/model/bag_m"
"hilo-user/domain/model/res_m"
"hilo-user/domain/model/user_m"
"hilo-user/resp"
"time"
)
type
MGetUserLevelReq
struct
{
...
...
@@ -43,3 +46,41 @@ func MGetUserLevels(c *gin.Context) (*mycontext.MyContext, error) {
resp
.
ResponseOk
(
c
,
response
)
return
myCtx
,
nil
}
type
GetUserBagReq
struct
{
BagId
mysql
.
ID
`form:"bagId" binding:"required"`
}
// @Tags 用户-内部
// @Summary 获取单个背包
// @Param bagId query int true "背包id"
// @Success 200 {object} user_cv.UserBag
// @Router /inner/user/bag [get]
func
GetUserBag
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myCtx
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
var
model
=
domain
.
CreateModelContext
(
myCtx
)
var
req
GetUserBagReq
if
err
:=
c
.
ShouldBindQuery
(
&
req
);
err
!=
nil
{
return
myCtx
,
err
}
bag
,
err
:=
bag_m
.
GetUserBag
(
model
,
req
.
BagId
)
if
err
!=
nil
{
return
myCtx
,
err
}
gift
,
err
:=
res_m
.
FindResGift
(
model
,
bag
.
ResId
)
if
err
!=
nil
{
return
myCtx
,
err
}
resp
.
ResponseOk
(
c
,
user_cv
.
UserBag
{
BagId
:
bag
.
ID
,
ResType
:
bag
.
ResType
,
ResId
:
bag
.
ResId
,
Name
:
gift
.
Name
,
DiamondNum
:
gift
.
DiamondNum
,
IconUrl
:
gift
.
IconUrl
,
SvgaUrl
:
gift
.
SvagUrl
,
Count
:
bag
.
Count
,
RemainDays
:
int
(
bag
.
EndTime
.
Sub
(
time
.
Now
())
.
Hours
()
/
24
),
})
return
myCtx
,
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