Merge remote-tracking branch 'origin/master'
# Conflicts: # internal/dao/internal/rewards.go # internal/model/do/rewards.go # internal/model/entity/rewards.go
This commit is contained in:
@ -27,8 +27,8 @@ type CreateReq struct {
|
|||||||
RewardTypeId int64 `json:"rewardTypeId" v:"required#奖励类型ID不能为空" dc:"奖励类型ID"`
|
RewardTypeId int64 `json:"rewardTypeId" v:"required#奖励类型ID不能为空" dc:"奖励类型ID"`
|
||||||
GameId int64 `json:"gameId" dc:"游戏ID"`
|
GameId int64 `json:"gameId" dc:"游戏ID"`
|
||||||
RewardImg string `json:"rewardImg" dc:"奖励图片"`
|
RewardImg string `json:"rewardImg" dc:"奖励图片"`
|
||||||
QQGoodsId string `json:"qqGoodsId" v:"required#不能为空" dc:"QQ网吧物品ID"`
|
QQGoodsId string `json:"qqGoodsId" dc:"QQ网吧物品ID"`
|
||||||
QQGoodsIdStr string `json:"qqGoodsIdStr" v:"required#不能为空" dc:"QQ网吧物品ID字符串"`
|
QQGoodsIdStr string `json:"qqGoodsIdStr" dc:"QQ网吧物品ID字符串"`
|
||||||
Status int `json:"status" dc:"状态" d:"1:启用 2:禁用"`
|
Status int `json:"status" dc:"状态" d:"1:启用 2:禁用"`
|
||||||
ExpireType int `json:"expireType" v:"required#过期类型只能为1或2" dc:"过期类型"`
|
ExpireType int `json:"expireType" v:"required#过期类型只能为1或2" dc:"过期类型"`
|
||||||
ValidFrom *gtime.Time `json:"validFrom" dc:"有效开始时间(expire_type=1 时使用)"`
|
ValidFrom *gtime.Time `json:"validFrom" dc:"有效开始时间(expire_type=1 时使用)"`
|
||||||
|
|||||||
@ -17,4 +17,5 @@ type ITaskV1 interface {
|
|||||||
List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error)
|
List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error)
|
||||||
Selector(ctx context.Context, req *v1.SelectorReq) (res *v1.SelectorRes, err error)
|
Selector(ctx context.Context, req *v1.SelectorReq) (res *v1.SelectorRes, err error)
|
||||||
GetTask(ctx context.Context, req *v1.GetTaskReq) (res *v1.GetTaskRes, err error)
|
GetTask(ctx context.Context, req *v1.GetTaskReq) (res *v1.GetTaskRes, err error)
|
||||||
|
GetUserTaskRecordsList(ctx context.Context, req *v1.GetUserTaskRecordsListReq) (res *v1.GetUserTaskRecordsListRes, err error)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,13 +75,28 @@ type SelectorRes struct {
|
|||||||
// GetTaskReq 添加任务记录
|
// GetTaskReq 添加任务记录
|
||||||
type GetTaskReq struct {
|
type GetTaskReq struct {
|
||||||
g.Meta `path:"/task/get" method:"post" tags:"Task" summary:"(PC)任务领取"`
|
g.Meta `path:"/task/get" method:"post" tags:"Task" summary:"(PC)任务领取"`
|
||||||
TaskId int `json:"taskId" v:"required#任务id不能为空" dc:"任务id"`
|
TaskId string `json:"taskId" v:"required#任务id不能为空" dc:"任务id"`
|
||||||
StoreId int `json:"storeId" dc:"门店 id、网关账号必传一个"`
|
StoreId int `json:"storeId" dc:"门店 id、网关账号必传一个"`
|
||||||
NetBarAccount string `json:"netBarAccount" dc:"门店 id、网关账号必传一个"`
|
NetBarAccount string `json:"netBarAccount" dc:"门店 id、网关账号必传一个"`
|
||||||
GameId int `json:"gid" v:"required#游戏唯一id不能为空" dc:"游戏唯一id"`
|
GameId int `json:"gameId" v:"required#游戏唯一id不能为空" dc:"游戏唯一id"`
|
||||||
TaskName string `json:"taskName" v:"required#任务名称不能为空" dc:"任务名称"`
|
TaskName string `json:"taskName" v:"required#任务名称不能为空" dc:"任务名称"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetTaskRes struct {
|
type GetTaskRes struct {
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetUserTaskRecordsListReq struct {
|
||||||
|
g.Meta `path:"/task/records" method:"get" tags:"Task" summary:"(PC)用户任务记录列表"`
|
||||||
|
TaskId string `json:"taskId" dc:"任务 id"`
|
||||||
|
StoreId int `json:"storeId" dc:"门店 id"`
|
||||||
|
NetbarAccount string `json:"netbarAccount" dc:"网关账号"`
|
||||||
|
Page int `json:"page" dc:"页数"`
|
||||||
|
Size int `json:"size" dc:"条数"`
|
||||||
|
StartTime int32 `json:"startTime" dc:"开始时间"`
|
||||||
|
EndTime int32 `json:"endTime" dc:"结束时间"`
|
||||||
|
}
|
||||||
|
type GetUserTaskRecordsListRes struct {
|
||||||
|
List interface{} `json:"list"`
|
||||||
|
Total int `json:"total"`
|
||||||
|
}
|
||||||
|
|||||||
@ -22,6 +22,6 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
NetbarOnlineNumberKey = "%s:online:device:%s"
|
NetbarOnlineNumberKey = "%s:online_number"
|
||||||
NetbarOnlineDeviceSetKey = "%s:online_devices"
|
OnlineDeviceSetKey = "online:devices"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -20,13 +20,11 @@ func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListR
|
|||||||
)
|
)
|
||||||
|
|
||||||
out, err := service.RewardType().List(ctx, &model.RewardTypeListIn{
|
out, err := service.RewardType().List(ctx, &model.RewardTypeListIn{
|
||||||
Page: req.Page,
|
Page: req.Page,
|
||||||
Size: req.Size,
|
Size: req.Size,
|
||||||
OperatorId: operatorId,
|
StoreId: req.StoreId,
|
||||||
OperatorRole: operatorRole,
|
Name: req.Name,
|
||||||
StoreId: req.StoreId,
|
Source: req.Source,
|
||||||
Name: req.Name,
|
|
||||||
Source: req.Source,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -10,6 +10,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (c *ControllerV1) GetOnlineDevice(ctx context.Context, req *v1.GetOnlineDeviceReq) (res *v1.GetOnlineDeviceRes, err error) {
|
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))
|
get, err := g.Redis().Get(ctx, fmt.Sprintf(consts.NetbarOnlineNumberKey, req.NetbarAccount))
|
||||||
return &v1.GetOnlineDeviceRes{Total: card}, err
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &v1.GetOnlineDeviceRes{
|
||||||
|
Total: get.Int64(),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,23 @@
|
|||||||
|
package task
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"server/internal/model"
|
||||||
|
"server/internal/service"
|
||||||
|
|
||||||
|
"server/api/task/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *ControllerV1) GetUserTaskRecordsList(ctx context.Context, req *v1.GetUserTaskRecordsListReq) (res *v1.GetUserTaskRecordsListRes, err error) {
|
||||||
|
fromCtx := g.RequestFromCtx(ctx)
|
||||||
|
userId := fromCtx.GetCtxVar("id").Int()
|
||||||
|
out, err := service.Task().GetUserTaskRecordsList(ctx, &model.UserTaskRecordsListIn{UserId: userId})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &v1.GetUserTaskRecordsListRes{
|
||||||
|
List: out.List,
|
||||||
|
Total: out.Total,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// AdminsDao is the data access object for the table admins.
|
// AdminsDao is the data access object for the table admins.
|
||||||
type AdminsDao struct {
|
type AdminsDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns AdminsColumns // columns contains all the column names of Table for convenient usage.
|
columns AdminsColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AdminsColumns defines and stores column names for the table admins.
|
// AdminsColumns defines and stores column names for the table admins.
|
||||||
@ -50,12 +49,11 @@ var adminsColumns = AdminsColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewAdminsDao creates and returns a new DAO object for table data access.
|
// NewAdminsDao creates and returns a new DAO object for table data access.
|
||||||
func NewAdminsDao(handlers ...gdb.ModelHandler) *AdminsDao {
|
func NewAdminsDao() *AdminsDao {
|
||||||
return &AdminsDao{
|
return &AdminsDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "admins",
|
table: "admins",
|
||||||
columns: adminsColumns,
|
columns: adminsColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,11 +79,7 @@ func (dao *AdminsDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *AdminsDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *AdminsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// FeedbacksDao is the data access object for the table feedbacks.
|
// FeedbacksDao is the data access object for the table feedbacks.
|
||||||
type FeedbacksDao struct {
|
type FeedbacksDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns FeedbacksColumns // columns contains all the column names of Table for convenient usage.
|
columns FeedbacksColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FeedbacksColumns defines and stores column names for the table feedbacks.
|
// FeedbacksColumns defines and stores column names for the table feedbacks.
|
||||||
@ -52,12 +51,11 @@ var feedbacksColumns = FeedbacksColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewFeedbacksDao creates and returns a new DAO object for table data access.
|
// NewFeedbacksDao creates and returns a new DAO object for table data access.
|
||||||
func NewFeedbacksDao(handlers ...gdb.ModelHandler) *FeedbacksDao {
|
func NewFeedbacksDao() *FeedbacksDao {
|
||||||
return &FeedbacksDao{
|
return &FeedbacksDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "feedbacks",
|
table: "feedbacks",
|
||||||
columns: feedbacksColumns,
|
columns: feedbacksColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,11 +81,7 @@ func (dao *FeedbacksDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *FeedbacksDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *FeedbacksDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// GamesDao is the data access object for the table games.
|
// GamesDao is the data access object for the table games.
|
||||||
type GamesDao struct {
|
type GamesDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns GamesColumns // columns contains all the column names of Table for convenient usage.
|
columns GamesColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GamesColumns defines and stores column names for the table games.
|
// GamesColumns defines and stores column names for the table games.
|
||||||
@ -46,12 +45,11 @@ var gamesColumns = GamesColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewGamesDao creates and returns a new DAO object for table data access.
|
// NewGamesDao creates and returns a new DAO object for table data access.
|
||||||
func NewGamesDao(handlers ...gdb.ModelHandler) *GamesDao {
|
func NewGamesDao() *GamesDao {
|
||||||
return &GamesDao{
|
return &GamesDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "games",
|
table: "games",
|
||||||
columns: gamesColumns,
|
columns: gamesColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,11 +75,7 @@ func (dao *GamesDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *GamesDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *GamesDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// MerchantAdminsDao is the data access object for the table merchant_admins.
|
// MerchantAdminsDao is the data access object for the table merchant_admins.
|
||||||
type MerchantAdminsDao struct {
|
type MerchantAdminsDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns MerchantAdminsColumns // columns contains all the column names of Table for convenient usage.
|
columns MerchantAdminsColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MerchantAdminsColumns defines and stores column names for the table merchant_admins.
|
// MerchantAdminsColumns defines and stores column names for the table merchant_admins.
|
||||||
@ -58,12 +57,11 @@ var merchantAdminsColumns = MerchantAdminsColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewMerchantAdminsDao creates and returns a new DAO object for table data access.
|
// NewMerchantAdminsDao creates and returns a new DAO object for table data access.
|
||||||
func NewMerchantAdminsDao(handlers ...gdb.ModelHandler) *MerchantAdminsDao {
|
func NewMerchantAdminsDao() *MerchantAdminsDao {
|
||||||
return &MerchantAdminsDao{
|
return &MerchantAdminsDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "merchant_admins",
|
table: "merchant_admins",
|
||||||
columns: merchantAdminsColumns,
|
columns: merchantAdminsColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,11 +87,7 @@ func (dao *MerchantAdminsDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *MerchantAdminsDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *MerchantAdminsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// MerchantsDao is the data access object for the table merchants.
|
// MerchantsDao is the data access object for the table merchants.
|
||||||
type MerchantsDao struct {
|
type MerchantsDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns MerchantsColumns // columns contains all the column names of Table for convenient usage.
|
columns MerchantsColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MerchantsColumns defines and stores column names for the table merchants.
|
// MerchantsColumns defines and stores column names for the table merchants.
|
||||||
@ -72,12 +71,11 @@ var merchantsColumns = MerchantsColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewMerchantsDao creates and returns a new DAO object for table data access.
|
// NewMerchantsDao creates and returns a new DAO object for table data access.
|
||||||
func NewMerchantsDao(handlers ...gdb.ModelHandler) *MerchantsDao {
|
func NewMerchantsDao() *MerchantsDao {
|
||||||
return &MerchantsDao{
|
return &MerchantsDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "merchants",
|
table: "merchants",
|
||||||
columns: merchantsColumns,
|
columns: merchantsColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,11 +101,7 @@ func (dao *MerchantsDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *MerchantsDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *MerchantsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// NoticesDao is the data access object for the table notices.
|
// NoticesDao is the data access object for the table notices.
|
||||||
type NoticesDao struct {
|
type NoticesDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns NoticesColumns // columns contains all the column names of Table for convenient usage.
|
columns NoticesColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NoticesColumns defines and stores column names for the table notices.
|
// NoticesColumns defines and stores column names for the table notices.
|
||||||
@ -50,12 +49,11 @@ var noticesColumns = NoticesColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewNoticesDao creates and returns a new DAO object for table data access.
|
// NewNoticesDao creates and returns a new DAO object for table data access.
|
||||||
func NewNoticesDao(handlers ...gdb.ModelHandler) *NoticesDao {
|
func NewNoticesDao() *NoticesDao {
|
||||||
return &NoticesDao{
|
return &NoticesDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "notices",
|
table: "notices",
|
||||||
columns: noticesColumns,
|
columns: noticesColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,11 +79,7 @@ func (dao *NoticesDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *NoticesDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *NoticesDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// RewardCallbackDao is the data access object for the table reward_callback.
|
// RewardCallbackDao is the data access object for the table reward_callback.
|
||||||
type RewardCallbackDao struct {
|
type RewardCallbackDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns RewardCallbackColumns // columns contains all the column names of Table for convenient usage.
|
columns RewardCallbackColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RewardCallbackColumns defines and stores column names for the table reward_callback.
|
// RewardCallbackColumns defines and stores column names for the table reward_callback.
|
||||||
@ -48,12 +47,11 @@ var rewardCallbackColumns = RewardCallbackColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewRewardCallbackDao creates and returns a new DAO object for table data access.
|
// NewRewardCallbackDao creates and returns a new DAO object for table data access.
|
||||||
func NewRewardCallbackDao(handlers ...gdb.ModelHandler) *RewardCallbackDao {
|
func NewRewardCallbackDao() *RewardCallbackDao {
|
||||||
return &RewardCallbackDao{
|
return &RewardCallbackDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "reward_callback",
|
table: "reward_callback",
|
||||||
columns: rewardCallbackColumns,
|
columns: rewardCallbackColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,11 +77,7 @@ func (dao *RewardCallbackDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *RewardCallbackDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *RewardCallbackDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,43 +13,39 @@ import (
|
|||||||
|
|
||||||
// RewardTypesDao is the data access object for the table reward_types.
|
// RewardTypesDao is the data access object for the table reward_types.
|
||||||
type RewardTypesDao struct {
|
type RewardTypesDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns RewardTypesColumns // columns contains all the column names of Table for convenient usage.
|
columns RewardTypesColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RewardTypesColumns defines and stores column names for the table reward_types.
|
// RewardTypesColumns defines and stores column names for the table reward_types.
|
||||||
type RewardTypesColumns struct {
|
type RewardTypesColumns struct {
|
||||||
Id string // 奖励类型ID
|
Id string // 奖励类型ID
|
||||||
Name string // 类型名称
|
Name string // 类型名称
|
||||||
TencentTypeId string // 腾讯奖励类型ID(仅系统奖励有效)
|
Code string // 唯一编码
|
||||||
Source string // 奖励来源:1=腾讯系统,2=本系统,3=其他
|
IconUrl string // 图标链接地址
|
||||||
CreatedAt string // 创建时间
|
CreatedAt string // 创建时间
|
||||||
UpdatedAt string // 更新时间
|
UpdatedAt string // 更新时间
|
||||||
DeletedAt string // 软删除时间
|
DeletedAt string // 软删除时间
|
||||||
StoreId string // 门店 id
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// rewardTypesColumns holds the columns for the table reward_types.
|
// rewardTypesColumns holds the columns for the table reward_types.
|
||||||
var rewardTypesColumns = RewardTypesColumns{
|
var rewardTypesColumns = RewardTypesColumns{
|
||||||
Id: "id",
|
Id: "id",
|
||||||
Name: "name",
|
Name: "name",
|
||||||
TencentTypeId: "tencent_type_id",
|
Code: "code",
|
||||||
Source: "source",
|
IconUrl: "icon_url",
|
||||||
CreatedAt: "created_at",
|
CreatedAt: "created_at",
|
||||||
UpdatedAt: "updated_at",
|
UpdatedAt: "updated_at",
|
||||||
DeletedAt: "deleted_at",
|
DeletedAt: "deleted_at",
|
||||||
StoreId: "store_id",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRewardTypesDao creates and returns a new DAO object for table data access.
|
// NewRewardTypesDao creates and returns a new DAO object for table data access.
|
||||||
func NewRewardTypesDao(handlers ...gdb.ModelHandler) *RewardTypesDao {
|
func NewRewardTypesDao() *RewardTypesDao {
|
||||||
return &RewardTypesDao{
|
return &RewardTypesDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "reward_types",
|
table: "reward_types",
|
||||||
columns: rewardTypesColumns,
|
columns: rewardTypesColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,11 +71,7 @@ func (dao *RewardTypesDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *RewardTypesDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *RewardTypesDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// RewardWatersDao is the data access object for the table reward_waters.
|
// RewardWatersDao is the data access object for the table reward_waters.
|
||||||
type RewardWatersDao struct {
|
type RewardWatersDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns RewardWatersColumns // columns contains all the column names of Table for convenient usage.
|
columns RewardWatersColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RewardWatersColumns defines and stores column names for the table reward_waters.
|
// RewardWatersColumns defines and stores column names for the table reward_waters.
|
||||||
@ -46,12 +45,11 @@ var rewardWatersColumns = RewardWatersColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewRewardWatersDao creates and returns a new DAO object for table data access.
|
// NewRewardWatersDao creates and returns a new DAO object for table data access.
|
||||||
func NewRewardWatersDao(handlers ...gdb.ModelHandler) *RewardWatersDao {
|
func NewRewardWatersDao() *RewardWatersDao {
|
||||||
return &RewardWatersDao{
|
return &RewardWatersDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "reward_waters",
|
table: "reward_waters",
|
||||||
columns: rewardWatersColumns,
|
columns: rewardWatersColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,11 +75,7 @@ func (dao *RewardWatersDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *RewardWatersDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *RewardWatersDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// RewardsDao is the data access object for the table rewards.
|
// RewardsDao is the data access object for the table rewards.
|
||||||
type RewardsDao struct {
|
type RewardsDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns RewardsColumns // columns contains all the column names of Table for convenient usage.
|
columns RewardsColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RewardsColumns defines and stores column names for the table rewards.
|
// RewardsColumns defines and stores column names for the table rewards.
|
||||||
@ -44,6 +43,7 @@ type RewardsColumns struct {
|
|||||||
UpdatedAt string // 更新时间
|
UpdatedAt string // 更新时间
|
||||||
DeletedAt string // 删除时间(软删除)
|
DeletedAt string // 删除时间(软删除)
|
||||||
PrizeId string // 券 id
|
PrizeId string // 券 id
|
||||||
|
Source string // 奖励来源,1 为系统奖励对接腾讯,2 是门店
|
||||||
}
|
}
|
||||||
|
|
||||||
// rewardsColumns holds the columns for the table rewards.
|
// rewardsColumns holds the columns for the table rewards.
|
||||||
@ -71,15 +71,15 @@ var rewardsColumns = RewardsColumns{
|
|||||||
UpdatedAt: "updated_at",
|
UpdatedAt: "updated_at",
|
||||||
DeletedAt: "deleted_at",
|
DeletedAt: "deleted_at",
|
||||||
PrizeId: "prize_id",
|
PrizeId: "prize_id",
|
||||||
|
Source: "source",
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRewardsDao creates and returns a new DAO object for table data access.
|
// NewRewardsDao creates and returns a new DAO object for table data access.
|
||||||
func NewRewardsDao(handlers ...gdb.ModelHandler) *RewardsDao {
|
func NewRewardsDao() *RewardsDao {
|
||||||
return &RewardsDao{
|
return &RewardsDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "rewards",
|
table: "rewards",
|
||||||
columns: rewardsColumns,
|
columns: rewardsColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,11 +105,7 @@ func (dao *RewardsDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *RewardsDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *RewardsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// RolesDao is the data access object for the table roles.
|
// RolesDao is the data access object for the table roles.
|
||||||
type RolesDao struct {
|
type RolesDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns RolesColumns // columns contains all the column names of Table for convenient usage.
|
columns RolesColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RolesColumns defines and stores column names for the table roles.
|
// RolesColumns defines and stores column names for the table roles.
|
||||||
@ -48,12 +47,11 @@ var rolesColumns = RolesColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewRolesDao creates and returns a new DAO object for table data access.
|
// NewRolesDao creates and returns a new DAO object for table data access.
|
||||||
func NewRolesDao(handlers ...gdb.ModelHandler) *RolesDao {
|
func NewRolesDao() *RolesDao {
|
||||||
return &RolesDao{
|
return &RolesDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "roles",
|
table: "roles",
|
||||||
columns: rolesColumns,
|
columns: rolesColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,11 +77,7 @@ func (dao *RolesDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *RolesDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *RolesDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// StoreAdminsDao is the data access object for the table store_admins.
|
// StoreAdminsDao is the data access object for the table store_admins.
|
||||||
type StoreAdminsDao struct {
|
type StoreAdminsDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns StoreAdminsColumns // columns contains all the column names of Table for convenient usage.
|
columns StoreAdminsColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// StoreAdminsColumns defines and stores column names for the table store_admins.
|
// StoreAdminsColumns defines and stores column names for the table store_admins.
|
||||||
@ -58,12 +57,11 @@ var storeAdminsColumns = StoreAdminsColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStoreAdminsDao creates and returns a new DAO object for table data access.
|
// NewStoreAdminsDao creates and returns a new DAO object for table data access.
|
||||||
func NewStoreAdminsDao(handlers ...gdb.ModelHandler) *StoreAdminsDao {
|
func NewStoreAdminsDao() *StoreAdminsDao {
|
||||||
return &StoreAdminsDao{
|
return &StoreAdminsDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "store_admins",
|
table: "store_admins",
|
||||||
columns: storeAdminsColumns,
|
columns: storeAdminsColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,11 +87,7 @@ func (dao *StoreAdminsDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *StoreAdminsDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *StoreAdminsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// StoreDesktopSettingsDao is the data access object for the table store_desktop_settings.
|
// StoreDesktopSettingsDao is the data access object for the table store_desktop_settings.
|
||||||
type StoreDesktopSettingsDao struct {
|
type StoreDesktopSettingsDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns StoreDesktopSettingsColumns // columns contains all the column names of Table for convenient usage.
|
columns StoreDesktopSettingsColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// StoreDesktopSettingsColumns defines and stores column names for the table store_desktop_settings.
|
// StoreDesktopSettingsColumns defines and stores column names for the table store_desktop_settings.
|
||||||
@ -34,12 +33,11 @@ var storeDesktopSettingsColumns = StoreDesktopSettingsColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStoreDesktopSettingsDao creates and returns a new DAO object for table data access.
|
// NewStoreDesktopSettingsDao creates and returns a new DAO object for table data access.
|
||||||
func NewStoreDesktopSettingsDao(handlers ...gdb.ModelHandler) *StoreDesktopSettingsDao {
|
func NewStoreDesktopSettingsDao() *StoreDesktopSettingsDao {
|
||||||
return &StoreDesktopSettingsDao{
|
return &StoreDesktopSettingsDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "store_desktop_settings",
|
table: "store_desktop_settings",
|
||||||
columns: storeDesktopSettingsColumns,
|
columns: storeDesktopSettingsColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,11 +63,7 @@ func (dao *StoreDesktopSettingsDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *StoreDesktopSettingsDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *StoreDesktopSettingsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// StoreIpsDao is the data access object for the table store_ips.
|
// StoreIpsDao is the data access object for the table store_ips.
|
||||||
type StoreIpsDao struct {
|
type StoreIpsDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns StoreIpsColumns // columns contains all the column names of Table for convenient usage.
|
columns StoreIpsColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// StoreIpsColumns defines and stores column names for the table store_ips.
|
// StoreIpsColumns defines and stores column names for the table store_ips.
|
||||||
@ -42,12 +41,11 @@ var storeIpsColumns = StoreIpsColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStoreIpsDao creates and returns a new DAO object for table data access.
|
// NewStoreIpsDao creates and returns a new DAO object for table data access.
|
||||||
func NewStoreIpsDao(handlers ...gdb.ModelHandler) *StoreIpsDao {
|
func NewStoreIpsDao() *StoreIpsDao {
|
||||||
return &StoreIpsDao{
|
return &StoreIpsDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "store_ips",
|
table: "store_ips",
|
||||||
columns: storeIpsColumns,
|
columns: storeIpsColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,11 +71,7 @@ func (dao *StoreIpsDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *StoreIpsDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *StoreIpsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// StoreNetfeeAreaLevelDao is the data access object for the table store_netfee_area_level.
|
// StoreNetfeeAreaLevelDao is the data access object for the table store_netfee_area_level.
|
||||||
type StoreNetfeeAreaLevelDao struct {
|
type StoreNetfeeAreaLevelDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns StoreNetfeeAreaLevelColumns // columns contains all the column names of Table for convenient usage.
|
columns StoreNetfeeAreaLevelColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// StoreNetfeeAreaLevelColumns defines and stores column names for the table store_netfee_area_level.
|
// StoreNetfeeAreaLevelColumns defines and stores column names for the table store_netfee_area_level.
|
||||||
@ -50,12 +49,11 @@ var storeNetfeeAreaLevelColumns = StoreNetfeeAreaLevelColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStoreNetfeeAreaLevelDao creates and returns a new DAO object for table data access.
|
// NewStoreNetfeeAreaLevelDao creates and returns a new DAO object for table data access.
|
||||||
func NewStoreNetfeeAreaLevelDao(handlers ...gdb.ModelHandler) *StoreNetfeeAreaLevelDao {
|
func NewStoreNetfeeAreaLevelDao() *StoreNetfeeAreaLevelDao {
|
||||||
return &StoreNetfeeAreaLevelDao{
|
return &StoreNetfeeAreaLevelDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "store_netfee_area_level",
|
table: "store_netfee_area_level",
|
||||||
columns: storeNetfeeAreaLevelColumns,
|
columns: storeNetfeeAreaLevelColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,11 +79,7 @@ func (dao *StoreNetfeeAreaLevelDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *StoreNetfeeAreaLevelDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *StoreNetfeeAreaLevelDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// StoreRolesDao is the data access object for the table store_roles.
|
// StoreRolesDao is the data access object for the table store_roles.
|
||||||
type StoreRolesDao struct {
|
type StoreRolesDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns StoreRolesColumns // columns contains all the column names of Table for convenient usage.
|
columns StoreRolesColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// StoreRolesColumns defines and stores column names for the table store_roles.
|
// StoreRolesColumns defines and stores column names for the table store_roles.
|
||||||
@ -40,12 +39,11 @@ var storeRolesColumns = StoreRolesColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStoreRolesDao creates and returns a new DAO object for table data access.
|
// NewStoreRolesDao creates and returns a new DAO object for table data access.
|
||||||
func NewStoreRolesDao(handlers ...gdb.ModelHandler) *StoreRolesDao {
|
func NewStoreRolesDao() *StoreRolesDao {
|
||||||
return &StoreRolesDao{
|
return &StoreRolesDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "store_roles",
|
table: "store_roles",
|
||||||
columns: storeRolesColumns,
|
columns: storeRolesColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,11 +69,7 @@ func (dao *StoreRolesDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *StoreRolesDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *StoreRolesDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// StoresDao is the data access object for the table stores.
|
// StoresDao is the data access object for the table stores.
|
||||||
type StoresDao struct {
|
type StoresDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns StoresColumns // columns contains all the column names of Table for convenient usage.
|
columns StoresColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// StoresColumns defines and stores column names for the table stores.
|
// StoresColumns defines and stores column names for the table stores.
|
||||||
@ -52,12 +51,11 @@ var storesColumns = StoresColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStoresDao creates and returns a new DAO object for table data access.
|
// NewStoresDao creates and returns a new DAO object for table data access.
|
||||||
func NewStoresDao(handlers ...gdb.ModelHandler) *StoresDao {
|
func NewStoresDao() *StoresDao {
|
||||||
return &StoresDao{
|
return &StoresDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "stores",
|
table: "stores",
|
||||||
columns: storesColumns,
|
columns: storesColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,11 +81,7 @@ func (dao *StoresDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *StoresDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *StoresDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// TaskRewardsDao is the data access object for the table task_rewards.
|
// TaskRewardsDao is the data access object for the table task_rewards.
|
||||||
type TaskRewardsDao struct {
|
type TaskRewardsDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns TaskRewardsColumns // columns contains all the column names of Table for convenient usage.
|
columns TaskRewardsColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TaskRewardsColumns defines and stores column names for the table task_rewards.
|
// TaskRewardsColumns defines and stores column names for the table task_rewards.
|
||||||
@ -32,12 +31,11 @@ var taskRewardsColumns = TaskRewardsColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewTaskRewardsDao creates and returns a new DAO object for table data access.
|
// NewTaskRewardsDao creates and returns a new DAO object for table data access.
|
||||||
func NewTaskRewardsDao(handlers ...gdb.ModelHandler) *TaskRewardsDao {
|
func NewTaskRewardsDao() *TaskRewardsDao {
|
||||||
return &TaskRewardsDao{
|
return &TaskRewardsDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "task_rewards",
|
table: "task_rewards",
|
||||||
columns: taskRewardsColumns,
|
columns: taskRewardsColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,11 +61,7 @@ func (dao *TaskRewardsDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *TaskRewardsDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *TaskRewardsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// TasksDao is the data access object for the table tasks.
|
// TasksDao is the data access object for the table tasks.
|
||||||
type TasksDao struct {
|
type TasksDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns TasksColumns // columns contains all the column names of Table for convenient usage.
|
columns TasksColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TasksColumns defines and stores column names for the table tasks.
|
// TasksColumns defines and stores column names for the table tasks.
|
||||||
@ -58,12 +57,11 @@ var tasksColumns = TasksColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewTasksDao creates and returns a new DAO object for table data access.
|
// NewTasksDao creates and returns a new DAO object for table data access.
|
||||||
func NewTasksDao(handlers ...gdb.ModelHandler) *TasksDao {
|
func NewTasksDao() *TasksDao {
|
||||||
return &TasksDao{
|
return &TasksDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "tasks",
|
table: "tasks",
|
||||||
columns: tasksColumns,
|
columns: tasksColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,11 +87,7 @@ func (dao *TasksDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *TasksDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *TasksDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// UserTaskRewardsDao is the data access object for the table user_task_rewards.
|
// UserTaskRewardsDao is the data access object for the table user_task_rewards.
|
||||||
type UserTaskRewardsDao struct {
|
type UserTaskRewardsDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns UserTaskRewardsColumns // columns contains all the column names of Table for convenient usage.
|
columns UserTaskRewardsColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserTaskRewardsColumns defines and stores column names for the table user_task_rewards.
|
// UserTaskRewardsColumns defines and stores column names for the table user_task_rewards.
|
||||||
@ -32,6 +31,7 @@ type UserTaskRewardsColumns struct {
|
|||||||
CreatedAt string // 创建时间
|
CreatedAt string // 创建时间
|
||||||
UpdatedAt string // 更新时间
|
UpdatedAt string // 更新时间
|
||||||
DeletedAt string // 软删除时间
|
DeletedAt string // 软删除时间
|
||||||
|
ExpiredAt string // 奖励过期时间
|
||||||
}
|
}
|
||||||
|
|
||||||
// userTaskRewardsColumns holds the columns for the table user_task_rewards.
|
// userTaskRewardsColumns holds the columns for the table user_task_rewards.
|
||||||
@ -47,15 +47,15 @@ var userTaskRewardsColumns = UserTaskRewardsColumns{
|
|||||||
CreatedAt: "created_at",
|
CreatedAt: "created_at",
|
||||||
UpdatedAt: "updated_at",
|
UpdatedAt: "updated_at",
|
||||||
DeletedAt: "deleted_at",
|
DeletedAt: "deleted_at",
|
||||||
|
ExpiredAt: "expired_at",
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewUserTaskRewardsDao creates and returns a new DAO object for table data access.
|
// NewUserTaskRewardsDao creates and returns a new DAO object for table data access.
|
||||||
func NewUserTaskRewardsDao(handlers ...gdb.ModelHandler) *UserTaskRewardsDao {
|
func NewUserTaskRewardsDao() *UserTaskRewardsDao {
|
||||||
return &UserTaskRewardsDao{
|
return &UserTaskRewardsDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "user_task_rewards",
|
table: "user_task_rewards",
|
||||||
columns: userTaskRewardsColumns,
|
columns: userTaskRewardsColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,11 +81,7 @@ func (dao *UserTaskRewardsDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *UserTaskRewardsDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *UserTaskRewardsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// UserTasksDao is the data access object for the table user_tasks.
|
// UserTasksDao is the data access object for the table user_tasks.
|
||||||
type UserTasksDao struct {
|
type UserTasksDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns UserTasksColumns // columns contains all the column names of Table for convenient usage.
|
columns UserTasksColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserTasksColumns defines and stores column names for the table user_tasks.
|
// UserTasksColumns defines and stores column names for the table user_tasks.
|
||||||
@ -52,12 +51,11 @@ var userTasksColumns = UserTasksColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewUserTasksDao creates and returns a new DAO object for table data access.
|
// NewUserTasksDao creates and returns a new DAO object for table data access.
|
||||||
func NewUserTasksDao(handlers ...gdb.ModelHandler) *UserTasksDao {
|
func NewUserTasksDao() *UserTasksDao {
|
||||||
return &UserTasksDao{
|
return &UserTasksDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "user_tasks",
|
table: "user_tasks",
|
||||||
columns: userTasksColumns,
|
columns: userTasksColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,11 +81,7 @@ func (dao *UserTasksDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *UserTasksDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *UserTasksDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -13,10 +13,9 @@ import (
|
|||||||
|
|
||||||
// UsersDao is the data access object for the table users.
|
// UsersDao is the data access object for the table users.
|
||||||
type UsersDao struct {
|
type UsersDao struct {
|
||||||
table string // table is the underlying table name of the DAO.
|
table string // table is the underlying table name of the DAO.
|
||||||
group string // group is the database configuration group name of the current DAO.
|
group string // group is the database configuration group name of the current DAO.
|
||||||
columns UsersColumns // columns contains all the column names of Table for convenient usage.
|
columns UsersColumns // columns contains all the column names of Table for convenient usage.
|
||||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UsersColumns defines and stores column names for the table users.
|
// UsersColumns defines and stores column names for the table users.
|
||||||
@ -60,12 +59,11 @@ var usersColumns = UsersColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewUsersDao creates and returns a new DAO object for table data access.
|
// NewUsersDao creates and returns a new DAO object for table data access.
|
||||||
func NewUsersDao(handlers ...gdb.ModelHandler) *UsersDao {
|
func NewUsersDao() *UsersDao {
|
||||||
return &UsersDao{
|
return &UsersDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "users",
|
table: "users",
|
||||||
columns: usersColumns,
|
columns: usersColumns,
|
||||||
handlers: handlers,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,11 +89,7 @@ func (dao *UsersDao) Group() string {
|
|||||||
|
|
||||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
func (dao *UsersDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *UsersDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
model := dao.DB().Model(dao.table)
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||||
for _, handler := range dao.handlers {
|
|
||||||
model = handler(model)
|
|
||||||
}
|
|
||||||
return model.Safe().Ctx(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction wraps the transaction logic using function f.
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
|||||||
@ -261,20 +261,18 @@ func (s *sReward) Delete(ctx context.Context, in *model.RewardDeleteIn) (out *mo
|
|||||||
func (s *sReward) List(ctx context.Context, in *model.RewardListIn) (out *model.RewardListOut, err error) {
|
func (s *sReward) List(ctx context.Context, in *model.RewardListIn) (out *model.RewardListOut, err error) {
|
||||||
|
|
||||||
rewardCols := dao.Rewards.Columns()
|
rewardCols := dao.Rewards.Columns()
|
||||||
rewardTypeCols := dao.RewardTypes.Columns()
|
orm := dao.Rewards.Ctx(ctx).LeftJoin(
|
||||||
rewardTypeIds := make([]int64, 0)
|
dao.RewardTypes.Table(),
|
||||||
// ==== 权限校验 ====
|
fmt.Sprintf(
|
||||||
|
"%s.%s = %s.%s",
|
||||||
|
dao.Rewards.Table(), dao.Rewards.Columns().RewardTypeId,
|
||||||
|
dao.RewardTypes.Table(), dao.RewardTypes.Columns().Id,
|
||||||
|
),
|
||||||
|
).Fields(fmt.Sprintf("%s.*,%s.name as reward_type_name", dao.Rewards.Table(), dao.RewardTypes.Table()))
|
||||||
switch in.OperatorRole {
|
switch in.OperatorRole {
|
||||||
case consts.AdminRoleCode:
|
case consts.AdminRoleCode:
|
||||||
// 系统管理员只能查询 source = 1 的奖励
|
// 系统管理员只能查询 source = 1 的奖励
|
||||||
array, err := dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Source: 1}).Fields(rewardTypeCols.Id).Array()
|
orm = orm.Where(rewardCols.Source, 1)
|
||||||
if err != nil {
|
|
||||||
return nil, ecode.Fail.Sub("获取奖励类型列表失败")
|
|
||||||
}
|
|
||||||
for _, value := range array {
|
|
||||||
rewardTypeIds = append(rewardTypeIds, value.Int64())
|
|
||||||
}
|
|
||||||
|
|
||||||
case consts.MerchantRoleCode, consts.StoreRoleCode:
|
case consts.MerchantRoleCode, consts.StoreRoleCode:
|
||||||
// 合并商户和门店角色权限校验
|
// 合并商户和门店角色权限校验
|
||||||
var exist bool
|
var exist bool
|
||||||
@ -309,28 +307,11 @@ func (s *sReward) List(ctx context.Context, in *model.RewardListIn) (out *model.
|
|||||||
if !exist {
|
if !exist {
|
||||||
return nil, ecode.Params.Sub("无门店权限")
|
return nil, ecode.Params.Sub("无门店权限")
|
||||||
}
|
}
|
||||||
|
orm = orm.Where(rewardCols.Source, 2)
|
||||||
//
|
|
||||||
array, err := dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Source: 2, StoreId: in.StoreId}).Fields(rewardTypeCols.Id).Array()
|
|
||||||
if err != nil {
|
|
||||||
return nil, ecode.Fail.Sub("获取奖励类型列表失败")
|
|
||||||
}
|
|
||||||
for _, value := range array {
|
|
||||||
rewardTypeIds = append(rewardTypeIds, value.Int64())
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return nil, ecode.Params.Sub("无效的角色")
|
return nil, ecode.Params.Sub("无效的角色")
|
||||||
}
|
}
|
||||||
|
|
||||||
orm := dao.Rewards.Ctx(ctx).LeftJoin(
|
|
||||||
dao.RewardTypes.Table(),
|
|
||||||
fmt.Sprintf(
|
|
||||||
"%s.%s = %s.%s",
|
|
||||||
dao.Rewards.Table(), dao.Rewards.Columns().RewardTypeId,
|
|
||||||
dao.RewardTypes.Table(), dao.RewardTypes.Columns().Id,
|
|
||||||
),
|
|
||||||
).Fields(fmt.Sprintf("%s.*,%s.name as reward_type_name", dao.Rewards.Table(), dao.RewardTypes.Table())).
|
|
||||||
WhereIn(dao.Rewards.Columns().RewardTypeId, rewardTypeIds)
|
|
||||||
// ==== 其他查询条件 ====
|
// ==== 其他查询条件 ====
|
||||||
if in.Status != 0 {
|
if in.Status != 0 {
|
||||||
orm = orm.Where(fmt.Sprintf("%s.%s = ?", dao.Rewards.Table(), rewardCols.Status), in.Status)
|
orm = orm.Where(fmt.Sprintf("%s.%s = ?", dao.Rewards.Table(), rewardCols.Status), in.Status)
|
||||||
|
|||||||
@ -32,10 +32,7 @@ func (s *sRewardType) Create(ctx context.Context, in *model.RewardTypeCreateIn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
data := do.RewardTypes{
|
data := do.RewardTypes{
|
||||||
Name: in.Name,
|
Name: in.Name,
|
||||||
Source: in.Source,
|
|
||||||
StoreId: in.StoreId,
|
|
||||||
TencentTypeId: in.TencentTypeId,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
id, err := dao.RewardTypes.Ctx(ctx).OmitEmptyData().Data(data).InsertAndGetId()
|
id, err := dao.RewardTypes.Ctx(ctx).OmitEmptyData().Data(data).InsertAndGetId()
|
||||||
@ -110,30 +107,6 @@ func (s *sRewardType) Delete(ctx context.Context, in *model.RewardTypeDeleteIn)
|
|||||||
func (s *sRewardType) List(ctx context.Context, in *model.RewardTypeListIn) (out *model.RewardTypeListOut, err error) {
|
func (s *sRewardType) List(ctx context.Context, in *model.RewardTypeListIn) (out *model.RewardTypeListOut, err error) {
|
||||||
mod := dao.RewardTypes.Ctx(ctx).Where("deleted_at IS NULL")
|
mod := dao.RewardTypes.Ctx(ctx).Where("deleted_at IS NULL")
|
||||||
|
|
||||||
switch in.OperatorRole {
|
|
||||||
case consts.AdminRoleCode:
|
|
||||||
// 系统管理员只能看系统奖励类型
|
|
||||||
mod = mod.Where("source", 1)
|
|
||||||
|
|
||||||
case consts.MerchantRoleCode:
|
|
||||||
// 校验商户是否对该门店有权限
|
|
||||||
if err = checkRewardTypePermission(ctx, in.OperatorRole, in.OperatorId, 2, in.StoreId); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
// 只查询该门店的奖励类型(source=2且store_id=指定门店)
|
|
||||||
mod = mod.Where("source", 2).WhereIn("store_id", in.StoreId)
|
|
||||||
|
|
||||||
case consts.StoreRoleCode:
|
|
||||||
// 校验门店权限
|
|
||||||
if err = checkRewardTypePermission(ctx, in.OperatorRole, in.OperatorId, 2, in.StoreId); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
mod = mod.Where("source", 2).Where("store_id", in.StoreId)
|
|
||||||
|
|
||||||
default:
|
|
||||||
return nil, ecode.Params.Sub("无效的操作角色")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 其余过滤条件
|
// 其余过滤条件
|
||||||
if in.Name != "" {
|
if in.Name != "" {
|
||||||
mod = mod.WhereLike("name", "%"+in.Name+"%")
|
mod = mod.WhereLike("name", "%"+in.Name+"%")
|
||||||
|
|||||||
@ -13,17 +13,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type sStoreDesktopSetting struct {
|
type sStoreDesktopSetting struct {
|
||||||
mqttCLient mqtt.MqttClient
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func New() service.IStoreDesktopSetting {
|
func New() service.IStoreDesktopSetting {
|
||||||
client, b := mqtt.GetClient("emqx")
|
return &sStoreDesktopSetting{}
|
||||||
if !b {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return &sStoreDesktopSetting{
|
|
||||||
mqttCLient: client,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
func init() {
|
func init() {
|
||||||
service.RegisterStoreDesktopSetting(New())
|
service.RegisterStoreDesktopSetting(New())
|
||||||
@ -74,7 +67,11 @@ func (s *sStoreDesktopSetting) Save(ctx context.Context, in model.SaveDesktopSet
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = s.mqttCLient.Publish(fmt.Sprintf("/desktop/%d", in.StoreId), marshal)
|
client, b := mqtt.GetClient("emqx")
|
||||||
|
if !b {
|
||||||
|
return nil, gerror.New("获取MQTT客户端失败")
|
||||||
|
}
|
||||||
|
err = client.Publish(fmt.Sprintf("/desktop/%d", in.StoreId), marshal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gogf/gf/v2/database/gdb"
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/util/guid"
|
||||||
"server/internal/consts"
|
"server/internal/consts"
|
||||||
"server/internal/dao"
|
"server/internal/dao"
|
||||||
"server/internal/model"
|
"server/internal/model"
|
||||||
@ -189,12 +190,10 @@ func (s *sTask) GetNonLoginTaskList(ctx context.Context, in *model.GetTaskListIn
|
|||||||
dao.RewardTypes.Table(), dao.RewardTypes.Columns().Id,
|
dao.RewardTypes.Table(), dao.RewardTypes.Columns().Id,
|
||||||
dao.Rewards.Table(), dao.Rewards.Columns().RewardTypeId)).
|
dao.Rewards.Table(), dao.Rewards.Columns().RewardTypeId)).
|
||||||
Fields(
|
Fields(
|
||||||
fmt.Sprintf("%s.*, `%s`.`%s` AS %s, `%s`.`%s` AS %s",
|
fmt.Sprintf(
|
||||||
|
"%s.*, `%s`.`%s` AS %s",
|
||||||
dao.Rewards.Table(),
|
dao.Rewards.Table(),
|
||||||
dao.RewardTypes.Table(), dao.RewardTypes.Columns().Name,
|
dao.RewardTypes.Table(), dao.RewardTypes.Columns().Name, "reward_type_name",
|
||||||
"reward_type_name",
|
|
||||||
dao.RewardTypes.Table(), dao.RewardTypes.Columns().Source,
|
|
||||||
"reward_type_source",
|
|
||||||
),
|
),
|
||||||
).Where(dao.TaskRewards.Columns().TaskId, task.TaskID).Scan(&data.Rewards)
|
).Where(dao.TaskRewards.Columns().TaskId, task.TaskID).Scan(&data.Rewards)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -359,6 +358,7 @@ func (s *sTask) GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.Ge
|
|||||||
return ecode.Fail.Sub("创建用户任务记录失败")
|
return ecode.Fail.Sub("创建用户任务记录失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snowid.GetSnowClient()
|
||||||
// 查询该任务相关联的奖励, 创建对应奖励下发记录id
|
// 查询该任务相关联的奖励, 创建对应奖励下发记录id
|
||||||
array, err := dao.TaskRewards.Ctx(ctx).Where(do.TaskRewards{TaskId: in.TaskId}).Fields(dao.TaskRewards.Columns().RewardId).Array()
|
array, err := dao.TaskRewards.Ctx(ctx).Where(do.TaskRewards{TaskId: in.TaskId}).Fields(dao.TaskRewards.Columns().RewardId).Array()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -366,9 +366,10 @@ func (s *sTask) GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.Ge
|
|||||||
}
|
}
|
||||||
for _, v := range array {
|
for _, v := range array {
|
||||||
_, err = dao.UserTaskRewards.Ctx(ctx).Data(do.UserTaskRewards{
|
_, err = dao.UserTaskRewards.Ctx(ctx).Data(do.UserTaskRewards{
|
||||||
UserTaskId: id,
|
UserTaskId: id,
|
||||||
RewardId: v.Int64(),
|
RewardId: v.Int64(),
|
||||||
Status: consts.RewardInitStatus,
|
Status: consts.RewardInitStatus,
|
||||||
|
InnerOrderId: fmt.Sprintf("reward%s", guid.S()),
|
||||||
}).Insert()
|
}).Insert()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ecode.Fail.Sub("创建用户任务奖励记录失败")
|
return ecode.Fail.Sub("创建用户任务奖励记录失败")
|
||||||
@ -382,3 +383,21 @@ func (s *sTask) GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.Ge
|
|||||||
Success: true,
|
Success: true,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *sTask) GetUserTaskRecordsList(ctx context.Context, in *model.UserTaskRecordsListIn) (out *model.UserTaskRecordsListOut, err error) {
|
||||||
|
list := make([]model.UserTask, 0)
|
||||||
|
var total int
|
||||||
|
orm := dao.UserTasks.Ctx(ctx).Where(dao.UserTasks.Columns().Id, in.UserId)
|
||||||
|
|
||||||
|
if in.StoreId != 0 {
|
||||||
|
orm = orm.Where(dao.UserTasks.Columns().StoreId, in.StoreId)
|
||||||
|
}
|
||||||
|
err = orm.Page(in.Page, in.Size).ScanAndCount(&list, &total, false)
|
||||||
|
if err != nil {
|
||||||
|
return nil, ecode.Fail.Sub("获取用户任务列表失败")
|
||||||
|
}
|
||||||
|
return &model.UserTaskRecordsListOut{
|
||||||
|
List: list,
|
||||||
|
Total: total,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|||||||
@ -11,13 +11,12 @@ import (
|
|||||||
|
|
||||||
// RewardTypes is the golang structure of table reward_types for DAO operations like Where/Data.
|
// RewardTypes is the golang structure of table reward_types for DAO operations like Where/Data.
|
||||||
type RewardTypes struct {
|
type RewardTypes struct {
|
||||||
g.Meta `orm:"table:reward_types, do:true"`
|
g.Meta `orm:"table:reward_types, do:true"`
|
||||||
Id interface{} // 奖励类型ID
|
Id interface{} // 奖励类型ID
|
||||||
Name interface{} // 类型名称
|
Name interface{} // 类型名称
|
||||||
TencentTypeId interface{} // 腾讯奖励类型ID(仅系统奖励有效)
|
Code interface{} // 唯一编码
|
||||||
Source interface{} // 奖励来源:1=腾讯系统,2=本系统,3=其他
|
IconUrl interface{} // 图标链接地址
|
||||||
CreatedAt *gtime.Time // 创建时间
|
CreatedAt *gtime.Time // 创建时间
|
||||||
UpdatedAt *gtime.Time // 更新时间
|
UpdatedAt *gtime.Time // 更新时间
|
||||||
DeletedAt *gtime.Time // 软删除时间
|
DeletedAt *gtime.Time // 软删除时间
|
||||||
StoreId interface{} // 门店 id
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,4 +35,5 @@ type Rewards struct {
|
|||||||
UpdatedAt *gtime.Time // 更新时间
|
UpdatedAt *gtime.Time // 更新时间
|
||||||
DeletedAt *gtime.Time // 删除时间(软删除)
|
DeletedAt *gtime.Time // 删除时间(软删除)
|
||||||
PrizeId interface{} // 券 id
|
PrizeId interface{} // 券 id
|
||||||
|
Source interface{} // 奖励来源,1 为系统奖励对接腾讯,2 是门店
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,4 +23,5 @@ type UserTaskRewards struct {
|
|||||||
CreatedAt *gtime.Time // 创建时间
|
CreatedAt *gtime.Time // 创建时间
|
||||||
UpdatedAt *gtime.Time // 更新时间
|
UpdatedAt *gtime.Time // 更新时间
|
||||||
DeletedAt *gtime.Time // 软删除时间
|
DeletedAt *gtime.Time // 软删除时间
|
||||||
|
ExpiredAt *gtime.Time // 奖励过期时间
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,12 +10,11 @@ import (
|
|||||||
|
|
||||||
// RewardTypes is the golang structure for table reward_types.
|
// RewardTypes is the golang structure for table reward_types.
|
||||||
type RewardTypes struct {
|
type RewardTypes struct {
|
||||||
Id int64 `json:"id" orm:"id" description:"奖励类型ID"` // 奖励类型ID
|
Id int64 `json:"id" orm:"id" description:"奖励类型ID"` // 奖励类型ID
|
||||||
Name string `json:"name" orm:"name" description:"类型名称"` // 类型名称
|
Name string `json:"name" orm:"name" description:"类型名称"` // 类型名称
|
||||||
TencentTypeId int `json:"tencentTypeId" orm:"tencent_type_id" description:"腾讯奖励类型ID(仅系统奖励有效)"` // 腾讯奖励类型ID(仅系统奖励有效)
|
Code string `json:"code" orm:"code" description:"唯一编码"` // 唯一编码
|
||||||
Source int `json:"source" orm:"source" description:"奖励来源:1=腾讯系统,2=本系统,3=其他"` // 奖励来源:1=腾讯系统,2=本系统,3=其他
|
IconUrl string `json:"iconUrl" orm:"icon_url" description:"图标链接地址"` // 图标链接地址
|
||||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
||||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
||||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
|
||||||
StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,4 +33,5 @@ type Rewards struct {
|
|||||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
||||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"删除时间(软删除)"` // 删除时间(软删除)
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"删除时间(软删除)"` // 删除时间(软删除)
|
||||||
PrizeId string `json:"prizeId" orm:"prize_id" description:"券 id"` // 券 id
|
PrizeId string `json:"prizeId" orm:"prize_id" description:"券 id"` // 券 id
|
||||||
|
Source int `json:"source" orm:"source" description:"奖励来源,1 为系统奖励对接腾讯,2 是门店"` // 奖励来源,1 为系统奖励对接腾讯,2 是门店
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,4 +21,5 @@ type UserTaskRewards struct {
|
|||||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
||||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
||||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
|
||||||
|
ExpiredAt *gtime.Time `json:"expiredAt" orm:"expired_at" description:"奖励过期时间"` // 奖励过期时间
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,30 +6,30 @@ import (
|
|||||||
|
|
||||||
// Reward 奖励表
|
// Reward 奖励表
|
||||||
type Reward struct {
|
type Reward struct {
|
||||||
Id int64 `json:"id" orm:"id" description:"奖励ID"` // 奖励ID
|
Id int64 `json:"id" orm:"id" description:"奖励ID"` // 奖励ID
|
||||||
StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID,系统奖励为NULL"` // 门店ID,系统奖励为NULL
|
StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID,系统奖励为NULL"` // 门店ID,系统奖励为NULL
|
||||||
Name string `json:"name" orm:"name" description:"奖励名称"` // 奖励名称
|
Name string `json:"name" orm:"name" description:"奖励名称"` // 奖励名称
|
||||||
RewardTypeId int64 `json:"rewardTypeId" orm:"reward_type_id" description:"奖励类型ID,关联 reward_types 表"` // 奖励类型ID,关联 reward_types 表
|
RewardTypeId int64 `json:"rewardTypeId" orm:"reward_type_id" description:"奖励类型ID,关联 reward_types 表"` // 奖励类型ID,关联 reward_types 表
|
||||||
RewardTypeName string `json:"rewardTypeName" orm:"reward_type_name" description:"奖励类型名称"` // 奖励类型名称
|
RewardTypeName string `json:"rewardTypeName" orm:"reward_type_name" description:"奖励类型名称"` // 奖励类型名称
|
||||||
RewardTypeSource int `json:"rewardTypeSource" orm:"reward_type_source" description:"奖励类型来源"` // 奖励类型来源
|
Source int `json:"source" orm:"source" description:"奖励来源,1=系统奖励(对接腾讯),2=门店追加"` // 奖励来源,1=系统奖励(对接腾讯),2=门店追加
|
||||||
GameId int64 `json:"gameId" orm:"game_id" description:"游戏ID"` // 游戏ID
|
GameId int64 `json:"gameId" orm:"game_id" description:"游戏ID"` // 游戏ID
|
||||||
ImageUrl string `json:"imageUrl" orm:"image_url" description:"奖励图片链接"` // 奖励图片链接
|
ImageUrl string `json:"imageUrl" orm:"image_url" description:"奖励图片链接"` // 奖励图片链接
|
||||||
QqGoodsId string `json:"qqGoodsId" orm:"qq_goods_id" description:"QQ网吧物品ID"` // QQ网吧物品ID
|
QqGoodsId string `json:"qqGoodsId" orm:"qq_goods_id" description:"QQ网吧物品ID"` // QQ网吧物品ID
|
||||||
QqGoodsIdStr string `json:"qqGoodsIdStr" orm:"qq_goods_id_str" description:"QQ网吧物品ID字符串"` // QQ网吧物品ID字符串
|
QqGoodsIdStr string `json:"qqGoodsIdStr" orm:"qq_goods_id_str" description:"QQ网吧物品ID字符串"` // QQ网吧物品ID字符串
|
||||||
Status int `json:"status" orm:"status" description:"状态:1=启用,2=禁用"` // 状态:1=启用,2=禁用
|
Status int `json:"status" orm:"status" description:"状态:1=启用,2=禁用"` // 状态:1=启用,2=禁用
|
||||||
ExpireType int `json:"expireType" orm:"expire_type" description:"过期方式:1=时间段过期,2=领取后过期"` // 过期方式:1=时间段过期,2=领取后过期
|
ExpireType int `json:"expireType" orm:"expire_type" description:"过期方式:1=时间段过期,2=领取后过期"` // 过期方式:1=时间段过期,2=领取后过期
|
||||||
ValidFrom *gtime.Time `json:"validFrom" orm:"valid_from" description:"有效期开始时间(expire_type=1时)"` // 有效期开始时间(expire_type=1时)
|
ValidFrom *gtime.Time `json:"validFrom" orm:"valid_from" description:"有效期开始时间(expire_type=1时)"` // 有效期开始时间(expire_type=1时)
|
||||||
ValidTo *gtime.Time `json:"validTo" orm:"valid_to" description:"有效期结束时间(expire_type=1时)"` // 有效期结束时间(expire_type=1时)
|
ValidTo *gtime.Time `json:"validTo" orm:"valid_to" description:"有效期结束时间(expire_type=1时)"` // 有效期结束时间(expire_type=1时)
|
||||||
ExpireDays int `json:"expireDays" orm:"expire_days" description:"领取后多少天过期(expire_type=2时)"` // 领取后多少天过期(expire_type=2时)
|
ExpireDays int `json:"expireDays" orm:"expire_days" description:"领取后多少天过期(expire_type=2时)"` // 领取后多少天过期(expire_type=2时)
|
||||||
DailyTotalLimit uint64 `json:"dailyTotalLimit" orm:"daily_total_limit" description:"每日发放总限(NULL表示不限制)"` // 每日发放总限(NULL表示不限制)
|
DailyTotalLimit uint64 `json:"dailyTotalLimit" orm:"daily_total_limit" description:"每日发放总限(NULL表示不限制)"` // 每日发放总限(NULL表示不限制)
|
||||||
TotalLimit uint64 `json:"totalLimit" orm:"total_limit" description:"奖励总限(NULL表示不限制)"` // 奖励总限(NULL表示不限制)
|
TotalLimit uint64 `json:"totalLimit" orm:"total_limit" description:"奖励总限(NULL表示不限制)"` // 奖励总限(NULL表示不限制)
|
||||||
UserDailyLimit uint64 `json:"userDailyLimit" orm:"user_daily_limit" description:"用户每日领取限制(NULL表示不限制)"` // 用户每日领取限制(NULL表示不限制)
|
UserDailyLimit uint64 `json:"userDailyLimit" orm:"user_daily_limit" description:"用户每日领取限制(NULL表示不限制)"` // 用户每日领取限制(NULL表示不限制)
|
||||||
UserTotalLimit uint64 `json:"userTotalLimit" orm:"user_total_limit" description:"用户领取总次数限制(NULL表示不限制)"` // 用户领取总次数限制(NULL表示不限制)
|
UserTotalLimit uint64 `json:"userTotalLimit" orm:"user_total_limit" description:"用户领取总次数限制(NULL表示不限制)"` // 用户领取总次数限制(NULL表示不限制)
|
||||||
ReceivedNum uint64 `json:"receivedNum" orm:"received_num" description:"已领取数量"` // 已领取数量
|
ReceivedNum uint64 `json:"receivedNum" orm:"received_num" description:"已领取数量"` // 已领取数量
|
||||||
GrantQuantity uint64 `json:"grantQuantity" orm:"grant_quantity" description:"每次发放个数"` // 每次发放个数
|
GrantQuantity uint64 `json:"grantQuantity" orm:"grant_quantity" description:"每次发放个数"` // 每次发放个数
|
||||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
||||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
||||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"删除时间(软删除)"` // 删除时间(软删除)
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"删除时间(软删除)"` // 删除时间(软删除)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RewardCreateIn 创建奖励入参
|
// RewardCreateIn 创建奖励入参
|
||||||
|
|||||||
@ -6,13 +6,13 @@ import (
|
|||||||
|
|
||||||
// RewardType 奖励类型表
|
// RewardType 奖励类型表
|
||||||
type RewardType struct {
|
type RewardType struct {
|
||||||
Id int64 `json:"id" dc:"奖励类型ID"`
|
Id int64 `json:"id" orm:"id" description:"奖励类型ID"` // 奖励类型ID
|
||||||
Name string `json:"name" dc:"奖励类型名称(如积分、优惠券)"`
|
Name string `json:"name" orm:"name" description:"类型名称"` // 类型名称
|
||||||
TencentTypeId int `json:"tencentTypeId" dc:"腾讯奖励类型ID(仅系统奖励有效)"`
|
Code string `json:"code" orm:"code" description:"唯一编码"` // 唯一编码
|
||||||
Source int `json:"source" dc:"来源:1=腾讯系统,2=本系统,3=其他"`
|
IconUrl string `json:"iconUrl" orm:"icon_url" description:"图标链接地址"` // 图标链接地址
|
||||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
||||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
||||||
DeletedAt *gtime.Time `json:"deletedAt" dc:"软删除时间戳"`
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
|
||||||
}
|
}
|
||||||
|
|
||||||
// RewardTypeCreateIn 创建奖励类型入参
|
// RewardTypeCreateIn 创建奖励类型入参
|
||||||
@ -59,14 +59,12 @@ type RewardTypeDeleteOut struct {
|
|||||||
|
|
||||||
// RewardTypeListIn 获取奖励类型列表入参
|
// RewardTypeListIn 获取奖励类型列表入参
|
||||||
type RewardTypeListIn struct {
|
type RewardTypeListIn struct {
|
||||||
OperatorId int64
|
Page int
|
||||||
OperatorRole string
|
Size int
|
||||||
Page int
|
Name string
|
||||||
Size int
|
StoreId int64
|
||||||
Name string
|
Status int
|
||||||
StoreId int64
|
Source int
|
||||||
Status int
|
|
||||||
Source int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RewardTypeListOut 获取奖励类型列表出参
|
// RewardTypeListOut 获取奖励类型列表出参
|
||||||
|
|||||||
@ -59,7 +59,7 @@ type LoginUserRankingNum struct {
|
|||||||
|
|
||||||
// GetTaskIn 添加任务记录入参
|
// GetTaskIn 添加任务记录入参
|
||||||
type GetTaskIn struct {
|
type GetTaskIn struct {
|
||||||
TaskId int `json:"taskId"`
|
TaskId string `json:"taskId"`
|
||||||
StoreId int `json:"storeId"`
|
StoreId int `json:"storeId"`
|
||||||
NetBarAccount string `json:"netBarAccount"`
|
NetBarAccount string `json:"netBarAccount"`
|
||||||
UserId int `json:"userId"`
|
UserId int `json:"userId"`
|
||||||
@ -70,3 +70,16 @@ type GetTaskIn struct {
|
|||||||
type GetTaskOut struct {
|
type GetTaskOut struct {
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UserTaskRecordsListIn struct {
|
||||||
|
UserId int
|
||||||
|
Page int
|
||||||
|
Size int
|
||||||
|
StoreId int
|
||||||
|
NetBarAccount string
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserTaskRecordsListOut struct {
|
||||||
|
List []UserTask
|
||||||
|
Total int
|
||||||
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import (
|
|||||||
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
|
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
|
||||||
_ "github.com/gogf/gf/contrib/nosql/redis/v2"
|
_ "github.com/gogf/gf/contrib/nosql/redis/v2"
|
||||||
_ "server/utility/gamelife"
|
_ "server/utility/gamelife"
|
||||||
//_ "server/utility/mqtt/emqx"
|
_ "server/utility/mqtt/emqx"
|
||||||
_ "server/utility/myCasbin"
|
_ "server/utility/myCasbin"
|
||||||
_ "server/utility/oss/aliyun"
|
_ "server/utility/oss/aliyun"
|
||||||
_ "server/utility/rsa"
|
_ "server/utility/rsa"
|
||||||
|
|||||||
@ -29,6 +29,7 @@ type (
|
|||||||
// GetGoodsDetails 物品详情
|
// GetGoodsDetails 物品详情
|
||||||
GetGoodsDetails(ctx context.Context, in *model.GetGoodsDetailsIn) (out *model.QueryUserGoodsDetailResponse, err error)
|
GetGoodsDetails(ctx context.Context, in *model.GetGoodsDetailsIn) (out *model.QueryUserGoodsDetailResponse, err error)
|
||||||
OperateTaskReward(ctx context.Context, in *model.OperateTaskRewardIn) (out *model.OperateTaskRewardOut, err error)
|
OperateTaskReward(ctx context.Context, in *model.OperateTaskRewardIn) (out *model.OperateTaskRewardOut, err error)
|
||||||
|
// CallBack 奖励回调
|
||||||
CallBack(ctx context.Context, in *model.RewardCallbackIn) (out *model.RewardCallbackOut, err error)
|
CallBack(ctx context.Context, in *model.RewardCallbackIn) (out *model.RewardCallbackOut, err error)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@ -21,6 +21,7 @@ type (
|
|||||||
GetSelectorList(ctx context.Context, in *model.SelectorIn) (out *[]model.SelectorOut, err error)
|
GetSelectorList(ctx context.Context, in *model.SelectorIn) (out *[]model.SelectorOut, err error)
|
||||||
// GetTask 完成任务
|
// GetTask 完成任务
|
||||||
GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.GetTaskOut, err error)
|
GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.GetTaskOut, err error)
|
||||||
|
GetUserTaskRecordsList(ctx context.Context, in *model.UserTaskRecordsListIn) (out *model.UserTaskRecordsListOut, err error)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,9 @@ package emqx
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/gogf/gf/v2/encoding/gjson"
|
||||||
|
"server/internal/consts"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -84,9 +87,20 @@ func (e *emqxClient) Subscribe(topic string, handler func(topic string, payload
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DeviceData struct {
|
||||||
|
NetbarAccount string `json:"netbarAccount"`
|
||||||
|
DeviceId string `json:"deviceId"`
|
||||||
|
DeviceName string `json:"deviceName"`
|
||||||
|
IP string `json:"ip"`
|
||||||
|
MACAddress string `json:"macAddress"`
|
||||||
|
}
|
||||||
|
|
||||||
// init 注册emqx客户端
|
// init 注册emqx客户端
|
||||||
func init() {
|
func init() {
|
||||||
|
|
||||||
|
// 创建可取消的上下文
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
// 加载 MQTT 配置
|
||||||
cfg := g.Config()
|
cfg := g.Config()
|
||||||
host := cfg.MustGet(ctx, "mqtt.emqx.host").String()
|
host := cfg.MustGet(ctx, "mqtt.emqx.host").String()
|
||||||
port := cfg.MustGet(ctx, "mqtt.emqx.port").Int()
|
port := cfg.MustGet(ctx, "mqtt.emqx.port").Int()
|
||||||
@ -97,6 +111,122 @@ func init() {
|
|||||||
broker := fmt.Sprintf("tcp://%s:%d", host, port)
|
broker := fmt.Sprintf("tcp://%s:%d", host, port)
|
||||||
client := New(broker, clientId, username, password)
|
client := New(broker, clientId, username, password)
|
||||||
|
|
||||||
|
// 注册 MQTT 客户端
|
||||||
mqtt.Register("emqx", client)
|
mqtt.Register("emqx", client)
|
||||||
glog.Infof(ctx, "EMQX客户端注册完成,broker=%s, clientID=%s", broker, clientId)
|
|
||||||
|
glog.Infof(ctx, "EMQX 客户端注册完成,broker=%s, clientID=%s", broker, clientId)
|
||||||
|
// 订阅设备上线消息
|
||||||
|
go func() {
|
||||||
|
ctx := context.Background()
|
||||||
|
err := client.Subscribe("/up", func(topic string, payload []byte) {
|
||||||
|
glog.Infof(ctx, "收到 MQTT 消息,topic=%s", topic)
|
||||||
|
|
||||||
|
var data DeviceData
|
||||||
|
if err := gjson.Unmarshal(payload, &data); err != nil {
|
||||||
|
glog.Errorf(ctx, "[/up] 解析设备信息失败: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 增加门店在线设备计数
|
||||||
|
key := fmt.Sprintf(consts.NetbarOnlineNumberKey, data.NetbarAccount)
|
||||||
|
if _, err := g.Redis().Incr(ctx, key); err != nil {
|
||||||
|
glog.Errorf(ctx, "增加 Redis 计数失败 %s: %v", key, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新在线设备集合
|
||||||
|
setKey := "system:online:devices"
|
||||||
|
if _, err := g.Redis().HSet(ctx, setKey, map[string]interface{}{
|
||||||
|
data.DeviceId: time.Now().Unix(),
|
||||||
|
}); err != nil {
|
||||||
|
glog.Errorf(ctx, "更新在线设备集合失败 %s: %v", setKey, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 存储设备信息(用于离线检测时获取 NetbarAccount)
|
||||||
|
deviceKey := fmt.Sprintf("device:%s", data.DeviceId)
|
||||||
|
if _, err := g.Redis().HSet(ctx, deviceKey, map[string]interface{}{
|
||||||
|
"netbarAccount": data.NetbarAccount,
|
||||||
|
"deviceName": data.DeviceName,
|
||||||
|
"ip": data.IP,
|
||||||
|
"macAddress": data.MACAddress,
|
||||||
|
}); err != nil {
|
||||||
|
glog.Errorf(ctx, "存储设备信息失败 %s: %v", deviceKey, err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf(ctx, "订阅 /up 失败: %v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// 监控离线设备
|
||||||
|
go func() {
|
||||||
|
ctx := context.Background()
|
||||||
|
ticker := time.NewTicker(10 * time.Second)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
glog.Info(ctx, "停止离线设备监控")
|
||||||
|
return
|
||||||
|
case <-ticker.C:
|
||||||
|
setKey := "system:online:devices"
|
||||||
|
devicesVar, err := g.Redis().HGetAll(ctx, setKey)
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf(ctx, "获取在线设备失败: %v", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// 转换为 map[string]string
|
||||||
|
devices := devicesVar.MapStrStr()
|
||||||
|
if len(devices) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
now := time.Now().Unix()
|
||||||
|
for deviceId, timestampStr := range devices {
|
||||||
|
// 使用 strconv.ParseInt 替代 time.ParseInt
|
||||||
|
timestamp, err := strconv.ParseInt(timestampStr, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf(ctx, "无效时间戳 for 设备 %s: %v", deviceId, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查设备是否离线(超过 10 秒未更新)
|
||||||
|
if now-timestamp > 10 {
|
||||||
|
// 获取设备信息
|
||||||
|
dataKey := fmt.Sprintf("device:%s", deviceId)
|
||||||
|
dataVar, err := g.Redis().HGetAll(ctx, dataKey)
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf(ctx, "获取设备数据失败 %s: %v", dataKey, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// 转换为 map[string]string
|
||||||
|
data := dataVar.MapStrStr()
|
||||||
|
netbarAccount, exists := data["netbarAccount"]
|
||||||
|
if !exists {
|
||||||
|
glog.Errorf(ctx, "设备 %s 缺少 netbarAccount", deviceId)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// 减少在线设备计数
|
||||||
|
key := fmt.Sprintf(consts.NetbarOnlineNumberKey, netbarAccount)
|
||||||
|
if _, err := g.Redis().Decr(ctx, key); err != nil {
|
||||||
|
glog.Errorf(ctx, "减少 Redis 计数失败 %s: %v", key, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从在线设备集合中移除
|
||||||
|
if _, err := g.Redis().HDel(ctx, setKey, deviceId); err != nil {
|
||||||
|
glog.Errorf(ctx, "移除设备 %s 从在线集合失败: %v", deviceId, err)
|
||||||
|
} else {
|
||||||
|
glog.Infof(ctx, "设备 %s 已标记为离线", deviceId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user