diff --git a/models/group.go b/models/group.go index 27965632..9a5ef39e 100644 --- a/models/group.go +++ b/models/group.go @@ -327,13 +327,10 @@ func insertTargetIntoGroup(tx *gorm.DB, t Target, gid int64) error { }).Error(err) return err } - err = tx.Where("group_id=? and target_id=?", gid, t.Id).Find(&GroupTarget{}).Error - if err == gorm.ErrRecordNotFound { - err = tx.Save(&GroupTarget{GroupId: gid, TargetId: t.Id}).Error - if err != nil { - log.Error(err) - return err - } + err = tx.Save(&GroupTarget{GroupId: gid, TargetId: t.Id}).Error + if err != nil { + log.Error(err) + return err } if err != nil { log.WithFields(logrus.Fields{