115 lines
2.5 KiB
Go
115 lines
2.5 KiB
Go
package user
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) SwitchDefPerCheck(session comm.IUserSession, req *pb.UserSwitchDefPerReq) (code pb.ErrorCode) {
|
|
|
|
return
|
|
}
|
|
|
|
//登录
|
|
func (this *apiComp) SwitchDefPer(session comm.IUserSession, req *pb.UserSwitchDefPerReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
|
var (
|
|
change map[string]interface{} = make(map[string]interface{})
|
|
user *pb.DBUser
|
|
conf *cfg.GamePlayerInfor_overviewData
|
|
err error
|
|
keep bool
|
|
)
|
|
|
|
if code = this.SwitchDefPerCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
|
|
user = this.module.GetUser(session.GetUserId())
|
|
|
|
if req.CurSkin != "" {
|
|
if conf, err = this.module.configure.GetPlayerOverview(req.CurSkin); err != nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
if conf.Type != 1 {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
return
|
|
}
|
|
for _, v := range user.Skins {
|
|
if v == req.CurSkin {
|
|
keep = true
|
|
}
|
|
}
|
|
if !keep {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
return
|
|
}
|
|
user.CurSkin = req.CurSkin
|
|
change["curSkin"] = req.CurSkin
|
|
}
|
|
|
|
if req.CurAction != "" {
|
|
if conf, err = this.module.configure.GetPlayerOverview(req.CurAction); err != nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
if conf.Type != 2 {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
return
|
|
}
|
|
for _, v := range user.Skins {
|
|
if v == req.CurAction {
|
|
keep = true
|
|
}
|
|
}
|
|
if !keep {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
return
|
|
}
|
|
user.CurAction = req.CurAction
|
|
change["curAction"] = req.CurAction
|
|
}
|
|
|
|
if req.CurBg != "" {
|
|
if conf, err = this.module.configure.GetPlayerOverview(req.CurBg); err != nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
if conf.Type != 3 {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
return
|
|
}
|
|
for _, v := range user.Skins {
|
|
if v == req.CurBg {
|
|
keep = true
|
|
}
|
|
}
|
|
if !keep {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
return
|
|
}
|
|
user.CurBg = req.CurBg
|
|
change["curBg"] = req.CurBg
|
|
}
|
|
if err = this.module.modelUser.Change(session.GetUserId(), change); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), "skinlist", &pb.UserSkinlistPush{
|
|
Skins: user.Skins,
|
|
CurSkin: user.CurSkin,
|
|
CurAction: user.CurAction,
|
|
CurBg: user.CurBg,
|
|
})
|
|
session.SendMsg(string(this.module.GetType()), "switchdefper", &pb.UserSwitchDefPerResp{
|
|
Issucc: true,
|
|
CurSkin: user.CurSkin,
|
|
CurAction: user.CurAction,
|
|
CurBg: user.CurBg,
|
|
})
|
|
return
|
|
}
|