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
9deac2a7
Commit
9deac2a7
authored
Jun 14, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
im check
parent
a0d100e4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
94 additions
and
1 deletion
+94
-1
cp_relation.go
cv/cp_cv/cp_relation.go
+3
-0
cp_relation.go
domain/model/cp_m/cp_relation.go
+30
-0
cp_relation.go
domain/service/cp_s/cp_relation.go
+5
-1
cp_relation.go
route/cp_r/cp_relation.go
+55
-0
router.go
route/router.go
+1
-0
No files found.
cv/cp_cv/cp_relation.go
View file @
9deac2a7
...
...
@@ -4,3 +4,6 @@ type CheckCpRelationRes struct {
Diamond
uint32
`json:"diamond"`
Msg
string
`json:"msg"`
}
type
CheckCpImRes
struct
{
}
domain/model/cp_m/cp_relation.go
View file @
9deac2a7
...
...
@@ -31,6 +31,8 @@ type CpInviteMessage struct {
Msg
string
`json:"msg"`
Tip
string
`json:"tip"`
Sender
*
user_m
.
UserTiny
`json:"sender"`
MsgType
int
`json:"msgType"`
MsgId
uint64
`json:"msgId"`
}
// 发送私信-接受邀请
...
...
@@ -62,6 +64,8 @@ type CpCancelMessage struct {
Msg
string
`json:"msg"`
Tip
string
`json:"tip"`
Sender
*
user_m
.
UserTiny
`json:"sender"`
MsgType
int
`json:"msgType"`
MsgId
uint64
`json:"msgId"`
}
// 发送私信-撤销解除、接受解除
...
...
@@ -145,6 +149,19 @@ func GetCpInvite(model *domain.Model, userId, userIdInvite uint64, status cp_e.C
return
res
,
nil
}
func
GetCpInviteById
(
model
*
domain
.
Model
,
id
uint64
,
status
cp_e
.
CpInviteStatus
)
(
*
CpInvite
,
error
)
{
res
:=
new
(
CpInvite
)
err
:=
model
.
DB
()
.
Model
(
CpInvite
{})
.
Where
(
CpInvite
{
Id
:
id
,
Status
:
status
})
.
First
(
&
res
)
.
Error
if
err
!=
nil
{
if
err
==
gorm
.
ErrRecordNotFound
{
return
nil
,
nil
}
model
.
Log
.
Errorf
(
"GetCpInviteById id:%d, err:%v"
,
id
,
err
)
return
nil
,
err
}
return
res
,
nil
}
func
CreateCpInvite
(
model
*
domain
.
Model
,
userId
,
userIdInvite
uint64
,
diamondNum
uint32
)
(
uint64
,
error
)
{
cpInvite
:=
CpInvite
{
UserId
:
userId
,
InviteUserId
:
userIdInvite
,
DiamondNum
:
diamondNum
,
Status
:
cp_e
.
CpInvite
}
err
:=
model
.
DB
()
.
Model
(
CpInvite
{})
.
Create
(
&
cpInvite
)
.
Error
...
...
@@ -192,6 +209,19 @@ func GetCpCancel(model *domain.Model, userIds []uint64, status cp_e.CpCancelStat
return
res
,
nil
}
func
GetCpCancelById
(
model
*
domain
.
Model
,
id
uint64
,
status
cp_e
.
CpCancelStatus
)
(
*
CpCancel
,
error
)
{
res
:=
new
(
CpCancel
)
err
:=
model
.
DB
()
.
Model
(
CpCancel
{})
.
Where
(
"status = ? and id = ?"
,
status
,
id
)
.
First
(
&
res
)
.
Error
if
err
!=
nil
{
if
err
==
gorm
.
ErrRecordNotFound
{
return
nil
,
nil
}
model
.
Log
.
Errorf
(
"GetCpCancelById id:%d, err:%v"
,
id
,
err
)
return
nil
,
err
}
return
res
,
nil
}
func
GetCpCancelWithMe
(
model
*
domain
.
Model
,
userId
uint64
,
status
cp_e
.
CpCancelStatus
)
(
*
CpCancel
,
error
)
{
res
:=
new
(
CpCancel
)
err
:=
model
.
DB
()
.
Model
(
CpCancel
{})
.
Where
(
"status = ? and (user_id = ? or rec_user_id = ?)"
,
status
,
userId
,
userId
)
.
First
(
&
res
)
.
Error
...
...
domain/service/cp_s/cp_relation.go
View file @
9deac2a7
...
...
@@ -87,6 +87,8 @@ func InviteCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
Msg
:
content
,
Tip
:
tip
,
Sender
:
user_m
.
ToUserTiny
(
user
),
MsgType
:
1
,
MsgId
:
cpInvId
,
})
if
err
:=
tencentyun
.
BatchSendCustomMsg
(
model
,
1
,
user
.
ExternalId
,
[]
string
{
userInvite
.
ExternalId
},
string
(
data
),
"cp邀请"
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"BatchSendCustomMsg fail:%v"
,
err
)
...
...
@@ -157,7 +159,7 @@ func CancelCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
err
=
model
.
Transaction
(
func
(
model
*
domain
.
Model
)
error
{
// 创建邀请记录
_
,
err
=
cp_m
.
CreateCpCancel
(
model
,
myUserId
,
userRec
.
ID
)
cancelId
,
err
:
=
cp_m
.
CreateCpCancel
(
model
,
myUserId
,
userRec
.
ID
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"CancelCpRelation myUserId:%d, err:%v"
,
myUserId
,
err
)
return
err
...
...
@@ -168,6 +170,8 @@ func CancelCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
Msg
:
content
,
Tip
:
tip
,
Sender
:
user_m
.
ToUserTiny
(
user
),
MsgType
:
2
,
MsgId
:
cancelId
,
})
if
err
:=
tencentyun
.
BatchSendCustomMsg
(
model
,
1
,
user
.
ExternalId
,
[]
string
{
userRec
.
ExternalId
},
string
(
data
),
"cp解除"
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"CancelCpRelation BatchSendCustomMsg fail:%v"
,
err
)
...
...
route/cp_r/cp_relation.go
View file @
9deac2a7
...
...
@@ -448,3 +448,58 @@ func CpDetailPage(c *gin.Context) (*mycontext.MyContext, error) {
resp
.
ResponseOk
(
c
,
res
)
return
myCtx
,
nil
}
// @Tags cp关系
// @Summary 检查cp的im是否失效
// @Param msgType query int true "类型"
// @Param msgId query int true "消息id"
// @Success 200 {object} cp_cv.CheckCpImRes
// @Router /v2/cp/im/check [get]
func
CheckCpImExpire
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myCtx
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
userId
,
lang
,
err
:=
req
.
GetUserIdLang
(
c
,
myCtx
)
if
err
!=
nil
{
return
myCtx
,
err
}
msgType
,
err
:=
strconv
.
Atoi
(
c
.
Query
(
"msgType"
))
if
err
!=
nil
{
return
myCtx
,
err
}
if
msgType
<
1
||
msgType
>
2
{
return
myCtx
,
bizerr
.
InvalidParameter
}
msgId
,
err
:=
strconv
.
ParseUint
(
c
.
Query
(
"msgId"
),
10
,
64
)
if
err
!=
nil
{
return
myCtx
,
err
}
if
msgId
<=
0
{
return
myCtx
,
bizerr
.
InvalidParameter
}
model
:=
domain
.
CreateModelContext
(
myCtx
)
switch
msgType
{
case
1
:
// 邀请的消息im检查是否过期
cpRecord
,
err
:=
cp_m
.
GetCpInviteById
(
model
,
msgId
,
cp_e
.
CpInvite
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"CheckCpImExpire userId:%d, msgType:%d, msgId:%d, err:%v"
,
userId
,
msgType
,
msgId
,
err
)
return
myCtx
,
err
}
if
cpRecord
==
nil
||
cpRecord
.
Id
==
0
{
return
myCtx
,
myerr
.
ToLocal
(
msg
.
GetErrByLanguage
(
model
,
common
.
MSG_ID_ALREADY_EXPIRED
,
lang
,
comerr
.
AlreadyExpired
))
}
case
2
:
// 解除的消息im检查是否过期
cpCancel
,
err
:=
cp_m
.
GetCpCancelById
(
model
,
msgId
,
cp_e
.
CpCancel
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"CheckCpImExpire userId:%d, msgType:%d, msgId:%d, err:%v"
,
userId
,
msgType
,
msgId
,
err
)
return
myCtx
,
err
}
if
cpCancel
==
nil
||
cpCancel
.
Id
==
0
{
return
myCtx
,
myerr
.
ToLocal
(
msg
.
GetErrByLanguage
(
model
,
common
.
MSG_ID_ALREADY_EXPIRED
,
lang
,
comerr
.
AlreadyExpired
))
}
}
resp
.
ResponseOk
(
c
,
cp_cv
.
CheckCpImRes
{})
return
myCtx
,
nil
}
route/router.go
View file @
9deac2a7
...
...
@@ -48,6 +48,7 @@ func InitRouter() *gin.Engine {
cp
.
POST
(
"/relation/invite/reply"
,
wrapper
(
cp_r
.
ReplyCpInvite
))
cp
.
POST
(
"/relation/cancel/reply"
,
wrapper
(
cp_r
.
ReplyCpCancel
))
cp
.
GET
(
"/relation/detail"
,
wrapper
(
cp_r
.
CpDetailPage
))
cp
.
GET
(
"/im/check"
,
wrapper
(
cp_r
.
CheckCpImExpire
))
}
inner
:=
r
.
Group
(
"/inner"
)
inner
.
Use
(
ExceptionHandle
,
LoggerHandle
)
...
...
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