return all busi-groups when subscribe

This commit is contained in:
Ulric Qin 2022-02-17 19:28:35 +08:00
parent 5c2581a90a
commit 8c4ab88888
2 changed files with 4 additions and 3 deletions

View File

@ -435,11 +435,11 @@ func (u *User) NopriIdents(idents []string) ([]string, error) {
// 我是管理员,返回所有 // 我是管理员,返回所有
// 或者我是成员 // 或者我是成员
func (u *User) BusiGroups(limit int, query string) ([]BusiGroup, error) { func (u *User) BusiGroups(limit int, query string, all ...bool) ([]BusiGroup, error) {
session := DB().Order("name").Limit(limit) session := DB().Order("name").Limit(limit)
var lst []BusiGroup var lst []BusiGroup
if u.IsAdmin() { if u.IsAdmin() || (len(all) > 0 && all[0]) {
err := session.Where("name like ?", "%"+query+"%").Find(&lst).Error err := session.Where("name like ?", "%"+query+"%").Find(&lst).Error
return lst, err return lst, err
} }

View File

@ -98,9 +98,10 @@ func busiGroupDel(c *gin.Context) {
func busiGroupGets(c *gin.Context) { func busiGroupGets(c *gin.Context) {
limit := ginx.QueryInt(c, "limit", defaultLimit) limit := ginx.QueryInt(c, "limit", defaultLimit)
query := ginx.QueryStr(c, "query", "") query := ginx.QueryStr(c, "query", "")
all := ginx.QueryBool(c, "all", false)
me := c.MustGet("user").(*models.User) me := c.MustGet("user").(*models.User)
lst, err := me.BusiGroups(limit, query) lst, err := me.BusiGroups(limit, query, all)
ginx.NewRender(c).Data(lst, err) ginx.NewRender(c).Data(lst, err)
} }