query busigroup by ident

This commit is contained in:
Ulric Qin 2022-07-26 17:59:57 +08:00
parent 39705787c9
commit 76e105c93a
1 changed files with 15 additions and 0 deletions

View File

@ -450,6 +450,21 @@ func (u *User) BusiGroups(limit int, query string, all ...bool) ([]BusiGroup, er
var lst []BusiGroup
if u.IsAdmin() || (len(all) > 0 && all[0]) {
err := session.Where("name like ?", "%"+query+"%").Find(&lst).Error
if err != nil {
return lst, err
}
if len(lst) == 0 && len(query) > 0 {
// 隐藏功能一般人不告诉哈哈。query可能是给的ident所以上面的sql没有查到当做ident来查一下试试
var t *Target
t, err = TargetGet("ident=?", query)
if err != nil {
return lst, err
}
err = session.Where("id=?", t.GroupId).Find(&lst).Error
}
return lst, err
}