mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-09 03:25:59 +08:00
Merge remote-tracking branch 'origin/errcode' into errcode
This commit is contained in:
@@ -8,6 +8,14 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type GroupModelInterface interface {
|
||||
Create(ctx context.Context, groups []*Group) (err error)
|
||||
Delete(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (err error)
|
||||
UpdateByMap(ctx context.Context, groupID string, args map[string]interface{}) (err error)
|
||||
Update(ctx context.Context, groups []*Group) (err error)
|
||||
Find(ctx context.Context, groupIDs []string) (groups []*Group, err error)
|
||||
Take(ctx context.Context, groupID string) (group *Group, err error)
|
||||
}
|
||||
type Group struct {
|
||||
GroupID string `gorm:"column:group_id;primary_key;size:64" json:"groupID" binding:"required"`
|
||||
GroupName string `gorm:"column:name;size:255" json:"groupName"`
|
||||
@@ -29,7 +37,8 @@ type Group struct {
|
||||
|
||||
func NewGroupDB() *Group {
|
||||
var group Group
|
||||
group.DB = initMysqlDB(&group)
|
||||
db := ConnectToDB()
|
||||
db = InitModel(db, &group)
|
||||
return &group
|
||||
}
|
||||
|
||||
@@ -41,11 +50,11 @@ func (*Group) Create(ctx context.Context, groups []*Group) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (*Group) Delete(ctx context.Context, groupIDs []string) (err error) {
|
||||
func (g *Group) Delete(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (err error) {
|
||||
defer func() {
|
||||
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs)
|
||||
}()
|
||||
return utils.Wrap(GroupDB.Where("group_id in (?)", groupIDs).Delete(&Group{}).Error, "")
|
||||
return utils.Wrap(getDBConn(g.DB, tx...).Where("group_id in (?)", groupIDs).Delete(&Group{}).Error, "")
|
||||
}
|
||||
|
||||
func (*Group) UpdateByMap(ctx context.Context, groupID string, args map[string]interface{}) (err error) {
|
||||
|
||||
Reference in New Issue
Block a user