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
65daebad
Commit
65daebad
authored
Jun 14, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
批量获取用户cp关系
parent
baa1f37b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
+41
-0
router.go
route/router.go
+1
-0
inner.go
route/user_r/inner.go
+40
-0
No files found.
route/router.go
View file @
65daebad
...
...
@@ -51,6 +51,7 @@ func InitRouter() *gin.Engine {
innerUser
.
GET
(
"/bag/id"
,
wrapper
(
user_r
.
GetUserBagId
))
innerUser
.
GET
(
"/cp"
,
wrapper
(
user_r
.
GetUserCp
))
innerUser
.
GET
(
"/cpRelation"
,
wrapper
(
user_r
.
GetUserCpRelation
))
innerUser
.
GET
(
"/cpRelations"
,
wrapper
(
user_r
.
MGetUserCpRelation
))
innerUser
.
GET
(
"/cp/pair"
,
wrapper
(
user_r
.
GetUserCpPair
))
}
// 道具相关
...
...
route/user_r/inner.go
View file @
65daebad
...
...
@@ -202,6 +202,46 @@ func GetUserCpRelation(c *gin.Context) (*mycontext.MyContext, error) {
return
myContext
,
nil
}
type
MGetUserCpRelationReq
struct
{
Ids
[]
mysql
.
ID
`form:"ids" binding:"required"`
}
// @Tags 用户-内部
// @Summary 批量获取用户cp关系
// @Param ids query int true "用户ids"
// @Success 200 {object} map[uint64]cp_cv.CvCpRelation
// @Router /inner/user/cpRelations [get]
func
MGetUserCpRelation
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myContext
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
var
model
=
domain
.
CreateModelContext
(
myContext
)
var
req
MGetUserCpRelationReq
if
err
:=
c
.
ShouldBindQuery
(
&
req
);
err
!=
nil
{
return
myContext
,
err
}
cpRelations
:=
cp_m
.
MGetCpRelation
(
model
,
req
.
Ids
)
var
m
=
make
(
map
[
uint64
]
cp_m
.
CpRelationTmp
)
for
i
,
v
:=
range
cpRelations
{
m
[
v
.
UserId1
]
=
cpRelations
[
i
]
m
[
v
.
UserId2
]
=
cpRelations
[
i
]
}
var
response
=
make
(
map
[
uint64
]
cp_cv
.
CvCpRelation
)
for
_
,
uid
:=
range
req
.
Ids
{
if
cpRelation
,
ok
:=
m
[
uid
];
ok
{
cpUserId
:=
cpRelation
.
UserId2
if
cpUserId
==
uid
{
cpUserId
=
cpRelation
.
UserId1
}
response
[
uid
]
=
cp_cv
.
CvCpRelation
{
CpId
:
cpRelation
.
ID
,
UserId
:
uid
,
CpUserId
:
cpUserId
,
}
}
}
resp
.
ResponseOk
(
c
,
response
)
return
myContext
,
nil
}
type
GetUserCpPairReq
struct
{
Ids
[]
mysql
.
ID
`form:"ids" binding:"required"`
}
...
...
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