奖励类型新增门店相关 id

This commit is contained in:
chy
2025-06-13 09:48:18 +08:00
parent fac2bd41b3
commit d7987a02f2
35 changed files with 561 additions and 129 deletions

View File

@ -14,12 +14,12 @@ type ListRes struct {
}
type CreateReq struct {
g.Meta `path:"/rewardType" method:"post" tags:"奖励类型" summary:"(系统)创建奖励类型"`
Name string `json:"name" v:"required#名称不能为空" dc:"名称"`
//Sort int `json:"sort" v:"required#排序不能为空" dc:"排序"`
g.Meta `path:"/rewardType" method:"post" tags:"奖励类型" summary:"(系统)创建奖励类型"`
Name string `json:"name" v:"required#名称不能为空" dc:"名称"`
Code string `json:"code" v:"required#代号不能为空" dc:"代号"`
Description string `json:"description" v:"required#描述不能为空" dc:"描述"`
//Status int `json:"status" v:"required#状态不能为空" dc:"状态"`
StoreId int `json:"store_id" dc:"门店ID"`
}
type CreateRes struct {
@ -33,6 +33,7 @@ type UpdateReq struct {
Code string `json:"code" v:"required#代号不能为空" dc:"代号"`
Description string `json:"description" v:"required#描述不能为空" dc:"描述"`
Status int `json:"status" v:"required#状态不能为空" dc:"状态"`
StoreId int `json:"store_id" dc:"门店ID"`
}
type UpdateRes struct {

View File

@ -13,6 +13,7 @@ func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.C
Code: req.Code,
Description: req.Description,
Name: req.Name,
StoreId: req.StoreId,
})
if err != nil {
return nil, err

View File

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

View File

@ -15,6 +15,7 @@ func (c *ControllerV1) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.U
Code: req.Code,
Status: req.Status,
Description: req.Description,
StoreId: req.StoreId,
})
if err != nil {

View File

@ -13,9 +13,10 @@ 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.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns AdminsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// AdminsColumns defines and stores column names for the table admins.
@ -49,11 +50,12 @@ var adminsColumns = AdminsColumns{
}
// NewAdminsDao creates and returns a new DAO object for table data access.
func NewAdminsDao() *AdminsDao {
func NewAdminsDao(handlers ...gdb.ModelHandler) *AdminsDao {
return &AdminsDao{
group: "default",
table: "admins",
columns: adminsColumns,
group: "default",
table: "admins",
columns: adminsColumns,
handlers: handlers,
}
}
@ -79,7 +81,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// FeedbacksDao is the data access object for the table feedbacks.
type FeedbacksDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns FeedbacksColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns FeedbacksColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// FeedbacksColumns defines and stores column names for the table feedbacks.
@ -51,11 +52,12 @@ var feedbacksColumns = FeedbacksColumns{
}
// NewFeedbacksDao creates and returns a new DAO object for table data access.
func NewFeedbacksDao() *FeedbacksDao {
func NewFeedbacksDao(handlers ...gdb.ModelHandler) *FeedbacksDao {
return &FeedbacksDao{
group: "default",
table: "feedbacks",
columns: feedbacksColumns,
group: "default",
table: "feedbacks",
columns: feedbacksColumns,
handlers: handlers,
}
}
@ -81,7 +83,11 @@ func (dao *FeedbacksDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *FeedbacksDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// GamesDao is the data access object for the table games.
type GamesDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns GamesColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns GamesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// GamesColumns defines and stores column names for the table games.
@ -43,11 +44,12 @@ var gamesColumns = GamesColumns{
}
// NewGamesDao creates and returns a new DAO object for table data access.
func NewGamesDao() *GamesDao {
func NewGamesDao(handlers ...gdb.ModelHandler) *GamesDao {
return &GamesDao{
group: "default",
table: "games",
columns: gamesColumns,
group: "default",
table: "games",
columns: gamesColumns,
handlers: handlers,
}
}
@ -73,7 +75,11 @@ func (dao *GamesDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *GamesDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ 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.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns MerchantAdminsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// MerchantAdminsColumns defines and stores column names for the table merchant_admins.
@ -57,11 +58,12 @@ var merchantAdminsColumns = MerchantAdminsColumns{
}
// NewMerchantAdminsDao creates and returns a new DAO object for table data access.
func NewMerchantAdminsDao() *MerchantAdminsDao {
func NewMerchantAdminsDao(handlers ...gdb.ModelHandler) *MerchantAdminsDao {
return &MerchantAdminsDao{
group: "default",
table: "merchant_admins",
columns: merchantAdminsColumns,
group: "default",
table: "merchant_admins",
columns: merchantAdminsColumns,
handlers: handlers,
}
}
@ -87,7 +89,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ 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.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns MerchantsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// MerchantsColumns defines and stores column names for the table merchants.
@ -71,11 +72,12 @@ var merchantsColumns = MerchantsColumns{
}
// NewMerchantsDao creates and returns a new DAO object for table data access.
func NewMerchantsDao() *MerchantsDao {
func NewMerchantsDao(handlers ...gdb.ModelHandler) *MerchantsDao {
return &MerchantsDao{
group: "default",
table: "merchants",
columns: merchantsColumns,
group: "default",
table: "merchants",
columns: merchantsColumns,
handlers: handlers,
}
}
@ -101,7 +103,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ 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.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns RewardTypesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// RewardTypesColumns defines and stores column names for the table reward_types.
@ -28,6 +29,7 @@ type RewardTypesColumns struct {
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
DeletedAt string // 软删除时间
StoreId string // 门店 id
}
// rewardTypesColumns holds the columns for the table reward_types.
@ -40,14 +42,16 @@ var rewardTypesColumns = RewardTypesColumns{
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
StoreId: "store_id",
}
// NewRewardTypesDao creates and returns a new DAO object for table data access.
func NewRewardTypesDao() *RewardTypesDao {
func NewRewardTypesDao(handlers ...gdb.ModelHandler) *RewardTypesDao {
return &RewardTypesDao{
group: "default",
table: "reward_types",
columns: rewardTypesColumns,
group: "default",
table: "reward_types",
columns: rewardTypesColumns,
handlers: handlers,
}
}
@ -73,7 +77,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// 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.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns RewardsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// RewardsColumns defines and stores column names for the table rewards.
@ -53,11 +54,12 @@ var rewardsColumns = RewardsColumns{
}
// NewRewardsDao creates and returns a new DAO object for table data access.
func NewRewardsDao() *RewardsDao {
func NewRewardsDao(handlers ...gdb.ModelHandler) *RewardsDao {
return &RewardsDao{
group: "default",
table: "rewards",
columns: rewardsColumns,
group: "default",
table: "rewards",
columns: rewardsColumns,
handlers: handlers,
}
}
@ -83,7 +85,11 @@ func (dao *RewardsDao) Group() string {
// 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)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ 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.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns RolesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// RolesColumns defines and stores column names for the table roles.
@ -29,6 +30,7 @@ type RolesColumns struct {
UpdatedAt string // 更新时间
DeletedAt string // 软删除时间戳
IsDeletable string // 是否可删除0=不可删除1=可删除
StoreId string // 门店ID
}
// rolesColumns holds the columns for the table roles.
@ -42,14 +44,16 @@ var rolesColumns = RolesColumns{
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
IsDeletable: "is_deletable",
StoreId: "store_id",
}
// NewRolesDao creates and returns a new DAO object for table data access.
func NewRolesDao() *RolesDao {
func NewRolesDao(handlers ...gdb.ModelHandler) *RolesDao {
return &RolesDao{
group: "default",
table: "roles",
columns: rolesColumns,
group: "default",
table: "roles",
columns: rolesColumns,
handlers: handlers,
}
}
@ -75,7 +79,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// StoreAdminsDao is the data access object for the table store_admins.
type StoreAdminsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreAdminsColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreAdminsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreAdminsColumns defines and stores column names for the table store_admins.
@ -34,6 +35,7 @@ type StoreAdminsColumns struct {
UpdatedAt string // 更新时间
DeletedAt string // 软删除时间戳
RoleId string // 角色ID
StoreRoleId string // 门店角色ID
}
// storeAdminsColumns holds the columns for the table store_admins.
@ -52,14 +54,16 @@ var storeAdminsColumns = StoreAdminsColumns{
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
RoleId: "role_id",
StoreRoleId: "store_role_id",
}
// NewStoreAdminsDao creates and returns a new DAO object for table data access.
func NewStoreAdminsDao() *StoreAdminsDao {
func NewStoreAdminsDao(handlers ...gdb.ModelHandler) *StoreAdminsDao {
return &StoreAdminsDao{
group: "default",
table: "store_admins",
columns: storeAdminsColumns,
group: "default",
table: "store_admins",
columns: storeAdminsColumns,
handlers: handlers,
}
}
@ -85,7 +89,11 @@ func (dao *StoreAdminsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoreAdminsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -0,0 +1,95 @@
// ==========================================================================
// 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"
)
// StoreDesktopSettingsDao is the data access object for the table store_desktop_settings.
type StoreDesktopSettingsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreDesktopSettingsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreDesktopSettingsColumns defines and stores column names for the table store_desktop_settings.
type StoreDesktopSettingsColumns struct {
Id string // 主键ID
StoreId string // 门店ID
BackgroundUrl string // 桌面背景图片URL
Resolution string // 分辨率例如1920x1080
IsTopWidgetVisible string // 顶部组件是否显示FALSE=隐藏TRUE=显示
IsRightWidgetVisible string // 右侧组件是否显示FALSE=隐藏TRUE=显示
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
DeletedAt string // 软删除时间戳
}
// storeDesktopSettingsColumns holds the columns for the table store_desktop_settings.
var storeDesktopSettingsColumns = StoreDesktopSettingsColumns{
Id: "id",
StoreId: "store_id",
BackgroundUrl: "background_url",
Resolution: "resolution",
IsTopWidgetVisible: "is_top_widget_visible",
IsRightWidgetVisible: "is_right_widget_visible",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewStoreDesktopSettingsDao creates and returns a new DAO object for table data access.
func NewStoreDesktopSettingsDao(handlers ...gdb.ModelHandler) *StoreDesktopSettingsDao {
return &StoreDesktopSettingsDao{
group: "default",
table: "store_desktop_settings",
columns: storeDesktopSettingsColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *StoreDesktopSettingsDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *StoreDesktopSettingsDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *StoreDesktopSettingsDao) Columns() StoreDesktopSettingsColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *StoreDesktopSettingsDao) 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 *StoreDesktopSettingsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// 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 *StoreDesktopSettingsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -13,9 +13,10 @@ import (
// 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.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreRewardsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreRewardsColumns defines and stores column names for the table store_rewards.
@ -33,11 +34,12 @@ var storeRewardsColumns = StoreRewardsColumns{
}
// NewStoreRewardsDao creates and returns a new DAO object for table data access.
func NewStoreRewardsDao() *StoreRewardsDao {
func NewStoreRewardsDao(handlers ...gdb.ModelHandler) *StoreRewardsDao {
return &StoreRewardsDao{
group: "default",
table: "store_rewards",
columns: storeRewardsColumns,
group: "default",
table: "store_rewards",
columns: storeRewardsColumns,
handlers: handlers,
}
}
@ -63,7 +65,11 @@ func (dao *StoreRewardsDao) Group() string {
// 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)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View 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"
)
// StoreRolesDao is the data access object for the table store_roles.
type StoreRolesDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreRolesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreRolesColumns defines and stores column names for the table store_roles.
type StoreRolesColumns struct {
Id string // 门店角色ID
StoreId string // 所属门店ID
Name string // 门店角色名称
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
DeletedAt string // 软删除时间戳
}
// storeRolesColumns holds the columns for the table store_roles.
var storeRolesColumns = StoreRolesColumns{
Id: "id",
StoreId: "store_id",
Name: "name",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewStoreRolesDao creates and returns a new DAO object for table data access.
func NewStoreRolesDao(handlers ...gdb.ModelHandler) *StoreRolesDao {
return &StoreRolesDao{
group: "default",
table: "store_roles",
columns: storeRolesColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *StoreRolesDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *StoreRolesDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *StoreRolesDao) Columns() StoreRolesColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *StoreRolesDao) 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 *StoreRolesDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// 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 *StoreRolesDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -13,9 +13,10 @@ 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.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoresColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoresColumns defines and stores column names for the table stores.
@ -49,11 +50,12 @@ var storesColumns = StoresColumns{
}
// NewStoresDao creates and returns a new DAO object for table data access.
func NewStoresDao() *StoresDao {
func NewStoresDao(handlers ...gdb.ModelHandler) *StoresDao {
return &StoresDao{
group: "default",
table: "stores",
columns: storesColumns,
group: "default",
table: "stores",
columns: storesColumns,
handlers: handlers,
}
}
@ -79,7 +81,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// TasksDao is the data access object for the table tasks.
type TasksDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns TasksColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns TasksColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// TasksColumns defines and stores column names for the table tasks.
@ -37,11 +38,12 @@ var tasksColumns = TasksColumns{
}
// NewTasksDao creates and returns a new DAO object for table data access.
func NewTasksDao() *TasksDao {
func NewTasksDao(handlers ...gdb.ModelHandler) *TasksDao {
return &TasksDao{
group: "default",
table: "tasks",
columns: tasksColumns,
group: "default",
table: "tasks",
columns: tasksColumns,
handlers: handlers,
}
}
@ -67,7 +69,11 @@ func (dao *TasksDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *TasksDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// UserTasksDao is the data access object for the table user_tasks.
type UserTasksDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns UserTasksColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns UserTasksColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// UserTasksColumns defines and stores column names for the table user_tasks.
@ -47,11 +48,12 @@ var userTasksColumns = UserTasksColumns{
}
// NewUserTasksDao creates and returns a new DAO object for table data access.
func NewUserTasksDao() *UserTasksDao {
func NewUserTasksDao(handlers ...gdb.ModelHandler) *UserTasksDao {
return &UserTasksDao{
group: "default",
table: "user_tasks",
columns: userTasksColumns,
group: "default",
table: "user_tasks",
columns: userTasksColumns,
handlers: handlers,
}
}
@ -77,7 +79,11 @@ func (dao *UserTasksDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *UserTasksDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ 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.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns UsersColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// UsersColumns defines and stores column names for the table users.
@ -61,11 +62,12 @@ var usersColumns = UsersColumns{
}
// NewUsersDao creates and returns a new DAO object for table data access.
func NewUsersDao() *UsersDao {
func NewUsersDao(handlers ...gdb.ModelHandler) *UsersDao {
return &UsersDao{
group: "default",
table: "users",
columns: usersColumns,
group: "default",
table: "users",
columns: usersColumns,
handlers: handlers,
}
}
@ -91,7 +93,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

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

View File

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

View File

@ -45,7 +45,7 @@ func (s *sReward) CreateSystemReward(ctx context.Context, in *model.RewardCreate
RewardTypeId: in.RewardTypeID,
RewardScope: consts.SystemReward, // 系统奖励
Name: in.Name,
Code: "xmax",
Code: "xmaxa",
Description: in.Description,
Status: in.Status,
Stock: in.Stock,

View File

@ -2,6 +2,8 @@ package rewardType
import (
"context"
"fmt"
"server/internal/consts"
"server/internal/dao"
"server/internal/model"
"server/internal/model/do"
@ -20,6 +22,7 @@ func init() {
service.RegisterRewardType(New())
}
func (s *sRewardType) List(ctx context.Context, in *model.RewardTypeIn) (out *model.RewardTypeOut, err error) {
m := dao.RewardTypes.Ctx(ctx)
// 默认分页
@ -30,9 +33,14 @@ func (s *sRewardType) List(ctx context.Context, in *model.RewardTypeIn) (out *mo
in.Size = 10
}
// 判断角色
if in.RoleName == consts.StoreRoleCode {
m = m.Where(do.RewardTypes{StoreId: in.OperatorId})
}
list := make([]model.RewardType, 0)
var total int
err = m.Page(in.Page, in.Size).OrderDesc(dao.RewardTypes.Columns().CreatedAt).ScanAndCount(&list, &total, false)
err = m.Fields(fmt.Sprintf("%s.*, %s.%s %s", dao.RewardTypes.Table(), dao.Stores.Table(), dao.Stores.Columns().Name, "store_name")).LeftJoin(dao.Stores.Table(), fmt.Sprintf("`%s`.`id` = `%s`.`store_id`", dao.Stores.Table(), dao.RewardTypes.Table())).Page(in.Page, in.Size).OrderDesc(dao.RewardTypes.Columns().CreatedAt).ScanAndCount(&list, &total, false)
if err != nil {
return nil, err
}
@ -45,17 +53,17 @@ func (s *sRewardType) List(ctx context.Context, in *model.RewardTypeIn) (out *mo
func (s *sRewardType) CreateRewardType(ctx context.Context, in *model.CreateRewardTypeIn) (out *model.CreateRewardTypeOut, err error) {
// 检查类型名称是否存在
exist, err := dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Name: in.Name}).Exist()
exist, err := dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Name: in.Name, StoreId: in.StoreId}).Exist()
if err != nil {
return nil, err
return nil, ecode.Fail.Sub("查询该奖励类型失败")
}
if exist {
return nil, ecode.Params.Sub("类型名称已存在")
}
exist, err = dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Code: in.Code}).Exist()
exist, err = dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Code: in.Code, StoreId: in.StoreId}).Exist()
if err != nil {
return nil, err
return nil, ecode.Fail.Sub("查询该奖励类型失败")
}
if exist {
return nil, ecode.Params.Sub("类型代号已存在")
@ -65,6 +73,7 @@ func (s *sRewardType) CreateRewardType(ctx context.Context, in *model.CreateRewa
Name: in.Name,
Code: in.Code,
Description: in.Description,
StoreId: in.StoreId,
})
if err != nil {
return nil, err
@ -75,17 +84,17 @@ func (s *sRewardType) CreateRewardType(ctx context.Context, in *model.CreateRewa
func (s *sRewardType) UpdateRewardType(ctx context.Context, in *model.UpdateRewardTypeIn) (out *model.UpdateRewardTypeOut, err error) {
// 检查更新的是否存在
exist, err := dao.RewardTypes.Ctx(ctx).WherePri(in.Id).Exist()
exist, err := dao.RewardTypes.Ctx(ctx).WherePri(in.Id).Where(do.RewardTypes{StoreId: in.StoreId}).Exist()
if err != nil {
return nil, ecode.Params.Sub("查询奖励失败")
return nil, ecode.Fail.Sub("查询奖励类型失败")
}
if !exist {
return nil, ecode.Params.Sub("更新的奖励不存在")
return nil, ecode.Params.Sub("更新的奖励类型不存在")
}
exist, err = dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Name: in.Name}).Exist()
exist, err = dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Name: in.Name, StoreId: in.StoreId}).Exist()
if err != nil {
return nil, ecode.Params.Sub("查询奖励类型失败")
return nil, ecode.Fail.Sub("查询奖励类型失败")
}
if exist {
return nil, ecode.Params.Sub("奖励类型名称已存在")

View File

@ -20,4 +20,5 @@ type RewardTypes struct {
CreatedAt *gtime.Time // 创建时间
UpdatedAt *gtime.Time // 更新时间
DeletedAt *gtime.Time // 软删除时间
StoreId interface{} // 门店 id
}

View File

@ -21,4 +21,5 @@ type Roles struct {
UpdatedAt *gtime.Time // 更新时间
DeletedAt *gtime.Time // 软删除时间戳
IsDeletable interface{} // 是否可删除0=不可删除1=可删除
StoreId interface{} // 门店ID
}

View File

@ -26,4 +26,5 @@ type StoreAdmins struct {
UpdatedAt *gtime.Time // 更新时间
DeletedAt *gtime.Time // 软删除时间戳
RoleId interface{} // 角色ID
StoreRoleId interface{} // 门店角色ID
}

View 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"
)
// StoreDesktopSettings is the golang structure of table store_desktop_settings for DAO operations like Where/Data.
type StoreDesktopSettings struct {
g.Meta `orm:"table:store_desktop_settings, do:true"`
Id interface{} // 主键ID
StoreId interface{} // 门店ID
BackgroundUrl interface{} // 桌面背景图片URL
Resolution interface{} // 分辨率例如1920x1080
IsTopWidgetVisible interface{} // 顶部组件是否显示FALSE=隐藏TRUE=显示
IsRightWidgetVisible interface{} // 右侧组件是否显示FALSE=隐藏TRUE=显示
CreatedAt *gtime.Time // 创建时间
UpdatedAt *gtime.Time // 更新时间
DeletedAt *gtime.Time // 软删除时间戳
}

View File

@ -0,0 +1,21 @@
// =================================================================================
// 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"
)
// StoreRoles is the golang structure of table store_roles for DAO operations like Where/Data.
type StoreRoles struct {
g.Meta `orm:"table:store_roles, do:true"`
Id interface{} // 门店角色ID
StoreId interface{} // 所属门店ID
Name interface{} // 门店角色名称
CreatedAt *gtime.Time // 创建时间
UpdatedAt *gtime.Time // 更新时间
DeletedAt *gtime.Time // 软删除时间戳
}

View File

@ -18,4 +18,5 @@ type RewardTypes struct {
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id
}

View File

@ -19,4 +19,5 @@ type Roles struct {
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳
IsDeletable bool `json:"isDeletable" orm:"is_deletable" description:"是否可删除0=不可删除1=可删除"` // 是否可删除0=不可删除1=可删除
StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID"` // 门店ID
}

View File

@ -24,4 +24,5 @@ type StoreAdmins struct {
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳
RoleId int64 `json:"roleId" orm:"role_id" description:"角色ID"` // 角色ID
StoreRoleId int64 `json:"storeRoleId" orm:"store_role_id" description:"门店角色ID"` // 门店角色ID
}

View 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"
)
// StoreDesktopSettings is the golang structure for table store_desktop_settings.
type StoreDesktopSettings struct {
Id int64 `json:"id" orm:"id" description:"主键ID"` // 主键ID
StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID"` // 门店ID
BackgroundUrl string `json:"backgroundUrl" orm:"background_url" description:"桌面背景图片URL"` // 桌面背景图片URL
Resolution string `json:"resolution" orm:"resolution" description:"分辨率例如1920x1080"` // 分辨率例如1920x1080
IsTopWidgetVisible int `json:"isTopWidgetVisible" orm:"is_top_widget_visible" description:"顶部组件是否显示FALSE=隐藏TRUE=显示"` // 顶部组件是否显示FALSE=隐藏TRUE=显示
IsRightWidgetVisible int `json:"isRightWidgetVisible" orm:"is_right_widget_visible" description:"右侧组件是否显示FALSE=隐藏TRUE=显示"` // 右侧组件是否显示FALSE=隐藏TRUE=显示
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳
}

View File

@ -0,0 +1,19 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// StoreRoles is the golang structure for table store_roles.
type StoreRoles struct {
Id int64 `json:"id" orm:"id" description:"门店角色ID"` // 门店角色ID
StoreId int64 `json:"storeId" orm:"store_id" description:"所属门店ID"` // 所属门店ID
Name string `json:"name" orm:"name" 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:"软删除时间戳"` // 软删除时间戳
}

View File

@ -15,10 +15,14 @@ type RewardType struct {
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"`
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"删除时间"`
//StoreId int `json:"storeId" dc:"门店ID" orm:"store_id"`
StoreName string `json:"storeName" dc:"门店名称" orm:"store_name"`
}
type RewardTypeIn struct {
Page int
Size int
Page int
Size int
RoleName string
OperatorId int
}
type RewardTypeOut struct {
@ -31,6 +35,7 @@ type CreateRewardTypeIn struct {
Code string
Description string
Status int
StoreId int
}
type CreateRewardTypeOut struct {
@ -44,6 +49,7 @@ type UpdateRewardTypeIn struct {
Code string
Description string
Status int
StoreId int
}
// UpdateRewardTypeOut 更新奖励类型返回参数