From 21976ba3efd8e51667bc88a6e81dddce1622b1d3 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Tue, 26 Mar 2024 17:33:18 +0800 Subject: [PATCH] update --- internal/logic/domain/friend/friend_service.go | 3 +++ pkg/gerrors/define.go | 1 + 2 files changed, 4 insertions(+) diff --git a/internal/logic/domain/friend/friend_service.go b/internal/logic/domain/friend/friend_service.go index 6fb363f..7bee84d 100644 --- a/internal/logic/domain/friend/friend_service.go +++ b/internal/logic/domain/friend/friend_service.go @@ -67,6 +67,9 @@ func (*friendService) DeleteFriend(ctx context.Context, userId, friendId int64) // AddFriend 添加好友 func (*friendService) AddFriend(ctx context.Context, userId, friendId int64, remarks, description string) error { + if userId == friendId { + return gerrors.ErrNotAllowAddSelf + } masterId, _ := grpclib.GetCtxMasterId(ctx) isAutoAddFriends := svc.SysCfgGet(masterId, "is_auto_add_friends") diff --git a/pkg/gerrors/define.go b/pkg/gerrors/define.go index c4e4faa..129805d 100644 --- a/pkg/gerrors/define.go +++ b/pkg/gerrors/define.go @@ -18,6 +18,7 @@ var ( ErrAlreadyIsFriend = newError(10015, "对方已经是好友了") ErrUserNotFound = newError(10016, "用户找不到") ErrNotIsFriend = newError(10017, "对方暂不是好友") + ErrNotAllowAddSelf = newError(10018, "不允许添加自己为好友") ) func newError(code int, message string) error {