1 Star 0 Fork 0

Ms.Guo/CSO2014

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
setcosmetics.go 1.66 KB
Copy Edit Raw Blame History
libaojie authored 2024-10-31 17:38 +08:00 . 初始化
package favorate
import (
"context"
"errors"
"net"
"gitee.com/wusuitaitou/cso2014/main_service/client"
"gitee.com/wusuitaitou/cso2014/main_service/model/packet"
"gitee.com/wusuitaitou/cso2014/main_service/model/user"
"gitee.com/wusuitaitou/cso2014/utils"
)
type SetCosmeticsService interface {
Handle(ctx context.Context) error
}
type setCosmeticsService struct {
CosmeticsID uint8
cosmetics *user.UserCosmetics
client net.Conn
}
func NewSetCosmeticsService(p *packet.PacketData, client net.Conn) SetCosmeticsService {
return &setCosmeticsService{
CosmeticsID: utils.ReadUint8(p.Data, &p.CurOffset),
cosmetics: &user.UserCosmetics{
CosmeticsName: utils.ReadStringToNULL(p.Data, &p.CurOffset),
MainWeapon: utils.ReadUint16(p.Data, &p.CurOffset),
MainBullet: utils.ReadUint16(p.Data, &p.CurOffset),
SecondWeapon: utils.ReadUint16(p.Data, &p.CurOffset),
SecondBullet: utils.ReadUint16(p.Data, &p.CurOffset),
FlashbangNum: utils.ReadUint16(p.Data, &p.CurOffset),
GrenadeID: utils.ReadUint16(p.Data, &p.CurOffset),
SmokeNum: utils.ReadUint16(p.Data, &p.CurOffset),
DefuserNum: utils.ReadUint16(p.Data, &p.CurOffset),
TelescopeNum: utils.ReadUint16(p.Data, &p.CurOffset),
BulletproofNum: utils.ReadUint16(p.Data, &p.CurOffset),
KnifeID: utils.ReadUint16(p.Data, &p.CurOffset),
},
client: client,
}
}
func (s *setCosmeticsService) Handle(ctx context.Context) error {
u := client.GetUserCacheClient().GetUserByConnection(ctx, s.client)
if u == nil {
return errors.New("can't find user")
}
_, err := client.GetUserClient().UpdateCosmetics(ctx, u.UserID, s.CosmeticsID, s.cosmetics)
return err
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wusuitaitou/cso2014.git
git@gitee.com:wusuitaitou/cso2014.git
wusuitaitou
cso2014
CSO2014
v1.0.0

Search