From f485a21a689e211bdeb59e7a67f44403c03e9799 Mon Sep 17 00:00:00 2001 From: chenweijian <820961417@qq.com> Date: Mon, 5 Jun 2023 14:15:52 +0800 Subject: [PATCH] cp --- domain/model/cp_m/cp_relation.go | 9 ++++++++- domain/service/cp_s/cp_relation.go | 4 ++-- route/cp_r/cp_relation.go | 14 +++++++------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/domain/model/cp_m/cp_relation.go b/domain/model/cp_m/cp_relation.go index fc53003..6a913d6 100644 --- a/domain/model/cp_m/cp_relation.go +++ b/domain/model/cp_m/cp_relation.go @@ -56,9 +56,16 @@ type CpCancel struct { // 发送私信(解除) type CpCancelMessage struct { + Identifier string `json:"identifier"` + Msg string `json:"msg"` + Sender *user_m.UserTiny `json:"sender"` +} + +// 发送私信-撤销解除、接受解除 +type CpDealCancelMessage struct { Identifier string `json:"identifier"` Msg string `json:"msg"` - Status uint8 `json:"status"` //1.发起解除2.撤销解除3.接受解除 + Status uint8 `json:"status"` //1.撤销解除2.接受解除 } type Cp struct { diff --git a/domain/service/cp_s/cp_relation.go b/domain/service/cp_s/cp_relation.go index 9d3fe3c..4a2304d 100644 --- a/domain/service/cp_s/cp_relation.go +++ b/domain/service/cp_s/cp_relation.go @@ -142,11 +142,11 @@ func CancelCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l model.Log.Errorf("CancelCpRelation myUserId:%d, err:%v", myUserId, err) return err } - // 发送私信 + // 发送私信-发起解除 data, _ := json.Marshal(cp_m.CpCancelMessage{ Identifier: "CpCancelMessage", Msg: "I want to unbind the CP relationship", - Status: 1, + Sender: user_m.ToUserTiny(user), }) if err := tencentyun.BatchSendCustomMsg(model, 1, user.ExternalId, []string{userRec.ExternalId}, string(data), "cp解除"); err != nil { model.Log.Errorf("CancelCpRelation BatchSendCustomMsg fail:%v", err) diff --git a/route/cp_r/cp_relation.go b/route/cp_r/cp_relation.go index 00a9065..506a427 100644 --- a/route/cp_r/cp_relation.go +++ b/route/cp_r/cp_relation.go @@ -294,10 +294,10 @@ func ReplyCpCancel(c *gin.Context) (*mycontext.MyContext, error) { var msgData []byte if optType == 1 { // 撤销解除 // 私信 - msgData, _ = json.Marshal(cp_m.CpCancelMessage{ - Identifier: "CpCancelMessage", + msgData, _ = json.Marshal(cp_m.CpDealCancelMessage{ + Identifier: "CpDealCancelMessage", Msg: fmt.Sprintf("%s withdrew my application to lift CP", myUser.Nick), - Status: 2, + Status: 1, }) } else { // 接受解除 // 删除cp关系表的记录 @@ -306,11 +306,11 @@ func ReplyCpCancel(c *gin.Context) (*mycontext.MyContext, error) { model.Log.Errorf("ReplyCpCancel myUser:%d, user2:%d, status:%d, err:%v", myUser.ID, user2.ID, updateStatus, err) return err } - // 私信 - msgData, _ = json.Marshal(cp_m.CpCancelMessage{ - Identifier: "CpCancelMessage", + // 私信-接受解除 + msgData, _ = json.Marshal(cp_m.CpDealCancelMessage{ + Identifier: "CpDealCancelMessage", Msg: "The CP relationship has been unbound, the CP value has been cleared, and the CP privilege has disappeared", - Status: 3, + Status: 2, }) } if err := tencentyun.BatchSendCustomMsg(model, 1, myUser.ExternalId, []string{user2.ExternalId}, string(msgData), "cp解除"); err != nil { -- 2.22.0