diff --git a/pkg/common/constant/constant.go b/pkg/common/constant/constant.go index cd08aa86c..f2d62c0d9 100644 --- a/pkg/common/constant/constant.go +++ b/pkg/common/constant/constant.go @@ -1,21 +1,6 @@ package constant const ( - - //group admin - // OrdinaryMember = 0 - // GroupOwner = 1 - // Administrator = 2 - //group application - // Application = 0 - // AgreeApplication = 1 - - //friend related - BlackListFlag = 1 - ApplicationFriendFlag = 0 - FriendFlag = 1 - RefuseFriendFlag = -1 - //Websocket Protocol WSGetNewestSeq = 1001 WSPullMsgBySeqList = 1002 diff --git a/pkg/common/constant/err_info.go b/pkg/common/constant/err_info.go index a578bafb2..c30bc4159 100644 --- a/pkg/common/constant/err_info.go +++ b/pkg/common/constant/err_info.go @@ -1,10 +1,7 @@ package constant import ( - sdkws "Open_IM/pkg/proto/sdk_ws" - "context" "encoding/json" - "fmt" "github.com/pkg/errors" "gorm.io/gorm" "strings" @@ -67,28 +64,3 @@ func ToAPIErrWithErr(err error) *ErrInfo { } return toDetail(err, ErrDefaultOther) } - -func SetErrorForResp(err error, commonResp *sdkws.CommonResp) { - errInfo := ToAPIErrWithErr(err) - commonResp.ErrCode = errInfo.ErrCode - commonResp.ErrMsg = errInfo.ErrMsg - commonResp.DetailErrMsg = err.Error() -} - -func CommonResp2Err(resp *sdkws.CommonResp) error { - if resp.ErrCode != NoError { - return errors.New(fmt.Sprintf("call rpc error, errCode is %d, errMsg is %s, detailErrMsg is %s", resp.ErrCode, resp.ErrMsg, resp.DetailErrMsg)) - } - return nil -} - -func Error2CommResp(ctx context.Context, info *ErrInfo, detailErrMsg string) *sdkws.CommonResp { - err := &sdkws.CommonResp{ - ErrCode: info.ErrCode, - ErrMsg: info.ErrMsg, - } - if detailErrMsg != "" { - err.DetailErrMsg = detailErrMsg - } - return err -} diff --git a/pkg/common/db/relation/friend_model_k.go b/pkg/common/db/relation/friend_model_k.go index 519e78fec..d581e1d25 100644 --- a/pkg/common/db/relation/friend_model_k.go +++ b/pkg/common/db/relation/friend_model_k.go @@ -26,7 +26,7 @@ type FriendUser struct { func NewFriendDB(db *gorm.DB) *Friend { var friend Friend - friend.DB = initModel(db, friend) + friend.DB = db return &friend } diff --git a/pkg/common/db/relation/user_model_k.go b/pkg/common/db/relation/user_model_k.go index c7dd8e778..48e3e35b6 100644 --- a/pkg/common/db/relation/user_model_k.go +++ b/pkg/common/db/relation/user_model_k.go @@ -84,7 +84,7 @@ func (u *User) GetByName(ctx context.Context, userName string, showNumber, pageN func (u *User) GetByNameAndID(ctx context.Context, content string, showNumber, pageNumber int32) (users []*User, count int64, err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userName", userName, "showNumber", showNumber, "pageNumber", pageNumber, "users", users) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "content", content, "showNumber", showNumber, "pageNumber", pageNumber, "users", users) }() db := u.DB.Where(" name like ? or user_id = ? ", fmt.Sprintf("%%%s%%", content), content) if err := db.Count(&count).Error; err != nil {