diff --git a/src/webapi/router/router.go b/src/webapi/router/router.go index a4cb564c..862ad723 100644 --- a/src/webapi/router/router.go +++ b/src/webapi/router/router.go @@ -137,6 +137,7 @@ func configRoute(r *gin.Engine, version string) { pages.DELETE("/user-group/:id", jwtAuth(), user(), userGroupWrite(), userGroupDel) pages.POST("/user-group/:id/members", jwtAuth(), user(), userGroupWrite(), userGroupMemberAdd) pages.DELETE("/user-group/:id/members", jwtAuth(), user(), userGroupWrite(), userGroupMemberDel) + pages.GET("/user-group/:id/perm/:perm", jwtAuth(), user(), checkBusiGroupPerm) pages.POST("/busi-groups", jwtAuth(), user(), busiGroupAdd) pages.GET("/busi-groups", jwtAuth(), user(), busiGroupGets) diff --git a/src/webapi/router/router_user_group.go b/src/webapi/router/router_user_group.go index bc2ec58f..87f8823c 100644 --- a/src/webapi/router/router_user_group.go +++ b/src/webapi/router/router_user_group.go @@ -10,6 +10,14 @@ import ( "github.com/didi/nightingale/v5/src/models" ) +func checkBusiGroupPerm(c *gin.Context) { + me := c.MustGet("user").(*models.User) + bg := BusiGroup(ginx.UrlParamInt64(c, "id")) + + can, err := me.CanDoBusiGroup(bg, ginx.UrlParamStr(c, "perm")) + ginx.NewRender(c).Data(can, err) +} + // Return all, front-end search and paging // I'm creator or member func userGroupGets(c *gin.Context) {