Refactor code

pull/131/head
wenxu12345 3 years ago
parent 5ae6e98572
commit 6d9ee74360

@ -453,7 +453,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
log.NewInfo(req.OperationID, "JoinGroup args ", req.String())
_, err := imdb.GetUserByUserID(req.OpUserID)
if err != nil {
log.NewError(req.OperationID, "FindUserByUID failed ", err.Error(), req.OpUserID)
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.OpUserID)
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}

@ -23,11 +23,10 @@ func UpdateGroupRequest(groupRequest GroupRequest) error {
if err != nil {
return err
}
err = dbConn.Table("group_request").Where("group_id=? and user_id=?", groupRequest.GroupID, groupRequest.UserID).Update(&groupRequest).Error
if err != nil {
return err
//RowsAffected
if dbConn.Table("group_request").Where("group_id=? and user_id=?", groupRequest.GroupID, groupRequest.UserID).Update(&groupRequest).RowsAffected == 0 {
return InsertIntoGroupRequest(groupRequest)
}
return nil
}
func InsertIntoGroupRequest(toInsertInfo GroupRequest) error {

Loading…
Cancel
Save