Skip to content

Commit

Permalink
feat: 优化InAdmin
Browse files Browse the repository at this point in the history
  • Loading branch information
2637309949 committed Dec 24, 2020
1 parent 9345c9e commit 3dfef9c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions platform/app/app.ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,14 @@ func (ctx *Context) InRole(role ...string) bool {
}

// InAdmin defined
func (ctx *Context) InAdmin() bool {
exit, _ := ctx.DB.Where(`role_id = ? and user_id = ?`, model.AdminRole.ID.String, ctx.GetToken().GetUserID()).Exist(new(model.SysRoleUser))
func (ctx *Context) InAdmin(idn ...string) bool {
roles := []string{model.AdminRole.ID.String}
roles = append(roles, idn...)
exit, err := ctx.DB.In("role_id", roles).Where(`user_id = ? and del_flag != 1`, ctx.GetToken().GetUserID()).Exist(new(model.SysRoleUser))
if err != nil {
logrus.Error(err)
return false
}
return exit
}

Expand Down
4 changes: 2 additions & 2 deletions platform/app/sys_app_fun.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3dfef9c

Please sign in to comment.