diff --git a/domain/model/cp_m/cp_relation.go b/domain/model/cp_m/cp_relation.go index 192bfb5f7263f00a8a57328947c10ced7250f50c..360c399284e4e0b39aa400b6c337d3afc0cff462 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 d2250e46b2e7a8cc516edd8a6fe87ab08d716e52..a19d0717d7162c2fd778be3c6d1605627db2da6e 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