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
Compare Revisions
master...fix/cp_cancel_cron
Source
fix/cp_cancel_cron
Select Git revision
...
Target
master
Select Git revision
Compare
Commits (5)
cp解除
· 69e00cfa
chenweijian
authored
Jul 13, 2023
69e00cfa
Merge remote-tracking branch 'origin/master' into fix/cp_cancel_cron
· e7b6c14a
chenweijian
authored
Jul 13, 2023
e7b6c14a
cp解除
· 4b98c331
chenweijian
authored
Jul 13, 2023
4b98c331
cp解除
· 2ca8a8de
chenweijian
authored
Jul 13, 2023
2ca8a8de
cp解除
· cc248b5e
chenweijian
authored
Jul 13, 2023
cc248b5e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
12 deletions
+35
-12
cp_relation.go
domain/model/cp_m/cp_relation.go
+15
-1
cp_relation.go
domain/service/cp_s/cp_relation.go
+20
-11
No files found.
domain/model/cp_m/cp_relation.go
View file @
cc248b5e
...
@@ -130,7 +130,21 @@ func GetCp(model *domain.Model, userId uint64) (*CpRelation, error) {
...
@@ -130,7 +130,21 @@ func GetCp(model *domain.Model, userId uint64) (*CpRelation, error) {
if
err
==
gorm
.
ErrRecordNotFound
{
if
err
==
gorm
.
ErrRecordNotFound
{
return
res
,
nil
return
res
,
nil
}
}
model
.
Log
.
Errorf
(
"CreateCp userId:%d, err:%v"
,
userId
,
err
)
model
.
Log
.
Errorf
(
"GetCp userId:%d, err:%v"
,
userId
,
err
)
return
nil
,
err
}
return
res
,
nil
}
func
GetCpByIds
(
model
*
domain
.
Model
,
userId1
,
userId2
uint64
)
(
*
CpRelation
,
error
)
{
ids
:=
[]
uint64
{
userId1
,
userId2
}
res
:=
new
(
CpRelation
)
err
:=
model
.
DB
()
.
Model
(
CpRelation
{})
.
Where
(
"user_id1 in (?) and user_id2 in (?)"
,
ids
,
ids
)
.
First
(
&
res
)
.
Error
if
err
!=
nil
{
if
err
==
gorm
.
ErrRecordNotFound
{
return
res
,
nil
}
model
.
Log
.
Errorf
(
"GetCpByIds userId1:%d, userId2:%d, err:%v"
,
userId1
,
userId2
,
err
)
return
nil
,
err
return
nil
,
err
}
}
return
res
,
nil
return
res
,
nil
...
...
domain/service/cp_s/cp_relation.go
View file @
cc248b5e
...
@@ -130,22 +130,31 @@ func CancelCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
...
@@ -130,22 +130,31 @@ func CancelCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
return
err
return
err
}
}
// 自己没有cp了
// 我和对方是否是cp,且cp关系存在
myCp
,
err
:=
cp_m
.
GetCp
(
model
,
myUserId
)
cpRelation
,
err
:=
cp_m
.
GetCpByIds
(
model
,
myUserId
,
userRec
.
ID
)
if
err
!=
nil
{
return
err
}
if
myCp
.
Id
==
0
{
return
myerr
.
WrapErr
(
bizerr
.
InvalidParameter
)
}
// 对方没有cp了
inviCp
,
err
:=
cp_m
.
GetCp
(
model
,
userRec
.
ID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
inviCp
.
Id
==
0
{
if
cpRelation
.
Id
==
0
{
model
.
Log
.
Errorf
(
"CancelCpRelation cp关系不存在 id1:%v, id2:%v"
,
myUserId
,
userRec
.
ID
)
return
myerr
.
WrapErr
(
bizerr
.
InvalidParameter
)
return
myerr
.
WrapErr
(
bizerr
.
InvalidParameter
)
}
}
//// 自己没有cp了
//myCp, err := cp_m.GetCp(model, myUserId)
//if err != nil {
// return err
//}
//if myCp.Id == 0 {
// return myerr.WrapErr(bizerr.InvalidParameter)
//}
//// 对方没有cp了
//inviCp, err := cp_m.GetCp(model, userRec.ID)
//if err != nil {
// return err
//}
//if inviCp.Id == 0 {
// return myerr.WrapErr(bizerr.InvalidParameter)
//}
// 是否有关于我的cp解除申请,且还未被处理
// 是否有关于我的cp解除申请,且还未被处理
myCancel
,
err
:=
cp_m
.
GetCpCancelWithMe
(
model
,
user
.
ID
,
cp_e
.
CpCancel
)
myCancel
,
err
:=
cp_m
.
GetCpCancelWithMe
(
model
,
user
.
ID
,
cp_e
.
CpCancel
)
...
...