This commit is contained in:
withchao 2023-01-28 18:46:42 +08:00
parent 891e631b91
commit 601fac7a04
2 changed files with 3 additions and 3 deletions

View File

@ -29,7 +29,7 @@ type Group struct {
func NewGroupDB(db *gorm.DB) *Group {
var group Group
group.DB = db.Model(&Group{})
group.DB = db
return &group
}
@ -45,7 +45,7 @@ func (g *Group) Delete(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs)
}()
return utils.Wrap(getDBConn(g.DB, tx...).Where("group_id in (?)", groupIDs).Delete(&Group{}).Error, "")
return utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Delete(&Group{}).Error, "")
}
func (g *Group) UpdateByMap(ctx context.Context, groupID string, args map[string]interface{}) (err error) {

View File

@ -87,7 +87,7 @@ func (w Writer) Printf(format string, args ...interface{}) {
fmt.Printf(format, args...)
}
func getDBConn(db *gorm.DB, tx ...*gorm.DB) *gorm.DB {
func getDBConn(db *gorm.DB, tx []*gorm.DB) *gorm.DB {
if len(tx) > 0 {
return tx[0]
}