|
|
|
package controller
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"github.com/gogf/gf/v2/encoding/gjson"
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
|
|
"log"
|
|
|
|
"tyj_admin/api/v1/game"
|
|
|
|
"tyj_admin/internal/model/entity"
|
|
|
|
"tyj_admin/internal/service"
|
|
|
|
"tyj_admin/internal/serviceGame"
|
|
|
|
"tyj_admin/library/libUtils"
|
|
|
|
"tyj_admin/library/liberr"
|
|
|
|
)
|
|
|
|
|
|
|
|
var GamePub = pubController{}
|
|
|
|
|
|
|
|
type pubController struct {
|
|
|
|
BaseController
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) Get(ctx context.Context, req *game.GetGameNoticeReq) (res *game.GetGameNoticeRes, err error) {
|
|
|
|
res, err = serviceGame.GameNotice().GetGameNotice(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) GetList(ctx context.Context, req *game.GetGameNoticeListReq) (res *game.GetGameNoticeListRes, err error) {
|
|
|
|
res, err = serviceGame.GameNotice().GetGameNoticeList(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) GetUpdateUrl(ctx context.Context, req *game.GetGameUpdateUrlReq) (res *game.GetGameUpdateUrlRes, err error) {
|
|
|
|
config := new(entity.SysConfig)
|
|
|
|
res = new(game.GetGameUpdateUrlRes)
|
|
|
|
config, err = service.Config().GetByKey(ctx, req.Channel+"_url")
|
|
|
|
if err == nil && config != nil {
|
|
|
|
res.Url = config.ConfigValue
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) GetLoginUrl(ctx context.Context, req *game.GetGameLoginUrlReq) (res *game.GetGameLoginUrlRes, err error) {
|
|
|
|
res, err = serviceGame.GameLoginUrl().GetGameLoginUrl(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) GetCCD(ctx context.Context, req *game.GetGameCCDReq) (res *game.GetGameCCDRes, err error) {
|
|
|
|
var set map[string]struct{}
|
|
|
|
set = make(map[string]struct{})
|
|
|
|
set["Android"] = struct{}{}
|
|
|
|
set["Ios"] = struct{}{}
|
|
|
|
set["Editor"] = struct{}{}
|
|
|
|
|
|
|
|
err = g.Try(ctx, func(ctx context.Context) {
|
|
|
|
if _, ok := set[req.Platform]; !ok {
|
|
|
|
liberr.ErrIsNil(ctx, err, "平台输入错误")
|
|
|
|
fmt.Println("err ", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
res, err = serviceGame.GameCCD().GetGameCCD(ctx, req)
|
|
|
|
g.Log().Debugf(ctx, "GetGameCCD -> "+res.Url, "Version: "+res.Version)
|
|
|
|
return
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) GetCCD1(ctx context.Context, req *game.GetGameCCD1Req) (res *game.GetGameCCD1Res, err error) {
|
|
|
|
var set map[string]struct{}
|
|
|
|
set = make(map[string]struct{})
|
|
|
|
set["Android"] = struct{}{}
|
|
|
|
set["Ios"] = struct{}{}
|
|
|
|
set["Editor"] = struct{}{}
|
|
|
|
|
|
|
|
err = g.Try(ctx, func(ctx context.Context) {
|
|
|
|
if _, ok := set[req.Platform]; !ok {
|
|
|
|
liberr.ErrIsNil(ctx, err, "平台输入错误")
|
|
|
|
fmt.Println("err ", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
res, err = serviceGame.GameCCD().GetGameCCD1(ctx, req)
|
|
|
|
g.Log().Debugf(ctx, "GetGameCCD -> ", "Version: "+res.Version)
|
|
|
|
return
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) GetWhiteState(ctx context.Context, req *game.GetWhiteListReq) (res *game.GetWhiteListRes, err error) {
|
|
|
|
err = g.Try(ctx, func(ctx context.Context) {
|
|
|
|
ip := libUtils.GetClientIp(ctx)
|
|
|
|
//fmt.Println("ip: ", ip)
|
|
|
|
res = new(game.GetWhiteListRes)
|
|
|
|
res.Count = serviceGame.GameWhiteList().GetWhiteState(ctx, ip)
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) GetWhiteList(ctx context.Context, req *game.WhiteListReq) (res *game.WhiteListRes, err error) {
|
|
|
|
err = g.Try(ctx, func(ctx context.Context) {
|
|
|
|
res = serviceGame.GameWhiteList().GetWhiteList(ctx)
|
|
|
|
log.Printf("res.WhiteList: %v", res)
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) LoginOut(ctx context.Context, req *game.LoginOutReq) (res *game.LoginOutRes, err error) {
|
|
|
|
err = g.Try(ctx, func(ctx context.Context) {
|
|
|
|
res = new(game.LoginOutRes)
|
|
|
|
res, err = serviceGame.GamePub().LoginOut(ctx, req)
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) GameRegister(ctx context.Context, req *game.RegisterReq) (res *game.RegisterRes, err error) {
|
|
|
|
err = g.Try(ctx, func(ctx context.Context) {
|
|
|
|
res = new(game.RegisterRes)
|
|
|
|
res, err = serviceGame.GameRole().GameRegister(ctx, req)
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) ItemIncomeExpenseRecords(ctx context.Context, req *game.ItemRecordReq) (res *game.ItemRecordRes, err error) {
|
|
|
|
err = g.Try(ctx, func(ctx context.Context) {
|
|
|
|
res = new(game.ItemRecordRes)
|
|
|
|
res, err = serviceGame.GamePub().ItemRecord(ctx, req)
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) ShopRecords(ctx context.Context, req *game.ShopRecordReq) (res *game.ShopRecordRes, err error) {
|
|
|
|
err = g.Try(ctx, func(ctx context.Context) {
|
|
|
|
res = new(game.ShopRecordRes)
|
|
|
|
res, err = serviceGame.GamePub().ShopRecords(ctx, req)
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) GetAuditMode(ctx context.Context, req *game.GetAuditModeReq) (res *game.GetAuditModeRes, err error) {
|
|
|
|
err = g.Try(ctx, func(ctx context.Context) {
|
|
|
|
res = new(game.GetAuditModeRes)
|
|
|
|
res, err = serviceGame.GamePub().GetAuditMode(ctx, req)
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) GameUnitChangeName(ctx context.Context, req *game.UnitChangeNameReq) (res *game.UnitChangeNameRes, err error) {
|
|
|
|
g.Log().Info(ctx, "GameUnitChangeName - json: ", gjson.MustEncodeString(req))
|
|
|
|
res, err = serviceGame.GameRole().GameUnitChangeName(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) RechargeControl(ctx context.Context, req *game.RechargeControlReq) (res *game.RechargeControlRes, err error) {
|
|
|
|
res, err = serviceGame.GameOrder().GameRechargeControl(ctx, req)
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) GetGenerateCode(ctx context.Context, req *game.GetGenerateCodeReq) (res *game.GetGenerateCodeRes, err error) {
|
|
|
|
res, err = serviceGame.GameCdKey().GetGenerateCode(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) Advertise(ctx context.Context, req *game.ADReq) (res *game.ADRes, err error) {
|
|
|
|
res, err = serviceGame.Advertisement().Advertise(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) DeepAdvertise(ctx context.Context, req *game.DeepADReq) (res *game.DeepADRes, err error) {
|
|
|
|
res, err = serviceGame.Advertisement().DeepAdvertise(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) SetOpenId(ctx context.Context, req *game.SetOpenIdReq) (res *game.SetOpenIdRes, err error) {
|
|
|
|
res, err = serviceGame.GamePub().SetOpenId(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) GetOpenId(ctx context.Context, req *game.GetOpenIdReq) (res *game.GetOpenIdRes, err error) {
|
|
|
|
res, err = serviceGame.GamePub().GetOpenId(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) AddClientBug(ctx context.Context, req *game.ClientBugAddReq) (res *game.ClientBugAddRes, err error) {
|
|
|
|
res, err = serviceGame.GameClientBug().Add(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) AddGenerateCode(ctx context.Context, req *game.AddGenerateCodeReq) (res *game.AddGenerateCodeRes, err error) {
|
|
|
|
res, err = serviceGame.GameCdKey().AddGenerateCode(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) SetGmToClient(ctx context.Context, req *game.SetGmToClientReq) (res *game.SetGmToClientRes, err error) {
|
|
|
|
res, err = serviceGame.GameManage().SetGmToClient(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) GetServerConfig(ctx context.Context, req *game.GetServerConfigReq) (res *game.GetServerConfigRes, err error) {
|
|
|
|
res, err = serviceGame.GamePub().GetServerConfig(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) CheckFirstRebate(ctx context.Context, req *game.CheckFirstRebateReq) (res *game.CheckFirstRebateRes, err error) {
|
|
|
|
res, err = serviceGame.GamePub().CheckFirstRebate(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) CheckSecondRebate(ctx context.Context, req *game.CheckSecondRebateReq) (res *game.CheckSecondRebateRes, err error) {
|
|
|
|
res, err = serviceGame.GamePub().CheckSecondRebate(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) CheckRechargeSign(ctx context.Context, req *game.CheckRechargeSignReq) (res *game.CheckRechargeSignRes, err error) {
|
|
|
|
res, err = serviceGame.GameOrder().CheckRechargeSign(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) AddRechargeSign(ctx context.Context, req *game.AddRechargeSignReq) (res *game.AddRechargeSignRes, err error) {
|
|
|
|
res, err = serviceGame.GameOrder().AddRechargeSign(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) GetTransactionId(ctx context.Context, req *game.GetTransactionIdReq) (res *game.GetTransactionIdRes, err error) {
|
|
|
|
res, err = serviceGame.GameOrder().GetTransactionId(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) AttributionHugeAmount(ctx context.Context, req *game.ATHAReq) (res *game.ATHARes, err error) {
|
|
|
|
res, err = serviceGame.Advertisement().AttributionHugeAmount(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) ConversionHugeAmount(ctx context.Context, req *game.CSHAReq) (res *game.CSHARes, err error) {
|
|
|
|
res, err = serviceGame.Advertisement().ConversionHugeAmount(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) AdvertiseHugeAmount(ctx context.Context, req *game.AdvertiseHAReq) (res *game.AdvertiseHARes, err error) {
|
|
|
|
log.Print("AdvertiseHugeAmount", gjson.MustEncodeString(req))
|
|
|
|
res, err = serviceGame.Advertisement().AdvertiseHugeAmount(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) AdvertiseHugeAmount1(ctx context.Context, req *game.AdvertiseHA1Req) (res *game.AdvertiseHA1Res, err error) {
|
|
|
|
log.Print("AdvertiseHugeAmount1", gjson.MustEncodeString(req))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) AdvertiseHugeAmount2(ctx context.Context, req *game.AdvertiseHA2Req) (res *game.AdvertiseHA2Res, err error) {
|
|
|
|
log.Print("AdvertiseHugeAmount2", gjson.MustEncodeString(req))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) AdvertiseHugeAmount3(ctx context.Context, req *game.AdvertiseHA3Req) (res *game.AdvertiseHA3Res, err error) {
|
|
|
|
log.Print("AdvertiseHugeAmount3", gjson.MustEncodeString(req))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) AdvertiseHugeAmount4(ctx context.Context, req *game.AdvertiseHA4Req) (res *game.AdvertiseHA4Res, err error) {
|
|
|
|
log.Print("AdvertiseHugeAmount4", gjson.MustEncodeString(req))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *pubController) AdvertiseHugeAmount5(ctx context.Context, req *game.AdvertiseHA5Req) (res *game.AdvertiseHA5Res, err error) {
|
|
|
|
log.Print("AdvertiseHugeAmount5", gjson.MustEncodeString(req))
|
|
|
|
return
|
|
|
|
}
|