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
6d699fdb
Commit
6d699fdb
authored
Jun 09, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
给出指定uids下的cp对
parent
dfed8595
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
1 deletion
+42
-1
level.go
domain/model/cp_m/level.go
+9
-1
router.go
route/router.go
+1
-0
inner.go
route/user_r/inner.go
+32
-0
No files found.
domain/model/cp_m/level.go
View file @
6d699fdb
...
@@ -82,7 +82,7 @@ func AddCpLevelDetail(model *domain.Model, detail CpLevelDetail) error {
...
@@ -82,7 +82,7 @@ func AddCpLevelDetail(model *domain.Model, detail CpLevelDetail) error {
return
model
.
DB
()
.
Create
(
&
detail
)
.
Error
return
model
.
DB
()
.
Create
(
&
detail
)
.
Error
}
}
// 获取cpRelation
pair
// 获取cpRelation
func
GetCpRelation
(
model
*
domain
.
Model
,
userId
mysql
.
ID
)
(
cpRelation
CpRelationTmp
,
exits
bool
)
{
func
GetCpRelation
(
model
*
domain
.
Model
,
userId
mysql
.
ID
)
(
cpRelation
CpRelationTmp
,
exits
bool
)
{
if
err
:=
model
.
DB
()
.
Model
(
CpRelationTmp
{})
.
Where
(
"user_id1 = ? or user_id2 = ?"
,
userId
,
userId
)
.
First
(
&
cpRelation
)
.
Error
;
err
!=
nil
{
if
err
:=
model
.
DB
()
.
Model
(
CpRelationTmp
{})
.
Where
(
"user_id1 = ? or user_id2 = ?"
,
userId
,
userId
)
.
First
(
&
cpRelation
)
.
Error
;
err
!=
nil
{
if
err
!=
gorm
.
ErrRecordNotFound
{
if
err
!=
gorm
.
ErrRecordNotFound
{
...
@@ -118,6 +118,14 @@ func GetCpRelationPair(model *domain.Model, userId1, userId2 mysql.ID) (cpRelati
...
@@ -118,6 +118,14 @@ func GetCpRelationPair(model *domain.Model, userId1, userId2 mysql.ID) (cpRelati
return
return
}
}
// 获取cpRelation pair
func
MGetCpRelation
(
model
*
domain
.
Model
,
userIds
[]
mysql
.
ID
)
(
cpRelation
[]
CpRelationTmp
)
{
if
err
:=
model
.
DB
()
.
Model
(
CpRelationTmp
{})
.
Where
(
"user_id1 in ? or user_id2 in ?"
,
userIds
,
userIds
)
.
Find
(
&
cpRelation
)
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetCpRelation fail:%v"
,
err
)
}
return
}
// 获取是否申请解绑中
// 获取是否申请解绑中
func
GetApplyToUnbind
(
model
*
domain
.
Model
,
userId
,
cpUserId
mysql
.
ID
)
bool
{
func
GetApplyToUnbind
(
model
*
domain
.
Model
,
userId
,
cpUserId
mysql
.
ID
)
bool
{
var
total
int64
var
total
int64
...
...
route/router.go
View file @
6d699fdb
...
@@ -51,6 +51,7 @@ func InitRouter() *gin.Engine {
...
@@ -51,6 +51,7 @@ func InitRouter() *gin.Engine {
innerUser
.
GET
(
"/bag/id"
,
wrapper
(
user_r
.
GetUserBagId
))
innerUser
.
GET
(
"/bag/id"
,
wrapper
(
user_r
.
GetUserBagId
))
innerUser
.
GET
(
"/cp"
,
wrapper
(
user_r
.
GetUserCp
))
innerUser
.
GET
(
"/cp"
,
wrapper
(
user_r
.
GetUserCp
))
innerUser
.
GET
(
"/cpRelation"
,
wrapper
(
user_r
.
GetUserCpRelation
))
innerUser
.
GET
(
"/cpRelation"
,
wrapper
(
user_r
.
GetUserCpRelation
))
innerUser
.
GET
(
"/cp/pair"
,
wrapper
(
user_r
.
GetUserCpPair
))
}
}
// 道具相关
// 道具相关
innerProp
:=
inner
.
Group
(
"/prop"
)
innerProp
:=
inner
.
Group
(
"/prop"
)
...
...
route/user_r/inner.go
View file @
6d699fdb
...
@@ -193,3 +193,35 @@ func GetUserCpRelation(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -193,3 +193,35 @@ func GetUserCpRelation(c *gin.Context) (*mycontext.MyContext, error) {
resp
.
ResponseOk
(
c
,
response
)
resp
.
ResponseOk
(
c
,
response
)
return
myContext
,
nil
return
myContext
,
nil
}
}
type
GetUserCpPairReq
struct
{
Ids
[]
mysql
.
ID
`form:"ids" binding:"required"`
}
// @Tags 用户-内部
// @Summary 给出指定uids下的cp对
// @Param ids query string true "用户id,如:ids=1&ids=2&ids=3"
// @Success 200 {object} [][]uint64
// @Router /inner/user/cpRelation [get]
func
GetUserCpPair
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myContext
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
var
model
=
domain
.
CreateModelContext
(
myContext
)
var
req
GetUserCpPairReq
if
err
:=
c
.
ShouldBindQuery
(
&
req
);
err
!=
nil
{
return
myContext
,
err
}
userIds
:=
req
.
Ids
m
:=
make
(
map
[
mysql
.
ID
]
bool
)
for
_
,
uid
:=
range
userIds
{
m
[
uid
]
=
true
}
pairs
:=
cp_m
.
MGetCpRelation
(
model
,
userIds
)
var
response
[][
2
]
uint64
for
_
,
pair
:=
range
pairs
{
if
m
[
pair
.
UserId1
]
&&
m
[
pair
.
UserId2
]
{
response
=
append
(
response
,
[
2
]
mysql
.
ID
{
pair
.
UserId1
,
pair
.
UserId2
})
}
}
resp
.
ResponseOk
(
c
,
response
)
return
myContext
,
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