mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-16 14:59:01 +08:00
Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode
# Conflicts: # pkg/common/db/mysql_model/im_mysql_model/group_model_k.go
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package im_mysql_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/trace_log"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Friend struct {
|
||||
OwnerUserID string `gorm:"column:owner_user_id;primary_key;size:64"`
|
||||
FriendUserID string `gorm:"column:friend_user_id;primary_key;size:64"`
|
||||
Remark string `gorm:"column:remark;size:255"`
|
||||
CreateTime time.Time `gorm:"column:create_time"`
|
||||
AddSource int32 `gorm:"column:add_source"`
|
||||
OperatorUserID string `gorm:"column:operator_user_id;size:64"`
|
||||
Ex string `gorm:"column:ex;size:1024"`
|
||||
}
|
||||
|
||||
func (*Friend) Create(ctx context.Context, friends []*Friend) (err error) {
|
||||
defer func() {
|
||||
trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "friends", friends)
|
||||
}()
|
||||
err = utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Create(&friends).Error, "")
|
||||
return err
|
||||
}
|
||||
|
||||
func (*Friend) Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) (err error) {
|
||||
defer func() {
|
||||
trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "friendUserIDs", friendUserIDs)
|
||||
}()
|
||||
err = utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Where("owner_user_id = ? and friend_user_id in (?)", ownerUserID, friendUserIDs).Delete(&Friend{}).Error, "")
|
||||
return err
|
||||
}
|
||||
|
||||
func (*Friend) UpdateByMap(ctx context.Context, ownerUserID string, args map[string]interface{}) (err error) {
|
||||
defer func() {
|
||||
trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "args", args)
|
||||
}()
|
||||
return utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Where("owner_user_id = ?", ownerUserID).Updates(args).Error, "")
|
||||
}
|
||||
|
||||
func (*Friend) Update(ctx context.Context, friends []*Friend) (err error) {
|
||||
defer func() {
|
||||
trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "friends", friends)
|
||||
}()
|
||||
return utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Updates(&friends).Error, "")
|
||||
}
|
||||
|
||||
func (*Friend) Find(ctx context.Context, ownerUserID string) (friends []*Friend, err error) {
|
||||
defer func() {
|
||||
trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "friends", friends)
|
||||
}()
|
||||
err = utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Where("owner_user_id = ?", ownerUserID).Find(&friends).Error, "")
|
||||
return friends, err
|
||||
}
|
||||
|
||||
func (*Friend) Take(ctx context.Context, ownerUserID, friendUserID string) (group *Group, err error) {
|
||||
group = &Group{}
|
||||
defer trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "friendUserID", friendUserID, "group", *group)
|
||||
err = utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Where("owner_user_id = ? and friend_user_id", ownerUserID, friendUserID).Take(group).Error, "")
|
||||
return group, err
|
||||
}
|
||||
@@ -26,37 +26,49 @@ type Group struct {
|
||||
NotificationUserID string `gorm:"column:notification_user_id;size:64"`
|
||||
}
|
||||
|
||||
func (*Group) Create(ctx context.Context, groupList []*Group) (err error) {
|
||||
defer trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "groupList", groupList)
|
||||
err = utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Create(&groupList).Error, "")
|
||||
func (*Group) Create(ctx context.Context, groups []*Group) (err error) {
|
||||
defer func() {
|
||||
trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "groupList", groups)
|
||||
}()
|
||||
err = utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Create(&groups).Error, "")
|
||||
return err
|
||||
}
|
||||
|
||||
func (*Group) Delete(ctx context.Context, groupIDList []string) (err error) {
|
||||
defer trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "groupIDList", groupIDList)
|
||||
err = utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Where("group_id in (?)", groupIDList).Delete(&Group{}).Error, "")
|
||||
func (*Group) Delete(ctx context.Context, groupIDs []string) (err error) {
|
||||
defer func() {
|
||||
trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "groupIDs", groupIDs)
|
||||
}()
|
||||
err = utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Where("group_id in (?)", groupIDs).Delete(&Group{}).Error, "")
|
||||
return err
|
||||
}
|
||||
|
||||
func (*Group) UpdateByMap(ctx context.Context, groupID string, args map[string]interface{}) (err error) {
|
||||
defer trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "groupID", groupID, "args", args)
|
||||
defer func() {
|
||||
trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "groupID", groupID, "args", args)
|
||||
}()
|
||||
return utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Where("group_id = ?", groupID).Updates(args).Error, "")
|
||||
}
|
||||
|
||||
func (*Group) Update(ctx context.Context, groups []*Group) (err error) {
|
||||
defer trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "groups", groups)
|
||||
defer func() {
|
||||
trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "groups", groups)
|
||||
}()
|
||||
return utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Updates(&groups).Error, "")
|
||||
}
|
||||
|
||||
func (*Group) Find(ctx context.Context, groupIDList []string) (groupList []*Group, err error) {
|
||||
defer trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "groupIDList", groupIDList, "groupList", groupList)
|
||||
err = utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Where("group_id in (?)", groupIDList).Find(&groupList).Error, "")
|
||||
func (*Group) Find(ctx context.Context, groupIDs []string) (groupList []*Group, err error) {
|
||||
defer func() {
|
||||
trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "groupIDList", groupIDs, "groupList", groupList)
|
||||
}()
|
||||
err = utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Where("group_id in (?)", groupIDs).Find(&groupList).Error, "")
|
||||
return groupList, err
|
||||
}
|
||||
|
||||
func (*Group) Take(ctx context.Context, groupID string) (group *Group, err error) {
|
||||
group = &Group{}
|
||||
defer trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "groupID", groupID, "group", *group)
|
||||
defer func() {
|
||||
trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "groupID", groupID, "group", *group)
|
||||
}()
|
||||
err = utils.Wrap(db.DB.MysqlDB.DefaultGormDB().Where("group_id = ?", groupID).Take(group).Error, "")
|
||||
return group, err
|
||||
}
|
||||
|
||||
@@ -32,15 +32,15 @@ type Invitation struct {
|
||||
// string Ex = 7;
|
||||
// }
|
||||
// open_im_sdk.FriendInfo(FriendUser) != imdb.Friend(FriendUserID)
|
||||
type Friend struct {
|
||||
OwnerUserID string `gorm:"column:owner_user_id;primary_key;size:64"`
|
||||
FriendUserID string `gorm:"column:friend_user_id;primary_key;size:64"`
|
||||
Remark string `gorm:"column:remark;size:255"`
|
||||
CreateTime time.Time `gorm:"column:create_time"`
|
||||
AddSource int32 `gorm:"column:add_source"`
|
||||
OperatorUserID string `gorm:"column:operator_user_id;size:64"`
|
||||
Ex string `gorm:"column:ex;size:1024"`
|
||||
}
|
||||
//type Friend struct {
|
||||
// OwnerUserID string `gorm:"column:owner_user_id;primary_key;size:64"`
|
||||
// FriendUserID string `gorm:"column:friend_user_id;primary_key;size:64"`
|
||||
// Remark string `gorm:"column:remark;size:255"`
|
||||
// CreateTime time.Time `gorm:"column:create_time"`
|
||||
// AddSource int32 `gorm:"column:add_source"`
|
||||
// OperatorUserID string `gorm:"column:operator_user_id;size:64"`
|
||||
// Ex string `gorm:"column:ex;size:1024"`
|
||||
//}
|
||||
|
||||
// message FriendRequest{
|
||||
// string FromUserID = 1;
|
||||
|
||||
Reference in New Issue
Block a user