44 lines
912 B
Go
44 lines
912 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 UpdateRoleLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewUpdateRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateRoleLogic {
|
|
return &UpdateRoleLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *UpdateRoleLogic) UpdateRole(req *types.UpdateRoleReq) (resp *types.IdResp, err error) {
|
|
id := ctxdata.GetPathId(l.ctx)
|
|
|
|
_, err = l.svcCtx.SystemRpc.UpdateRole(l.ctx, &pb.UpdateRoleReq{
|
|
RoleId: id,
|
|
RoleName: req.RoleName,
|
|
RoleKey: req.RoleKey,
|
|
RoleDesc: req.RoleDesc,
|
|
SortOrder: req.SortOrder,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &types.IdResp{Id: id}, nil
|
|
}
|