diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 2c747466d..17228a4aa 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -489,7 +489,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) groupRequest.ReqMsg = req.ReqMessage groupRequest.GroupID = req.GroupID - err = imdb.UpdateGroupRequest(groupRequest) + err = imdb.InsertIntoGroupRequest(groupRequest) if err != nil { log.NewError(req.OperationID, "UpdateGroupRequest ", err.Error(), groupRequest) return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil diff --git a/pkg/common/db/mysql_model/im_mysql_model/group_request_model.go b/pkg/common/db/mysql_model/im_mysql_model/group_request_model.go index 307dac166..9ccffeaba 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/group_request_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/group_request_model.go @@ -27,13 +27,7 @@ func UpdateGroupRequest(groupRequest GroupRequest) error { if groupRequest.HandledTime.Unix() < 0 { groupRequest.HandledTime = utils.UnixSecondToTime(0) } - t := dbConn.Table("group_request").Where("group_id=? and user_id=?", groupRequest.GroupID, groupRequest.UserID).Update(&groupRequest) - //RowsAffected - if t.RowsAffected == 0 { - return InsertIntoGroupRequest(groupRequest) - } else { - return t.Error - } + return dbConn.Table("group_request").Where("group_id=? and user_id=?", groupRequest.GroupID, groupRequest.UserID).Update(&groupRequest).Error } func InsertIntoGroupRequest(toInsertInfo GroupRequest) error {