fix the issue of model repetition

This commit is contained in:
AIASS Group 2023-11-23 15:36:07 +08:00 committed by GitHub
parent 3808ae8dca
commit 15d3e9819d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,13 +14,9 @@ type Ability struct {
} }
func GetGroupModels(group string) []string { func GetGroupModels(group string) []string {
var abilities []Ability var models []string
//去重 enabled = true // Find distinct models
DB.Where("`group` = ? and enabled = ?", group, true).Find(&abilities) DB.Table("abilities").Where("`group` = ? and enabled = ?", group, true).Distinct("model").Pluck("model", &models)
models := make([]string, 0, len(abilities))
for _, ability := range abilities {
models = append(models, ability.Model)
}
return models return models
} }