调整接口
This commit is contained in:
15
api/statistic/statistic.go
Normal file
15
api/statistic/statistic.go
Normal file
@ -0,0 +1,15 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package statistic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"server/api/statistic/v1"
|
||||
)
|
||||
|
||||
type IStatisticV1 interface {
|
||||
GetOnlineDevice(ctx context.Context, req *v1.GetOnlineDeviceReq) (res *v1.GetOnlineDeviceRes, err error)
|
||||
}
|
||||
11
api/statistic/v1/statistic.go
Normal file
11
api/statistic/v1/statistic.go
Normal file
@ -0,0 +1,11 @@
|
||||
package v1
|
||||
|
||||
import "github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
type GetOnlineDeviceReq struct {
|
||||
g.Meta `path:"/statistic/onlineDevice" method:"get" tags:"Statistic" summary:"获取门店设备在线列表"`
|
||||
NetbarAccount string `json:"netbarAccount" v:"required#网吧网关账号不能为空" dc:"网吧网关账号"`
|
||||
}
|
||||
type GetOnlineDeviceRes struct {
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
@ -19,4 +19,5 @@ type IStoreV1 interface {
|
||||
DeleteIp(ctx context.Context, req *v1.DeleteIpReq) (res *v1.DeleteIpRes, err error)
|
||||
UpdateIp(ctx context.Context, req *v1.UpdateIpReq) (res *v1.UpdateIpRes, err error)
|
||||
GetIpList(ctx context.Context, req *v1.GetIpListReq) (res *v1.GetIpListRes, err error)
|
||||
Detail(ctx context.Context, req *v1.DetailReq) (res *v1.DetailRes, err error)
|
||||
}
|
||||
|
||||
@ -86,3 +86,10 @@ type GetIpListRes struct {
|
||||
List interface{} `json:"list" dc:"IP列表"`
|
||||
Total int64 `json:"total" dc:"总数"`
|
||||
}
|
||||
type DetailReq struct {
|
||||
g.Meta `path:"/store/detail" method:"get" tags:"Store" summary:"(系统、商户门店后台)门店详情"`
|
||||
NetbarAccount string `json:"netbarAccount" v:"required" dc:"门店账号"`
|
||||
}
|
||||
type DetailRes struct {
|
||||
Id int64 `json:"id" dc:"门店ID"`
|
||||
}
|
||||
|
||||
@ -4,7 +4,8 @@ import "github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
type RankingReq struct {
|
||||
g.Meta `path:"/task/ranking" method:"get" tags:"Task" summary:"(PC)任务排行榜"`
|
||||
StoreId int `json:"storeId" v:"required#请选择店铺" dc:"门店id"`
|
||||
StoreId int `json:"storeId" dc:"门店id"`
|
||||
NetBarAccount string `json:"netBarAccount" dc:"网关账号"`
|
||||
Page int `json:"page" dc:"页数"`
|
||||
Size int `json:"size" dc:"条数"`
|
||||
Type int `json:"type" v:"required#请选择排行榜类型" dc:"排行榜类型"`
|
||||
@ -75,7 +76,8 @@ type SelectorRes struct {
|
||||
type GetTaskReq struct {
|
||||
g.Meta `path:"/task/get" method:"post" tags:"Task" summary:"(PC)任务领取"`
|
||||
TaskId int `json:"taskId" v:"required#任务id不能为空" dc:"任务id"`
|
||||
StoreId int `json:"storeId" v:"required#门店 id不能为空" dc:"门店 id"`
|
||||
StoreId int `json:"storeId" dc:"门店 id、网关账号必传一个"`
|
||||
NetBarAccount string `json:"netBarAccount" dc:"门店 id、网关账号必传一个"`
|
||||
GameId int `json:"gid" v:"required#游戏唯一id不能为空" dc:"游戏唯一id"`
|
||||
TaskName string `json:"taskName" v:"required#任务名称不能为空" dc:"任务名称"`
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ import (
|
||||
"server/internal/controller/reward"
|
||||
"server/internal/controller/rewardType"
|
||||
"server/internal/controller/role"
|
||||
"server/internal/controller/statistic"
|
||||
"server/internal/controller/store"
|
||||
"server/internal/controller/storeAdmin"
|
||||
"server/internal/controller/storeRole"
|
||||
@ -58,6 +59,7 @@ var (
|
||||
rewardType.NewV1(),
|
||||
reward.NewV1(),
|
||||
desktop.NewV1(),
|
||||
statistic.NewV1(),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@ -20,3 +20,8 @@ const (
|
||||
const (
|
||||
WechatAccessTokenKey = "wechat:access_token"
|
||||
)
|
||||
|
||||
const (
|
||||
NetbarOnlineNumberKey = "%s:online:device:%s"
|
||||
NetbarOnlineDeviceSetKey = "%s:online_devices"
|
||||
)
|
||||
|
||||
5
internal/controller/statistic/statistic.go
Normal file
5
internal/controller/statistic/statistic.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package statistic
|
||||
15
internal/controller/statistic/statistic_new.go
Normal file
15
internal/controller/statistic/statistic_new.go
Normal file
@ -0,0 +1,15 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package statistic
|
||||
|
||||
import (
|
||||
"server/api/statistic"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() statistic.IStatisticV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package statistic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/consts"
|
||||
|
||||
"server/api/statistic/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) GetOnlineDevice(ctx context.Context, req *v1.GetOnlineDeviceReq) (res *v1.GetOnlineDeviceRes, err error) {
|
||||
card, err := g.Redis().SCard(ctx, fmt.Sprintf(consts.NetbarOnlineDeviceSetKey, req.NetbarAccount))
|
||||
return &v1.GetOnlineDeviceRes{Total: card}, err
|
||||
}
|
||||
17
internal/controller/store/store_v1_detail.go
Normal file
17
internal/controller/store/store_v1_detail.go
Normal file
@ -0,0 +1,17 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/store/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Detail(ctx context.Context, req *v1.DetailReq) (res *v1.DetailRes, err error) {
|
||||
out, err := service.Store().Detail(ctx, &model.StoreDetailIn{NetbarAccount: req.NetbarAccount})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.DetailRes{Id: out.Id}, nil
|
||||
}
|
||||
@ -15,6 +15,7 @@ func (c *ControllerV1) GetTask(ctx context.Context, req *v1.GetTaskReq) (res *v1
|
||||
out, err := service.Task().GetTask(ctx, &model.GetTaskIn{
|
||||
TaskId: req.TaskId,
|
||||
StoreId: req.StoreId,
|
||||
NetBarAccount: req.NetBarAccount,
|
||||
UserId: userId,
|
||||
GameId: req.GameId,
|
||||
TaskName: req.TaskName,
|
||||
|
||||
@ -16,6 +16,7 @@ func (c *ControllerV1) Ranking(ctx context.Context, req *v1.RankingReq) (res *v1
|
||||
Page: req.Page,
|
||||
Size: req.Size,
|
||||
StoreId: req.StoreId,
|
||||
NetBarAccount: req.NetBarAccount,
|
||||
Type: req.Type,
|
||||
OperatorId: operatorId,
|
||||
})
|
||||
|
||||
@ -263,3 +263,16 @@ func (s *sStore) DeleteIP(ctx context.Context, in *model.IPDeleteIn) (*model.IPD
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *sStore) Detail(ctx context.Context, in *model.StoreDetailIn) (out *model.StoreDetailOut, err error) {
|
||||
one, err := dao.Stores.Ctx(ctx).Where(do.Stores{NetbarAccount: in.NetbarAccount}).One()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询门店出现异常")
|
||||
}
|
||||
if one.IsEmpty() {
|
||||
return nil, ecode.Params.Sub("门店不存在")
|
||||
}
|
||||
return &model.StoreDetailOut{
|
||||
Id: one[dao.Stores.Columns().Id].Int64(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -13,10 +13,17 @@ import (
|
||||
)
|
||||
|
||||
type sStoreDesktopSetting struct {
|
||||
mqttCLient mqtt.MqttClient
|
||||
}
|
||||
|
||||
func New() service.IStoreDesktopSetting {
|
||||
return &sStoreDesktopSetting{}
|
||||
client, b := mqtt.GetClient("emqx")
|
||||
if !b {
|
||||
return nil
|
||||
}
|
||||
return &sStoreDesktopSetting{
|
||||
mqttCLient: client,
|
||||
}
|
||||
}
|
||||
func init() {
|
||||
service.RegisterStoreDesktopSetting(New())
|
||||
@ -63,15 +70,11 @@ func (s *sStoreDesktopSetting) Save(ctx context.Context, in model.SaveDesktopSet
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client, b := mqtt.GetClient("emqx")
|
||||
if !b {
|
||||
return nil, gerror.New("获取MQTT客户端失败")
|
||||
}
|
||||
marshal, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = client.Publish(fmt.Sprintf("/desktop/%d", in.StoreId), marshal)
|
||||
err = s.mqttCLient.Publish(fmt.Sprintf("/desktop/%d", in.StoreId), marshal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -76,6 +76,17 @@ func (s *sTask) UserTaskRankingList(ctx context.Context, in *model.UserTaskRanki
|
||||
|
||||
if in.StoreId > 0 {
|
||||
m = m.Where(dao.UserTasks.Columns().StoreId, in.StoreId)
|
||||
} else if in.NetBarAccount != "" && in.StoreId <= 0 {
|
||||
value, err := dao.Stores.Ctx(ctx).Where(dao.Stores.Columns().NetbarAccount, in.NetBarAccount).Fields(dao.Stores.Columns().Id).Value()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询门店ID失败")
|
||||
}
|
||||
if value.IsEmpty() {
|
||||
return nil, ecode.Fail.Sub("门店不存在")
|
||||
}
|
||||
|
||||
m = m.Where(dao.UserTasks.Columns().StoreId, value.Int())
|
||||
|
||||
}
|
||||
|
||||
list := make([]model.UserTaskRankingArgs, 0)
|
||||
@ -302,9 +313,22 @@ func (s *sTask) GetSelectorList(ctx context.Context, in *model.SelectorIn) (out
|
||||
|
||||
// GetTask 完成任务
|
||||
func (s *sTask) GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.GetTaskOut, err error) {
|
||||
|
||||
var storeId int
|
||||
if in.StoreId > 0 {
|
||||
storeId = in.StoreId
|
||||
} else if in.NetBarAccount != "" && in.StoreId <= 0 {
|
||||
value, err := dao.Stores.Ctx(ctx).Where(do.Stores{NetbarAccount: in.NetBarAccount}).Fields(dao.Stores.Columns().Id).Value()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("获取门店ID异常")
|
||||
}
|
||||
if value.IsEmpty() {
|
||||
return nil, ecode.Fail.Sub("获取门店ID异常")
|
||||
}
|
||||
storeId = value.Int()
|
||||
}
|
||||
var userTask []*model.UserTask
|
||||
err = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{UserId: in.UserId, TaskId: in.TaskId, StoreId: in.StoreId, GameId: in.GameId}).WhereNot("status", 3).Scan(&userTask)
|
||||
|
||||
err = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{UserId: in.UserId, TaskId: in.TaskId, StoreId: storeId, GameId: in.GameId}).WhereNot("status", 3).Scan(&userTask)
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询用户该任务记录失败")
|
||||
}
|
||||
@ -323,7 +347,7 @@ func (s *sTask) GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.Ge
|
||||
_, err = dao.UserTasks.Ctx(ctx).Insert(do.UserTasks{
|
||||
UserId: in.UserId,
|
||||
TaskId: in.TaskId,
|
||||
StoreId: in.StoreId,
|
||||
StoreId: storeId,
|
||||
Status: 1,
|
||||
SerialNumber: serialNumber,
|
||||
TaskName: in.TaskName,
|
||||
|
||||
@ -110,3 +110,9 @@ type IPCreateIn struct {
|
||||
type IPCreateOut struct {
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
type StoreDetailIn struct {
|
||||
NetbarAccount string
|
||||
}
|
||||
type StoreDetailOut struct {
|
||||
Id int64 `json:"id"`
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@ type UserTaskRankingIn struct {
|
||||
Page int
|
||||
Size int
|
||||
StoreId int
|
||||
NetBarAccount string
|
||||
Type int // 排行榜类型 1:日 2:周 3:月
|
||||
OperatorId int
|
||||
}
|
||||
@ -60,6 +61,7 @@ type LoginUserRankingNum struct {
|
||||
type GetTaskIn struct {
|
||||
TaskId int `json:"taskId"`
|
||||
StoreId int `json:"storeId"`
|
||||
NetBarAccount string `json:"netBarAccount"`
|
||||
UserId int `json:"userId"`
|
||||
TaskName string `json:"taskName"`
|
||||
GameId int `json:"gid"`
|
||||
|
||||
@ -4,7 +4,7 @@ import (
|
||||
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
|
||||
_ "github.com/gogf/gf/contrib/nosql/redis/v2"
|
||||
_ "server/utility/gamelife"
|
||||
//_ "server/utility/mqtt/emqx"
|
||||
_ "server/utility/mqtt/emqx"
|
||||
_ "server/utility/myCasbin"
|
||||
_ "server/utility/oss/aliyun"
|
||||
_ "server/utility/rsa"
|
||||
|
||||
@ -18,6 +18,7 @@ type (
|
||||
Update(ctx context.Context, in *model.RewardUpdateIn) (out *model.RewardUpdateOut, err error)
|
||||
// Delete 删除奖励
|
||||
Delete(ctx context.Context, in *model.RewardDeleteIn) (out *model.RewardDeleteOut, err error)
|
||||
// List 奖励列表
|
||||
List(ctx context.Context, in *model.RewardListIn) (out *model.RewardListOut, err error)
|
||||
// GetLift 领取奖励
|
||||
GetLift(ctx context.Context, in *model.GetRewardIn) (out *model.GetRewardOut, err error)
|
||||
|
||||
@ -22,6 +22,7 @@ type (
|
||||
CreateIP(ctx context.Context, in *model.IPCreateIn) (*model.IPCreateOut, error)
|
||||
UpdateIP(ctx context.Context, in *model.IPUpdateIn) (*model.IPUpdateOut, error)
|
||||
DeleteIP(ctx context.Context, in *model.IPDeleteIn) (*model.IPDeleteOut, error)
|
||||
Detail(ctx context.Context, in *model.StoreDetailIn) (out *model.StoreDetailOut, err error)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -133,6 +133,8 @@ func init() {
|
||||
enforcer.AddPolicy("store", "/x/store/del/*", "DELETE", "删除门店 ip信息")
|
||||
enforcer.AddPolicy("store", "/x/store/updateIp", "PUT", "修改门店 ip信息")
|
||||
|
||||
// statistics
|
||||
enforcer.AddPolicy("store", "/x/statistic/onlineDevice", "GET", "获取门店在线设备列表")
|
||||
}
|
||||
// 商户
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user