Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ccfos/nightingale
Browse files Browse the repository at this point in the history
  • Loading branch information
710leo committed Nov 10, 2023
2 parents 10c462a + 694c432 commit 6fd75ae
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions center/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@ func (rt *Router) Config(r *gin.Engine) {
pages.GET("/config", rt.auth(), rt.admin(), rt.configGetByKey)
pages.PUT("/config", rt.auth(), rt.admin(), rt.configPutByKey)

// for admin api
pages.GET("/user/busi-groups", rt.auth(), rt.admin(), rt.userBusiGroupsGets)

}

r.GET("/api/n9e/versions", func(c *gin.Context) {
Expand Down
22 changes: 22 additions & 0 deletions center/router/router_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@ import (
"github.com/toolkits/pkg/ginx"
)

func (rt *Router) userBusiGroupsGets(c *gin.Context) {
userid := ginx.QueryInt64(c, "userid", 0)
username := ginx.QueryStr(c, "username", "")

if userid == 0 && username == "" {
ginx.Bomb(http.StatusBadRequest, "userid or username required")
}

var user *models.User
var err error
if userid > 0 {
user, err = models.UserGetById(rt.Ctx, userid)
} else {
user, err = models.UserGetByUsername(rt.Ctx, username)
}

ginx.Dangerous(err)

groups, err := user.BusiGroups(rt.Ctx, 10000, "")
ginx.NewRender(c).Data(groups, err)
}

func (rt *Router) userFindAll(c *gin.Context) {
list, err := models.UserGetAll(rt.Ctx)
ginx.NewRender(c).Data(list, err)
Expand Down

0 comments on commit 6fd75ae

Please sign in to comment.