Error code standardization

test-errcode
skiffer-git 2 years ago
parent ca6b704377
commit 96ef753c77

@ -1,6 +1,7 @@
package controller
import (
relation2 "Open_IM/pkg/common/db/relation"
"Open_IM/pkg/common/db/table/relation"
"context"
"errors"
@ -27,12 +28,12 @@ func NewBlackController(db *gorm.DB) *BlackController {
}
// Create 增加黑名单
func (b *BlackController) Create(ctx context.Context, blacks []*relation.Black) (err error) {
func (b *BlackController) Create(ctx context.Context, blacks []*relation.BlackModel) (err error) {
return b.database.Create(ctx, blacks)
}
// Delete 删除黑名单
func (b *BlackController) Delete(ctx context.Context, blacks []*relation.Black) (err error) {
func (b *BlackController) Delete(ctx context.Context, blacks []*relation.BlackModel) (err error) {
return b.database.Delete(ctx, blacks)
}
@ -48,9 +49,9 @@ func (b *BlackController) CheckIn(ctx context.Context, userID1, userID2 string)
type BlackDatabaseInterface interface {
// Create 增加黑名单
Create(ctx context.Context, blacks []*relation.Black) (err error)
Create(ctx context.Context, blacks []*relation.BlackModel) (err error)
// Delete 删除黑名单
Delete(ctx context.Context, blacks []*relation.Black) (err error)
Delete(ctx context.Context, blacks []*relation.BlackModel) (err error)
// FindOwnerBlacks 获取黑名单列表
FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*relation.Black, total int64, err error)
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true)
@ -58,11 +59,11 @@ type BlackDatabaseInterface interface {
}
type BlackDatabase struct {
sqlDB *relation.Black
sqlDB *relation2.BlackGorm
}
func NewBlackDatabase(db *gorm.DB) *BlackDatabase {
sqlDB := relation.NewBlack(db)
sqlDB := relation2.NewBlackGorm(db)
database := &BlackDatabase{
sqlDB: sqlDB,
}
@ -70,17 +71,17 @@ func NewBlackDatabase(db *gorm.DB) *BlackDatabase {
}
// Create 增加黑名单
func (b *BlackDatabase) Create(ctx context.Context, blacks []*relation.Black) (err error) {
func (b *BlackDatabase) Create(ctx context.Context, blacks []*relation.BlackModel) (err error) {
return b.sqlDB.Create(ctx, blacks)
}
// Delete 删除黑名单
func (b *BlackDatabase) Delete(ctx context.Context, blacks []*relation.Black) (err error) {
func (b *BlackDatabase) Delete(ctx context.Context, blacks []*relation.BlackModel) (err error) {
return b.sqlDB.Delete(ctx, blacks)
}
// FindOwnerBlacks 获取黑名单列表
func (b *BlackDatabase) FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*relation.Black, total int64, err error) {
func (b *BlackDatabase) FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*relation.BlackModel, total int64, err error) {
return b.sqlDB.FindOwnerBlacks(ctx, ownerUserID, pageNumber, showNumber)
}

@ -81,23 +81,23 @@ func (f *FriendController) UpdateRemark(ctx context.Context, ownerUserID, friend
}
// FindOwnerFriends 获取ownerUserID的好友列表
func (f *FriendController) FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
return f.database.FindOwnerFriends(ctx, ownerUserID, pageNumber, showNumber)
func (f *FriendController) PageOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
return f.database.PageOwnerFriends(ctx, ownerUserID, pageNumber, showNumber)
}
// FindInWhoseFriends friendUserID在哪些人的好友列表中
func (f *FriendController) FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
return f.database.FindInWhoseFriends(ctx, friendUserID, pageNumber, showNumber)
func (f *FriendController) PageInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
return f.database.PageInWhoseFriends(ctx, friendUserID, pageNumber, showNumber)
}
// FindFriendRequestFromMe 获取我发出去的好友申请
func (f *FriendController) FindFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
return f.database.FindFriendRequestFromMe(ctx, userID, pageNumber, showNumber)
func (f *FriendController) PageFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
return f.database.PageFriendRequestFromMe(ctx, userID, pageNumber, showNumber)
}
// FindFriendRequestToMe 获取我收到的的好友申请
func (f *FriendController) FindFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
return f.database.FindFriendRequestToMe(ctx, userID, pageNumber, showNumber)
func (f *FriendController) PageFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
return f.database.PageFriendRequestToMe(ctx, userID, pageNumber, showNumber)
}
// FindFriends 获取某人指定好友的信息
@ -121,13 +121,13 @@ type FriendDatabaseInterface interface {
// 更新好友备注
UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error)
// 获取ownerUserID的好友列表
FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error)
PageOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error)
// friendUserID在哪些人的好友列表中
FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error)
PageInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error)
// 获取我发出去的好友申请
FindFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error)
PageFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error)
// 获取我收到的的好友申请
FindFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error)
PageFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error)
// 获取某人指定好友的信息
FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error)
}
@ -302,22 +302,22 @@ func (f *FriendDatabase) UpdateRemark(ctx context.Context, ownerUserID, friendUs
}
// 获取ownerUserID的好友列表 无结果不返回错误
func (f *FriendDatabase) FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
func (f *FriendDatabase) PageOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
return f.friend.FindOwnerFriends(ctx, ownerUserID, pageNumber, showNumber)
}
// friendUserID在哪些人的好友列表中
func (f *FriendDatabase) FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
func (f *FriendDatabase) PageInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
return f.friend.FindInWhoseFriends(ctx, friendUserID, pageNumber, showNumber)
}
// 获取我发出去的好友申请 无结果不返回错误
func (f *FriendDatabase) FindFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
func (f *FriendDatabase) PageFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
return f.friendRequest.FindFromUserID(ctx, userID, pageNumber, showNumber)
}
// 获取我收到的的好友申请 无结果不返回错误
func (f *FriendDatabase) FindFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
func (f *FriendDatabase) PageFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
return f.friendRequest.FindToUserID(ctx, userID, pageNumber, showNumber)
}

Loading…
Cancel
Save