From 401c26802ede9c59c36e84ce77608f9d33eed9d3 Mon Sep 17 00:00:00 2001 From: chenweijian <820961417@qq.com> Date: Thu, 1 Jun 2023 18:20:34 +0800 Subject: [PATCH] =?UTF-8?q?cp=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- domain/model/cp_m/cp_relation.go | 6 +++--- route/cp_r/cp_relation.go | 11 ++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/domain/model/cp_m/cp_relation.go b/domain/model/cp_m/cp_relation.go index 192bfb5..360c399 100644 --- a/domain/model/cp_m/cp_relation.go +++ b/domain/model/cp_m/cp_relation.go @@ -49,7 +49,7 @@ type CpCancelMessage struct { func CreateCp(model *domain.Model, userId1, userId2 uint64) error { userIds := []uint64{userId1, userId2} - result := model.DB().Exec("insert into cp_relation(user_id1, user_id2) values(?,?) where not exists (select user_id1 from cp_relation where user_id1 in (?) or user_id2 in (?));", userId1, userId2, userIds, userIds) + result := model.DB().Exec("insert into cp_relation(user_id1, user_id2) select ?,? where not exists (select user_id1 from cp_relation where user_id1 in (?) or user_id2 in (?));", userId1, userId2, userIds, userIds) if result.Error != nil { model.Log.Errorf("CreateCp user1:%d, user2:%d, err:%v", userId1, userId2, result.Error) return result.Error @@ -89,7 +89,7 @@ func GetCpInvite(model *domain.Model, userId, userIdInvite uint64, status cp_e.C 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 + err := model.DB().Model(CpInvite{}).Create(&cpInvite).Error if err != nil { model.Log.Errorf("CreateCpInvite user1:%d, user2:%d, diamondNum:%d, err:%v", userId, userIdInvite, diamondNum, err) return 0, err @@ -113,7 +113,7 @@ func UpdateStatusCpInvite(model *domain.Model, id uint64, status cp_e.CpInviteSt func CreateCpCancel(model *domain.Model, userId, recUserId uint64) (uint64, error) { cpCancel := CpCancel{UserId: userId, RecUserId: recUserId, Status: cp_e.CpCancel} - err := model.DB().Model(CpCancel{}).Create(cpCancel).Error + err := model.DB().Model(CpCancel{}).Create(&cpCancel).Error if err != nil { model.Log.Errorf("CreateCpCancel user1:%d, user2:%d, err:%v", userId, recUserId, err) return 0, err diff --git a/route/cp_r/cp_relation.go b/route/cp_r/cp_relation.go index d2250e4..a19d071 100644 --- a/route/cp_r/cp_relation.go +++ b/route/cp_r/cp_relation.go @@ -37,6 +37,10 @@ func CheckUserCpRelation(c *gin.Context) (*mycontext.MyContext, error) { return myCtx, err } + if externalId == "" { + return myCtx, bizerr.InvalidParameter + } + model := domain.CreateModelContext(myCtx) user, err := user_m.GetUserByExtId(model, externalId) if err != nil { @@ -48,7 +52,7 @@ func CheckUserCpRelation(c *gin.Context) (*mycontext.MyContext, error) { return myCtx, err } if cp.Id > 0 { - return myCtx, msg.GetErrByLanguage(model, 0, lang, comerr.InvalidParameter) + return myCtx, msg.GetErrByLanguage(model, 0, lang, comerr.InvalidParameter) // cwj---- } resp.ResponseOk(c, cp_cv.CheckCpRelationRes{}) @@ -208,7 +212,7 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) { return myCtx, err } - resp.ResponseOk(c, cp_cv.CheckCpRelationRes{}) + resp.ResponseOk(c, nil) return myCtx, nil } @@ -338,9 +342,10 @@ func CpDetailPage(c *gin.Context) (*mycontext.MyContext, error) { GradeName string `json:"gradeName"` // 等级称号 CreatedTime int64 `json:"createdTime"` // cp创建时间 } - res := new(CpDetail) + var res *CpDetail if cp.Id > 0 { + res = new(CpDetail) if cp.UserId1 == user.ID { res.Avatar1 = user.Avatar res.Nick1 = user.Nick -- 2.22.0