Merge remote-tracking branch 'origin/master'

This commit is contained in:
chy
2025-06-17 14:27:28 +08:00
62 changed files with 117 additions and 2260 deletions

View File

@ -1,23 +0,0 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package reward
import (
"context"
"server/api/reward/v1"
)
type IRewardV1 interface {
CreateSystemReward(ctx context.Context, req *v1.CreateSystemRewardReq) (res *v1.CreateSystemRewardRes, err error)
CreateStoreReward(ctx context.Context, req *v1.CreateStoreRewardReq) (res *v1.CreateStoreRewardRes, err error)
ListSystemReward(ctx context.Context, req *v1.ListSystemRewardReq) (res *v1.ListSystemRewardRes, err error)
ListStoreReward(ctx context.Context, req *v1.ListStoreRewardReq) (res *v1.ListStoreRewardRes, err error)
UpdateSystemReward(ctx context.Context, req *v1.UpdateSystemRewardReq) (res *v1.UpdateSystemRewardRes, err error)
UpdateStoreReward(ctx context.Context, req *v1.UpdateStoreRewardReq) (res *v1.UpdateStoreRewardRes, err error)
DeleteSystemReward(ctx context.Context, req *v1.DeleteSystemRewardReq) (res *v1.DeleteSystemRewardRes, err error)
DeleteStoreReward(ctx context.Context, req *v1.DeleteStoreRewardReq) (res *v1.DeleteStoreRewardRes, err error)
RewardCallback(ctx context.Context, req *v1.RewardCallbackReq) (res *v1.RewardCallbackRes, err error)
}

View File

@ -1,156 +0,0 @@
package v1
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// CreateSystemRewardReq 创建系统奖励请求
type CreateSystemRewardReq struct {
g.Meta `path:"/reward/system" method:"post" tags:"Reward" summary:"(系统)创建系统奖励"`
RewardTypeId int64 `v:"required|min:1#奖励类型ID不能为空|奖励类型ID无效" json:"rewardTypeId" dc:"奖励类型ID"`
Name string `v:"required|length:1,100#奖励名称不能为空|奖励名称长度为1-100" json:"name" dc:"奖励名称"`
Description string `v:"length:0,255#奖励描述长度为0-255" json:"description" dc:"奖励描述,可选"`
Status int `v:"in:1,2#状态必须为1或2" json:"status" dc:"状态1=启用2=禁用默认1" d:"1"`
Stock int `v:"min:0#库存不能为负" json:"stock" dc:"奖励库存0表示无限制" d:"0"`
StartAt *gtime.Time `v:"date#开始时间格式无效" json:"startAt" dc:"奖励有效开始时间,可选"`
ExpireAt *gtime.Time `v:"date|after-equal:start_at#结束时间格式无效|结束时间必须晚于开始时间" json:"expireAt" dc:"奖励有效结束时间,可选"`
}
// CreateSystemRewardRes 创建系统奖励响应
type CreateSystemRewardRes struct {
Id int64 `json:"id" dc:"创建的奖励ID"`
}
// CreateStoreRewardReq 创建门店奖励请求
type CreateStoreRewardReq struct {
g.Meta `path:"/reward/store" method:"post" tags:"Reward" summary:"(商户门店后台)创建门店奖励"`
StoreIds []int64 `v:"required|distinct|min-length:1#门店ID列表不能为空|门店ID不能重复|门店ID列表不能为空" json:"storeIds" dc:"门店ID列表"`
RewardTypeId int64 `v:"required|min:1#奖励类型ID不能为空|奖励类型ID无效" json:"rewardTypeId" dc:"奖励类型ID"`
Name string `v:"required|length:1,100#奖励名称不能为空|奖励名称长度为1-100" json:"name" dc:"奖励名称"`
Description string `v:"length:0,255#奖励描述长度为0-255" json:"description" dc:"奖励描述,可选"`
Status int `v:"in:1,2#状态必须为1或2" json:"status" dc:"状态1=启用2=禁用默认1" d:"1"`
Stock int `v:"min:0#库存不能为负" json:"stock" dc:"奖励库存0表示无限制" d:"0"`
StartAt *gtime.Time `v:"date#开始时间格式无效" json:"startAt" dc:"奖励有效开始时间,可选"`
ExpireAt *gtime.Time `v:"date|after-equal:start_at#结束时间格式无效|结束时间必须晚于开始时间" json:"expireAt" dc:"奖励有效结束时间,可选"`
}
// CreateStoreRewardRes 创建门店奖励响应
type CreateStoreRewardRes struct {
Id int64 `json:"id" dc:"创建的奖励ID"`
}
// ListSystemRewardReq 查询系统奖励列表请求
type ListSystemRewardReq struct {
g.Meta `path:"/reward/system" method:"get" tags:"Reward" summary:"(系统)获取系统奖励列表"`
Page int `v:"min:1#页码必须大于0" json:"page" d:"1" dc:"页码"`
PageSize int `v:"min:1|max:100#每页数量必须为1-100" json:"pageSize" d:"10" dc:"每页数量"`
Name string `json:"name" dc:"奖励名称,模糊查询,可选"`
Status int `v:"in:0,1,2#状态无效" json:"status" d:"0" dc:"状态0=全部1=启用2=禁用,可选"`
RewardTypeId int64 `v:"min:0#奖励类型ID无效" json:"rewardTypeId" d:"0" dc:"奖励类型ID0=全部,可选"`
}
// ListSystemRewardRes 查询系统奖励列表响应
type ListSystemRewardRes struct {
List interface{} `json:"list" dc:"奖励列表"`
Total int `json:"total" dc:"总记录数"`
}
// ListStoreRewardReq 查询门店奖励列表请求
type ListStoreRewardReq struct {
g.Meta `path:"/reward/store" method:"get" tags:"Reward" summary:"(系统、商户门店后台)获取门店奖励列表"`
Page int `v:"min:1#页码必须大于0" json:"page" d:"1" dc:"页码"`
PageSize int `v:"min:1|max:100#每页数量必须为1-100" json:"pageSize" d:"10" dc:"每页数量"`
StoreId int64 `v:"min:0#门店ID无效" json:"storeId" d:"0" dc:"门店ID0=全部(管理员使用),其他值过滤该门店可见的奖励,可选"`
Name string `json:"name" dc:"奖励名称,模糊查询,可选"`
Status int `v:"in:0,1,2#状态无效" json:"status" d:"0" dc:"状态0=全部1=启用2=禁用,可选"`
RewardTypeId int64 `v:"min:0#奖励类型ID无效" json:"rewardTypeId" d:"0" dc:"奖励类型ID0=全部,可选"`
}
// ListStoreRewardRes 查询门店奖励列表响应
type ListStoreRewardRes struct {
List interface{} `json:"list" dc:"奖励列表"`
Total int `json:"total" dc:"总记录数"`
}
// UpdateSystemRewardReq 更新系统奖励请求
type UpdateSystemRewardReq struct {
g.Meta `path:"/reward/system" method:"put" tags:"Reward" summary:"(系统)更新系统奖励"`
Id uint64 `v:"required|min:1#奖励ID不能为空|奖励ID无效" json:"id" dc:"奖励ID"`
RewardTypeId int64 `v:"required|min:1#奖励类型ID不能为空|奖励类型ID无效" json:"rewardTypeId" dc:"奖励类型ID"`
Name string `v:"required|length:1,100#奖励名称不能为空|奖励名称长度为1-100" json:"name" dc:"奖励名称"`
Description string `v:"length:0,255#奖励描述长度为0-255" json:"description" dc:"奖励描述,可选"`
Status int `v:"in:1,2#状态必须为1或2" json:"status" dc:"状态1=启用2=禁用"`
Stock int `v:"min:0#库存不能为负" json:"stock" dc:"奖励库存0表示无限制"`
StartAt *gtime.Time `v:"date#开始时间格式无效" json:"startAt" dc:"奖励有效开始时间,可选"`
ExpireAt *gtime.Time `v:"date|after-equal:start_at#结束时间格式无效|结束时间必须晚于开始时间" json:"expireAt" dc:"奖励有效结束时间,可选"`
}
// UpdateSystemRewardRes 更新系统奖励响应
type UpdateSystemRewardRes struct {
Success bool `json:"success" dc:"更新成功"`
}
// UpdateStoreRewardReq 更新门店奖励请求
type UpdateStoreRewardReq struct {
g.Meta `path:"/reward/store/{id}" method:"put" tags:"Reward" summary:"(系统、商户门店后台)更新门店奖励"`
Id uint64 `v:"required|min:1#奖励ID不能为空|奖励ID无效" json:"id" dc:"奖励ID"`
StoreIds []int64 `v:"required|distinct|min-length:1#门店ID列表不能为空|门店ID不能重复|至少指定一个门店ID" json:"storeIds" dc:"关联门店ID列表"`
RewardTypeId int64 `v:"required|min:1#奖励类型ID不能为空|奖励类型ID无效" json:"rewardTypeId" dc:"奖励类型ID"`
Name string `v:"required|length:1,100#奖励名称不能为空|奖励名称长度为1-100" json:"name" dc:"奖励名称"`
Description string `v:"length:0,255#奖励描述长度为0-255" json:"description" dc:"奖励描述,可选"`
Status int `v:"in:1,2#状态必须为1或2" json:"status" dc:"状态1=启用2=禁用"`
Stock int `v:"min:0#库存不能为负" json:"stock" dc:"奖励库存0表示无限制"`
StartAt *gtime.Time `v:"date#开始时间格式无效" json:"startAt" dc:"奖励有效开始时间,可选"`
ExpireAt *gtime.Time `v:"date|after-equal:start_at#结束时间格式无效|结束时间必须晚于开始时间" json:"expireAt" dc:"奖励有效结束时间,可选"`
}
// UpdateStoreRewardRes 更新门店奖励响应
type UpdateStoreRewardRes struct {
Success bool `json:"success" dc:"更新成功"`
}
// DeleteSystemRewardReq 删除系统奖励请求
type DeleteSystemRewardReq struct {
g.Meta `path:"/reward/system/{id}" method:"delete" tags:"Reward" summary:"(系统)删除系统奖励"`
Id uint64 `v:"required|min:1#奖励ID不能为空|奖励ID无效" json:"id" dc:"奖励ID"`
}
// DeleteSystemRewardRes 删除系统奖励响应
type DeleteSystemRewardRes struct {
Success bool `json:"success" dc:"删除成功"`
}
// DeleteStoreRewardReq 删除门店奖励请求
type DeleteStoreRewardReq struct {
g.Meta `path:"/reward/store/{id}" method:"delete" tags:"Reward" summary:"(系统、商户门店后台)删除门店奖励"`
Id uint64 `v:"required|min:1#奖励ID不能为空|奖励ID无效" json:"id" dc:"奖励ID"`
}
// DeleteStoreRewardRes 删除门店奖励响应
type DeleteStoreRewardRes struct {
Success bool `json:"success" dc:"删除成功"`
}
type RewardCallbackReq struct {
g.Meta `path:"/reward/callback" method:"post" tags:"Reward" summary:"(系统)奖励回调"`
UId string `json:"uid"`
OrderId string `json:"order_id"`
PrizeChannelId string `json:"prize_channel_id"`
PrizeId string `json:"prize_id" v:"required|#券ID不能为空"`
PrizeType uint32 `json:"prize_type"`
PrizeSubType uint32 `json:"prize_sub_type"`
Num uint32 `json:"num"`
CustomInfo string `json:"custom_info"`
}
type RewardCallbackRes struct {
ErrCode int32 `json:"errcode"` // 必填
ErrMsg string `json:"errmsg"`
Appid string `json:"appid"`
OrderId string `json:"order_id"` // 必填
Data []RewardCallbackData `json:"data"` // 必填
}
type RewardCallbackData struct {
PrizeCode string `json:"prize_code"` // 必填
Comment string `json:"comment"`
}

View File

@ -1,18 +0,0 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package rewardType
import (
"context"
"server/api/rewardType/v1"
)
type IRewardTypeV1 interface {
List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error)
Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error)
Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error)
Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error)
}

View File

@ -1,50 +0,0 @@
package v1
import "github.com/gogf/gf/v2/frame/g"
type ListReq struct {
g.Meta `path:"/rewardType" method:"get" tags:"奖励类型" summary:"(系统、商户门店后台)获取奖励类型列表"`
Page int `json:"page" v:"required#页码不能为空" dc:"页码"`
Size int `json:"size" v:"required#页大小不能为空" dc:"页大小"`
}
type ListRes struct {
List interface{} `json:"list" dc:"奖励类型列表"`
Total int `json:"total" dc:"总条数"`
}
type CreateReq struct {
g.Meta `path:"/rewardType" method:"post" tags:"奖励类型" summary:"(系统)创建奖励类型"`
Name string `json:"name" v:"required#名称不能为空" dc:"名称"`
Code string `json:"code" v:"required#代号不能为空" dc:"代号"`
Description string `json:"description" v:"required#描述不能为空" dc:"描述"`
//Status int `json:"status" v:"required#状态不能为空" dc:"状态"`
StoreId int `json:"store_id" dc:"门店ID"`
}
type CreateRes struct {
Id int64 `json:"id" dc:"ID"`
}
type UpdateReq struct {
g.Meta `path:"/rewardType" method:"put" tags:"奖励类型" summary:"(系统)更新奖励类型"`
Id int64 `json:"id" v:"required#ID不能为空" dc:"ID"`
Name string `json:"name" v:"required#名称不能为空" dc:"名称"`
Code string `json:"code" v:"required#代号不能为空" dc:"代号"`
Description string `json:"description" v:"required#描述不能为空" dc:"描述"`
Status int `json:"status" v:"required#状态不能为空" dc:"状态"`
StoreId int `json:"store_id" dc:"门店ID"`
}
type UpdateRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type DeleteReq struct {
g.Meta `path:"/rewardType/{id}" method:"delete" tags:"奖励类型" summary:"(系统)删除奖励类型"`
Id int64 `path:"id" v:"required#ID不能为空" dc:"ID"`
}
type DeleteRes struct {
Success bool `json:"success" dc:"是否成功"`
}

View File

@ -11,8 +11,6 @@ import (
"server/internal/controller/game"
"server/internal/controller/merchant"
"server/internal/controller/merchantAdmin"
"server/internal/controller/reward"
"server/internal/controller/rewardType"
"server/internal/controller/role"
"server/internal/controller/store"
"server/internal/controller/storeAdmin"
@ -50,10 +48,8 @@ var (
store.NewV1(),
storeRole.NewV1(),
storeAdmin.NewV1(),
rewardType.NewV1(),
feedback.NewV1(),
user.NewV1(),
reward.NewV1(),
task.NewV1(),
game.NewV1(),
)

View File

@ -1,5 +0,0 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package reward

View File

@ -1,15 +0,0 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package reward
import (
"server/api/reward"
)
type ControllerV1 struct{}
func NewV1() reward.IRewardV1 {
return &ControllerV1{}
}

View File

@ -1,22 +0,0 @@
package reward
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"server/internal/model"
"server/internal/service"
"server/api/reward/v1"
)
func (c *ControllerV1) CreateStoreReward(ctx context.Context, req *v1.CreateStoreRewardReq) (res *v1.CreateStoreRewardRes, err error) {
fromCtx := g.RequestFromCtx(ctx)
operatorId := fromCtx.Get("id").Int64()
operatorRole := fromCtx.Get("role").String()
out, err := service.Reward().CreateStoreReward(ctx, &model.RewardCreateIn{OperatorId: operatorId, OperatorRole: operatorRole, Name: req.Name, Description: req.Description,
RewardTypeID: req.RewardTypeId, StartAt: req.StartAt, ExpireAt: req.ExpireAt, Status: req.Status, Stock: req.Stock, StoreIDs: req.StoreIds})
if err != nil {
return nil, err
}
return &v1.CreateStoreRewardRes{Id: out.Id}, nil
}

View File

@ -1,26 +0,0 @@
package reward
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/reward/v1"
)
func (c *ControllerV1) CreateSystemReward(ctx context.Context, req *v1.CreateSystemRewardReq) (res *v1.CreateSystemRewardRes, err error) {
out, err := service.Reward().CreateSystemReward(ctx, &model.RewardCreateIn{
Description: req.Description,
ExpireAt: req.ExpireAt,
Name: req.Name,
RewardTypeID: req.RewardTypeId,
StartAt: req.StartAt,
Status: req.Status,
Stock: req.Stock,
})
if err != nil {
return nil, err
}
return &v1.CreateSystemRewardRes{Id: out.Id}, nil
}

View File

@ -1,14 +0,0 @@
package reward
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"server/api/reward/v1"
)
func (c *ControllerV1) DeleteStoreReward(ctx context.Context, req *v1.DeleteStoreRewardReq) (res *v1.DeleteStoreRewardRes, err error) {
return nil, gerror.NewCode(gcode.CodeNotImplemented)
}

View File

@ -1,22 +0,0 @@
package reward
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/reward/v1"
)
func (c *ControllerV1) DeleteSystemReward(ctx context.Context, req *v1.DeleteSystemRewardReq) (res *v1.DeleteSystemRewardRes, err error) {
out, err := service.Reward().DeleteSystemReward(ctx, &model.RewardDeleteIn{
ID: int64(req.Id),
})
if err != nil {
return nil, err
}
return &v1.DeleteSystemRewardRes{
Success: out.Success,
}, nil
}

View File

@ -1,14 +0,0 @@
package reward
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"server/api/reward/v1"
)
func (c *ControllerV1) ListStoreReward(ctx context.Context, req *v1.ListStoreRewardReq) (res *v1.ListStoreRewardRes, err error) {
return nil, gerror.NewCode(gcode.CodeNotImplemented)
}

View File

@ -1,27 +0,0 @@
package reward
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/reward/v1"
)
func (c *ControllerV1) ListSystemReward(ctx context.Context, req *v1.ListSystemRewardReq) (res *v1.ListSystemRewardRes, err error) {
out, err := service.Reward().ListSystemReward(ctx, &model.RewardListIn{
Name: req.Name,
Page: req.Page,
Size: req.PageSize,
Status: req.Status,
RewardTypeID: req.RewardTypeId,
})
if err != nil {
return nil, err
}
return &v1.ListSystemRewardRes{
List: out.List,
Total: out.Total,
}, nil
}

View File

@ -1,29 +0,0 @@
package reward
import (
"context"
"fmt"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/glog"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"server/api/reward/v1"
)
func (c *ControllerV1) RewardCallback(ctx context.Context, req *v1.RewardCallbackReq) (res *v1.RewardCallbackRes, err error) {
appId := g.RequestFromCtx(ctx).GetHeader("Custom-Data-Appid")
timestamp := g.RequestFromCtx(ctx).GetHeader("Custom-Data-Timestamp")
nonce := g.RequestFromCtx(ctx).GetHeader("Custom-Data-Nonce")
auth := g.RequestFromCtx(ctx).GetHeader("Custom-Data-Auth")
glog.Infof(ctx, "appId: %s, timestamp: %s, nonce: %s, auth: %s", appId, timestamp, nonce, auth)
secret := ""
data := fmt.Sprintf("%s%s%s%s%d%d%d%s%s%s#%s", req.UId, req.OrderId, req.PrizeId, req.PrizeChannelId, req.PrizeType, req.PrizeSubType, req.Num, appId, timestamp, nonce, secret)
if data != auth {
}
return nil, gerror.NewCode(gcode.CodeNotImplemented)
}

View File

@ -1,14 +0,0 @@
package reward
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"server/api/reward/v1"
)
func (c *ControllerV1) UpdateStoreReward(ctx context.Context, req *v1.UpdateStoreRewardReq) (res *v1.UpdateStoreRewardRes, err error) {
return nil, gerror.NewCode(gcode.CodeNotImplemented)
}

View File

@ -1,27 +0,0 @@
package reward
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/reward/v1"
)
func (c *ControllerV1) UpdateSystemReward(ctx context.Context, req *v1.UpdateSystemRewardReq) (res *v1.UpdateSystemRewardRes, err error) {
out, err := service.Reward().UpdateSystemReward(ctx, &model.RewardUpdateIn{
ID: int64(req.Id),
Name: req.Name,
Description: req.Description,
StartAt: req.StartAt,
ExpireAt: req.ExpireAt,
Status: req.Status,
Stock: req.Stock,
RewardTypeID: req.RewardTypeId,
})
if err != nil {
return nil, err
}
return &v1.UpdateSystemRewardRes{Success: out.Success}, nil
}

View File

@ -1,5 +0,0 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package rewardType

View File

@ -1,15 +0,0 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package rewardType
import (
"server/api/rewardType"
)
type ControllerV1 struct{}
func NewV1() rewardType.IRewardTypeV1 {
return &ControllerV1{}
}

View File

@ -1,24 +0,0 @@
package rewardType
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/rewardType/v1"
)
func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) {
out, err := service.RewardType().CreateRewardType(ctx, &model.CreateRewardTypeIn{
Code: req.Code,
Description: req.Description,
Name: req.Name,
StoreId: req.StoreId,
})
if err != nil {
return nil, err
}
return &v1.CreateRes{
Id: out.Id,
}, err
}

View File

@ -1,19 +0,0 @@
package rewardType
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/rewardType/v1"
)
func (c *ControllerV1) Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) {
out, err := service.RewardType().DeleteRewardType(ctx, &model.DeleteRewardTypeIn{Id: req.Id})
if err != nil {
return nil, err
}
return &v1.DeleteRes{
Success: out.Success,
}, err
}

View File

@ -1,24 +0,0 @@
package rewardType
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"server/internal/model"
"server/internal/service"
"server/api/rewardType/v1"
)
func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error) {
roleName := g.RequestFromCtx(ctx).GetCtxVar("role").String()
operatorId := g.RequestFromCtx(ctx).GetCtxVar("id").Int()
out, err := service.RewardType().List(ctx, &model.RewardTypeIn{Page: req.Page, Size: req.Size, RoleName: roleName, OperatorId: operatorId})
if err != nil {
return nil, err
}
return &v1.ListRes{
List: out.List,
Total: out.Total,
}, nil
}

View File

@ -1,27 +0,0 @@
package rewardType
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/rewardType/v1"
)
func (c *ControllerV1) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) {
out, err := service.RewardType().UpdateRewardType(ctx, &model.UpdateRewardTypeIn{
Id: req.Id,
Name: req.Name,
Code: req.Code,
Status: req.Status,
Description: req.Description,
StoreId: req.StoreId,
})
if err != nil {
return nil, err
}
return &v1.UpdateRes{
Success: out.Success,
}, err
}

View File

@ -16,7 +16,6 @@ type AdminsDao struct {
table string // table is the underlying table name of the 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.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// 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.
func NewAdminsDao(handlers ...gdb.ModelHandler) *AdminsDao {
func NewAdminsDao() *AdminsDao {
return &AdminsDao{
group: "default",
table: "admins",
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.
func (dao *AdminsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type FeedbacksDao struct {
table string // table is the underlying table name of the 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.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// 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.
func NewFeedbacksDao(handlers ...gdb.ModelHandler) *FeedbacksDao {
func NewFeedbacksDao() *FeedbacksDao {
return &FeedbacksDao{
group: "default",
table: "feedbacks",
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.
func (dao *FeedbacksDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type GamesDao struct {
table string // table is the underlying table name of the 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.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// GamesColumns defines and stores column names for the table games.
@ -44,12 +43,11 @@ var gamesColumns = GamesColumns{
}
// NewGamesDao creates and returns a new DAO object for table data access.
func NewGamesDao(handlers ...gdb.ModelHandler) *GamesDao {
func NewGamesDao() *GamesDao {
return &GamesDao{
group: "default",
table: "games",
columns: gamesColumns,
handlers: handlers,
}
}
@ -75,11 +73,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.
func (dao *GamesDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type MerchantAdminsDao struct {
table string // table is the underlying table name of the 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.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// 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.
func NewMerchantAdminsDao(handlers ...gdb.ModelHandler) *MerchantAdminsDao {
func NewMerchantAdminsDao() *MerchantAdminsDao {
return &MerchantAdminsDao{
group: "default",
table: "merchant_admins",
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.
func (dao *MerchantAdminsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type MerchantsDao struct {
table string // table is the underlying table name of the 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.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// 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.
func NewMerchantsDao(handlers ...gdb.ModelHandler) *MerchantsDao {
func NewMerchantsDao() *MerchantsDao {
return &MerchantsDao{
group: "default",
table: "merchants",
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.
func (dao *MerchantsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -1,95 +0,0 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// RewardTypesDao is the data access object for the table reward_types.
type RewardTypesDao struct {
table string // table is the underlying table name of the 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.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// RewardTypesColumns defines and stores column names for the table reward_types.
type RewardTypesColumns struct {
Id string // 类型ID
Name string // 类型名称
Code string // 类型编码
Description string // 类型描述
Status string // 状态1=启用2=禁用
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
DeletedAt string // 软删除时间
StoreId string // 门店 id
}
// rewardTypesColumns holds the columns for the table reward_types.
var rewardTypesColumns = RewardTypesColumns{
Id: "id",
Name: "name",
Code: "code",
Description: "description",
Status: "status",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
StoreId: "store_id",
}
// NewRewardTypesDao creates and returns a new DAO object for table data access.
func NewRewardTypesDao(handlers ...gdb.ModelHandler) *RewardTypesDao {
return &RewardTypesDao{
group: "default",
table: "reward_types",
columns: rewardTypesColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *RewardTypesDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *RewardTypesDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *RewardTypesDao) Columns() RewardTypesColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *RewardTypesDao) Group() string {
return dao.group
}
// 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 {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *RewardTypesDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -1,105 +0,0 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// RewardsDao is the data access object for the table rewards.
type RewardsDao struct {
table string // table is the underlying table name of the 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.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// RewardsColumns defines and stores column names for the table rewards.
type RewardsColumns struct {
Id string // 奖励唯一标识符
RewardTypeId string // 奖励类型ID
RewardScope string // 奖励范围1=系统奖励2=门店奖励
Name string // 奖励名称
Code string // 奖励编号
Description string // 奖励描述
Status string // 状态1=启用2=禁用
Stock string // 奖励库存0表示无限制
StartAt string // 奖励有效开始时间
ExpireAt string // 奖励有效结束时间
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
DeletedAt string // 软删除时间戳
RemainStock string // 剩余库存数量
}
// rewardsColumns holds the columns for the table rewards.
var rewardsColumns = RewardsColumns{
Id: "id",
RewardTypeId: "reward_type_id",
RewardScope: "reward_scope",
Name: "name",
Code: "code",
Description: "description",
Status: "status",
Stock: "stock",
StartAt: "start_at",
ExpireAt: "expire_at",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
RemainStock: "remain_stock",
}
// NewRewardsDao creates and returns a new DAO object for table data access.
func NewRewardsDao(handlers ...gdb.ModelHandler) *RewardsDao {
return &RewardsDao{
group: "default",
table: "rewards",
columns: rewardsColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *RewardsDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *RewardsDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *RewardsDao) Columns() RewardsColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *RewardsDao) Group() string {
return dao.group
}
// 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 {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *RewardsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -16,7 +16,6 @@ type RolesDao struct {
table string // table is the underlying table name of the 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.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// 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.
func NewRolesDao(handlers ...gdb.ModelHandler) *RolesDao {
func NewRolesDao() *RolesDao {
return &RolesDao{
group: "default",
table: "roles",
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.
func (dao *RolesDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type StoreAdminsDao struct {
table string // table is the underlying table name of the 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.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// 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.
func NewStoreAdminsDao(handlers ...gdb.ModelHandler) *StoreAdminsDao {
func NewStoreAdminsDao() *StoreAdminsDao {
return &StoreAdminsDao{
group: "default",
table: "store_admins",
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.
func (dao *StoreAdminsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type StoreDesktopSettingsDao struct {
table string // table is the underlying table name of the 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.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreDesktopSettingsColumns defines and stores column names for the table store_desktop_settings.
@ -46,12 +45,11 @@ var storeDesktopSettingsColumns = StoreDesktopSettingsColumns{
}
// NewStoreDesktopSettingsDao creates and returns a new DAO object for table data access.
func NewStoreDesktopSettingsDao(handlers ...gdb.ModelHandler) *StoreDesktopSettingsDao {
func NewStoreDesktopSettingsDao() *StoreDesktopSettingsDao {
return &StoreDesktopSettingsDao{
group: "default",
table: "store_desktop_settings",
columns: storeDesktopSettingsColumns,
handlers: handlers,
}
}
@ -77,11 +75,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.
func (dao *StoreDesktopSettingsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -1,83 +0,0 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// StoreRewardsDao is the data access object for the table store_rewards.
type StoreRewardsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreRewardsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreRewardsColumns defines and stores column names for the table store_rewards.
type StoreRewardsColumns struct {
StoreId string // 门店ID
RewardId string // 奖励ID
CreatedAt string // 创建时间
}
// storeRewardsColumns holds the columns for the table store_rewards.
var storeRewardsColumns = StoreRewardsColumns{
StoreId: "store_id",
RewardId: "reward_id",
CreatedAt: "created_at",
}
// NewStoreRewardsDao creates and returns a new DAO object for table data access.
func NewStoreRewardsDao(handlers ...gdb.ModelHandler) *StoreRewardsDao {
return &StoreRewardsDao{
group: "default",
table: "store_rewards",
columns: storeRewardsColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *StoreRewardsDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *StoreRewardsDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *StoreRewardsDao) Columns() StoreRewardsColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *StoreRewardsDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoreRewardsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *StoreRewardsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -16,7 +16,6 @@ type StoreRolesDao struct {
table string // table is the underlying table name of the 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.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// 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.
func NewStoreRolesDao(handlers ...gdb.ModelHandler) *StoreRolesDao {
func NewStoreRolesDao() *StoreRolesDao {
return &StoreRolesDao{
group: "default",
table: "store_roles",
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.
func (dao *StoreRolesDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -1,101 +0,0 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// StoreTaskRewardsDao is the data access object for the table store_task_rewards.
type StoreTaskRewardsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreTaskRewardsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreTaskRewardsColumns defines and stores column names for the table store_task_rewards.
type StoreTaskRewardsColumns struct {
Id string // 奖励唯一标识符
TaskId string // 任务ID关联tasks表的id
StoreId string // 门店ID
Name string // 奖励名称
RewardTypeId string // 奖励类型ID
TotalNum string // 奖励总数
UsedNum string // 已使用数量
LimitNum string // 限制数量
CoverImage string // 封面图URL
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
DeletedAt string // 软删除时间戳
}
// storeTaskRewardsColumns holds the columns for the table store_task_rewards.
var storeTaskRewardsColumns = StoreTaskRewardsColumns{
Id: "id",
TaskId: "task_id",
StoreId: "store_id",
Name: "name",
RewardTypeId: "reward_type_id",
TotalNum: "total_num",
UsedNum: "used_num",
LimitNum: "limit_num",
CoverImage: "cover_image",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewStoreTaskRewardsDao creates and returns a new DAO object for table data access.
func NewStoreTaskRewardsDao(handlers ...gdb.ModelHandler) *StoreTaskRewardsDao {
return &StoreTaskRewardsDao{
group: "default",
table: "store_task_rewards",
columns: storeTaskRewardsColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *StoreTaskRewardsDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *StoreTaskRewardsDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *StoreTaskRewardsDao) Columns() StoreTaskRewardsColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *StoreTaskRewardsDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoreTaskRewardsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *StoreTaskRewardsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -16,7 +16,6 @@ type StoresDao struct {
table string // table is the underlying table name of the 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.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// 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.
func NewStoresDao(handlers ...gdb.ModelHandler) *StoresDao {
func NewStoresDao() *StoresDao {
return &StoresDao{
group: "default",
table: "stores",
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.
func (dao *StoresDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type TasksDao struct {
table string // table is the underlying table name of the 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.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// TasksColumns defines and stores column names for the table tasks.
@ -48,12 +47,11 @@ var tasksColumns = TasksColumns{
}
// NewTasksDao creates and returns a new DAO object for table data access.
func NewTasksDao(handlers ...gdb.ModelHandler) *TasksDao {
func NewTasksDao() *TasksDao {
return &TasksDao{
group: "default",
table: "tasks",
columns: tasksColumns,
handlers: handlers,
}
}
@ -79,11 +77,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.
func (dao *TasksDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type UserTasksDao struct {
table string // table is the underlying table name of the 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.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// UserTasksColumns defines and stores column names for the table user_tasks.
@ -48,12 +47,11 @@ var userTasksColumns = UserTasksColumns{
}
// NewUserTasksDao creates and returns a new DAO object for table data access.
func NewUserTasksDao(handlers ...gdb.ModelHandler) *UserTasksDao {
func NewUserTasksDao() *UserTasksDao {
return &UserTasksDao{
group: "default",
table: "user_tasks",
columns: userTasksColumns,
handlers: handlers,
}
}
@ -79,11 +77,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.
func (dao *UserTasksDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type UsersDao struct {
table string // table is the underlying table name of the 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.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// 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.
func NewUsersDao(handlers ...gdb.ModelHandler) *UsersDao {
func NewUsersDao() *UsersDao {
return &UsersDao{
group: "default",
table: "users",
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.
func (dao *UsersDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -1,27 +0,0 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"server/internal/dao/internal"
)
// internalRewardTypesDao is an internal type for wrapping the internal DAO implementation.
type internalRewardTypesDao = *internal.RewardTypesDao
// rewardTypesDao is the data access object for the table reward_types.
// You can define custom methods on it to extend its functionality as needed.
type rewardTypesDao struct {
internalRewardTypesDao
}
var (
// RewardTypes is a globally accessible object for table reward_types operations.
RewardTypes = rewardTypesDao{
internal.NewRewardTypesDao(),
}
)
// Add your custom methods and functionality below.

View File

@ -1,27 +0,0 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"server/internal/dao/internal"
)
// internalRewardsDao is an internal type for wrapping the internal DAO implementation.
type internalRewardsDao = *internal.RewardsDao
// rewardsDao is the data access object for the table rewards.
// You can define custom methods on it to extend its functionality as needed.
type rewardsDao struct {
internalRewardsDao
}
var (
// Rewards is a globally accessible object for table rewards operations.
Rewards = rewardsDao{
internal.NewRewardsDao(),
}
)
// Add your custom methods and functionality below.

View File

@ -1,27 +0,0 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"server/internal/dao/internal"
)
// internalStoreRewardsDao is an internal type for wrapping the internal DAO implementation.
type internalStoreRewardsDao = *internal.StoreRewardsDao
// storeRewardsDao is the data access object for the table store_rewards.
// You can define custom methods on it to extend its functionality as needed.
type storeRewardsDao struct {
internalStoreRewardsDao
}
var (
// StoreRewards is a globally accessible object for table store_rewards operations.
StoreRewards = storeRewardsDao{
internal.NewStoreRewardsDao(),
}
)
// Add your custom methods and functionality below.

View File

@ -1,22 +0,0 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"server/internal/dao/internal"
)
// storeTaskRewardsDao is the data access object for the table store_task_rewards.
// You can define custom methods on it to extend its functionality as needed.
type storeTaskRewardsDao struct {
*internal.StoreTaskRewardsDao
}
var (
// StoreTaskRewards is a globally accessible object for table store_task_rewards operations.
StoreTaskRewards = storeTaskRewardsDao{internal.NewStoreTaskRewardsDao()}
)
// Add your custom methods and functionality below.

View File

@ -10,8 +10,6 @@ import (
_ "server/internal/logic/game"
_ "server/internal/logic/merchant"
_ "server/internal/logic/merchantAdmin"
_ "server/internal/logic/reward"
_ "server/internal/logic/rewardType"
_ "server/internal/logic/role"
_ "server/internal/logic/store"
_ "server/internal/logic/storeAdmin"

View File

@ -1,419 +0,0 @@
package reward
import (
"context"
"fmt"
"github.com/gogf/gf/v2/os/gtime"
"server/internal/consts"
"server/internal/dao"
"server/internal/model"
"server/internal/model/do"
"server/internal/service"
"server/utility/ecode"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/errors/gerror"
)
type sReward struct{}
func New() service.IReward {
return &sReward{}
}
func init() {
service.RegisterReward(New())
}
// CreateSystemReward 创建系统奖励
func (s *sReward) CreateSystemReward(ctx context.Context, in *model.RewardCreateIn) (out *model.CreateOut, err error) {
if in.Name == "" {
return nil, gerror.New("奖励名称不能为空")
}
exist, err := dao.RewardTypes.Ctx(ctx).WherePri(in.RewardTypeID).Exist()
if err != nil {
return nil, ecode.Fail.Sub("奖励类型不存在")
}
if !exist {
return nil, ecode.Params.Sub("奖励类型不存在")
}
// TODO 生成奖励唯一 code
// 插入数据
id, err := dao.Rewards.Ctx(ctx).Data(do.Rewards{
RewardTypeId: in.RewardTypeID,
RewardScope: consts.SystemReward, // 系统奖励
Name: in.Name,
Code: "xmaxa",
Description: in.Description,
Status: in.Status,
Stock: in.Stock,
StartAt: in.StartAt,
ExpireAt: in.ExpireAt,
}).OmitEmptyData().InsertAndGetId()
if err != nil {
return nil, ecode.Fail.Sub("创建奖励失败")
}
return &model.CreateOut{
Id: id,
}, nil
}
// CreateStoreReward 创建门店奖励
func (s *sReward) CreateStoreReward(ctx context.Context, in *model.RewardCreateIn) (out *model.CreateOut, err error) {
if in.OperatorRole != consts.MerchantRoleCode && in.OperatorRole != consts.StoreRoleCode {
return nil, ecode.Params.Sub("只有管理员和商户才能创建门店奖励")
}
// 验证 OperatorId 对 门店 id 是否存在权限
if in.OperatorRole == consts.MerchantRoleCode {
count, err := dao.MerchantAdmins.Ctx(ctx).LeftJoin(
dao.Stores.Table(),
fmt.Sprintf("%s.%s=%s.%s", dao.Stores.Table(), dao.Stores.Columns().MerchantId, dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId),
).Where(dao.Stores.Columns().Id, in.StoreIDs).WherePri(in.OperatorId).Count()
if err != nil {
return nil, gerror.Wrap(err, "检查商户权限失败")
}
if count != len(in.StoreIDs) {
return nil, ecode.Params.Sub("商户权限不足")
}
} else {
count, err := dao.StoreAdmins.Ctx(ctx).
LeftJoin(
dao.Stores.Table(),
fmt.Sprintf("%s.%s=%s.%s", dao.Stores.Table(), dao.Stores.Columns().Id, dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId),
).WherePri(in.OperatorId).WhereIn(dao.Stores.Columns().Id, in.StoreIDs).Count()
if err != nil {
return nil, gerror.Wrap(err, "检查门店权限失败")
}
if count != len(in.StoreIDs) {
return nil, ecode.Params.Sub("门店权限不足")
}
}
if in.Name == "" {
return nil, gerror.New("奖励名称不能为空")
}
exist, err := dao.RewardTypes.Ctx(ctx).WherePri(in.RewardTypeID).Exist()
if err != nil {
return nil, ecode.Fail.Sub("奖励类型不存在")
}
if !exist {
return nil, ecode.Params.Sub("奖励类型不存在")
}
if err = dao.Rewards.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
// TODO 生成奖励唯一 code
// 首先插入奖励
id, err := dao.Rewards.Ctx(ctx).Data(do.Rewards{
RewardTypeId: in.RewardTypeID,
RewardScope: consts.StoreReward, // 门店奖励
Name: in.Name,
Code: "",
Description: in.Description,
Status: in.Status,
Stock: in.Stock,
StartAt: in.StartAt,
ExpireAt: in.ExpireAt,
}).OmitEmptyData().InsertAndGetId() // 忽略空值插入
if err != nil {
return ecode.Fail.Sub("创建门店奖励失败")
}
insertDatas := make([]do.StoreRewards, 0, len(in.StoreIDs))
// 插入门店奖励关系表
for _, d := range in.StoreIDs {
insertDatas = append(insertDatas, do.StoreRewards{
RewardId: id,
StoreId: d,
})
}
if _, err := dao.StoreRewards.Ctx(ctx).Data(insertDatas).Insert(); err != nil {
return ecode.Fail.Sub("创建门店奖励关联失败")
}
return nil
}); err != nil {
return nil, err
}
return
}
// ListSystemReward 查询系统奖励列表
func (s *sReward) ListSystemReward(ctx context.Context, in *model.RewardListIn) (out *model.RewardListOut, err error) {
m := dao.Rewards.Ctx(ctx)
// 构建查询条件
if in.Name != "" {
m = m.WhereLike(dao.Rewards.Columns().Name, "%"+in.Name+"%")
}
if in.RewardTypeID != 0 {
m = m.Where(do.Rewards{RewardTypeId: in.RewardTypeID})
}
if in.Status > 0 {
m = m.Where(do.Rewards{
Status: in.Status,
})
}
list := make([]model.Reward, 0)
var total int
err = m.Page(in.Page, in.Size).Where(do.Rewards{RewardScope: 1}).OrderDesc(dao.Rewards.Columns().CreatedAt).OrderDesc(dao.Rewards.Columns().Id).ScanAndCount(&list, &total, false)
if err != nil {
return nil, ecode.Fail.Sub("查询系统奖励失败")
}
return &model.RewardListOut{
List: list,
Total: total,
}, nil
}
// ListStoreReward 查询门店奖励列表
func (s *sReward) ListStoreReward(ctx context.Context, in *model.RewardListIn) (out *model.RewardListOut, err error) {
// 商户可以查询下属门店的所有商品信息,商户只能查询自己的门店商品信息
if in.OperatorRole != consts.MerchantRoleCode && in.OperatorRole != consts.StoreRoleCode {
return nil, ecode.Params.Sub("只有管理员和商户才能查询门店奖励")
}
if in.OperatorRole == consts.MerchantRoleCode {
// 获取商户管理员所属商户 id根据 商户 id 和门店 id 查询记录是否
exist, err := dao.MerchantAdmins.Ctx(ctx).LeftJoin(
dao.Stores.Table(),
fmt.Sprintf("%s.%s=%s.%s", dao.Stores.Table(), dao.Stores.Columns().MerchantId, dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId),
).WherePri(in.StoreID).Exist()
if err != nil {
return nil, gerror.Wrap(err, "检查商户权限失败")
}
if !exist {
return nil, ecode.Params.Sub("商户权限不足")
}
}
// 构建查询
query := dao.Rewards.Ctx(ctx).LeftJoin(
dao.StoreRewards.Table(),
fmt.Sprintf("%s.%s=%s.%s", dao.Rewards.Table(), dao.Rewards.Columns().Id, dao.StoreRewards.Table(), dao.StoreRewards.Columns().RewardId),
).Where(dao.Rewards.Columns().RewardScope, consts.StoreReward)
// 应用过滤条件
if in.StoreID != nil && *in.StoreID > 0 {
query = query.Where(dao.StoreRewards.Columns().StoreId, *in.StoreID)
}
if in.RewardTypeID > 0 {
query = query.Where(dao.Rewards.Columns().RewardTypeId, in.RewardTypeID)
}
if in.Name != "" {
query = query.WhereLike(dao.Rewards.Columns().Name, "%"+in.Name+"%")
}
if in.Status > 0 {
query = query.Where(dao.Rewards.Columns().Status, in.Status)
}
if in.RewardScope > 0 {
query = query.Where(dao.Rewards.Columns().RewardScope, in.RewardScope)
}
// 查询奖励列表
list := make([]model.Reward, 0)
var total int
err = query.Fields(dao.Rewards.Columns()).Page(in.Page, in.Size).ScanAndCount(&list, &total, false)
if err != nil {
return nil, ecode.Fail.Sub("查询奖励列表失败")
}
return &model.RewardListOut{
List: list,
Total: total,
}, nil
}
// UpdateSystemReward 更新系统奖励
func (s *sReward) UpdateSystemReward(ctx context.Context, in *model.RewardUpdateIn) (out *model.UpdateOut, err error) {
exist, err := dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: in.ID}).Exist()
if err != nil {
return nil, ecode.Fail.Sub("查询该奖励失败")
}
if !exist {
return nil, ecode.Params.Sub("该奖励不存在")
}
_, err = dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: in.ID, RewardScope: 1}).Update(do.Rewards{
RewardTypeId: in.RewardTypeID,
Name: in.Name,
Description: in.Description,
Status: in.Status,
Stock: in.Stock,
StartAt: in.StartAt,
ExpireAt: in.ExpireAt,
})
if err != nil {
return nil, ecode.Fail.Sub("更新奖励失败")
}
return &model.UpdateOut{Success: true}, nil
}
// UpdateStoreReward 更新门店奖励
func (s *sReward) UpdateStoreReward(ctx context.Context, in *model.RewardUpdateIn) (out *model.UpdateOut, err error) {
if in.OperatorRole != consts.MerchantRoleCode && in.OperatorRole != consts.StoreRoleCode {
return nil, ecode.Params.Sub("只有管理员和商户才能更新门店奖励")
}
// 1. 如果是门店管理员,只需要更新奖励信息即可
// 2. 如果是商户管理员,更新奖励信息,同时将 StoreIds 中id 不在门店关系表的数据删除
// 验证奖励是否存在且为门店奖励
exist, err := dao.Rewards.Ctx(ctx).Where("id = ? AND reward_scope = ? AND deleted_at IS NULL", in.ID, consts.StoreReward).Exist()
if err != nil {
return nil, ecode.Fail.Sub("检查奖励是否存在失败")
}
if !exist {
return nil, ecode.Params.Sub("门店奖励不存在或已删除")
}
if in.Name == "" {
return nil, ecode.Params.Sub("奖励名称不能为空")
}
exist, err = dao.RewardTypes.Ctx(ctx).WherePri(in.RewardTypeID).Exist()
if err != nil {
return nil, ecode.Fail.Sub("检查奖励类型失败")
}
if !exist {
return nil, ecode.Params.Sub("奖励类型不存在")
}
// 使用事务确保数据一致性
err = dao.Rewards.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
// 更新 rewards 表
_, err := tx.Model(dao.Rewards).Data(do.Rewards{
RewardTypeId: in.RewardTypeID,
Name: in.Name,
Description: in.Description,
Status: in.Status,
Stock: in.Stock,
StartAt: in.StartAt,
ExpireAt: in.ExpireAt,
UpdatedAt: gtime.Now(),
}).Where("id = ?", in.ID).OmitEmptyData().Update()
if err != nil {
return ecode.Fail.Sub("更新奖励信息失败")
}
// 门店管理员不修改门店关联
if in.OperatorRole == consts.MerchantRoleCode {
return nil
}
// 验证 StoreIDs 是否存在
count, err := dao.Stores.Ctx(ctx).WhereIn("id", in.StoreIDs).Count()
if err != nil {
return ecode.Fail.Sub("检查门店ID失败")
}
if count != len(in.StoreIDs) {
return ecode.Params.Sub("存在无效的门店ID")
}
// 删除旧的门店关联
_, err = tx.Model(dao.StoreRewards).Where(do.StoreRewards{RewardId: in.ID}).Delete()
if err != nil {
return ecode.Fail.Sub("删除旧门店关联失败")
}
// 插入新的门店关联
storeRewardData := make([]do.StoreRewards, len(in.StoreIDs))
for i, storeID := range in.StoreIDs {
storeRewardData[i] = do.StoreRewards{
StoreId: storeID,
RewardId: in.ID,
}
}
_, err = tx.Model(dao.StoreRewards).Data(storeRewardData).Insert()
if err != nil {
return ecode.Fail.Sub("关联门店失败")
}
return nil
})
if err != nil {
return nil, err
}
return &model.UpdateOut{
Success: true,
}, nil
}
// DeleteSystemReward 删除系统奖励
func (s *sReward) DeleteSystemReward(ctx context.Context, in *model.RewardDeleteIn) (out *model.DeleteOut, err error) {
exist, err := dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: in.ID}).Exist()
if err != nil {
return nil, ecode.Fail.Sub("查询该奖励失败")
}
if !exist {
return nil, ecode.Params.Sub("该奖励不存在")
}
_, err = dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: in.ID}).Delete()
if err != nil {
return nil, ecode.Fail.Sub("删除奖励失败")
}
return &model.DeleteOut{Success: true}, nil
}
// DeleteStoreReward 删除门店奖励
func (s *sReward) DeleteStoreReward(ctx context.Context, in *model.RewardDeleteIn) (out *model.DeleteOut, err error) {
// 验证操作者角色
if in.OperatorRole != consts.MerchantRoleCode && in.OperatorRole != consts.StoreRoleCode {
return nil, ecode.Params.Sub("只有管理员和商户才能删除门店奖励")
}
// 验证奖励是否存在且为门店奖励
exist, err := dao.Rewards.Ctx(ctx).WherePri(in.ID).Where(do.Rewards{RewardScope: consts.StoreReward}).Exist()
if err != nil {
return nil, ecode.Fail.Sub("检查奖励是否存在失败")
}
if !exist {
return nil, ecode.Params.Sub("门店奖励不存在或已删除")
}
storeIds := make([]int64, 0)
if in.OperatorRole == consts.MerchantRoleCode {
array, err := dao.MerchantAdmins.Ctx(ctx).LeftJoin(
dao.Stores.Table(),
fmt.Sprintf("%s.%s=%s.%s", dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId, dao.Stores.Table(), dao.Stores.Columns().MerchantId),
).Where(do.MerchantAdmins{Id: in.OperatorId}).Fields(dao.Stores.Columns().Id).Array()
if err != nil {
return nil, ecode.Fail.Sub("查询商户门店失败")
}
for _, value := range array {
storeIds = append(storeIds, value.Int64())
}
} else {
value, err := dao.StoreAdmins.Ctx(ctx).LeftJoin().WherePri(in.OperatorId).Fields(dao.StoreRewards.Columns().StoreId).Value()
if err != nil {
return nil, ecode.Fail.Sub("查询门店失败")
}
storeIds = append(storeIds, value.Int64())
}
if err = dao.Rewards.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
if _, err := dao.Rewards.Ctx(ctx).WherePri(in.ID).Delete(); err != nil {
return ecode.Fail.Sub("删除奖励失败")
}
if _, err := dao.StoreRewards.Ctx(ctx).Where(do.StoreRewards{RewardId: in.ID}).WhereIn(dao.StoreRewards.Columns().StoreId, storeIds).Delete(); err != nil {
return ecode.Fail.Sub("删除门店奖励关联失败")
}
return nil
}); err != nil {
return nil, err
}
return &model.DeleteOut{
Success: true,
}, nil
}
func (s *sReward) Detail(ctx context.Context, in *model.RewardDetailIn) (out *model.RewardDetailOut, err error) {
return
}

View File

@ -1,136 +0,0 @@
package rewardType
import (
"context"
"fmt"
"server/internal/consts"
"server/internal/dao"
"server/internal/model"
"server/internal/model/do"
"server/internal/service"
"server/utility/ecode"
)
type sRewardType struct {
}
func New() service.IRewardType {
return &sRewardType{}
}
func init() {
service.RegisterRewardType(New())
}
func (s *sRewardType) List(ctx context.Context, in *model.RewardTypeIn) (out *model.RewardTypeOut, err error) {
m := dao.RewardTypes.Ctx(ctx)
// 默认分页
if in.Page == 0 {
in.Page = 1
}
if in.Size == 0 {
in.Size = 10
}
// 判断角色
if in.RoleName == consts.StoreRoleCode {
m = m.Where(do.RewardTypes{StoreId: in.OperatorId})
}
list := make([]model.RewardType, 0)
var total int
err = m.Fields(fmt.Sprintf("%s.*, %s.%s %s", dao.RewardTypes.Table(), dao.Stores.Table(), dao.Stores.Columns().Name, "store_name")).LeftJoin(dao.Stores.Table(), fmt.Sprintf("`%s`.`id` = `%s`.`store_id`", dao.Stores.Table(), dao.RewardTypes.Table())).Page(in.Page, in.Size).OrderDesc(dao.RewardTypes.Columns().CreatedAt).ScanAndCount(&list, &total, false)
if err != nil {
return nil, err
}
return &model.RewardTypeOut{
List: list,
Total: total,
}, nil
}
func (s *sRewardType) CreateRewardType(ctx context.Context, in *model.CreateRewardTypeIn) (out *model.CreateRewardTypeOut, err error) {
// 检查类型名称是否存在
exist, err := dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Name: in.Name, StoreId: in.StoreId}).Exist()
if err != nil {
return nil, ecode.Fail.Sub("查询该奖励类型失败")
}
if exist {
return nil, ecode.Params.Sub("类型名称已存在")
}
exist, err = dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Code: in.Code, StoreId: in.StoreId}).Exist()
if err != nil {
return nil, ecode.Fail.Sub("查询该奖励类型失败")
}
if exist {
return nil, ecode.Params.Sub("类型代号已存在")
}
id, err := dao.RewardTypes.Ctx(ctx).InsertAndGetId(do.RewardTypes{
Name: in.Name,
Code: in.Code,
Description: in.Description,
StoreId: in.StoreId,
})
if err != nil {
return nil, err
}
return &model.CreateRewardTypeOut{Id: id}, nil
}
func (s *sRewardType) UpdateRewardType(ctx context.Context, in *model.UpdateRewardTypeIn) (out *model.UpdateRewardTypeOut, err error) {
// 检查更新的是否存在
exist, err := dao.RewardTypes.Ctx(ctx).WherePri(in.Id).Where(do.RewardTypes{StoreId: in.StoreId}).Exist()
if err != nil {
return nil, ecode.Fail.Sub("查询奖励类型失败")
}
if !exist {
return nil, ecode.Params.Sub("更新的奖励类型不存在")
}
exist, err = dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Name: in.Name, StoreId: in.StoreId}).Exist()
if err != nil {
return nil, ecode.Fail.Sub("查询奖励类型失败")
}
if exist {
return nil, ecode.Params.Sub("奖励类型名称已存在")
}
// 更新奖励类型
_, err = dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Id: in.Id}).Update(do.RewardTypes{
Name: in.Name,
Status: in.Status,
Code: in.Code,
Description: in.Description,
})
if err != nil {
return nil, err
}
return &model.UpdateRewardTypeOut{Success: true}, nil
}
func (s *sRewardType) DeleteRewardType(ctx context.Context, in *model.DeleteRewardTypeIn) (out *model.DeleteRewardTypeOut, err error) {
exist, err := dao.RewardTypes.Ctx(ctx).WherePri(do.RewardTypes{
Id: in.Id,
}).Exist()
if err != nil {
return nil, ecode.Params.Sub("查询删除奖励类型失败")
}
if !exist {
return nil, ecode.Params.Sub("删除的奖励类型不存在")
}
_, err = dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Id: in.Id}).Delete()
if err != nil {
return nil, err
}
return &model.DeleteRewardTypeOut{Success: true}, nil
}

View File

@ -43,6 +43,7 @@ func Auth(r *ghttp.Request) {
r.SetCtxVar("id", tokenOut.UserId)
r.SetCtxVar("role", tokenOut.Role)
r.SetCtxVar("jti", tokenOut.JTI)
glog.Infof(ctx, "%s用户访问: %s %s", tokenOut.Role, r.URL.Path, r.Method)
}
r.Middleware.Next()
}

View File

@ -1,24 +0,0 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// RewardTypes is the golang structure of table reward_types for DAO operations like Where/Data.
type RewardTypes struct {
g.Meta `orm:"table:reward_types, do:true"`
Id interface{} // 类型ID
Name interface{} // 类型名称
Code interface{} // 类型编码
Description interface{} // 类型描述
Status interface{} // 状态1=启用2=禁用
CreatedAt *gtime.Time // 创建时间
UpdatedAt *gtime.Time // 更新时间
DeletedAt *gtime.Time // 软删除时间
StoreId interface{} // 门店 id
}

View File

@ -1,29 +0,0 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// Rewards is the golang structure of table rewards for DAO operations like Where/Data.
type Rewards struct {
g.Meta `orm:"table:rewards, do:true"`
Id interface{} // 奖励唯一标识符
RewardTypeId interface{} // 奖励类型ID
RewardScope interface{} // 奖励范围1=系统奖励2=门店奖励
Name interface{} // 奖励名称
Code interface{} // 奖励编号
Description interface{} // 奖励描述
Status interface{} // 状态1=启用2=禁用
Stock interface{} // 奖励库存0表示无限制
StartAt *gtime.Time // 奖励有效开始时间
ExpireAt *gtime.Time // 奖励有效结束时间
CreatedAt *gtime.Time // 创建时间
UpdatedAt *gtime.Time // 更新时间
DeletedAt *gtime.Time // 软删除时间戳
RemainStock interface{} // 剩余库存数量
}

View File

@ -1,18 +0,0 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// StoreRewards is the golang structure of table store_rewards for DAO operations like Where/Data.
type StoreRewards struct {
g.Meta `orm:"table:store_rewards, do:true"`
StoreId interface{} // 门店ID
RewardId interface{} // 奖励ID
CreatedAt *gtime.Time // 创建时间
}

View File

@ -1,27 +0,0 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// StoreTaskRewards is the golang structure of table store_task_rewards for DAO operations like Where/Data.
type StoreTaskRewards struct {
g.Meta `orm:"table:store_task_rewards, do:true"`
Id interface{} // 奖励唯一标识符
TaskId interface{} // 任务ID关联tasks表的id
StoreId interface{} // 门店ID
Name interface{} // 奖励名称
RewardTypeId interface{} // 奖励类型ID
TotalNum interface{} // 奖励总数
UsedNum interface{} // 已使用数量
LimitNum interface{} // 限制数量
CoverImage interface{} // 封面图URL
CreatedAt *gtime.Time // 创建时间
UpdatedAt *gtime.Time // 更新时间
DeletedAt *gtime.Time // 软删除时间戳
}

View File

@ -1,22 +0,0 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// RewardTypes is the golang structure for table reward_types.
type RewardTypes struct {
Id int64 `json:"id" orm:"id" description:"类型ID"` // 类型ID
Name string `json:"name" orm:"name" description:"类型名称"` // 类型名称
Code string `json:"code" orm:"code" description:"类型编码"` // 类型编码
Description string `json:"description" orm:"description" description:"类型描述"` // 类型描述
Status int `json:"status" orm:"status" description:"状态1=启用2=禁用"` // 状态1=启用2=禁用
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id
}

View File

@ -1,27 +0,0 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// Rewards is the golang structure for table rewards.
type Rewards struct {
Id int64 `json:"id" orm:"id" description:"奖励唯一标识符"` // 奖励唯一标识符
RewardTypeId int64 `json:"rewardTypeId" orm:"reward_type_id" description:"奖励类型ID"` // 奖励类型ID
RewardScope int `json:"rewardScope" orm:"reward_scope" description:"奖励范围1=系统奖励2=门店奖励"` // 奖励范围1=系统奖励2=门店奖励
Name string `json:"name" orm:"name" description:"奖励名称"` // 奖励名称
Code string `json:"code" orm:"code" description:"奖励编号"` // 奖励编号
Description string `json:"description" orm:"description" description:"奖励描述"` // 奖励描述
Status int `json:"status" orm:"status" description:"状态1=启用2=禁用"` // 状态1=启用2=禁用
Stock int `json:"stock" orm:"stock" description:"奖励库存0表示无限制"` // 奖励库存0表示无限制
StartAt *gtime.Time `json:"startAt" orm:"start_at" description:"奖励有效开始时间"` // 奖励有效开始时间
ExpireAt *gtime.Time `json:"expireAt" orm:"expire_at" description:"奖励有效结束时间"` // 奖励有效结束时间
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳
RemainStock int `json:"remainStock" orm:"remain_stock" description:"剩余库存数量"` // 剩余库存数量
}

View File

@ -1,16 +0,0 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// StoreRewards is the golang structure for table store_rewards.
type StoreRewards struct {
StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID"` // 门店ID
RewardId int64 `json:"rewardId" orm:"reward_id" description:"奖励ID"` // 奖励ID
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
}

View File

@ -1,25 +0,0 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// StoreTaskRewards is the golang structure for table store_task_rewards.
type StoreTaskRewards struct {
Id int64 `json:"id" orm:"id" description:"奖励唯一标识符"` // 奖励唯一标识符
TaskId int64 `json:"taskId" orm:"task_id" description:"任务ID关联tasks表的id"` // 任务ID关联tasks表的id
StoreId string `json:"storeId" orm:"store_id" description:"门店ID"` // 门店ID
Name string `json:"name" orm:"name" description:"奖励名称"` // 奖励名称
RewardTypeId string `json:"rewardTypeId" orm:"reward_type_id" description:"奖励类型ID"` // 奖励类型ID
TotalNum int `json:"totalNum" orm:"total_num" description:"奖励总数"` // 奖励总数
UsedNum int `json:"usedNum" orm:"used_num" description:"已使用数量"` // 已使用数量
LimitNum int `json:"limitNum" orm:"limit_num" description:"限制数量"` // 限制数量
CoverImage string `json:"coverImage" orm:"cover_image" description:"封面图URL"` // 封面图URL
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳
}

View File

@ -1,82 +0,0 @@
package model
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// Reward 奖励信息
type Reward struct {
g.Meta `orm:"table:rewards"`
ID int64 `json:"id" orm:"id,primary"` // 奖励ID
RewardTypeID int64 `json:"rewardTypeId" orm:"reward_type_id,not null"` // 奖励类型ID
RewardScope int `json:"rewardScope" orm:"reward_scope,not null,default:2"` // 奖励范围1=系统奖励2=门店奖励
Name string `json:"name" orm:"name,not null"` // 奖励名称
Code string `json:"code" orm:"code,unique"` // 奖励编号
Description string `json:"description" orm:"description"` // 奖励描述
Status int `json:"status" orm:"status,default:1"` // 状态1=启用2=禁用
Stock int `json:"stock" orm:"stock,default:0"` // 奖励库存0表示无限制
StartAt *gtime.Time `json:"startAt" orm:"start_at"` // 奖励有效开始时间
ExpireAt *gtime.Time `json:"expireAt" orm:"expire_at"` // 奖励有效结束时间
}
type RewardCreateIn struct {
OperatorId int64 // 操作人ID
OperatorRole string // 操作人角色
RewardTypeID int64 // 奖励类型ID
RewardScope int // 奖励范围1=系统奖励2=门店奖励
Name string // 奖励名称
Description string // 奖励描述
Status int // 状态1=启用2=禁用
Stock int // 奖励库存0表示无限制
StartAt *gtime.Time // 奖励有效开始时间
ExpireAt *gtime.Time // 奖励有效结束时间
StoreIDs []int64 // 关联门店ID列表仅门店奖励需要
}
type RewardUpdateIn struct {
ID int64 // 奖励ID
OperatorId int64 // 操作人ID
OperatorRole string // 操作人角色
RewardTypeID int64 // 奖励类型ID
RewardScope int // 奖励范围1=系统奖励2=门店奖励
Name string // 奖励名称
Description string // 奖励描述
Status int // 状态1=启用2=禁用
Stock int // 奖励库存0表示无限制
StartAt *gtime.Time // 奖励有效开始时间
ExpireAt *gtime.Time // 奖励有效结束时间
StoreIDs []int64 // 关联门店ID列表仅门店奖励需要
}
type RewardListIn struct {
OperatorId int64 // 操作人ID
OperatorRole string // 操作人角色
Page int // 页码
Size int // 每页数量
StoreID *int64 // 门店ID用于过滤门店可见的奖励
RewardTypeID int64 // 奖励类型ID
Name string // 奖励名称(模糊查询)
Status int // 状态1=启用2=禁用
RewardScope int // 奖励范围1=系统奖励2=门店奖励
}
type RewardListOut struct {
List []Reward // 奖励列表
Total int // 总记录数
}
type RewardDeleteIn struct {
ID int64 // 奖励ID
OperatorId int64 // 操作人ID
OperatorRole string // 操作人角色
}
type RewardDetailIn struct {
ID int64 // 奖励ID
}
type RewardDetailOut struct {
*Reward
StoreIDs []int64 // 关联门店ID列表仅门店奖励有值
}

View File

@ -1,68 +0,0 @@
package model
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
type RewardType struct {
g.Meta `orm:"table:reward_type"`
Id int64 `json:"id" dc:"ID" orm:"id,primary"`
Name string `json:"name" dc:"名称" orm:"name"`
Code string `json:"code" dc:"代号" orm:"code"`
Status int `json:"status" dc:"状态1=启用2=禁用" orm:"status"`
Description string `json:"description" dc:"描述" orm:"description"`
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"`
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"删除时间"`
//StoreId int `json:"storeId" dc:"门店ID" orm:"store_id"`
StoreName string `json:"storeName" dc:"门店名称" orm:"store_name"`
}
type RewardTypeIn struct {
Page int
Size int
RoleName string
OperatorId int
}
type RewardTypeOut struct {
List []RewardType
Total int
}
type CreateRewardTypeIn struct {
Name string
Code string
Description string
Status int
StoreId int
}
type CreateRewardTypeOut struct {
Id int64
}
// UpdateRewardTypeIn 更新奖励类型传入参数
type UpdateRewardTypeIn struct {
Id int64
Name string
Code string
Description string
Status int
StoreId int
}
// UpdateRewardTypeOut 更新奖励类型返回参数
type UpdateRewardTypeOut struct {
Success bool
}
// DeleteRewardTypeIn 删除奖励类型传入参数
type DeleteRewardTypeIn struct {
Id int64
}
// DeleteRewardTypeOut 删除奖励类型返回参数
type DeleteRewardTypeOut struct {
Success bool
}

View File

@ -1,22 +0,0 @@
package model
import (
"github.com/gogf/gf/v2/frame/g"
"time"
)
type StoreTaskReward struct {
g.Meta `orm:"table:store_task_rewards"`
Id int64 `orm:"id" json:"id"` // 奖励唯一标识符
TaskId int64 `orm:"task_id" json:"task_id"` // 任务ID关联tasks表的id
StoreId string `orm:"store_id" json:"store_id"` // 门店ID
Name string `orm:"name" json:"name"` // 奖励名称
RewardTypeId string `orm:"reward_type_id" json:"reward_type_id"` // 奖励类型ID
TotalNum int32 `orm:"total_num" json:"total_num"` // 奖励总数
UsedNum int32 `orm:"used_num" json:"used_num"` // 已使用数量
LimitNum int32 `orm:"limit_num" json:"limit_num"` // 限制数量
CoverImage string `orm:"cover_image" json:"cover_image"` // 封面图URL
CreatedAt time.Time `orm:"created_at" json:"created_at"` // 创建时间
UpdatedAt time.Time `orm:"updated_at" json:"updated_at"` // 更新时间
DeletedAt time.Time `orm:"deleted_at" json:"deleted_at"` // 软删除时间戳
}

View File

@ -16,7 +16,6 @@ type Tasks struct {
QqNetbarTaskRules string `json:"qqNetbarTaskRules" orm:"qq_netbar_task_rules" description:"任务规则"` // 任务规则
GameId int64 `json:"gameId" orm:"game_id" description:"游戏唯一id"` // 游戏唯一id
StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id
StoreTaskRewards []StoreTaskReward `json:"storeTaskRewards" orm:"with:task_id=id"`
}
type GetNonLoginTaskListIn struct {

View File

@ -1,48 +0,0 @@
// ================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================
package service
import (
"context"
"server/internal/model"
)
type (
IReward interface {
// CreateSystemReward 创建系统奖励
CreateSystemReward(ctx context.Context, in *model.RewardCreateIn) (out *model.CreateOut, err error)
// CreateStoreReward 创建门店奖励
CreateStoreReward(ctx context.Context, in *model.RewardCreateIn) (out *model.CreateOut, err error)
// ListSystemReward 查询系统奖励列表
ListSystemReward(ctx context.Context, in *model.RewardListIn) (out *model.RewardListOut, err error)
// ListStoreReward 查询门店奖励列表
ListStoreReward(ctx context.Context, in *model.RewardListIn) (out *model.RewardListOut, err error)
// UpdateSystemReward 更新系统奖励
UpdateSystemReward(ctx context.Context, in *model.RewardUpdateIn) (out *model.UpdateOut, err error)
// UpdateStoreReward 更新门店奖励
UpdateStoreReward(ctx context.Context, in *model.RewardUpdateIn) (out *model.UpdateOut, err error)
// DeleteSystemReward 删除系统奖励
DeleteSystemReward(ctx context.Context, in *model.RewardDeleteIn) (out *model.DeleteOut, err error)
// DeleteStoreReward 删除门店奖励
DeleteStoreReward(ctx context.Context, in *model.RewardDeleteIn) (out *model.DeleteOut, err error)
Detail(ctx context.Context, in *model.RewardDetailIn) (out *model.RewardDetailOut, err error)
}
)
var (
localReward IReward
)
func Reward() IReward {
if localReward == nil {
panic("implement not found for interface IReward, forgot register?")
}
return localReward
}
func RegisterReward(i IReward) {
localReward = i
}

View File

@ -1,35 +0,0 @@
// ================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================
package service
import (
"context"
"server/internal/model"
)
type (
IRewardType interface {
List(ctx context.Context, in *model.RewardTypeIn) (out *model.RewardTypeOut, err error)
CreateRewardType(ctx context.Context, in *model.CreateRewardTypeIn) (out *model.CreateRewardTypeOut, err error)
UpdateRewardType(ctx context.Context, in *model.UpdateRewardTypeIn) (out *model.UpdateRewardTypeOut, err error)
DeleteRewardType(ctx context.Context, in *model.DeleteRewardTypeIn) (out *model.DeleteRewardTypeOut, err error)
}
)
var (
localRewardType IRewardType
)
func RewardType() IRewardType {
if localRewardType == nil {
panic("implement not found for interface IRewardType, forgot register?")
}
return localRewardType
}
func RegisterRewardType(i IRewardType) {
localRewardType = i
}

View File

@ -88,6 +88,8 @@ func init() {
enforcer.AddPolicy("store", "/x/rewardType", "PUT", "更新奖励类型")
enforcer.AddPolicy("store", "/x/rewardType/*", "DELETE", "删除奖励类型")
enforcer.AddPolicy("store", "/x/reward/store", "GET", "获取门店奖励列表")
// 门店角色
enforcer.AddPolicy("store", "/x/store/role", "GET", "获取门店角色列表")
enforcer.AddPolicy("store", "/x/store/role", "POST", "添加门店角色")