You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
3 years ago
|
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,
|
||
|
})
|
||
|
}
|