41 lines
898 B
Go
41 lines
898 B
Go
|
|
package role
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"muyu-apiserver/gateway/internal/svc"
|
||
|
|
"muyu-apiserver/gateway/internal/types"
|
||
|
|
"muyu-apiserver/pkg/ctxdata"
|
||
|
|
"muyu-apiserver/rpc/system/pb"
|
||
|
|
|
||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
|
)
|
||
|
|
|
||
|
|
type SetRolePermissionsLogic struct {
|
||
|
|
logx.Logger
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewSetRolePermissionsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetRolePermissionsLogic {
|
||
|
|
return &SetRolePermissionsLogic{
|
||
|
|
Logger: logx.WithContext(ctx),
|
||
|
|
ctx: ctx,
|
||
|
|
svcCtx: svcCtx,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (l *SetRolePermissionsLogic) SetRolePermissions(req *types.SetRolePermissionsReq) (resp *types.IdResp, err error) {
|
||
|
|
id := ctxdata.GetPathId(l.ctx)
|
||
|
|
|
||
|
|
_, err = l.svcCtx.SystemRpc.SetRolePermissions(l.ctx, &pb.SetRolePermissionsReq{
|
||
|
|
RoleId: id,
|
||
|
|
MenuIds: req.MenuIds,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
|
||
|
|
return &types.IdResp{Id: id}, nil
|
||
|
|
}
|