package user import ( "dcg/app/user_center/usercenter" pbCommon "dcg/game/pb/common" "dcg/game/svc" "git.noahlan.cn/northlan/ngs/component" "git.noahlan.cn/northlan/ngs/session" ) type UserIntegral struct { component.Base svcCtx *svc.ServiceContext } func NewUserIntegral(svcCtx *svc.ServiceContext) *UserIntegral { return &UserIntegral{ svcCtx: svcCtx, } } func (p *UserIntegral) Init() { } func (p *UserIntegral) Shutdown() { } func (p *UserIntegral) CMD() string { return "user" } func (p *UserIntegral) Prefix() string { return "integral" } // Change 更新积分 func (p *UserIntegral) Change(s *session.Session, msg *pbCommon.ChangeUserIntegralReq) error { integral, err := p.svcCtx.UserCenterRpc.ChangeIntegral(p.svcCtx.Ctx, &usercenter.ChangeIntegralReq{ UserId: msg.UserId, Change: msg.Change, }) if err != nil { return s.Response(&pbCommon.ChangeUserIntegralResp{ Success: false, Msg: err.Error(), UserId: msg.UserId, Change: 0, Integral: 0, }) } return s.Response(&pbCommon.ChangeUserIntegralResp{ Success: true, Msg: "成功", UserId: msg.UserId, Change: msg.Change, Integral: integral.Integral, }) }