生成奖励相关代码,实现新增门店奖励
This commit is contained in:
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)
|
||||
}
|
||||
@ -13,10 +13,9 @@ import (
|
||||
|
||||
// AdminsDao is the data access object for the table admins.
|
||||
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.
|
||||
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.
|
||||
}
|
||||
|
||||
// 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,
|
||||
group: "default",
|
||||
table: "admins",
|
||||
columns: adminsColumns,
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -13,10 +13,9 @@ import (
|
||||
|
||||
// MerchantAdminsDao is the data access object for the table merchant_admins.
|
||||
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.
|
||||
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.
|
||||
}
|
||||
|
||||
// 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.
|
||||
func NewMerchantAdminsDao(handlers ...gdb.ModelHandler) *MerchantAdminsDao {
|
||||
func NewMerchantAdminsDao() *MerchantAdminsDao {
|
||||
return &MerchantAdminsDao{
|
||||
group: "default",
|
||||
table: "merchant_admins",
|
||||
columns: merchantAdminsColumns,
|
||||
handlers: handlers,
|
||||
group: "default",
|
||||
table: "merchant_admins",
|
||||
columns: merchantAdminsColumns,
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.
|
||||
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.
|
||||
|
||||
@ -13,10 +13,9 @@ import (
|
||||
|
||||
// MerchantsDao is the data access object for the table merchants.
|
||||
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.
|
||||
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.
|
||||
}
|
||||
|
||||
// MerchantsColumns defines and stores column names for the table merchants.
|
||||
@ -42,6 +41,7 @@ type MerchantsColumns struct {
|
||||
AuditAt string // 审核时间
|
||||
AuditRemark string // 审核备注
|
||||
RejectReason string // 拒绝原因
|
||||
MerchantCode string // 商户编号
|
||||
}
|
||||
|
||||
// merchantsColumns holds the columns for the table merchants.
|
||||
@ -67,15 +67,15 @@ var merchantsColumns = MerchantsColumns{
|
||||
AuditAt: "audit_at",
|
||||
AuditRemark: "audit_remark",
|
||||
RejectReason: "reject_reason",
|
||||
MerchantCode: "merchant_code",
|
||||
}
|
||||
|
||||
// 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,
|
||||
group: "default",
|
||||
table: "merchants",
|
||||
columns: merchantsColumns,
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.
|
||||
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.
|
||||
|
||||
@ -13,10 +13,9 @@ import (
|
||||
|
||||
// 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.
|
||||
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.
|
||||
}
|
||||
|
||||
// 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.
|
||||
func NewRewardTypesDao(handlers ...gdb.ModelHandler) *RewardTypesDao {
|
||||
func NewRewardTypesDao() *RewardTypesDao {
|
||||
return &RewardTypesDao{
|
||||
group: "default",
|
||||
table: "reward_types",
|
||||
columns: rewardTypesColumns,
|
||||
handlers: handlers,
|
||||
group: "default",
|
||||
table: "reward_types",
|
||||
columns: rewardTypesColumns,
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.
|
||||
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)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
@ -13,10 +13,9 @@ import (
|
||||
|
||||
// RolesDao is the data access object for the table roles.
|
||||
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.
|
||||
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.
|
||||
}
|
||||
|
||||
// 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.
|
||||
func NewRolesDao(handlers ...gdb.ModelHandler) *RolesDao {
|
||||
func NewRolesDao() *RolesDao {
|
||||
return &RolesDao{
|
||||
group: "default",
|
||||
table: "roles",
|
||||
columns: rolesColumns,
|
||||
handlers: handlers,
|
||||
group: "default",
|
||||
table: "roles",
|
||||
columns: rolesColumns,
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.
|
||||
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.
|
||||
|
||||
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)
|
||||
}
|
||||
@ -13,10 +13,9 @@ import (
|
||||
|
||||
// StoresDao is the data access object for the table stores.
|
||||
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.
|
||||
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.
|
||||
}
|
||||
|
||||
// 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.
|
||||
func NewStoresDao(handlers ...gdb.ModelHandler) *StoresDao {
|
||||
func NewStoresDao() *StoresDao {
|
||||
return &StoresDao{
|
||||
group: "default",
|
||||
table: "stores",
|
||||
columns: storesColumns,
|
||||
handlers: handlers,
|
||||
group: "default",
|
||||
table: "stores",
|
||||
columns: storesColumns,
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.
|
||||
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.
|
||||
|
||||
@ -13,10 +13,9 @@ import (
|
||||
|
||||
// UsersDao is the data access object for the table users.
|
||||
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.
|
||||
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.
|
||||
}
|
||||
|
||||
// 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,
|
||||
group: "default",
|
||||
table: "users",
|
||||
columns: usersColumns,
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.
|
||||
|
||||
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/merchant"
|
||||
_ "server/internal/logic/merchantAdmin"
|
||||
_ "server/internal/logic/reward"
|
||||
_ "server/internal/logic/rewardType"
|
||||
_ "server/internal/logic/role"
|
||||
_ "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
|
||||
|
||||
import "github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
// Admin 管理员信息
|
||||
type Admin struct {
|
||||
g.Meta `orm:"table:admins"`
|
||||
Id int64 `json:"id" orm:"id,primary"` // 管理员ID
|
||||
RoleId int64 `json:"roleId" orm:"role_id,not null"` // 角色ID
|
||||
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