Chever John 71a2d912e2 feat: initial commit for muyu-apiserver
Go service with gateway, RPC, model layers and k8s deploy configs.

Made-with: Cursor
2026-02-28 15:29:16 +08:00

50 lines
1.0 KiB
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 GetRoleLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRoleLogic {
return &GetRoleLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetRoleLogic) GetRole() (resp *types.RoleInfo, err error) {
id := ctxdata.GetPathId(l.ctx)
rpcResp, err := l.svcCtx.SystemRpc.GetRole(l.ctx, &pb.GetRoleReq{
RoleId: id,
})
if err != nil {
return nil, err
}
return &types.RoleInfo{
RoleId: rpcResp.RoleId,
RoleName: rpcResp.RoleName,
RoleKey: rpcResp.RoleKey,
RoleDesc: rpcResp.RoleDesc,
SortOrder: rpcResp.SortOrder,
Status: rpcResp.Status,
MenuIds: rpcResp.MenuIds,
CreatedAt: rpcResp.CreatedAt,
UpdatedAt: rpcResp.UpdatedAt,
}, nil
}