39 changed files with 1152 additions and 85 deletions
@ -0,0 +1,87 @@
|
||||
package game |
||||
|
||||
import ( |
||||
"github.com/gogf/gf/v2/frame/g" |
||||
"tyj_admin/internal/model/entity" |
||||
) |
||||
|
||||
type GetBattlePassReq struct { |
||||
g.Meta `path:"/battlePass/get" tags:"战令" method:"get" summary:"获取战令"` |
||||
ServerId int32 `p:"serverId"` |
||||
PeriodId int32 `p:"periodId"` |
||||
} |
||||
|
||||
type GetBattlePassRes struct { |
||||
g.Meta `mime:"application/json"` |
||||
List []map[string]interface{} `json:"list"` |
||||
} |
||||
|
||||
type CheckPeriodIdReq struct { |
||||
g.Meta `path:"/battlePass/checkPeriodId" tags:"战令" method:"get" summary:"获取战令"` |
||||
PeriodId int32 `p:"periodId"` |
||||
} |
||||
|
||||
type CheckPeriodIdRes struct { |
||||
g.Meta `mime:"application/json"` |
||||
List []map[string]interface{} `json:"list"` |
||||
} |
||||
|
||||
type UpdateBattlePassReq struct { |
||||
g.Meta `path:"/battlePass/update" tags:"战令" method:"get" summary:"更新战令"` |
||||
Id string `p:"Id"` |
||||
BeginTime string `p:"BeginTime"` |
||||
EndTime string `p:"EndTime"` |
||||
State int32 `p:"State"` |
||||
//Server int32 `p:"Server"`
|
||||
//PeriodId int32 `p:"PeriodId"`
|
||||
} |
||||
|
||||
type UpdateBattlePassRes struct { |
||||
} |
||||
|
||||
type InsertBattlePassReq struct { |
||||
g.Meta `path:"/battlePass/insert" tags:"战令" method:"get" summary:"添加战令"` |
||||
BeginTime string `p:"BeginTime"` |
||||
EndTime string `p:"EndTime"` |
||||
State int32 `p:"State"` |
||||
Server int32 `p:"Server"` |
||||
PeriodId int32 `p:"PeriodId"` |
||||
} |
||||
|
||||
type InsertBattlePassRes struct { |
||||
} |
||||
|
||||
type CheckBattlePassReq struct { |
||||
g.Meta `path:"/battlePass/check" tags:"战令" method:"get" summary:"校验战令"` |
||||
BeginTime string `p:"BeginTime"` |
||||
Server int64 `p:"Server"` |
||||
PeriodId int64 `p:"PeriodId"` |
||||
} |
||||
|
||||
type CheckBattlePassRes struct { |
||||
g.Meta `mime:"application/json"` |
||||
Total int64 `json:"total"` |
||||
} |
||||
|
||||
type InsertBattlePassLogReq struct { |
||||
g.Meta `path:"/battlePassLog/add" tags:"log接口" method:"post" summary:"操作日志"` |
||||
PeriodId int32 `p:"periodId"` |
||||
Server int32 `p:"server"` |
||||
Uid int64 `p:"unitId"` |
||||
} |
||||
|
||||
type InsertBattlePassLogRes struct { |
||||
g.Meta `mime:"application/json"` |
||||
} |
||||
|
||||
type GetBattlePassLogReq struct { |
||||
g.Meta `path:"/battlePassLog/get" tags:"log接口" method:"get" summary:"操作日志"` |
||||
PeriodId int32 `p:"periodId"` |
||||
} |
||||
|
||||
type GetBattlePassLogRes struct { |
||||
g.Meta `mime:"application/json"` |
||||
List []entity.ServerBattlePass `json:"list"` |
||||
RechargeTotal int `json:"rechargeTotal"` |
||||
Total int `json:"total"` |
||||
} |
@ -0,0 +1,43 @@
|
||||
package controller |
||||
|
||||
import ( |
||||
"context" |
||||
"tyj_admin/api/v1/game" |
||||
"tyj_admin/internal/serviceGame" |
||||
) |
||||
|
||||
var GameBattlePass = battlePassController{} |
||||
|
||||
type battlePassController struct { |
||||
BaseController |
||||
} |
||||
|
||||
func (c *battlePassController) Get(ctx context.Context, req *game.GetBattlePassReq) (res *game.GetBattlePassRes, err error) { |
||||
res, err = serviceGame.GameBattlePass().Get(ctx, req) |
||||
return |
||||
} |
||||
|
||||
func (c *battlePassController) CheckPeriodId(ctx context.Context, req *game.CheckPeriodIdReq) (res *game.CheckPeriodIdRes, err error) { |
||||
res, err = serviceGame.GameBattlePass().CheckPeriodId(ctx, req) |
||||
return |
||||
} |
||||
|
||||
func (c *battlePassController) Update(ctx context.Context, req *game.UpdateBattlePassReq) (res *game.UpdateBattlePassRes, err error) { |
||||
res, err = serviceGame.GameBattlePass().Update(ctx, req) |
||||
return |
||||
} |
||||
|
||||
func (c *battlePassController) Insert(ctx context.Context, req *game.InsertBattlePassReq) (res *game.InsertBattlePassRes, err error) { |
||||
res, err = serviceGame.GameBattlePass().Insert(ctx, req) |
||||
return |
||||
} |
||||
|
||||
func (c *battlePassController) Check(ctx context.Context, req *game.CheckBattlePassReq) (res *game.CheckBattlePassRes, err error) { |
||||
res, err = serviceGame.GameBattlePass().Check(ctx, req) |
||||
return |
||||
} |
||||
|
||||
func (c *battlePassController) GetBattlePassLog(ctx context.Context, req *game.GetBattlePassLogReq) (res *game.GetBattlePassLogRes, err error) { |
||||
res, err = serviceGame.GameBattlePass().GetBattlePassLog(ctx, req) |
||||
return |
||||
} |
@ -0,0 +1,81 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal |
||||
|
||||
import ( |
||||
"context" |
||||
|
||||
"github.com/gogf/gf/v2/database/gdb" |
||||
"github.com/gogf/gf/v2/frame/g" |
||||
) |
||||
|
||||
// ServerBattlePassDao is the data access object for table server_battle_pass.
|
||||
type ServerBattlePassDao struct { |
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of current DAO.
|
||||
columns ServerBattlePassColumns // columns contains all the column names of Table for convenient usage.
|
||||
} |
||||
|
||||
// ServerBattlePassColumns defines and stores column names for table server_battle_pass.
|
||||
type ServerBattlePassColumns struct { |
||||
Id string //
|
||||
Server string // 区服
|
||||
Uid string // 账号id
|
||||
PeriodId string // 战令期数
|
||||
CDate string // 创建时间
|
||||
} |
||||
|
||||
// serverBattlePassColumns holds the columns for table server_battle_pass.
|
||||
var serverBattlePassColumns = ServerBattlePassColumns{ |
||||
Id: "id", |
||||
Server: "server", |
||||
Uid: "uid", |
||||
PeriodId: "period_id", |
||||
CDate: "c_date", |
||||
} |
||||
|
||||
// NewServerBattlePassDao creates and returns a new DAO object for table data access.
|
||||
func NewServerBattlePassDao() *ServerBattlePassDao { |
||||
return &ServerBattlePassDao{ |
||||
group: "default", |
||||
table: "server_battle_pass", |
||||
columns: serverBattlePassColumns, |
||||
} |
||||
} |
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *ServerBattlePassDao) DB() gdb.DB { |
||||
return g.DB(dao.group) |
||||
} |
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *ServerBattlePassDao) Table() string { |
||||
return dao.table |
||||
} |
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *ServerBattlePassDao) Columns() ServerBattlePassColumns { |
||||
return dao.columns |
||||
} |
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *ServerBattlePassDao) Group() string { |
||||
return dao.group |
||||
} |
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *ServerBattlePassDao) Ctx(ctx context.Context) *gdb.Model { |
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx) |
||||
} |
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
|
||||
// It commits the transaction and returns nil if function f returns nil.
|
||||
//
|
||||
// Note that, you should not Commit or Rollback the transaction in function f
|
||||
// as it is automatically handled by this function.
|
||||
func (dao *ServerBattlePassDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) { |
||||
return dao.Ctx(ctx).Transaction(ctx, f) |
||||
} |
@ -0,0 +1,27 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package dao |
||||
|
||||
import ( |
||||
"tyj_admin/internal/dao/internal" |
||||
) |
||||
|
||||
// internalServerBattlePassDao is internal type for wrapping internal DAO implements.
|
||||
type internalServerBattlePassDao = *internal.ServerBattlePassDao |
||||
|
||||
// serverBattlePassDao is the data access object for table server_battle_pass.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type serverBattlePassDao struct { |
||||
internalServerBattlePassDao |
||||
} |
||||
|
||||
var ( |
||||
// ServerBattlePass is globally public accessible object for table server_battle_pass operations.
|
||||
ServerBattlePass = serverBattlePassDao{ |
||||
internal.NewServerBattlePassDao(), |
||||
} |
||||
) |
||||
|
||||
// Fill with you ideas below.
|
@ -0,0 +1,20 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package do |
||||
|
||||
import ( |
||||
"github.com/gogf/gf/v2/frame/g" |
||||
"github.com/gogf/gf/v2/os/gtime" |
||||
) |
||||
|
||||
// ServerBattlePass is the golang structure of table server_battle_pass for DAO operations like Where/Data.
|
||||
type ServerBattlePass struct { |
||||
g.Meta `orm:"table:server_battle_pass, do:true"` |
||||
Id interface{} //
|
||||
Server interface{} // 区服
|
||||
Uid interface{} // 账号id
|
||||
PeriodId interface{} // 战令期数
|
||||
CDate *gtime.Time // 创建时间
|
||||
} |
@ -0,0 +1,18 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package entity |
||||
|
||||
import ( |
||||
"github.com/gogf/gf/v2/os/gtime" |
||||
) |
||||
|
||||
// ServerBattlePass is the golang structure for table server_battle_pass.
|
||||
type ServerBattlePass struct { |
||||
Id int64 `json:"id" description:""` |
||||
Server int `json:"server" description:"区服"` |
||||
Uid int64 `json:"uid" description:"账号id"` |
||||
PeriodId int `json:"periodId" description:"战令期数"` |
||||
CDate *gtime.Time `json:"cDate" description:"创建时间"` |
||||
} |
@ -0,0 +1,74 @@
|
||||
package service |
||||
|
||||
import ( |
||||
"encoding/base64" |
||||
"encoding/json" |
||||
"errors" |
||||
"fmt" |
||||
"io/ioutil" |
||||
"net/http" |
||||
"net/url" |
||||
) |
||||
|
||||
type DemoConfig struct { |
||||
ClientSecret string |
||||
ClientId string |
||||
TokenUrl string |
||||
RootUrlOrder string |
||||
AccessToken string |
||||
} |
||||
|
||||
func GetDefaultConfig() *DemoConfig { |
||||
var demoConfig DemoConfig |
||||
// TODO: (clientId, clientSecret, tokenUrl)请使用实际值替换
|
||||
// App secret, 在AppGallery Connect创建应用之后,系统自动分配的公钥
|
||||
demoConfig.ClientSecret = "524921589d516c7216951aa389c030681923cd22dfc4477871f9306430eefb6d" |
||||
// client id指的是您的APP ID
|
||||
// App ID, 在AppGallery Connect创建应用之后,系统自动分配的唯一标识符
|
||||
demoConfig.ClientId = "112487401" |
||||
// 用于获取authorization token的url,具体请参见基于OAuth 2.0开放鉴权
|
||||
demoConfig.TokenUrl = "https://oauth-login.cloud.huawei.com/oauth2/v3/token" |
||||
|
||||
return &demoConfig |
||||
} |
||||
|
||||
type AtResponse struct { |
||||
AccessToken string `json:"access_token"` |
||||
} |
||||
|
||||
type AtClient struct { |
||||
} |
||||
|
||||
var AtDemo = &AtClient{} |
||||
|
||||
func (atDemo *AtClient) GetAppAt() (string, error) { |
||||
demoConfig := GetDefaultConfig() |
||||
urlValue := url.Values{"grant_type": {"client_credentials"}, "client_secret": {demoConfig.ClientSecret}, "client_id": {demoConfig.ClientId}} |
||||
resp, err := http.PostForm(demoConfig.TokenUrl, urlValue) |
||||
if err != nil { |
||||
return "", err |
||||
} |
||||
defer resp.Body.Close() |
||||
bodyBytes, err := ioutil.ReadAll(resp.Body) |
||||
if err != nil { |
||||
return "", err |
||||
} |
||||
var atResponse AtResponse |
||||
json.Unmarshal(bodyBytes, &atResponse) |
||||
if atResponse.AccessToken != "" { |
||||
return atResponse.AccessToken, nil |
||||
} else { |
||||
return "", errors.New("Get token fail, " + string(bodyBytes)) |
||||
} |
||||
} |
||||
|
||||
func BuildAuthorization() (string, error) { |
||||
appAt, err := AtDemo.GetAppAt() |
||||
if err != nil { |
||||
return "", err |
||||
} |
||||
oriString := fmt.Sprintf("APPAT:%s", appAt) |
||||
var authString = base64.StdEncoding.EncodeToString([]byte(oriString)) |
||||
var authHeaderString = fmt.Sprintf("Basic %s", authString) |
||||
return authHeaderString, nil |
||||
} |
@ -0,0 +1,58 @@
|
||||
package service |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"errors" |
||||
"fmt" |
||||
"github.com/gogf/gf/v2/encoding/gjson" |
||||
"io/ioutil" |
||||
"net/http" |
||||
"strings" |
||||
"time" |
||||
"tyj_admin/api/v1/game" |
||||
) |
||||
|
||||
func GetHuaWeiConfig() *DemoConfig { |
||||
var demoConfig DemoConfig |
||||
demoConfig.RootUrlOrder = "https://orders-drcn.iap.cloud.huawei.com.cn/applications/v1/merchantQuery" |
||||
|
||||
return &demoConfig |
||||
} |
||||
|
||||
func GetHuaWeiOrderList(continuationToken string, startAt, endAt int64) (*game.HuaWeiOrderResponse, error) { |
||||
demoConfig := GetHuaWeiConfig() |
||||
|
||||
urlValue := map[string]interface{}{ |
||||
"startAt": startAt, |
||||
"endAt": endAt, |
||||
} |
||||
if len(continuationToken) > 0 { |
||||
urlValue["continuationToken"] = continuationToken |
||||
} |
||||
|
||||
var atResponse game.HuaWeiOrderResponse |
||||
req, err := http.NewRequest("POST", demoConfig.RootUrlOrder, strings.NewReader(gjson.MustEncodeString(urlValue))) |
||||
if err != nil { |
||||
return &atResponse, err |
||||
} |
||||
auth, _ := BuildAuthorization() |
||||
req.Header.Set("Authorization", auth) |
||||
req.Header.Set("Content-Type", "application/json; charset=UTF-8") |
||||
req.Header.Set("Accept", "application/json") |
||||
client := &http.Client{Timeout: 15 * time.Second} |
||||
resp, err := client.Do(req) |
||||
if err != nil { |
||||
return nil, fmt.Errorf("API请求失败: %v", err) |
||||
} |
||||
defer resp.Body.Close() |
||||
bodyBytes, err := ioutil.ReadAll(resp.Body) |
||||
if err != nil { |
||||
return &atResponse, err |
||||
} |
||||
_ = json.Unmarshal(bodyBytes, &atResponse) |
||||
if atResponse.ResponseCode != "" { |
||||
return &atResponse, nil |
||||
} else { |
||||
return &atResponse, errors.New("Get order fail, " + string(bodyBytes)) |
||||
} |
||||
} |
@ -0,0 +1,155 @@
|
||||
package internal |
||||
|
||||
import ( |
||||
"context" |
||||
"errors" |
||||
"fmt" |
||||
"github.com/gogf/gf/v2/encoding/gcharset" |
||||
"github.com/gogf/gf/v2/encoding/gjson" |
||||
"github.com/gogf/gf/v2/frame/g" |
||||
"github.com/gogf/gf/v2/os/gtime" |
||||
"go.mongodb.org/mongo-driver/bson" |
||||
"log" |
||||
"strconv" |
||||
"time" |
||||
"tyj_admin/api/v1/game" |
||||
"tyj_admin/internal/consts" |
||||
"tyj_admin/internal/dao" |
||||
"tyj_admin/internal/model/do" |
||||
"tyj_admin/utils" |
||||
) |
||||
|
||||
func GetBattlePass(ctx context.Context, req *game.GetBattlePassReq) (res *game.GetBattlePassRes, err error) { |
||||
res = new(game.GetBattlePassRes) |
||||
filter := bson.M{} |
||||
if req.ServerId != 0 { |
||||
filter["Server"] = req.ServerId |
||||
} |
||||
if req.PeriodId != 0 { |
||||
filter["PeriodId"] = req.PeriodId |
||||
} |
||||
err = MongoDatabaseList["0"].Collection(consts.PeachAdmin_Db_Battle_pass).Find(ctx, filter).All(&res.List) |
||||
if err != nil { |
||||
return |
||||
} |
||||
for _, v := range res.List { |
||||
v["StringId"] = fmt.Sprint(v["_id"]) |
||||
} |
||||
return res, err |
||||
} |
||||
|
||||
func CheckPeriodId(ctx context.Context, req *game.CheckPeriodIdReq) (res *game.CheckPeriodIdRes, err error) { |
||||
res = new(game.CheckPeriodIdRes) |
||||
filter := bson.M{"$or": bson.A{bson.M{"PeriodId": req.PeriodId}, bson.M{"PeriodId": bson.M{"$gt": req.PeriodId}, "BeginTime": bson.M{"$lte": time.Now().Unix()}}}} |
||||
log.Printf("CheckPeriodId filter %v", gjson.MustEncodeString(filter)) |
||||
err = MongoDatabaseList["0"].Collection(consts.PeachAdmin_Db_Battle_pass).Find(ctx, filter).All(&res.List) |
||||
return |
||||
} |
||||
|
||||
func UpdateBattlePass(ctx context.Context, req *game.UpdateBattlePassReq) (err error) { |
||||
|
||||
data := bson.M{} |
||||
id, _ := strconv.ParseInt(req.Id, 10, 64) |
||||
filter := bson.M{"_id": id} |
||||
if req.BeginTime != "" { |
||||
data["BeginTime"], _ = strconv.ParseInt(req.BeginTime, 10, 64) |
||||
} |
||||
if req.EndTime != "" { |
||||
data["EndTime"], _ = strconv.ParseInt(req.EndTime, 10, 64) |
||||
} |
||||
if req.State != 0 { |
||||
data["State"] = req.State |
||||
} |
||||
err = MongoDatabaseList["0"].Collection(consts.PeachAdmin_Db_Battle_pass).UpdateOne(ctx, filter, bson.M{"$set": data}) |
||||
if req.State != 0 { |
||||
go SendMsgToC(ctx, id, req.State) |
||||
} |
||||
return |
||||
} |
||||
|
||||
func SendMsgToC(ctx context.Context, id int64, state int32) (res *game.MailSendRes, err error) { |
||||
res = new(game.MailSendRes) |
||||
filter := bson.M{"_id": id} |
||||
var list []map[string]interface{} |
||||
err = MongoDatabaseList["0"].Collection(consts.PeachAdmin_Db_Battle_pass).Find(ctx, filter).All(&list) |
||||
if len(list) == 0 { |
||||
g.Log().Info(ctx, "BattlePass SendMsgToC - req: ", gjson.MustEncodeString(list)) |
||||
return |
||||
} |
||||
|
||||
ip := ServerConfig[fmt.Sprint(list[0]["Server"])] |
||||
reqData := map[string]interface{}{"periodId": list[0]["PeriodId"], "state": state} |
||||
url := "http://" + ip + "/BattlePass?periodId=" + fmt.Sprint(list[0]["PeriodId"]) + "&state=" + fmt.Sprint(state) |
||||
srcCharset := "UTF-8" |
||||
g.Client().SetHeader("Content-Type", "application/json;charset=UTF-8") |
||||
g.Log().Info(ctx, "BattlePass SendMsgToC - req: ", url, gjson.MustEncodeString(reqData)) |
||||
bytes := g.Client().GetBytes(ctx, url) |
||||
src := string(bytes) |
||||
if g.IsEmpty(src) { |
||||
return |
||||
} |
||||
|
||||
tmp, _ := gcharset.ToUTF8(srcCharset, src) |
||||
json, err1 := gjson.DecodeToJson(tmp) |
||||
if err1 != nil { |
||||
return |
||||
} |
||||
if json.Get("Error").Int() != 200 { |
||||
return |
||||
} |
||||
|
||||
g.Log().Info(ctx, "BattlePass - success ", gjson.MustEncodeString(reqData)) |
||||
return |
||||
} |
||||
|
||||
func InsertBattlePass(ctx context.Context, req *game.InsertBattlePassReq) (err error) { |
||||
var list []map[string]interface{} |
||||
filter1 := bson.M{"Server": req.Server, "PeriodId": bson.M{"$gt": req.PeriodId}, "BeginTime": bson.M{"$lte": time.Now().Unix()}} |
||||
filter := bson.M{"$or": bson.A{bson.M{"Server": req.Server, "periodId": req.PeriodId}, filter1}} |
||||
err = MongoDatabaseList["0"].Collection(consts.PeachAdmin_Db_Battle_pass).Find(ctx, filter).All(&list) |
||||
if len(list) > 0 { |
||||
return errors.New("重复期数或永久关闭") |
||||
} |
||||
data := bson.M{} |
||||
data["_id"], _ = strconv.ParseInt(fmt.Sprintf("%d%d", gtime.TimestampMilli(), utils.RandInt(100, 999)), 10, 64) |
||||
data["State"] = req.State |
||||
data["Server"] = req.Server |
||||
data["BeginTime"], _ = strconv.ParseInt(req.BeginTime, 10, 64) |
||||
data["EndTime"], _ = strconv.ParseInt(req.EndTime, 10, 64) |
||||
data["PeriodId"] = req.PeriodId |
||||
ss, err := MongoDatabaseList["0"].Collection(consts.PeachAdmin_Db_Battle_pass).InsertOne(ctx, data) |
||||
log.Printf("InsertBattlePass %v, data: %s", ss, gjson.MustEncodeString(data)) |
||||
return |
||||
} |
||||
|
||||
func CheckBattlePass(ctx context.Context, req *game.CheckBattlePassReq) (total int64, err error) { |
||||
log.Print("CheckBattlePass", gjson.MustEncodeString(req)) |
||||
filter1 := bson.M{"$and": bson.A{bson.M{"PeriodId": req.PeriodId}, bson.M{"Server": req.Server}}} |
||||
log.Printf("CheckBattlePass filter %v", gjson.MustEncodeString(filter1)) |
||||
total, err = MongoDatabaseList["0"].Collection(consts.PeachAdmin_Db_Battle_pass).Find(ctx, filter1).Count() |
||||
if total > 0 { |
||||
err = errors.New(fmt.Sprint(req.Server) + "区期数重复配置") |
||||
return |
||||
} |
||||
//beginTime, _ := strconv.ParseInt(req.BeginTime, 10, 64)
|
||||
//log.Print("CheckBattlePass", gjson.MustEncodeString(req))
|
||||
//filter := bson.M{"$and": bson.A{bson.M{"BeginTime": bson.M{"$gte": beginTime}}, bson.M{"Server": req.Server}}}
|
||||
//log.Printf("CheckBattlePass filter %v", gjson.MustEncodeString(filter))
|
||||
//total, err = MongoDatabaseList["0"].Collection(consts.PeachAdmin_Db_Battle_pass).Find(ctx, filter).Count()
|
||||
return total, err |
||||
} |
||||
|
||||
func BattlePassLog(ctx context.Context, req *game.InsertBattlePassLogReq) (res *game.InsertBattlePassLogRes, err error) { |
||||
res = new(game.InsertBattlePassLogRes) |
||||
ss, err := dao.ServerBattlePass.Ctx(ctx).Insert(do.ServerBattlePass{Server: req.Server, Uid: req.Uid, PeriodId: req.PeriodId}) |
||||
log.Printf("InsertBattlePass %v", ss) |
||||
return |
||||
} |
||||
|
||||
func GetBattlePassLog(ctx context.Context, req *game.GetBattlePassLogReq) (res *game.GetBattlePassLogRes, err error) { |
||||
res = new(game.GetBattlePassLogRes) |
||||
err = dao.ServerBattlePass.Ctx(ctx).Where("period_id=?", req.PeriodId).Fields("count(DISTINCT uid) uid", "server").Group("server").Scan(&res.List) |
||||
res.Total, err = dao.ServerBattlePass.Ctx(ctx).Fields("DISTINCT uid").Where("period_id=?", req.PeriodId).Count() |
||||
res.RechargeTotal, err = dao.GameRecharge.Ctx(ctx).Fields("DISTINCT unitId").Where("status=?", 2).Count() |
||||
return |
||||
} |
@ -0,0 +1,68 @@
|
||||
package serviceGame |
||||
|
||||
import ( |
||||
"context" |
||||
"log" |
||||
"tyj_admin/api/v1/game" |
||||
"tyj_admin/internal/serviceGame/internal" |
||||
) |
||||
|
||||
type IGameBattlePass interface { |
||||
Get(ctx context.Context, req *game.GetBattlePassReq) (res *game.GetBattlePassRes, err error) |
||||
CheckPeriodId(ctx context.Context, req *game.CheckPeriodIdReq) (res *game.CheckPeriodIdRes, err error) |
||||
Update(ctx context.Context, req *game.UpdateBattlePassReq) (res *game.UpdateBattlePassRes, err error) |
||||
Insert(ctx context.Context, req *game.InsertBattlePassReq) (res *game.InsertBattlePassRes, err error) |
||||
Check(ctx context.Context, req *game.CheckBattlePassReq) (res *game.CheckBattlePassRes, err error) |
||||
BattlePassLog(ctx context.Context, req *game.InsertBattlePassLogReq) (res *game.InsertBattlePassLogRes, err error) |
||||
GetBattlePassLog(ctx context.Context, req *game.GetBattlePassLogReq) (res *game.GetBattlePassLogRes, err error) |
||||
} |
||||
|
||||
type gameBattlePassImpl struct { |
||||
} |
||||
|
||||
var gameBattlePassService = gameBattlePassImpl{} |
||||
|
||||
func GameBattlePass() IGameBattlePass { |
||||
return &gameBattlePassService |
||||
} |
||||
|
||||
func (g *gameBattlePassImpl) Get(ctx context.Context, req *game.GetBattlePassReq) (res *game.GetBattlePassRes, err error) { |
||||
res, err = internal.GetBattlePass(ctx, req) |
||||
return |
||||
} |
||||
|
||||
func (g *gameBattlePassImpl) CheckPeriodId(ctx context.Context, req *game.CheckPeriodIdReq) (res *game.CheckPeriodIdRes, err error) { |
||||
res, err = internal.CheckPeriodId(ctx, req) |
||||
return |
||||
} |
||||
|
||||
func (g *gameBattlePassImpl) Update(ctx context.Context, req *game.UpdateBattlePassReq) (res *game.UpdateBattlePassRes, err error) { |
||||
err = internal.UpdateBattlePass(ctx, req) |
||||
log.Print("UpdateBattlePass: ", err) |
||||
return |
||||
} |
||||
|
||||
func (g *gameBattlePassImpl) Insert(ctx context.Context, req *game.InsertBattlePassReq) (res *game.InsertBattlePassRes, err error) { |
||||
err = internal.InsertBattlePass(ctx, req) |
||||
log.Print("InsertBattlePass: ", err) |
||||
return |
||||
} |
||||
|
||||
func (g *gameBattlePassImpl) Check(ctx context.Context, req *game.CheckBattlePassReq) (res *game.CheckBattlePassRes, err error) { |
||||
res = new(game.CheckBattlePassRes) |
||||
res.Total, err = internal.CheckBattlePass(ctx, req) |
||||
log.Print("CheckBattlePass: ", err) |
||||
return |
||||
} |
||||
|
||||
func (g *gameBattlePassImpl) BattlePassLog(ctx context.Context, req *game.InsertBattlePassLogReq) (res *game.InsertBattlePassLogRes, err error) { |
||||
res, err = internal.BattlePassLog(ctx, req) |
||||
log.Print("InsertBattlePass: ", err) |
||||
return |
||||
} |
||||
|
||||
func (g *gameBattlePassImpl) GetBattlePassLog(ctx context.Context, req *game.GetBattlePassLogReq) (res *game.GetBattlePassLogRes, err error) { |
||||
res, err = internal.GetBattlePassLog(ctx, req) |
||||
log.Print("GetBattlePassLog: ", err) |
||||
return |
||||
} |
@ -0,0 +1,14 @@
|
||||
-----BEGIN CERTIFICATE----- |
||||
MIICGjCCAaGgAwIBAgIIShhpn519jNAwCgYIKoZIzj0EAwMwUzELMAkGA1UEBhMC |
||||
Q04xDzANBgNVBAoMBkh1YXdlaTETMBEGA1UECwwKSHVhd2VpIENCRzEeMBwGA1UE |
||||
AwwVSHVhd2VpIENCRyBSb290IENBIEcyMB4XDTIwMDMxNjAzMDQzOVoXDTQ5MDMx |
||||
NjAzMDQzOVowUzELMAkGA1UEBhMCQ04xDzANBgNVBAoMBkh1YXdlaTETMBEGA1UE |
||||
CwwKSHVhd2VpIENCRzEeMBwGA1UEAwwVSHVhd2VpIENCRyBSb290IENBIEcyMHYw |
||||
EAYHKoZIzj0CAQYFK4EEACIDYgAEWidkGnDSOw3/HE2y2GHl+fpWBIa5S+IlnNrs |
||||
GUvwC1I2QWvtqCHWmwFlFK95zKXiM8s9yV3VVXh7ivN8ZJO3SC5N1TCrvB2lpHMB |
||||
wcz4DA0kgHCMm/wDec6kOHx1xvCRo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0T |
||||
AQH/BAUwAwEB/zAdBgNVHQ4EFgQUo45a9Vq8cYwqaiVyfkiS4pLcIAAwCgYIKoZI |
||||
zj0EAwMDZwAwZAIwMypeB7P0IbY7c6gpWcClhRznOJFj8uavrNu2PIoz9KIqr3jn |
||||
BlBHJs0myI7ntYpEAjBbm8eDMZY5zq5iMZUC6H7UzYSix4Uy1YlsLVV738PtKP9h |
||||
FTjgDHctXJlC5L7+ZDY= |
||||
-----END CERTIFICATE----- |
Loading…
Reference in new issue