作者 yangfu

角色权限

... ... @@ -30,6 +30,9 @@ service Core {
@doc "角色列表搜索"
@handler systemSearchRole
post /system/role/search (RoleSearchRequest) returns (RoleSearchResponse)
@doc "角色权限列表"
@handler systemGetRoleAuths
get /system/role/auths
}
type (
... ...
package role
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"net/http"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/role"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
)
func SystemGetRoleAuthsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
l := role.NewSystemGetRoleAuthsLogic(r.Context(), svcCtx)
resp, err := l.SystemGetRoleAuths()
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -593,6 +593,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/system/role/search",
Handler: role.SystemSearchRoleHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/system/role/auths",
Handler: role.SystemGetRoleAuthsHandler(serverCtx),
},
}...,
),
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
... ...
package role
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"github.com/zeromicro/go-zero/core/logx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
)
type SystemGetRoleAuthsLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemGetRoleAuthsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemGetRoleAuthsLogic {
return &SystemGetRoleAuthsLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemGetRoleAuthsLogic) SystemGetRoleAuths() (interface{}, error) {
return map[string]interface{}{
"list": domain.Auths,
}, nil
}
... ...