实现奖励类型的增删改查
This commit is contained in:
@ -11,6 +11,7 @@ import (
|
||||
"server/internal/controller/game"
|
||||
"server/internal/controller/merchant"
|
||||
"server/internal/controller/merchantAdmin"
|
||||
"server/internal/controller/rewardType"
|
||||
"server/internal/controller/role"
|
||||
"server/internal/controller/store"
|
||||
"server/internal/controller/storeAdmin"
|
||||
@ -52,6 +53,7 @@ var (
|
||||
user.NewV1(),
|
||||
task.NewV1(),
|
||||
game.NewV1(),
|
||||
rewardType.NewV1(),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
5
internal/controller/rewardType/rewardType.go
Normal file
5
internal/controller/rewardType/rewardType.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package rewardType
|
||||
15
internal/controller/rewardType/rewardType_new.go
Normal file
15
internal/controller/rewardType/rewardType_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 rewardType
|
||||
|
||||
import (
|
||||
"server/api/rewardType"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() rewardType.IRewardTypeV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
22
internal/controller/rewardType/rewardType_v1_create.go
Normal file
22
internal/controller/rewardType/rewardType_v1_create.go
Normal file
@ -0,0 +1,22 @@
|
||||
package rewardType
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/rewardType/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) {
|
||||
fromCtx := g.RequestFromCtx(ctx)
|
||||
operatorId := fromCtx.GetCtxVar("id").Int64()
|
||||
operatorRole := fromCtx.GetCtxVar("role").String()
|
||||
out, err := service.RewardType().Create(ctx, &model.RewardTypeCreateIn{OperatorId: operatorId, OperatorRole: operatorRole, Name: req.Name, Description: req.Description, Source: req.Source, Status: req.Status, StoreId: req.StoreId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.CreateRes{Id: out.Id}, nil
|
||||
|
||||
}
|
||||
21
internal/controller/rewardType/rewardType_v1_delete.go
Normal file
21
internal/controller/rewardType/rewardType_v1_delete.go
Normal file
@ -0,0 +1,21 @@
|
||||
package rewardType
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/rewardType/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) {
|
||||
fromCtx := g.RequestFromCtx(ctx)
|
||||
operatorId := fromCtx.GetCtxVar("id").Int64()
|
||||
operatorRole := fromCtx.GetCtxVar("role").String()
|
||||
out, err := service.RewardType().Delete(ctx, &model.RewardTypeDeleteIn{Id: req.Id, OperatorId: operatorId, OperatorRole: operatorRole})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.DeleteRes{Success: out.Success}, nil
|
||||
}
|
||||
24
internal/controller/rewardType/rewardType_v1_list.go
Normal file
24
internal/controller/rewardType/rewardType_v1_list.go
Normal file
@ -0,0 +1,24 @@
|
||||
package rewardType
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/rewardType/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error) {
|
||||
fromCtx := g.RequestFromCtx(ctx)
|
||||
operatorId := fromCtx.GetCtxVar("id").Int64()
|
||||
operatorRole := fromCtx.GetCtxVar("role").String()
|
||||
out, err := service.RewardType().List(ctx, &model.RewardTypeListIn{Page: req.Page, Size: req.Size, OperatorId: operatorId, OperatorRole: operatorRole, StoreId: req.StoreId, Name: req.Name, Status: req.Status})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ListRes{
|
||||
List: out.List,
|
||||
Total: out.Total,
|
||||
}, nil
|
||||
}
|
||||
29
internal/controller/rewardType/rewardType_v1_update.go
Normal file
29
internal/controller/rewardType/rewardType_v1_update.go
Normal file
@ -0,0 +1,29 @@
|
||||
package rewardType
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/rewardType/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) {
|
||||
fromCtx := g.RequestFromCtx(ctx)
|
||||
operatorId := fromCtx.GetCtxVar("id").Int64()
|
||||
operatorRole := fromCtx.GetCtxVar("role").String()
|
||||
out, err := service.RewardType().Update(ctx, &model.RewardTypeUpdateIn{
|
||||
Id: req.Id,
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
Status: req.Status,
|
||||
OperatorId: operatorId,
|
||||
OperatorRole: operatorRole,
|
||||
StoreId: req.StoreId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.UpdateRes{Success: out.Success}, nil
|
||||
}
|
||||
89
internal/dao/internal/reward_types.go
Normal file
89
internal/dao/internal/reward_types.go
Normal file
@ -0,0 +1,89 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// RewardTypesDao is the data access object for the table reward_types.
|
||||
type RewardTypesDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns RewardTypesColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// RewardTypesColumns defines and stores column names for the table reward_types.
|
||||
type RewardTypesColumns struct {
|
||||
Id string // 奖励类型ID
|
||||
Name string // 奖励类型名称(如积分、优惠券)
|
||||
Description string // 奖励类型描述
|
||||
Source string // 来源:1=系统默认,2=门店自定义
|
||||
StoreId string // 门店ID,系统默认类型为NULL
|
||||
Status string // 状态:1=正常,0=禁用
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
}
|
||||
|
||||
// rewardTypesColumns holds the columns for the table reward_types.
|
||||
var rewardTypesColumns = RewardTypesColumns{
|
||||
Id: "id",
|
||||
Name: "name",
|
||||
Description: "description",
|
||||
Source: "source",
|
||||
StoreId: "store_id",
|
||||
Status: "status",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewRewardTypesDao creates and returns a new DAO object for table data access.
|
||||
func NewRewardTypesDao() *RewardTypesDao {
|
||||
return &RewardTypesDao{
|
||||
group: "default",
|
||||
table: "reward_types",
|
||||
columns: rewardTypesColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *RewardTypesDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *RewardTypesDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *RewardTypesDao) Columns() RewardTypesColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *RewardTypesDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *RewardTypesDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
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 *RewardTypesDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
93
internal/dao/internal/rewards.go
Normal file
93
internal/dao/internal/rewards.go
Normal file
@ -0,0 +1,93 @@
|
||||
// ==========================================================================
|
||||
// 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 // 奖励ID
|
||||
RewardTypeId string // 奖励类型ID
|
||||
Name string // 奖励名称(如100积分、5元优惠券)
|
||||
Description string // 奖励描述
|
||||
Source string // 来源:1=系统内置,2=门店自定义
|
||||
StoreId string // 门店ID,系统内置奖励为NULL
|
||||
Value string // 奖励值(如积分数额、优惠金额)
|
||||
Status string // 状态:1=正常,0=禁用
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
}
|
||||
|
||||
// rewardsColumns holds the columns for the table rewards.
|
||||
var rewardsColumns = RewardsColumns{
|
||||
Id: "id",
|
||||
RewardTypeId: "reward_type_id",
|
||||
Name: "name",
|
||||
Description: "description",
|
||||
Source: "source",
|
||||
StoreId: "store_id",
|
||||
Value: "value",
|
||||
Status: "status",
|
||||
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)
|
||||
}
|
||||
89
internal/dao/internal/store_task_rewards.go
Normal file
89
internal/dao/internal/store_task_rewards.go
Normal file
@ -0,0 +1,89 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// StoreTaskRewardsDao is the data access object for the table store_task_rewards.
|
||||
type StoreTaskRewardsDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns StoreTaskRewardsColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// StoreTaskRewardsColumns defines and stores column names for the table store_task_rewards.
|
||||
type StoreTaskRewardsColumns struct {
|
||||
Id string // 任务奖励关联ID
|
||||
TaskId string // 门店任务ID
|
||||
RewardId string // 奖励ID
|
||||
StoreId string // 门店ID
|
||||
Quantity string // 奖励数量(如发放多少个奖励)
|
||||
Status string // 状态:1=正常,0=禁用
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
}
|
||||
|
||||
// storeTaskRewardsColumns holds the columns for the table store_task_rewards.
|
||||
var storeTaskRewardsColumns = StoreTaskRewardsColumns{
|
||||
Id: "id",
|
||||
TaskId: "task_id",
|
||||
RewardId: "reward_id",
|
||||
StoreId: "store_id",
|
||||
Quantity: "quantity",
|
||||
Status: "status",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewStoreTaskRewardsDao creates and returns a new DAO object for table data access.
|
||||
func NewStoreTaskRewardsDao() *StoreTaskRewardsDao {
|
||||
return &StoreTaskRewardsDao{
|
||||
group: "default",
|
||||
table: "store_task_rewards",
|
||||
columns: storeTaskRewardsColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *StoreTaskRewardsDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *StoreTaskRewardsDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *StoreTaskRewardsDao) Columns() StoreTaskRewardsColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *StoreTaskRewardsDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *StoreTaskRewardsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
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 *StoreTaskRewardsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
27
internal/dao/reward_types.go
Normal file
27
internal/dao/reward_types.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"
|
||||
)
|
||||
|
||||
// internalRewardTypesDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalRewardTypesDao = *internal.RewardTypesDao
|
||||
|
||||
// rewardTypesDao is the data access object for the table reward_types.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type rewardTypesDao struct {
|
||||
internalRewardTypesDao
|
||||
}
|
||||
|
||||
var (
|
||||
// RewardTypes is a globally accessible object for table reward_types operations.
|
||||
RewardTypes = rewardTypesDao{
|
||||
internal.NewRewardTypesDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
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_task_rewards.go
Normal file
27
internal/dao/store_task_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"
|
||||
)
|
||||
|
||||
// internalStoreTaskRewardsDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalStoreTaskRewardsDao = *internal.StoreTaskRewardsDao
|
||||
|
||||
// storeTaskRewardsDao is the data access object for the table store_task_rewards.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type storeTaskRewardsDao struct {
|
||||
internalStoreTaskRewardsDao
|
||||
}
|
||||
|
||||
var (
|
||||
// StoreTaskRewards is a globally accessible object for table store_task_rewards operations.
|
||||
StoreTaskRewards = storeTaskRewardsDao{
|
||||
internal.NewStoreTaskRewardsDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
@ -10,6 +10,8 @@ import (
|
||||
_ "server/internal/logic/game"
|
||||
_ "server/internal/logic/merchant"
|
||||
_ "server/internal/logic/merchantAdmin"
|
||||
_ "server/internal/logic/reward"
|
||||
_ "server/internal/logic/rewardType"
|
||||
_ "server/internal/logic/role"
|
||||
_ "server/internal/logic/store"
|
||||
_ "server/internal/logic/storeAdmin"
|
||||
|
||||
23
internal/logic/reward/reward.go
Normal file
23
internal/logic/reward/reward.go
Normal file
@ -0,0 +1,23 @@
|
||||
package reward
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
type sReward struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterReward(New())
|
||||
}
|
||||
|
||||
func New() service.IReward {
|
||||
return &sReward{}
|
||||
}
|
||||
|
||||
func (s *sReward) List(ctx context.Context, in *model.RewardListIn) (out *model.RewardListOut, err error) {
|
||||
return
|
||||
|
||||
}
|
||||
311
internal/logic/rewardType/rewardType.go
Normal file
311
internal/logic/rewardType/rewardType.go
Normal file
@ -0,0 +1,311 @@
|
||||
package reward
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"server/internal/consts"
|
||||
"server/internal/dao"
|
||||
"server/internal/model"
|
||||
"server/internal/model/do"
|
||||
"server/internal/service"
|
||||
"server/utility/ecode"
|
||||
)
|
||||
|
||||
type sRewardType struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterRewardType(New())
|
||||
}
|
||||
|
||||
func New() service.IRewardType {
|
||||
return &sRewardType{}
|
||||
}
|
||||
|
||||
// Create 创建奖励类型
|
||||
func (s *sRewardType) Create(ctx context.Context, in *model.RewardTypeCreateIn) (out *model.RewardTypeCreateOut, err error) {
|
||||
// 创建时,source为1的奖励类型只能由管理员创建
|
||||
// 商户和门店管理员创建奖励时需要判断是有拥有 storeId 的权限
|
||||
|
||||
// 检查 source=1 的奖励类型只能由管理员创建
|
||||
if in.Source == 1 && in.OperatorRole != consts.AdminRoleCode {
|
||||
return nil, ecode.Params.Sub("只有管理员可以创建 source=1 的奖励类型")
|
||||
}
|
||||
|
||||
// 根据角色和权限检查
|
||||
switch in.OperatorRole {
|
||||
case consts.MerchantRoleCode:
|
||||
// 检查商户是否有该门店权限
|
||||
exist, err := dao.MerchantAdmins.Ctx(ctx).LeftJoin(
|
||||
dao.Stores.Table(),
|
||||
fmt.Sprintf("%s.%s = %s.%s",
|
||||
dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId,
|
||||
dao.Stores.Table(), dao.Stores.Columns().MerchantId,
|
||||
),
|
||||
).Where(
|
||||
fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId,
|
||||
).Where(
|
||||
do.MerchantAdmins{Id: in.OperatorId},
|
||||
).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("检查操作者权限出现异常")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.Params.Sub("无门店权限")
|
||||
}
|
||||
|
||||
case consts.StoreRoleCode:
|
||||
// 检查门店是否有权限
|
||||
exist, err := dao.StoreAdmins.Ctx(ctx).LeftJoin(
|
||||
dao.Stores.Table(),
|
||||
fmt.Sprintf("%s.%s = %s.%s",
|
||||
dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId,
|
||||
dao.Stores.Table(), dao.Stores.Columns().Id,
|
||||
),
|
||||
).Where(
|
||||
fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId,
|
||||
).Where(
|
||||
do.StoreAdmins{Id: in.OperatorId},
|
||||
).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("检查操作者权限出现异常")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.Params.Sub("无门店权限")
|
||||
}
|
||||
}
|
||||
|
||||
id, err := dao.RewardTypes.Ctx(ctx).Data(do.RewardTypes{
|
||||
Name: in.Name,
|
||||
Description: in.Description,
|
||||
Source: in.Source,
|
||||
StoreId: in.StoreId,
|
||||
}).OmitEmptyData().InsertAndGetId()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &model.RewardTypeCreateOut{
|
||||
Id: id,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Update 更新奖励类型
|
||||
// Update 更新奖励类型
|
||||
func (s *sRewardType) Update(ctx context.Context, in *model.RewardTypeUpdateIn) (out *model.RewardTypeUpdateOut, err error) {
|
||||
// 查询原始记录,确保存在,并获取 store_id 和 source 字段用于权限判断
|
||||
value, err := dao.RewardTypes.Ctx(ctx).
|
||||
Fields(dao.RewardTypes.Columns().Id, dao.RewardTypes.Columns().Source, dao.RewardTypes.Columns().StoreId).
|
||||
Where(do.RewardTypes{Id: in.Id}).One()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询奖励类型失败")
|
||||
}
|
||||
if value.IsEmpty() {
|
||||
return nil, ecode.Params.Sub("奖励类型不存在")
|
||||
}
|
||||
|
||||
// source=1 的奖励类型只能由管理员修改
|
||||
|
||||
if value[dao.RewardTypes.Columns().Source].Int() == 1 && in.OperatorRole != consts.AdminRoleCode {
|
||||
return nil, ecode.Params.Sub("只有管理员可以修改的系统奖励类型")
|
||||
}
|
||||
|
||||
// 权限校验(管理员跳过)
|
||||
switch in.OperatorRole {
|
||||
case consts.MerchantRoleCode:
|
||||
exist, err := dao.MerchantAdmins.Ctx(ctx).LeftJoin(
|
||||
dao.Stores.Table(),
|
||||
fmt.Sprintf("%s.%s = %s.%s",
|
||||
dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId,
|
||||
dao.Stores.Table(), dao.Stores.Columns().MerchantId,
|
||||
),
|
||||
).Where(
|
||||
fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), value[dao.RewardTypes.Columns().StoreId].Int(),
|
||||
).Where(
|
||||
do.MerchantAdmins{Id: in.OperatorId},
|
||||
).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("检查操作者权限出现异常")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.Params.Sub("无门店权限")
|
||||
}
|
||||
|
||||
case consts.StoreRoleCode:
|
||||
exist, err := dao.StoreAdmins.Ctx(ctx).LeftJoin(
|
||||
dao.Stores.Table(),
|
||||
fmt.Sprintf("%s.%s = %s.%s",
|
||||
dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId,
|
||||
dao.Stores.Table(), dao.Stores.Columns().Id,
|
||||
),
|
||||
).Where(
|
||||
fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), value[dao.RewardTypes.Columns().StoreId].Int(),
|
||||
).Where(
|
||||
do.StoreAdmins{Id: in.OperatorId},
|
||||
).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("检查操作者权限出现异常")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.Params.Sub("无门店权限")
|
||||
}
|
||||
}
|
||||
|
||||
// 执行更新(不允许更新 store_id 和 source)
|
||||
_, err = dao.RewardTypes.Ctx(ctx).
|
||||
Where(do.RewardTypes{Id: in.Id}).
|
||||
Data(do.RewardTypes{
|
||||
Name: in.Name,
|
||||
Description: in.Description,
|
||||
Status: in.Status,
|
||||
}).OmitEmptyData().
|
||||
Update()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("更新奖励类型失败")
|
||||
}
|
||||
|
||||
return &model.RewardTypeUpdateOut{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Delete 删除奖励类型
|
||||
func (s *sRewardType) Delete(ctx context.Context, in *model.RewardTypeDeleteIn) (out *model.RewardTypeDeleteOut, err error) {
|
||||
// 查询原始记录,确保存在,并获取 store_id 和 source 字段用于权限判断
|
||||
value, err := dao.RewardTypes.Ctx(ctx).
|
||||
Fields(dao.RewardTypes.Columns().Id, dao.RewardTypes.Columns().Source, dao.RewardTypes.Columns().StoreId).
|
||||
Where(do.RewardTypes{Id: in.Id}).
|
||||
One()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询奖励类型失败")
|
||||
}
|
||||
if value.IsEmpty() {
|
||||
return nil, ecode.Params.Sub("奖励类型不存在")
|
||||
}
|
||||
|
||||
// source=1 的奖励类型只能由管理员删除
|
||||
if value[dao.RewardTypes.Columns().Source].Int() == 1 && in.OperatorRole != consts.AdminRoleCode {
|
||||
return nil, ecode.Params.Sub("只有管理员可以删除的系统奖励类型")
|
||||
}
|
||||
|
||||
// 权限校验(管理员跳过)
|
||||
switch in.OperatorRole {
|
||||
case consts.MerchantRoleCode:
|
||||
exist, err := dao.MerchantAdmins.Ctx(ctx).LeftJoin(
|
||||
dao.Stores.Table(),
|
||||
fmt.Sprintf("%s.%s = %s.%s",
|
||||
dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId,
|
||||
dao.Stores.Table(), dao.Stores.Columns().MerchantId,
|
||||
),
|
||||
).Where(
|
||||
fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id),
|
||||
value[dao.RewardTypes.Columns().StoreId].Int(),
|
||||
).Where(
|
||||
do.MerchantAdmins{Id: in.OperatorId},
|
||||
).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("检查操作者权限出现异常")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.Params.Sub("无门店权限")
|
||||
}
|
||||
|
||||
case consts.StoreRoleCode:
|
||||
exist, err := dao.StoreAdmins.Ctx(ctx).LeftJoin(
|
||||
dao.Stores.Table(),
|
||||
fmt.Sprintf("%s.%s = %s.%s",
|
||||
dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId,
|
||||
dao.Stores.Table(), dao.Stores.Columns().Id,
|
||||
),
|
||||
).Where(
|
||||
fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id),
|
||||
value[dao.RewardTypes.Columns().StoreId].Int(),
|
||||
).Where(
|
||||
do.StoreAdmins{Id: in.OperatorId},
|
||||
).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("检查操作者权限出现异常")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.Params.Sub("无门店权限")
|
||||
}
|
||||
}
|
||||
|
||||
// 执行删除(软删除)
|
||||
_, err = dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Id: in.Id}).Delete()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("删除奖励类型失败")
|
||||
}
|
||||
|
||||
return &model.RewardTypeDeleteOut{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// List 获取奖励类型列表
|
||||
func (s *sRewardType) List(ctx context.Context, in *model.RewardTypeListIn) (out *model.RewardTypeListOut, err error) {
|
||||
list := make([]model.RewardType, 0)
|
||||
orm := dao.RewardTypes.Ctx(ctx)
|
||||
|
||||
// 根据角色和权限构建查询条件
|
||||
switch in.OperatorRole {
|
||||
case consts.MerchantRoleCode:
|
||||
// 检查商户是否有该门店权限
|
||||
exist, err := dao.MerchantAdmins.Ctx(ctx).Where(do.MerchantAdmins{Id: in.OperatorId}).LeftJoin(
|
||||
dao.Stores.Table(),
|
||||
fmt.Sprintf(
|
||||
"%s.%s = %s.%s",
|
||||
dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId,
|
||||
dao.Stores.Table(), dao.Stores.Columns().MerchantId,
|
||||
),
|
||||
).Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId).Exist()
|
||||
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("检查操作者权限出现异常")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.Params.Sub("无门店权限")
|
||||
}
|
||||
case consts.StoreRoleCode: // 门店
|
||||
// 检查门店是否有权限
|
||||
exist, err := dao.StoreAdmins.Ctx(ctx).
|
||||
Where(do.StoreAdmins{Id: in.OperatorId}).
|
||||
LeftJoin(
|
||||
dao.Stores.Table(),
|
||||
fmt.Sprintf(
|
||||
"%s.%s = %s.%s",
|
||||
dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId,
|
||||
dao.Stores.Table(), dao.Stores.Columns().Id,
|
||||
),
|
||||
).
|
||||
Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("检查操作者权限出现异常")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.Params.Sub("无门店权限")
|
||||
}
|
||||
}
|
||||
if in.Status != 0 {
|
||||
orm = orm.Where(do.RewardTypes{Status: in.Status})
|
||||
}
|
||||
if in.Name != "" {
|
||||
orm = orm.WhereLike(dao.RewardTypes.Columns().Name, "%"+in.Name+"%")
|
||||
}
|
||||
// 查询总数
|
||||
count, err := orm.Count()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 查询结果
|
||||
err = orm.Page(in.Page, in.Size).OrderAsc(dao.RewardTypes.Columns().Source).Scan(&list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &model.RewardTypeListOut{
|
||||
List: list,
|
||||
Total: count,
|
||||
}, nil
|
||||
}
|
||||
@ -43,7 +43,7 @@ func Auth(r *ghttp.Request) {
|
||||
r.SetCtxVar("id", tokenOut.UserId)
|
||||
r.SetCtxVar("role", tokenOut.Role)
|
||||
r.SetCtxVar("jti", tokenOut.JTI)
|
||||
glog.Infof(ctx, "%s用户访问: %s %s", tokenOut.Role, r.URL.Path, r.Method)
|
||||
glog.Infof(ctx, "%s用户Id:%d 访问: %s %s", tokenOut.Role, tokenOut.UserId, r.URL.Path, r.Method)
|
||||
}
|
||||
r.Middleware.Next()
|
||||
}
|
||||
|
||||
24
internal/model/do/reward_types.go
Normal file
24
internal/model/do/reward_types.go
Normal file
@ -0,0 +1,24 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package do
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// RewardTypes is the golang structure of table reward_types for DAO operations like Where/Data.
|
||||
type RewardTypes struct {
|
||||
g.Meta `orm:"table:reward_types, do:true"`
|
||||
Id interface{} // 奖励类型ID
|
||||
Name interface{} // 奖励类型名称(如积分、优惠券)
|
||||
Description interface{} // 奖励类型描述
|
||||
Source interface{} // 来源:1=系统默认,2=门店自定义
|
||||
StoreId interface{} // 门店ID,系统默认类型为NULL
|
||||
Status interface{} // 状态:1=正常,0=禁用
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
DeletedAt *gtime.Time // 软删除时间戳
|
||||
}
|
||||
26
internal/model/do/rewards.go
Normal file
26
internal/model/do/rewards.go
Normal file
@ -0,0 +1,26 @@
|
||||
// =================================================================================
|
||||
// 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{} // 奖励ID
|
||||
RewardTypeId interface{} // 奖励类型ID
|
||||
Name interface{} // 奖励名称(如100积分、5元优惠券)
|
||||
Description interface{} // 奖励描述
|
||||
Source interface{} // 来源:1=系统内置,2=门店自定义
|
||||
StoreId interface{} // 门店ID,系统内置奖励为NULL
|
||||
Value interface{} // 奖励值(如积分数额、优惠金额)
|
||||
Status interface{} // 状态:1=正常,0=禁用
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
DeletedAt *gtime.Time // 软删除时间戳
|
||||
}
|
||||
24
internal/model/do/store_task_rewards.go
Normal file
24
internal/model/do/store_task_rewards.go
Normal file
@ -0,0 +1,24 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package do
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// StoreTaskRewards is the golang structure of table store_task_rewards for DAO operations like Where/Data.
|
||||
type StoreTaskRewards struct {
|
||||
g.Meta `orm:"table:store_task_rewards, do:true"`
|
||||
Id interface{} // 任务奖励关联ID
|
||||
TaskId interface{} // 门店任务ID
|
||||
RewardId interface{} // 奖励ID
|
||||
StoreId interface{} // 门店ID
|
||||
Quantity interface{} // 奖励数量(如发放多少个奖励)
|
||||
Status interface{} // 状态:1=正常,0=禁用
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
DeletedAt *gtime.Time // 软删除时间戳
|
||||
}
|
||||
22
internal/model/entity/reward_types.go
Normal file
22
internal/model/entity/reward_types.go
Normal file
@ -0,0 +1,22 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package entity
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// RewardTypes is the golang structure for table reward_types.
|
||||
type RewardTypes struct {
|
||||
Id int64 `json:"id" orm:"id" description:"奖励类型ID"` // 奖励类型ID
|
||||
Name string `json:"name" orm:"name" description:"奖励类型名称(如积分、优惠券)"` // 奖励类型名称(如积分、优惠券)
|
||||
Description string `json:"description" orm:"description" description:"奖励类型描述"` // 奖励类型描述
|
||||
Source int `json:"source" orm:"source" description:"来源:1=系统默认,2=门店自定义"` // 来源:1=系统默认,2=门店自定义
|
||||
StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID,系统默认类型为NULL"` // 门店ID,系统默认类型为NULL
|
||||
Status int `json:"status" orm:"status" description:"状态:1=正常,0=禁用"` // 状态:1=正常,0=禁用
|
||||
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:"软删除时间戳"` // 软删除时间戳
|
||||
}
|
||||
24
internal/model/entity/rewards.go
Normal file
24
internal/model/entity/rewards.go
Normal file
@ -0,0 +1,24 @@
|
||||
// =================================================================================
|
||||
// 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:"奖励ID"` // 奖励ID
|
||||
RewardTypeId int64 `json:"rewardTypeId" orm:"reward_type_id" description:"奖励类型ID"` // 奖励类型ID
|
||||
Name string `json:"name" orm:"name" description:"奖励名称(如100积分、5元优惠券)"` // 奖励名称(如100积分、5元优惠券)
|
||||
Description string `json:"description" orm:"description" description:"奖励描述"` // 奖励描述
|
||||
Source int `json:"source" orm:"source" description:"来源:1=系统内置,2=门店自定义"` // 来源:1=系统内置,2=门店自定义
|
||||
StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID,系统内置奖励为NULL"` // 门店ID,系统内置奖励为NULL
|
||||
Value float64 `json:"value" orm:"value" description:"奖励值(如积分数额、优惠金额)"` // 奖励值(如积分数额、优惠金额)
|
||||
Status int `json:"status" orm:"status" description:"状态:1=正常,0=禁用"` // 状态:1=正常,0=禁用
|
||||
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:"软删除时间戳"` // 软删除时间戳
|
||||
}
|
||||
22
internal/model/entity/store_task_rewards.go
Normal file
22
internal/model/entity/store_task_rewards.go
Normal file
@ -0,0 +1,22 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package entity
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// StoreTaskRewards is the golang structure for table store_task_rewards.
|
||||
type StoreTaskRewards struct {
|
||||
Id int64 `json:"id" orm:"id" description:"任务奖励关联ID"` // 任务奖励关联ID
|
||||
TaskId int64 `json:"taskId" orm:"task_id" description:"门店任务ID"` // 门店任务ID
|
||||
RewardId int64 `json:"rewardId" orm:"reward_id" description:"奖励ID"` // 奖励ID
|
||||
StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID"` // 门店ID
|
||||
Quantity int `json:"quantity" orm:"quantity" description:"奖励数量(如发放多少个奖励)"` // 奖励数量(如发放多少个奖励)
|
||||
Status int `json:"status" orm:"status" description:"状态:1=正常,0=禁用"` // 状态:1=正常,0=禁用
|
||||
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:"软删除时间戳"` // 软删除时间戳
|
||||
}
|
||||
11
internal/model/reward.go
Normal file
11
internal/model/reward.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
type Reward struct {
|
||||
}
|
||||
|
||||
type RewardListIn struct {
|
||||
}
|
||||
type RewardListOut struct {
|
||||
List []Reward
|
||||
Total int
|
||||
}
|
||||
79
internal/model/rewardType.go
Normal file
79
internal/model/rewardType.go
Normal file
@ -0,0 +1,79 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// RewardType 奖励类型表
|
||||
type RewardType struct {
|
||||
Id int64 `json:"id" dc:"奖励类型ID" orm:"id,primary"`
|
||||
Name string `json:"name" dc:"奖励类型名称(如积分、优惠券)" orm:"name"`
|
||||
Description string `json:"description" dc:"奖励类型描述" orm:"description"`
|
||||
Source int `json:"source" dc:"来源:1=系统默认,2=门店自定义" orm:"source"`
|
||||
StoreId int64 `json:"storeId" dc:"门店ID,系统默认类型为NULL" orm:"store_id"`
|
||||
Status int `json:"status" dc:"状态:1=正常,2=禁用" orm:"status"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间" orm:"created_at"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间" orm:"updated_at"`
|
||||
DeletedAt *gtime.Time `json:"deletedAt" dc:"软删除时间戳" orm:"deleted_at"`
|
||||
}
|
||||
|
||||
// RewardTypeCreateIn 创建奖励类型入参
|
||||
type RewardTypeCreateIn struct {
|
||||
OperatorId int64
|
||||
OperatorRole string
|
||||
Name string
|
||||
Description string
|
||||
Source int
|
||||
StoreId int64
|
||||
Status int
|
||||
}
|
||||
|
||||
// RewardTypeCreateOut 创建奖励类型出参
|
||||
type RewardTypeCreateOut struct {
|
||||
Id int64
|
||||
}
|
||||
|
||||
// RewardTypeUpdateIn 更新奖励类型入参
|
||||
type RewardTypeUpdateIn struct {
|
||||
OperatorId int64
|
||||
OperatorRole string
|
||||
Id int64
|
||||
Name string
|
||||
Description string
|
||||
StoreId int64
|
||||
Status int
|
||||
}
|
||||
|
||||
// RewardTypeUpdateOut 更新奖励类型出参
|
||||
type RewardTypeUpdateOut struct {
|
||||
Success bool
|
||||
}
|
||||
|
||||
// RewardTypeDeleteIn 删除奖励类型入参
|
||||
type RewardTypeDeleteIn struct {
|
||||
Id int64
|
||||
OperatorId int64
|
||||
OperatorRole string
|
||||
}
|
||||
|
||||
// RewardTypeDeleteOut 删除奖励类型出参
|
||||
type RewardTypeDeleteOut struct {
|
||||
Success bool
|
||||
}
|
||||
|
||||
// RewardTypeListIn 获取奖励类型列表入参
|
||||
type RewardTypeListIn struct {
|
||||
OperatorId int64
|
||||
OperatorRole string
|
||||
Page int
|
||||
Size int
|
||||
Name string
|
||||
StoreId int64
|
||||
Status int
|
||||
}
|
||||
|
||||
// RewardTypeListOut 获取奖励类型列表出参
|
||||
type RewardTypeListOut struct {
|
||||
List []RewardType
|
||||
Total int
|
||||
}
|
||||
32
internal/service/reward.go
Normal file
32
internal/service/reward.go
Normal file
@ -0,0 +1,32 @@
|
||||
// ================================================================================
|
||||
// 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 {
|
||||
List(ctx context.Context, in *model.RewardListIn) (out *model.RewardListOut, 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
|
||||
}
|
||||
39
internal/service/reward_type.go
Normal file
39
internal/service/reward_type.go
Normal file
@ -0,0 +1,39 @@
|
||||
// ================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// You can delete these comments if you wish manually maintain this interface file.
|
||||
// ================================================================================
|
||||
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
)
|
||||
|
||||
type (
|
||||
IRewardType interface {
|
||||
// Create 创建奖励类型
|
||||
Create(ctx context.Context, in *model.RewardTypeCreateIn) (out *model.RewardTypeCreateOut, err error)
|
||||
// Update 更新奖励类型
|
||||
Update(ctx context.Context, in *model.RewardTypeUpdateIn) (out *model.RewardTypeUpdateOut, err error)
|
||||
// Delete 删除奖励类型
|
||||
Delete(ctx context.Context, in *model.RewardTypeDeleteIn) (out *model.RewardTypeDeleteOut, err error)
|
||||
// List 获取奖励类型列表
|
||||
List(ctx context.Context, in *model.RewardTypeListIn) (out *model.RewardTypeListOut, err error)
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
localRewardType IRewardType
|
||||
)
|
||||
|
||||
func RewardType() IRewardType {
|
||||
if localRewardType == nil {
|
||||
panic("implement not found for interface IRewardType, forgot register?")
|
||||
}
|
||||
return localRewardType
|
||||
}
|
||||
|
||||
func RegisterRewardType(i IRewardType) {
|
||||
localRewardType = i
|
||||
}
|
||||
Reference in New Issue
Block a user