feat: rbac完善,file接入完成
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package role
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/system"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AssignRoleMenusLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAssignRoleMenusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AssignRoleMenusLogic {
|
||||
return &AssignRoleMenusLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *AssignRoleMenusLogic) AssignRoleMenus(req *types.AssignRoleMenusReq) error {
|
||||
_, err := l.svcCtx.SystemRpc.AssignRoleMenus(l.ctx, &system.AssignRoleMenusReq{
|
||||
RoleId: req.RoleId,
|
||||
MenuIds: req.MenuIds,
|
||||
})
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package role
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
"sundynix-micro-go/app/system/rpc/system"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetRoleDetailLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 角色详情(含已授权菜单)
|
||||
func NewGetRoleDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRoleDetailLogic {
|
||||
return &GetRoleDetailLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetRoleDetailLogic) GetRoleDetail(req *types.IdQueryReq) (resp *types.RoleDetailResp, err error) {
|
||||
rpcResp, err := l.svcCtx.SystemRpc.GetRoleDetail(l.ctx, &system.GetRoleDetailReq{
|
||||
Id: req.Id,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.RoleDetailResp{
|
||||
Id: rpcResp.Id,
|
||||
Name: rpcResp.Name,
|
||||
Code: rpcResp.Code,
|
||||
Sort: int(rpcResp.Sort),
|
||||
MenuIds: rpcResp.MenuIds,
|
||||
}, nil
|
||||
}
|
||||
@@ -20,7 +20,7 @@ func NewUpdateRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Update
|
||||
|
||||
func (l *UpdateRoleLogic) UpdateRole(req *types.RoleUpdateReq) error {
|
||||
_, err := l.svcCtx.SystemRpc.UpdateRole(l.ctx, &system.RoleUpdateReq{
|
||||
Id: req.Id, Name: req.Name, Code: req.Code, Sort: int32(req.Sort), MenuIds: req.MenuIds,
|
||||
Id: req.Id, Name: req.Name, Code: req.Code, Sort: int32(req.Sort),
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user