You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.9 KiB
97 lines
2.9 KiB
4 months ago
|
package serviceGame
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"github.com/gogf/gf/v2/frame/g"
|
||
|
"tyj_admin/api/v1/game"
|
||
|
"tyj_admin/internal/serviceGame/internal"
|
||
|
)
|
||
|
|
||
|
type IGamePub interface {
|
||
|
GetId(ctx context.Context, req *game.GetOutIdReq) (res *game.GetOutIdRes, err error)
|
||
|
LoginOut(ctx context.Context, req *game.LoginOutReq) (res *game.LoginOutRes, err error)
|
||
|
ItemRecord(ctx context.Context, req *game.ItemRecordReq) (res *game.ItemRecordRes, err error)
|
||
|
ShopRecords(ctx context.Context, req *game.ShopRecordReq) (res *game.ShopRecordRes, err error)
|
||
|
GetAuditMode(ctx context.Context, req *game.GetAuditModeReq) (res *game.GetAuditModeRes, err error)
|
||
|
SetOpenId(ctx context.Context, req *game.SetOpenIdReq) (res *game.SetOpenIdRes, err error)
|
||
|
GetOpenId(ctx context.Context, req *game.GetOpenIdReq) (res *game.GetOpenIdRes, err error)
|
||
|
}
|
||
|
|
||
|
type gamePubImpl struct {
|
||
|
}
|
||
|
|
||
|
var gamePubService = gamePubImpl{}
|
||
|
|
||
|
func GamePub() IGamePub {
|
||
|
return &gamePubService
|
||
|
}
|
||
|
|
||
|
func (c *gamePubImpl) GetId(ctx context.Context, req *game.GetOutIdReq) (res *game.GetOutIdRes, err error) {
|
||
|
//ip := libUtils.GetClientIp(ctx)
|
||
|
//fmt.Println("ip: ", ip)
|
||
|
g.Try(ctx, func(ctx context.Context) {
|
||
|
res = new(game.GetOutIdRes)
|
||
|
res.Id, err = internal.GetIdToUid(ctx, req.Uid)
|
||
|
if res.Id > 0 {
|
||
|
return
|
||
|
}
|
||
|
res.Id, err = internal.GetIdIncrease(ctx)
|
||
|
internal.AddIdToUid(ctx, res.Id, req.Uid)
|
||
|
return
|
||
|
})
|
||
|
return
|
||
|
}
|
||
|
|
||
|
func (c *gamePubImpl) LoginOut(ctx context.Context, req *game.LoginOutReq) (res *game.LoginOutRes, err error) {
|
||
|
//ip := libUtils.GetClientIp(ctx)
|
||
|
//fmt.Println("ip: ", ip)
|
||
|
g.Try(ctx, func(ctx context.Context) {
|
||
|
res = new(game.LoginOutRes)
|
||
|
res, err = internal.LoginOut(ctx, req)
|
||
|
return
|
||
|
})
|
||
|
return
|
||
|
}
|
||
|
|
||
|
func (c *gamePubImpl) ItemRecord(ctx context.Context, req *game.ItemRecordReq) (res *game.ItemRecordRes, err error) {
|
||
|
//ip := libUtils.GetClientIp(ctx)
|
||
|
//fmt.Println("ip: ", ip)
|
||
|
g.Try(ctx, func(ctx context.Context) {
|
||
|
res = new(game.ItemRecordRes)
|
||
|
res, err = internal.ItemIncomeExpenseRecords(ctx, req)
|
||
|
return
|
||
|
})
|
||
|
return
|
||
|
}
|
||
|
|
||
|
func (c *gamePubImpl) ShopRecords(ctx context.Context, req *game.ShopRecordReq) (res *game.ShopRecordRes, err error) {
|
||
|
res, err = internal.ShopRecords(ctx, req)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
func (c *gamePubImpl) GetAuditMode(ctx context.Context, req *game.GetAuditModeReq) (res *game.GetAuditModeRes, err error) {
|
||
|
res = new(game.GetAuditModeRes)
|
||
|
|
||
|
//if 1 == internal.GetEnableHotfix(ctx, req.Channel) {
|
||
|
// res.AuditMode = 1
|
||
|
//}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
func (c *gamePubImpl) SetOpenId(ctx context.Context, req *game.SetOpenIdReq) (res *game.SetOpenIdRes, err error) {
|
||
|
res = new(game.SetOpenIdRes)
|
||
|
if req.InitUnit == 2 {
|
||
|
res, err = internal.SetOpenId(ctx, req)
|
||
|
} else if req.InitUnit == 1 {
|
||
|
internal.SetUid(ctx)
|
||
|
}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
func (c *gamePubImpl) GetOpenId(ctx context.Context, req *game.GetOpenIdReq) (res *game.GetOpenIdRes, err error) {
|
||
|
res = new(game.GetOpenIdRes)
|
||
|
res.State, err = internal.GetOpenId(ctx, req)
|
||
|
//res.State = 1
|
||
|
return
|
||
|
}
|