生成奖励相关代码,实现新增门店奖励
This commit is contained in:
22
api/reward/reward.go
Normal file
22
api/reward/reward.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
133
api/reward/v1/reward.go
Normal file
133
api/reward/v1/reward.go
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
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:"奖励类型ID,0=全部,可选"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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:"门店ID,0=全部(管理员使用),其他值过滤该门店可见的奖励,可选"`
|
||||||
|
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:"奖励类型ID,0=全部,可选"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListStoreRewardRes 查询门店奖励列表响应
|
||||||
|
type ListStoreRewardRes struct {
|
||||||
|
List interface{} `json:"list" dc:"奖励列表"`
|
||||||
|
Total int `json:"total" dc:"总记录数"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateSystemRewardReq 更新系统奖励请求
|
||||||
|
type UpdateSystemRewardReq struct {
|
||||||
|
g.Meta `path:"/reward/system/{id}" 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:"删除成功"`
|
||||||
|
}
|
||||||
6
internal/consts/reward.go
Normal file
6
internal/consts/reward.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package consts
|
||||||
|
|
||||||
|
const (
|
||||||
|
SystemReward = iota + 1
|
||||||
|
StoreReward
|
||||||
|
)
|
||||||
5
internal/controller/reward/reward.go
Normal file
5
internal/controller/reward/reward.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package reward
|
||||||
15
internal/controller/reward/reward_new.go
Normal file
15
internal/controller/reward/reward_new.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package reward
|
||||||
|
|
||||||
|
import (
|
||||||
|
"server/api/reward"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ControllerV1 struct{}
|
||||||
|
|
||||||
|
func NewV1() reward.IRewardV1 {
|
||||||
|
return &ControllerV1{}
|
||||||
|
}
|
||||||
22
internal/controller/reward/reward_v1_create_store_reward.go
Normal file
22
internal/controller/reward/reward_v1_create_store_reward.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
14
internal/controller/reward/reward_v1_create_system_reward.go
Normal file
14
internal/controller/reward/reward_v1_create_system_reward.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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) CreateSystemReward(ctx context.Context, req *v1.CreateSystemRewardReq) (res *v1.CreateSystemRewardRes, err error) {
|
||||||
|
return nil, gerror.NewCode(gcode.CodeNotImplemented)
|
||||||
|
}
|
||||||
14
internal/controller/reward/reward_v1_delete_store_reward.go
Normal file
14
internal/controller/reward/reward_v1_delete_store_reward.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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)
|
||||||
|
}
|
||||||
14
internal/controller/reward/reward_v1_delete_system_reward.go
Normal file
14
internal/controller/reward/reward_v1_delete_system_reward.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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) DeleteSystemReward(ctx context.Context, req *v1.DeleteSystemRewardReq) (res *v1.DeleteSystemRewardRes, err error) {
|
||||||
|
return nil, gerror.NewCode(gcode.CodeNotImplemented)
|
||||||
|
}
|
||||||
14
internal/controller/reward/reward_v1_list_store_reward.go
Normal file
14
internal/controller/reward/reward_v1_list_store_reward.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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)
|
||||||
|
}
|
||||||
14
internal/controller/reward/reward_v1_list_system_reward.go
Normal file
14
internal/controller/reward/reward_v1_list_system_reward.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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) ListSystemReward(ctx context.Context, req *v1.ListSystemRewardReq) (res *v1.ListSystemRewardRes, err error) {
|
||||||
|
return nil, gerror.NewCode(gcode.CodeNotImplemented)
|
||||||
|
}
|
||||||
14
internal/controller/reward/reward_v1_update_store_reward.go
Normal file
14
internal/controller/reward/reward_v1_update_store_reward.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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)
|
||||||
|
}
|
||||||
14
internal/controller/reward/reward_v1_update_system_reward.go
Normal file
14
internal/controller/reward/reward_v1_update_system_reward.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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) UpdateSystemReward(ctx context.Context, req *v1.UpdateSystemRewardReq) (res *v1.UpdateSystemRewardRes, err error) {
|
||||||
|
return nil, gerror.NewCode(gcode.CodeNotImplemented)
|
||||||
|
}
|
||||||
@ -16,7 +16,6 @@ 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.
|
||||||
|
|||||||
@ -16,7 +16,6 @@ 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.
|
||||||
@ -60,12 +59,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,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,11 +89,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.
|
||||||
|
|||||||
@ -16,7 +16,6 @@ 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.
|
||||||
@ -42,6 +41,7 @@ type MerchantsColumns struct {
|
|||||||
AuditAt string // 审核时间
|
AuditAt string // 审核时间
|
||||||
AuditRemark string // 审核备注
|
AuditRemark string // 审核备注
|
||||||
RejectReason string // 拒绝原因
|
RejectReason string // 拒绝原因
|
||||||
|
MerchantCode string // 商户编号
|
||||||
}
|
}
|
||||||
|
|
||||||
// merchantsColumns holds the columns for the table merchants.
|
// merchantsColumns holds the columns for the table merchants.
|
||||||
@ -67,15 +67,15 @@ var merchantsColumns = MerchantsColumns{
|
|||||||
AuditAt: "audit_at",
|
AuditAt: "audit_at",
|
||||||
AuditRemark: "audit_remark",
|
AuditRemark: "audit_remark",
|
||||||
RejectReason: "reject_reason",
|
RejectReason: "reject_reason",
|
||||||
|
MerchantCode: "merchant_code",
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,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.
|
||||||
|
|||||||
@ -16,7 +16,6 @@ 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.
|
||||||
@ -44,12 +43,11 @@ var rewardTypesColumns = RewardTypesColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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 +73,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.
|
||||||
|
|||||||
97
internal/dao/internal/rewards.go
Normal file
97
internal/dao/internal/rewards.go
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// 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.
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 // 软删除时间戳
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRewardsDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewRewardsDao() *RewardsDao {
|
||||||
|
return &RewardsDao{
|
||||||
|
group: "default",
|
||||||
|
table: "rewards",
|
||||||
|
columns: rewardsColumns,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 {
|
||||||
|
return dao.DB().Model(dao.table).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)
|
||||||
|
}
|
||||||
@ -16,7 +16,6 @@ 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.
|
||||||
@ -46,12 +45,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,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,11 +75,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.
|
||||||
|
|||||||
77
internal/dao/internal/store_rewards.go
Normal file
77
internal/dao/internal/store_rewards.go
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// 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.
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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() *StoreRewardsDao {
|
||||||
|
return &StoreRewardsDao{
|
||||||
|
group: "default",
|
||||||
|
table: "store_rewards",
|
||||||
|
columns: storeRewardsColumns,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 {
|
||||||
|
return dao.DB().Model(dao.table).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)
|
||||||
|
}
|
||||||
@ -16,7 +16,6 @@ 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.
|
||||||
@ -50,12 +49,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,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,11 +79,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.
|
||||||
|
|||||||
@ -16,7 +16,6 @@ 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.
|
||||||
|
|||||||
27
internal/dao/rewards.go
Normal file
27
internal/dao/rewards.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// 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.
|
||||||
27
internal/dao/store_rewards.go
Normal file
27
internal/dao/store_rewards.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// 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.
|
||||||
@ -9,6 +9,7 @@ import (
|
|||||||
_ "server/internal/logic/feedback"
|
_ "server/internal/logic/feedback"
|
||||||
_ "server/internal/logic/merchant"
|
_ "server/internal/logic/merchant"
|
||||||
_ "server/internal/logic/merchantAdmin"
|
_ "server/internal/logic/merchantAdmin"
|
||||||
|
_ "server/internal/logic/reward"
|
||||||
_ "server/internal/logic/rewardType"
|
_ "server/internal/logic/rewardType"
|
||||||
_ "server/internal/logic/role"
|
_ "server/internal/logic/role"
|
||||||
_ "server/internal/logic/store"
|
_ "server/internal/logic/store"
|
||||||
|
|||||||
171
internal/logic/reward/reward.go
Normal file
171
internal/logic/reward/reward.go
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
package reward
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"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: "",
|
||||||
|
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.AdminRoleCode {
|
||||||
|
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) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListStoreReward 查询门店奖励列表
|
||||||
|
func (s *sReward) ListStoreReward(ctx context.Context, in *model.RewardListIn) (out *model.RewardListOut, err error) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateSystemReward 更新系统奖励
|
||||||
|
func (s *sReward) UpdateSystemReward(ctx context.Context, in *model.RewardUpdateIn) (out *model.UpdateOut, err error) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStoreReward 更新门店奖励
|
||||||
|
func (s *sReward) UpdateStoreReward(ctx context.Context, in *model.RewardUpdateIn) (out *model.UpdateOut, err error) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteSystemReward 删除系统奖励
|
||||||
|
func (s *sReward) DeleteSystemReward(ctx context.Context, in *model.RewardDeleteIn) (out *model.DeleteOut, err error) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteStoreReward 删除门店奖励
|
||||||
|
func (s *sReward) DeleteStoreReward(ctx context.Context, in *model.RewardDeleteIn) (out *model.DeleteOut, err error) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *sReward) Detail(ctx context.Context, in *model.RewardDetailIn) (out *model.RewardDetailOut, err error) {
|
||||||
|
return
|
||||||
|
}
|
||||||
@ -1,7 +1,10 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
|
import "github.com/gogf/gf/v2/frame/g"
|
||||||
|
|
||||||
// Admin 管理员信息
|
// Admin 管理员信息
|
||||||
type Admin struct {
|
type Admin struct {
|
||||||
|
g.Meta `orm:"table:admins"`
|
||||||
Id int64 `json:"id" orm:"id,primary"` // 管理员ID
|
Id int64 `json:"id" orm:"id,primary"` // 管理员ID
|
||||||
RoleId int64 `json:"roleId" orm:"role_id,not null"` // 角色ID
|
RoleId int64 `json:"roleId" orm:"role_id,not null"` // 角色ID
|
||||||
Username string `json:"username" orm:"username,not null"` // 管理员用户名
|
Username string `json:"username" orm:"username,not null"` // 管理员用户名
|
||||||
|
|||||||
28
internal/model/do/rewards.go
Normal file
28
internal/model/do/rewards.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// 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 // 软删除时间戳
|
||||||
|
}
|
||||||
18
internal/model/do/store_rewards.go
Normal file
18
internal/model/do/store_rewards.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// 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 // 创建时间
|
||||||
|
}
|
||||||
26
internal/model/entity/rewards.go
Normal file
26
internal/model/entity/rewards.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// 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:"软删除时间戳"` // 软删除时间戳
|
||||||
|
}
|
||||||
16
internal/model/entity/store_rewards.go
Normal file
16
internal/model/entity/store_rewards.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// 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:"创建时间"` // 创建时间
|
||||||
|
}
|
||||||
74
internal/model/reward.go
Normal file
74
internal/model/reward.go
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reward 奖励信息
|
||||||
|
type Reward struct {
|
||||||
|
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
|
||||||
|
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 {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
type RewardDetailIn struct {
|
||||||
|
ID int64 // 奖励ID
|
||||||
|
}
|
||||||
|
|
||||||
|
type RewardDetailOut struct {
|
||||||
|
*Reward
|
||||||
|
StoreIDs []int64 // 关联门店ID列表(仅门店奖励有值)
|
||||||
|
}
|
||||||
48
internal/service/reward.go
Normal file
48
internal/service/reward.go
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// ================================================================================
|
||||||
|
// 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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user