From db9f18222639262f58539e91b72ccefb8836aef8 Mon Sep 17 00:00:00 2001 From: denghui <1016848185@qq.com> Date: Fri, 4 Jul 2025 18:24:57 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E5=85=88=E9=97=A8=E5=BA=97=E5=AF=B9?= =?UTF-8?q?=E7=BD=91=E8=B4=B9=E8=BF=9B=E8=A1=8C=20=E6=BF=80=E5=8A=B1?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/store/store.go | 3 + api/store/v1/store.go | 38 ++++++++++ .../store/store_v1_get_netfee_setting.go | 29 +++++++ .../store/store_v1_get_store_area_list.go | 26 +++++++ .../store/store_v1_save_netfee_setting.go | 26 +++++++ internal/dao/internal/admins.go | 22 ++---- internal/dao/internal/feedbacks.go | 22 ++---- internal/dao/internal/games.go | 22 ++---- internal/dao/internal/merchant_admins.go | 22 ++---- internal/dao/internal/merchants.go | 22 ++---- internal/dao/internal/notices.go | 22 ++---- internal/dao/internal/reward_callback.go | 22 ++---- internal/dao/internal/reward_types.go | 22 ++---- internal/dao/internal/reward_waters.go | 22 ++---- internal/dao/internal/rewards.go | 22 ++---- internal/dao/internal/roles.go | 22 ++---- internal/dao/internal/store_admins.go | 22 ++---- internal/dao/internal/store_areas.go | 22 ++---- internal/dao/internal/store_clients.go | 22 ++---- .../dao/internal/store_desktop_settings.go | 22 ++---- internal/dao/internal/store_ips.go | 22 ++---- internal/dao/internal/store_member_levels.go | 22 ++---- .../dao/internal/store_netfee_area_level.go | 62 +++++++-------- internal/dao/internal/store_roles.go | 22 ++---- internal/dao/internal/stores.go | 22 ++---- internal/dao/internal/task_rewards.go | 22 ++---- internal/dao/internal/tasks.go | 22 ++---- internal/dao/internal/user_task_rewards.go | 22 ++---- internal/dao/internal/user_tasks.go | 22 ++---- internal/dao/internal/users.go | 22 ++---- internal/logic/store/store.go | 75 +++++++++++++++++++ internal/model/do/store_netfee_area_level.go | 22 +++--- .../model/entity/store_netfee_area_level.go | 20 +++-- internal/model/netfeeAreaLevel.go | 29 +++++++ internal/model/storeArea.go | 17 +++++ internal/service/store.go | 3 + utility/myCasbin/casbin.go | 3 + 37 files changed, 486 insertions(+), 395 deletions(-) create mode 100644 internal/controller/store/store_v1_get_netfee_setting.go create mode 100644 internal/controller/store/store_v1_get_store_area_list.go create mode 100644 internal/controller/store/store_v1_save_netfee_setting.go create mode 100644 internal/model/netfeeAreaLevel.go create mode 100644 internal/model/storeArea.go diff --git a/api/store/store.go b/api/store/store.go index 8d1447c..b31fabe 100644 --- a/api/store/store.go +++ b/api/store/store.go @@ -21,4 +21,7 @@ type IStoreV1 interface { GetIpList(ctx context.Context, req *v1.GetIpListReq) (res *v1.GetIpListRes, err error) Detail(ctx context.Context, req *v1.DetailReq) (res *v1.DetailRes, err error) StoreMemberLevel(ctx context.Context, req *v1.StoreMemberLevelReq) (res *v1.StoreMemberLevelRes, err error) + GetStoreAreaList(ctx context.Context, req *v1.GetStoreAreaListReq) (res *v1.GetStoreAreaListRes, err error) + GetNetfeeSetting(ctx context.Context, req *v1.GetNetfeeSettingReq) (res *v1.GetNetfeeSettingRes, err error) + SaveNetfeeSetting(ctx context.Context, req *v1.SaveNetfeeSettingReq) (res *v1.SaveNetfeeSettingRes, err error) } diff --git a/api/store/v1/store.go b/api/store/v1/store.go index d830c8f..702898f 100644 --- a/api/store/v1/store.go +++ b/api/store/v1/store.go @@ -105,3 +105,41 @@ type StoreMemberLevelRes struct { List interface{} `json:"list"` Total int64 `json:"total"` } +type GetStoreAreaListReq struct { + g.Meta `path:"/store/area" method:"get" tags:"Backend/Store" summary:"(系统、商户门店后台)获取门店区域列表"` + StoreId int64 `json:"storeId" v:"required#门店ID不能为空" dc:"门店ID"` +} + +type GetStoreAreaListRes struct { + List interface{} `json:"list"` + Total int `json:"total"` +} + +type GetNetfeeSettingReq struct { + g.Meta `path:"/store/netfeeSetting" method:"get" tags:"Backend/Store" summary:"(系统、商户门店后台)获取门店网络费设置"` + StoreId int64 `json:"storeId" v:"required#门店ID不能为空" dc:"门店ID"` + LevelId int64 `json:"levelId" v:"required#会员等级ID不能为空" dc:"会员等级ID"` + AreaId int64 `json:"areaId" v:"required#区域ID不能为空" dc:"区域ID"` + RewardId int64 `json:"rewardId" v:"required#奖励ID不能为空" dc:"奖励ID"` +} + +type GetNetfeeSettingRes struct { + Id int64 `json:"id" dc:"主键ID"` // 主键ID + StoreId int64 `json:"storeId" dc:"门店ID"` // 门店ID + RewardId int64 `json:"rewardId" dc:"奖励ID(rewards表主键)"` // 奖励ID(rewards表主键) + AreaId int64 `json:"areaId" dc:"区域ID(外部系统)"` // 区域ID(外部系统) + MemberLevelId int64 `json:"memberLevelId" dc:"会员等级ID(外部系统)"` // 会员等级ID(外部系统) + PriceData string `json:"priceData" dc:"7x24价格矩阵"` // 7x24价格矩阵 +} +type SaveNetfeeSettingReq struct { + g.Meta `path:"/store/netfeeSetting" method:"post" tags:"Backend/Store" summary:"(系统、商户门店后台)保存门店网络费设置"` + StoreId int64 `json:"storeId" v:"required#门店ID不能为空" dc:"门店ID"` + LevelId int64 `json:"levelId" v:"required#会员等级ID不能为空" dc:"会员等级ID"` + AreaId int64 `json:"areaId" v:"required#区域ID不能为空" dc:"区域ID"` + RewardId int64 `json:"rewardId" v:"required#奖励ID不能为空" dc:"奖励ID"` + PriceData string `json:"priceData" v:"required#价格矩阵不能为空" dc:"价格矩阵"` + Id int64 `json:"id" dc:"id"` +} +type SaveNetfeeSettingRes struct { + Success bool `json:"success" dc:"是否成功"` +} diff --git a/internal/controller/store/store_v1_get_netfee_setting.go b/internal/controller/store/store_v1_get_netfee_setting.go new file mode 100644 index 0000000..09fedcd --- /dev/null +++ b/internal/controller/store/store_v1_get_netfee_setting.go @@ -0,0 +1,29 @@ +package store + +import ( + "context" + "server/internal/model" + "server/internal/service" + + "server/api/store/v1" +) + +func (c *ControllerV1) GetNetfeeSetting(ctx context.Context, req *v1.GetNetfeeSettingReq) (res *v1.GetNetfeeSettingRes, err error) { + out, err := service.Store().GetNetfeeSetting(ctx, &model.GetNetfeeSettingIn{ + StoreId: req.StoreId, + RewardId: req.RewardId, + AreaId: req.AreaId, + MemberLevelId: req.LevelId, + }) + if err != nil { + return + } + return &v1.GetNetfeeSettingRes{ + AreaId: out.AreaId, + Id: out.Id, + MemberLevelId: out.MemberLevelId, + PriceData: out.PriceData, + RewardId: out.RewardId, + StoreId: out.StoreId, + }, nil +} diff --git a/internal/controller/store/store_v1_get_store_area_list.go b/internal/controller/store/store_v1_get_store_area_list.go new file mode 100644 index 0000000..cf2259e --- /dev/null +++ b/internal/controller/store/store_v1_get_store_area_list.go @@ -0,0 +1,26 @@ +package store + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "server/internal/model" + "server/internal/service" + + "server/api/store/v1" +) + +func (c *ControllerV1) GetStoreAreaList(ctx context.Context, req *v1.GetStoreAreaListReq) (res *v1.GetStoreAreaListRes, err error) { + fromCtx := g.RequestFromCtx(ctx) + operatorId := fromCtx.GetCtxVar("id").Int64() + operatorRole := fromCtx.GetCtxVar("role").String() + + out, err := service.Store().GetStoreAreaList(ctx, &model.StoreAreaListIn{StoreId: req.StoreId, OperatorRole: operatorRole, OperatorId: operatorId}) + + if err != nil { + return nil, err + } + return &v1.GetStoreAreaListRes{ + List: out.List, + Total: out.Total, + }, nil +} diff --git a/internal/controller/store/store_v1_save_netfee_setting.go b/internal/controller/store/store_v1_save_netfee_setting.go new file mode 100644 index 0000000..9ebb495 --- /dev/null +++ b/internal/controller/store/store_v1_save_netfee_setting.go @@ -0,0 +1,26 @@ +package store + +import ( + "context" + "server/internal/model" + "server/internal/service" + + "server/api/store/v1" +) + +func (c *ControllerV1) SaveNetfeeSetting(ctx context.Context, req *v1.SaveNetfeeSettingReq) (res *v1.SaveNetfeeSettingRes, err error) { + out, err := service.Store().SaveNetfeeSetting(ctx, &model.SaveNetfeeSettingIn{ + AreaId: req.AreaId, + MemberLevelId: req.LevelId, + PriceData: req.PriceData, + RewardId: req.RewardId, + StoreId: req.StoreId, + Id: req.Id, + }) + if err != nil { + return nil, err + } + return &v1.SaveNetfeeSettingRes{ + Success: out.Success, + }, nil +} diff --git a/internal/dao/internal/admins.go b/internal/dao/internal/admins.go index dc72d15..7c3f2be 100644 --- a/internal/dao/internal/admins.go +++ b/internal/dao/internal/admins.go @@ -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. diff --git a/internal/dao/internal/feedbacks.go b/internal/dao/internal/feedbacks.go index 7a8d085..d67a1e5 100644 --- a/internal/dao/internal/feedbacks.go +++ b/internal/dao/internal/feedbacks.go @@ -13,10 +13,9 @@ 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. - 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 FeedbacksColumns // columns contains all the column names of Table for convenient usage. } // FeedbacksColumns defines and stores column names for the table feedbacks. @@ -52,12 +51,11 @@ var feedbacksColumns = FeedbacksColumns{ } // NewFeedbacksDao creates and returns a new DAO object for table data access. -func NewFeedbacksDao(handlers ...gdb.ModelHandler) *FeedbacksDao { +func NewFeedbacksDao() *FeedbacksDao { return &FeedbacksDao{ - group: "default", - table: "feedbacks", - columns: feedbacksColumns, - handlers: handlers, + group: "default", + table: "feedbacks", + columns: feedbacksColumns, } } @@ -83,11 +81,7 @@ func (dao *FeedbacksDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *FeedbacksDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/games.go b/internal/dao/internal/games.go index dac75c7..b53dd54 100644 --- a/internal/dao/internal/games.go +++ b/internal/dao/internal/games.go @@ -13,10 +13,9 @@ 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. - 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 GamesColumns // columns contains all the column names of Table for convenient usage. } // GamesColumns defines and stores column names for the table games. @@ -46,12 +45,11 @@ var gamesColumns = GamesColumns{ } // NewGamesDao creates and returns a new DAO object for table data access. -func NewGamesDao(handlers ...gdb.ModelHandler) *GamesDao { +func NewGamesDao() *GamesDao { return &GamesDao{ - group: "default", - table: "games", - columns: gamesColumns, - handlers: handlers, + group: "default", + table: "games", + columns: gamesColumns, } } @@ -77,11 +75,7 @@ func (dao *GamesDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *GamesDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/merchant_admins.go b/internal/dao/internal/merchant_admins.go index 64533e1..51ac691 100644 --- a/internal/dao/internal/merchant_admins.go +++ b/internal/dao/internal/merchant_admins.go @@ -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. @@ -58,12 +57,11 @@ var merchantAdminsColumns = MerchantAdminsColumns{ } // NewMerchantAdminsDao creates and returns a new DAO object for table data access. -func NewMerchantAdminsDao(handlers ...gdb.ModelHandler) *MerchantAdminsDao { +func NewMerchantAdminsDao() *MerchantAdminsDao { return &MerchantAdminsDao{ - group: "default", - table: "merchant_admins", - columns: merchantAdminsColumns, - handlers: handlers, + group: "default", + table: "merchant_admins", + columns: merchantAdminsColumns, } } @@ -89,11 +87,7 @@ func (dao *MerchantAdminsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *MerchantAdminsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/merchants.go b/internal/dao/internal/merchants.go index 717f855..6dd5d05 100644 --- a/internal/dao/internal/merchants.go +++ b/internal/dao/internal/merchants.go @@ -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. @@ -72,12 +71,11 @@ var merchantsColumns = MerchantsColumns{ } // NewMerchantsDao creates and returns a new DAO object for table data access. -func NewMerchantsDao(handlers ...gdb.ModelHandler) *MerchantsDao { +func NewMerchantsDao() *MerchantsDao { return &MerchantsDao{ - group: "default", - table: "merchants", - columns: merchantsColumns, - handlers: handlers, + group: "default", + table: "merchants", + columns: merchantsColumns, } } @@ -103,11 +101,7 @@ func (dao *MerchantsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *MerchantsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/notices.go b/internal/dao/internal/notices.go index 9c2cfce..5cc451a 100644 --- a/internal/dao/internal/notices.go +++ b/internal/dao/internal/notices.go @@ -13,10 +13,9 @@ import ( // NoticesDao is the data access object for the table notices. type NoticesDao 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 NoticesColumns // 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 NoticesColumns // columns contains all the column names of Table for convenient usage. } // NoticesColumns defines and stores column names for the table notices. @@ -50,12 +49,11 @@ var noticesColumns = NoticesColumns{ } // NewNoticesDao creates and returns a new DAO object for table data access. -func NewNoticesDao(handlers ...gdb.ModelHandler) *NoticesDao { +func NewNoticesDao() *NoticesDao { return &NoticesDao{ - group: "default", - table: "notices", - columns: noticesColumns, - handlers: handlers, + group: "default", + table: "notices", + columns: noticesColumns, } } @@ -81,11 +79,7 @@ func (dao *NoticesDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *NoticesDao) 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. diff --git a/internal/dao/internal/reward_callback.go b/internal/dao/internal/reward_callback.go index d148d1c..3cc67a2 100644 --- a/internal/dao/internal/reward_callback.go +++ b/internal/dao/internal/reward_callback.go @@ -13,10 +13,9 @@ import ( // RewardCallbackDao is the data access object for the table reward_callback. type RewardCallbackDao 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 RewardCallbackColumns // 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 RewardCallbackColumns // columns contains all the column names of Table for convenient usage. } // RewardCallbackColumns defines and stores column names for the table reward_callback. @@ -50,12 +49,11 @@ var rewardCallbackColumns = RewardCallbackColumns{ } // NewRewardCallbackDao creates and returns a new DAO object for table data access. -func NewRewardCallbackDao(handlers ...gdb.ModelHandler) *RewardCallbackDao { +func NewRewardCallbackDao() *RewardCallbackDao { return &RewardCallbackDao{ - group: "default", - table: "reward_callback", - columns: rewardCallbackColumns, - handlers: handlers, + group: "default", + table: "reward_callback", + columns: rewardCallbackColumns, } } @@ -81,11 +79,7 @@ func (dao *RewardCallbackDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *RewardCallbackDao) 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. diff --git a/internal/dao/internal/reward_types.go b/internal/dao/internal/reward_types.go index c035828..b79610a 100644 --- a/internal/dao/internal/reward_types.go +++ b/internal/dao/internal/reward_types.go @@ -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. @@ -46,12 +45,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, } } @@ -77,11 +75,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. diff --git a/internal/dao/internal/reward_waters.go b/internal/dao/internal/reward_waters.go index 83c4803..593f014 100644 --- a/internal/dao/internal/reward_waters.go +++ b/internal/dao/internal/reward_waters.go @@ -13,10 +13,9 @@ import ( // RewardWatersDao is the data access object for the table reward_waters. type RewardWatersDao 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 RewardWatersColumns // 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 RewardWatersColumns // columns contains all the column names of Table for convenient usage. } // RewardWatersColumns defines and stores column names for the table reward_waters. @@ -48,12 +47,11 @@ var rewardWatersColumns = RewardWatersColumns{ } // NewRewardWatersDao creates and returns a new DAO object for table data access. -func NewRewardWatersDao(handlers ...gdb.ModelHandler) *RewardWatersDao { +func NewRewardWatersDao() *RewardWatersDao { return &RewardWatersDao{ - group: "default", - table: "reward_waters", - columns: rewardWatersColumns, - handlers: handlers, + group: "default", + table: "reward_waters", + columns: rewardWatersColumns, } } @@ -79,11 +77,7 @@ func (dao *RewardWatersDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *RewardWatersDao) 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. diff --git a/internal/dao/internal/rewards.go b/internal/dao/internal/rewards.go index dd33c89..6b91001 100644 --- a/internal/dao/internal/rewards.go +++ b/internal/dao/internal/rewards.go @@ -13,10 +13,9 @@ 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. - 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 RewardsColumns // columns contains all the column names of Table for convenient usage. } // RewardsColumns defines and stores column names for the table rewards. @@ -76,12 +75,11 @@ var rewardsColumns = RewardsColumns{ } // NewRewardsDao creates and returns a new DAO object for table data access. -func NewRewardsDao(handlers ...gdb.ModelHandler) *RewardsDao { +func NewRewardsDao() *RewardsDao { return &RewardsDao{ - group: "default", - table: "rewards", - columns: rewardsColumns, - handlers: handlers, + group: "default", + table: "rewards", + columns: rewardsColumns, } } @@ -107,11 +105,7 @@ 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 { - 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. diff --git a/internal/dao/internal/roles.go b/internal/dao/internal/roles.go index b540549..9eab304 100644 --- a/internal/dao/internal/roles.go +++ b/internal/dao/internal/roles.go @@ -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. @@ -48,12 +47,11 @@ var rolesColumns = RolesColumns{ } // NewRolesDao creates and returns a new DAO object for table data access. -func NewRolesDao(handlers ...gdb.ModelHandler) *RolesDao { +func NewRolesDao() *RolesDao { return &RolesDao{ - group: "default", - table: "roles", - columns: rolesColumns, - handlers: handlers, + group: "default", + table: "roles", + columns: rolesColumns, } } @@ -79,11 +77,7 @@ func (dao *RolesDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *RolesDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_admins.go b/internal/dao/internal/store_admins.go index 538322c..7bcffcc 100644 --- a/internal/dao/internal/store_admins.go +++ b/internal/dao/internal/store_admins.go @@ -13,10 +13,9 @@ 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. - 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 StoreAdminsColumns // columns contains all the column names of Table for convenient usage. } // StoreAdminsColumns defines and stores column names for the table store_admins. @@ -58,12 +57,11 @@ var storeAdminsColumns = StoreAdminsColumns{ } // NewStoreAdminsDao creates and returns a new DAO object for table data access. -func NewStoreAdminsDao(handlers ...gdb.ModelHandler) *StoreAdminsDao { +func NewStoreAdminsDao() *StoreAdminsDao { return &StoreAdminsDao{ - group: "default", - table: "store_admins", - columns: storeAdminsColumns, - handlers: handlers, + group: "default", + table: "store_admins", + columns: storeAdminsColumns, } } @@ -89,11 +87,7 @@ func (dao *StoreAdminsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreAdminsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_areas.go b/internal/dao/internal/store_areas.go index 96110ad..913b53e 100644 --- a/internal/dao/internal/store_areas.go +++ b/internal/dao/internal/store_areas.go @@ -13,10 +13,9 @@ import ( // StoreAreasDao is the data access object for the table store_areas. type StoreAreasDao 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 StoreAreasColumns // 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 StoreAreasColumns // columns contains all the column names of Table for convenient usage. } // StoreAreasColumns defines and stores column names for the table store_areas. @@ -40,12 +39,11 @@ var storeAreasColumns = StoreAreasColumns{ } // NewStoreAreasDao creates and returns a new DAO object for table data access. -func NewStoreAreasDao(handlers ...gdb.ModelHandler) *StoreAreasDao { +func NewStoreAreasDao() *StoreAreasDao { return &StoreAreasDao{ - group: "default", - table: "store_areas", - columns: storeAreasColumns, - handlers: handlers, + group: "default", + table: "store_areas", + columns: storeAreasColumns, } } @@ -71,11 +69,7 @@ func (dao *StoreAreasDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreAreasDao) 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. diff --git a/internal/dao/internal/store_clients.go b/internal/dao/internal/store_clients.go index 4cde1d8..b128455 100644 --- a/internal/dao/internal/store_clients.go +++ b/internal/dao/internal/store_clients.go @@ -13,10 +13,9 @@ import ( // StoreClientsDao is the data access object for the table store_clients. type StoreClientsDao 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 StoreClientsColumns // 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 StoreClientsColumns // columns contains all the column names of Table for convenient usage. } // StoreClientsColumns defines and stores column names for the table store_clients. @@ -44,12 +43,11 @@ var storeClientsColumns = StoreClientsColumns{ } // NewStoreClientsDao creates and returns a new DAO object for table data access. -func NewStoreClientsDao(handlers ...gdb.ModelHandler) *StoreClientsDao { +func NewStoreClientsDao() *StoreClientsDao { return &StoreClientsDao{ - group: "default", - table: "store_clients", - columns: storeClientsColumns, - handlers: handlers, + group: "default", + table: "store_clients", + columns: storeClientsColumns, } } @@ -75,11 +73,7 @@ func (dao *StoreClientsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreClientsDao) 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. diff --git a/internal/dao/internal/store_desktop_settings.go b/internal/dao/internal/store_desktop_settings.go index 88c9cb5..dec1ba9 100644 --- a/internal/dao/internal/store_desktop_settings.go +++ b/internal/dao/internal/store_desktop_settings.go @@ -13,10 +13,9 @@ import ( // 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. + 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. } // StoreDesktopSettingsColumns defines and stores column names for the table store_desktop_settings. @@ -34,12 +33,11 @@ var storeDesktopSettingsColumns = StoreDesktopSettingsColumns{ } // NewStoreDesktopSettingsDao creates and returns a new DAO object for table data access. -func NewStoreDesktopSettingsDao(handlers ...gdb.ModelHandler) *StoreDesktopSettingsDao { +func NewStoreDesktopSettingsDao() *StoreDesktopSettingsDao { return &StoreDesktopSettingsDao{ - group: "default", - table: "store_desktop_settings", - columns: storeDesktopSettingsColumns, - handlers: handlers, + group: "default", + table: "store_desktop_settings", + columns: storeDesktopSettingsColumns, } } @@ -65,11 +63,7 @@ func (dao *StoreDesktopSettingsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreDesktopSettingsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_ips.go b/internal/dao/internal/store_ips.go index dfdfd58..20197cb 100644 --- a/internal/dao/internal/store_ips.go +++ b/internal/dao/internal/store_ips.go @@ -13,10 +13,9 @@ import ( // StoreIpsDao is the data access object for the table store_ips. type StoreIpsDao 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 StoreIpsColumns // 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 StoreIpsColumns // columns contains all the column names of Table for convenient usage. } // StoreIpsColumns defines and stores column names for the table store_ips. @@ -42,12 +41,11 @@ var storeIpsColumns = StoreIpsColumns{ } // NewStoreIpsDao creates and returns a new DAO object for table data access. -func NewStoreIpsDao(handlers ...gdb.ModelHandler) *StoreIpsDao { +func NewStoreIpsDao() *StoreIpsDao { return &StoreIpsDao{ - group: "default", - table: "store_ips", - columns: storeIpsColumns, - handlers: handlers, + group: "default", + table: "store_ips", + columns: storeIpsColumns, } } @@ -73,11 +71,7 @@ func (dao *StoreIpsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreIpsDao) 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. diff --git a/internal/dao/internal/store_member_levels.go b/internal/dao/internal/store_member_levels.go index ded56eb..e41bf31 100644 --- a/internal/dao/internal/store_member_levels.go +++ b/internal/dao/internal/store_member_levels.go @@ -13,10 +13,9 @@ import ( // StoreMemberLevelsDao is the data access object for the table store_member_levels. type StoreMemberLevelsDao 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 StoreMemberLevelsColumns // 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 StoreMemberLevelsColumns // columns contains all the column names of Table for convenient usage. } // StoreMemberLevelsColumns defines and stores column names for the table store_member_levels. @@ -48,12 +47,11 @@ var storeMemberLevelsColumns = StoreMemberLevelsColumns{ } // NewStoreMemberLevelsDao creates and returns a new DAO object for table data access. -func NewStoreMemberLevelsDao(handlers ...gdb.ModelHandler) *StoreMemberLevelsDao { +func NewStoreMemberLevelsDao() *StoreMemberLevelsDao { return &StoreMemberLevelsDao{ - group: "default", - table: "store_member_levels", - columns: storeMemberLevelsColumns, - handlers: handlers, + group: "default", + table: "store_member_levels", + columns: storeMemberLevelsColumns, } } @@ -79,11 +77,7 @@ func (dao *StoreMemberLevelsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreMemberLevelsDao) 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. diff --git a/internal/dao/internal/store_netfee_area_level.go b/internal/dao/internal/store_netfee_area_level.go index ffa209a..a3a8b0f 100644 --- a/internal/dao/internal/store_netfee_area_level.go +++ b/internal/dao/internal/store_netfee_area_level.go @@ -13,49 +13,43 @@ import ( // StoreNetfeeAreaLevelDao is the data access object for the table store_netfee_area_level. type StoreNetfeeAreaLevelDao 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 StoreNetfeeAreaLevelColumns // 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 StoreNetfeeAreaLevelColumns // columns contains all the column names of Table for convenient usage. } // StoreNetfeeAreaLevelColumns defines and stores column names for the table store_netfee_area_level. type StoreNetfeeAreaLevelColumns struct { - Id string // 主键ID - StoreId string // 门店ID - RewardId string // 奖励ID(rewards表主键) - AreaId string // 区域ID(外部系统) - AreaName string // 区域名称 - MemberLevelId string // 会员等级ID(外部系统) - MemberLevelName string // 会员等级名称 - PriceData string // 7x24价格矩阵 - CreatedAt string // 创建时间 - UpdatedAt string // 更新时间 - DeletedAt string // 删除时间 + Id string // 主键ID + StoreId string // 门店ID + RewardId string // 奖励ID(rewards表主键) + AreaId string // 区域ID(外部系统) + MemberLevelId string // 会员等级ID(外部系统) + PriceData string // 7x24价格矩阵 + CreatedAt string // 创建时间 + UpdatedAt string // 更新时间 + DeletedAt string // 删除时间 } // storeNetfeeAreaLevelColumns holds the columns for the table store_netfee_area_level. var storeNetfeeAreaLevelColumns = StoreNetfeeAreaLevelColumns{ - Id: "id", - StoreId: "store_id", - RewardId: "reward_id", - AreaId: "area_id", - AreaName: "area_name", - MemberLevelId: "member_level_id", - MemberLevelName: "member_level_name", - PriceData: "price_data", - CreatedAt: "created_at", - UpdatedAt: "updated_at", - DeletedAt: "deleted_at", + Id: "id", + StoreId: "store_id", + RewardId: "reward_id", + AreaId: "area_id", + MemberLevelId: "member_level_id", + PriceData: "price_data", + CreatedAt: "created_at", + UpdatedAt: "updated_at", + DeletedAt: "deleted_at", } // NewStoreNetfeeAreaLevelDao creates and returns a new DAO object for table data access. -func NewStoreNetfeeAreaLevelDao(handlers ...gdb.ModelHandler) *StoreNetfeeAreaLevelDao { +func NewStoreNetfeeAreaLevelDao() *StoreNetfeeAreaLevelDao { return &StoreNetfeeAreaLevelDao{ - group: "default", - table: "store_netfee_area_level", - columns: storeNetfeeAreaLevelColumns, - handlers: handlers, + group: "default", + table: "store_netfee_area_level", + columns: storeNetfeeAreaLevelColumns, } } @@ -81,11 +75,7 @@ func (dao *StoreNetfeeAreaLevelDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreNetfeeAreaLevelDao) 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. diff --git a/internal/dao/internal/store_roles.go b/internal/dao/internal/store_roles.go index 137e1fa..8528459 100644 --- a/internal/dao/internal/store_roles.go +++ b/internal/dao/internal/store_roles.go @@ -13,10 +13,9 @@ import ( // 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. + 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. } // StoreRolesColumns defines and stores column names for the table store_roles. @@ -40,12 +39,11 @@ var storeRolesColumns = StoreRolesColumns{ } // NewStoreRolesDao creates and returns a new DAO object for table data access. -func NewStoreRolesDao(handlers ...gdb.ModelHandler) *StoreRolesDao { +func NewStoreRolesDao() *StoreRolesDao { return &StoreRolesDao{ - group: "default", - table: "store_roles", - columns: storeRolesColumns, - handlers: handlers, + group: "default", + table: "store_roles", + columns: storeRolesColumns, } } @@ -71,11 +69,7 @@ func (dao *StoreRolesDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreRolesDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/stores.go b/internal/dao/internal/stores.go index 69ed619..8bbdc42 100644 --- a/internal/dao/internal/stores.go +++ b/internal/dao/internal/stores.go @@ -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. @@ -52,12 +51,11 @@ var storesColumns = StoresColumns{ } // NewStoresDao creates and returns a new DAO object for table data access. -func NewStoresDao(handlers ...gdb.ModelHandler) *StoresDao { +func NewStoresDao() *StoresDao { return &StoresDao{ - group: "default", - table: "stores", - columns: storesColumns, - handlers: handlers, + group: "default", + table: "stores", + columns: storesColumns, } } @@ -83,11 +81,7 @@ func (dao *StoresDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoresDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/task_rewards.go b/internal/dao/internal/task_rewards.go index adf18fb..d745649 100644 --- a/internal/dao/internal/task_rewards.go +++ b/internal/dao/internal/task_rewards.go @@ -13,10 +13,9 @@ import ( // TaskRewardsDao is the data access object for the table task_rewards. type TaskRewardsDao 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 TaskRewardsColumns // 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 TaskRewardsColumns // columns contains all the column names of Table for convenient usage. } // TaskRewardsColumns defines and stores column names for the table task_rewards. @@ -36,12 +35,11 @@ var taskRewardsColumns = TaskRewardsColumns{ } // NewTaskRewardsDao creates and returns a new DAO object for table data access. -func NewTaskRewardsDao(handlers ...gdb.ModelHandler) *TaskRewardsDao { +func NewTaskRewardsDao() *TaskRewardsDao { return &TaskRewardsDao{ - group: "default", - table: "task_rewards", - columns: taskRewardsColumns, - handlers: handlers, + group: "default", + table: "task_rewards", + columns: taskRewardsColumns, } } @@ -67,11 +65,7 @@ func (dao *TaskRewardsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *TaskRewardsDao) 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. diff --git a/internal/dao/internal/tasks.go b/internal/dao/internal/tasks.go index 72333ac..ced9c75 100644 --- a/internal/dao/internal/tasks.go +++ b/internal/dao/internal/tasks.go @@ -13,10 +13,9 @@ 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. - 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 TasksColumns // columns contains all the column names of Table for convenient usage. } // TasksColumns defines and stores column names for the table tasks. @@ -46,12 +45,11 @@ var tasksColumns = TasksColumns{ } // NewTasksDao creates and returns a new DAO object for table data access. -func NewTasksDao(handlers ...gdb.ModelHandler) *TasksDao { +func NewTasksDao() *TasksDao { return &TasksDao{ - group: "default", - table: "tasks", - columns: tasksColumns, - handlers: handlers, + group: "default", + table: "tasks", + columns: tasksColumns, } } @@ -77,11 +75,7 @@ func (dao *TasksDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *TasksDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/user_task_rewards.go b/internal/dao/internal/user_task_rewards.go index aff73a2..3aaa431 100644 --- a/internal/dao/internal/user_task_rewards.go +++ b/internal/dao/internal/user_task_rewards.go @@ -13,10 +13,9 @@ import ( // UserTaskRewardsDao is the data access object for the table user_task_rewards. type UserTaskRewardsDao 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 UserTaskRewardsColumns // 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 UserTaskRewardsColumns // columns contains all the column names of Table for convenient usage. } // UserTaskRewardsColumns defines and stores column names for the table user_task_rewards. @@ -58,12 +57,11 @@ var userTaskRewardsColumns = UserTaskRewardsColumns{ } // NewUserTaskRewardsDao creates and returns a new DAO object for table data access. -func NewUserTaskRewardsDao(handlers ...gdb.ModelHandler) *UserTaskRewardsDao { +func NewUserTaskRewardsDao() *UserTaskRewardsDao { return &UserTaskRewardsDao{ - group: "default", - table: "user_task_rewards", - columns: userTaskRewardsColumns, - handlers: handlers, + group: "default", + table: "user_task_rewards", + columns: userTaskRewardsColumns, } } @@ -89,11 +87,7 @@ func (dao *UserTaskRewardsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *UserTaskRewardsDao) 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. diff --git a/internal/dao/internal/user_tasks.go b/internal/dao/internal/user_tasks.go index 8b66fba..a9c2e7f 100644 --- a/internal/dao/internal/user_tasks.go +++ b/internal/dao/internal/user_tasks.go @@ -13,10 +13,9 @@ 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. - 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 UserTasksColumns // columns contains all the column names of Table for convenient usage. } // UserTasksColumns defines and stores column names for the table user_tasks. @@ -54,12 +53,11 @@ var userTasksColumns = UserTasksColumns{ } // NewUserTasksDao creates and returns a new DAO object for table data access. -func NewUserTasksDao(handlers ...gdb.ModelHandler) *UserTasksDao { +func NewUserTasksDao() *UserTasksDao { return &UserTasksDao{ - group: "default", - table: "user_tasks", - columns: userTasksColumns, - handlers: handlers, + group: "default", + table: "user_tasks", + columns: userTasksColumns, } } @@ -85,11 +83,7 @@ func (dao *UserTasksDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *UserTasksDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/users.go b/internal/dao/internal/users.go index 2922a48..55d0eda 100644 --- a/internal/dao/internal/users.go +++ b/internal/dao/internal/users.go @@ -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. @@ -62,12 +61,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, } } @@ -93,11 +91,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. diff --git a/internal/logic/store/store.go b/internal/logic/store/store.go index e6ef597..b6a7a49 100644 --- a/internal/logic/store/store.go +++ b/internal/logic/store/store.go @@ -2,6 +2,7 @@ package store import ( "context" + "fmt" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/errors/gerror" "server/internal/consts" @@ -299,3 +300,77 @@ func (s *sStore) GetStoreMemberList(ctx context.Context, in *model.StoreMemberLe Total: total, }, nil } +func (s *sStore) GetStoreAreaList(ctx context.Context, in *model.StoreAreaListIn) (out *model.StoreAreaListOut, err error) { + + // 根据角色权限获取门店ID + switch in.OperatorRole { + case consts.MerchantRoleCode: + exist, err := dao.MerchantAdmins.Ctx(ctx).Where(do.MerchantAdmins{ + MerchantId: in.OperatorId, + }).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("stores.id = ?", in.StoreId).Exist() + if err != nil { + return nil, ecode.Fail.Sub("检查商户权限失败") + } + if !exist { + return nil, ecode.Params.Sub("无门店权限") + } + case consts.StoreRoleCode: + // 检查门店管理员是否有该门店权限 + value, err := dao.StoreAdmins.Ctx(ctx).WherePri(in.OperatorId).Fields(dao.StoreAdmins.Columns().StoreId).Value() + if err != nil { + return nil, ecode.Fail.Sub("检查门店权限失败") + } + if value.IsEmpty() || value.Int64() != in.StoreId { + return nil, ecode.Params.Sub("无门店权限") + } + default: + return nil, ecode.Params.Sub("无操作权限") + } + out = &model.StoreAreaListOut{} + if err = dao.StoreAreas.Ctx(ctx).Where(do.StoreAreas{StoreId: in.StoreId}).ScanAndCount(&out.List, &out.Total, false); err != nil { + return nil, ecode.Fail.Sub("门店区域列表获取失败") + } + return +} + +func (s *sStore) GetNetfeeSetting(ctx context.Context, in *model.GetNetfeeSettingIn) (out *model.StoreNetfeeAreaLevel, err error) { + out = &model.StoreNetfeeAreaLevel{} + one, err := dao.StoreNetfeeAreaLevel.Ctx(ctx).Where(do.StoreNetfeeAreaLevel{StoreId: in.StoreId, RewardId: in.RewardId, AreaId: in.AreaId, MemberLevelId: in.MemberLevelId}).One() + if err != nil { + return nil, ecode.Fail.Sub("门店区域价格获取失败") + } + if one.IsEmpty() { + return + } + if err = one.Struct(out); err != nil { + return nil, ecode.Fail.Sub("门店区域价格获取失败") + } + return +} +func (s *sStore) SaveNetfeeSetting(ctx context.Context, in *model.SaveNetfeeSettingIn) (out *model.SaveNetfeeSettingOut, err error) { + exist, err := dao.StoreNetfeeAreaLevel.Ctx(ctx).Where(do.StoreNetfeeAreaLevel{StoreId: in.StoreId, RewardId: in.RewardId, AreaId: in.AreaId, MemberLevelId: in.MemberLevelId}).Exist() + if err != nil { + return nil, ecode.Fail.Sub("门店区域价格保存失败") + } + if exist { + _, err = dao.StoreNetfeeAreaLevel.Ctx(ctx).Where(do.StoreNetfeeAreaLevel{StoreId: in.StoreId, RewardId: in.RewardId, AreaId: in.AreaId, MemberLevelId: in.MemberLevelId}). + Update(do.StoreNetfeeAreaLevel{PriceData: in.PriceData}) + if err != nil { + return nil, ecode.Fail.Sub("门店区域价格保存失败") + } + } else { + _, err = dao.StoreNetfeeAreaLevel.Ctx(ctx).Insert(do.StoreNetfeeAreaLevel{ + AreaId: in.AreaId, + MemberLevelId: in.MemberLevelId, + PriceData: in.PriceData, + RewardId: in.RewardId, + StoreId: in.StoreId, + }) + if err != nil { + return nil, ecode.Fail.Sub("门店区域价格保存失败") + } + } + return &model.SaveNetfeeSettingOut{ + Success: true, + }, nil +} diff --git a/internal/model/do/store_netfee_area_level.go b/internal/model/do/store_netfee_area_level.go index 4301bfb..da3e91a 100644 --- a/internal/model/do/store_netfee_area_level.go +++ b/internal/model/do/store_netfee_area_level.go @@ -11,16 +11,14 @@ import ( // StoreNetfeeAreaLevel is the golang structure of table store_netfee_area_level for DAO operations like Where/Data. type StoreNetfeeAreaLevel struct { - g.Meta `orm:"table:store_netfee_area_level, do:true"` - Id interface{} // 主键ID - StoreId interface{} // 门店ID - RewardId interface{} // 奖励ID(rewards表主键) - AreaId interface{} // 区域ID(外部系统) - AreaName interface{} // 区域名称 - MemberLevelId interface{} // 会员等级ID(外部系统) - MemberLevelName interface{} // 会员等级名称 - PriceData interface{} // 7x24价格矩阵 - CreatedAt *gtime.Time // 创建时间 - UpdatedAt *gtime.Time // 更新时间 - DeletedAt *gtime.Time // 删除时间 + g.Meta `orm:"table:store_netfee_area_level, do:true"` + Id interface{} // 主键ID + StoreId interface{} // 门店ID + RewardId interface{} // 奖励ID(rewards表主键) + AreaId interface{} // 区域ID(外部系统) + MemberLevelId interface{} // 会员等级ID(外部系统) + PriceData interface{} // 7x24价格矩阵 + CreatedAt *gtime.Time // 创建时间 + UpdatedAt *gtime.Time // 更新时间 + DeletedAt *gtime.Time // 删除时间 } diff --git a/internal/model/entity/store_netfee_area_level.go b/internal/model/entity/store_netfee_area_level.go index fbb4db0..b82a6b1 100644 --- a/internal/model/entity/store_netfee_area_level.go +++ b/internal/model/entity/store_netfee_area_level.go @@ -10,15 +10,13 @@ import ( // StoreNetfeeAreaLevel is the golang structure for table store_netfee_area_level. type StoreNetfeeAreaLevel struct { - Id int64 `json:"id" orm:"id" description:"主键ID"` // 主键ID - StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID"` // 门店ID - RewardId int64 `json:"rewardId" orm:"reward_id" description:"奖励ID(rewards表主键)"` // 奖励ID(rewards表主键) - AreaId int64 `json:"areaId" orm:"area_id" description:"区域ID(外部系统)"` // 区域ID(外部系统) - AreaName string `json:"areaName" orm:"area_name" description:"区域名称"` // 区域名称 - MemberLevelId int64 `json:"memberLevelId" orm:"member_level_id" description:"会员等级ID(外部系统)"` // 会员等级ID(外部系统) - MemberLevelName string `json:"memberLevelName" orm:"member_level_name" description:"会员等级名称"` // 会员等级名称 - PriceData string `json:"priceData" orm:"price_data" description:"7x24价格矩阵"` // 7x24价格矩阵 - 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:"删除时间"` // 删除时间 + Id int64 `json:"id" orm:"id" description:"主键ID"` // 主键ID + StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID"` // 门店ID + RewardId int64 `json:"rewardId" orm:"reward_id" description:"奖励ID(rewards表主键)"` // 奖励ID(rewards表主键) + AreaId int64 `json:"areaId" orm:"area_id" description:"区域ID(外部系统)"` // 区域ID(外部系统) + MemberLevelId int64 `json:"memberLevelId" orm:"member_level_id" description:"会员等级ID(外部系统)"` // 会员等级ID(外部系统) + PriceData string `json:"priceData" orm:"price_data" description:"7x24价格矩阵"` // 7x24价格矩阵 + 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:"删除时间"` // 删除时间 } diff --git a/internal/model/netfeeAreaLevel.go b/internal/model/netfeeAreaLevel.go new file mode 100644 index 0000000..0a71b85 --- /dev/null +++ b/internal/model/netfeeAreaLevel.go @@ -0,0 +1,29 @@ +package model + +type StoreNetfeeAreaLevel struct { + Id int64 `json:"id" orm:"id" description:"主键ID"` // 主键ID + StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID"` // 门店ID + RewardId int64 `json:"rewardId" orm:"reward_id" description:"奖励ID(rewards表主键)"` // 奖励ID(rewards表主键) + AreaId int64 `json:"areaId" orm:"area_id" description:"区域ID(外部系统)"` // 区域ID(外部系统) + MemberLevelId int64 `json:"memberLevelId" orm:"member_level_id" description:"会员等级ID(外部系统)"` // 会员等级ID(外部系统) + PriceData string `json:"priceData" orm:"price_data" description:"7x24价格矩阵"` // 7x24价格矩阵 +} + +type GetNetfeeSettingIn struct { + StoreId int64 + AreaId int64 + MemberLevelId int64 + RewardId int64 +} + +type SaveNetfeeSettingIn struct { + StoreId int64 + RewardId int64 + AreaId int64 + MemberLevelId int64 + PriceData string + Id int64 +} +type SaveNetfeeSettingOut struct { + Success bool +} diff --git a/internal/model/storeArea.go b/internal/model/storeArea.go new file mode 100644 index 0000000..75417a5 --- /dev/null +++ b/internal/model/storeArea.go @@ -0,0 +1,17 @@ +package model + +type StoreArea struct { + Id int64 `json:"id" orm:"id" description:"区域ID"` // 区域ID + StoreId int64 `json:"storeId" orm:"store_id" description:"所属门店ID"` // 所属门店ID + AreaName string `json:"areaName" orm:"area_name" description:"区域名称"` // 区域名称 +} + +type StoreAreaListIn struct { + OperatorId int64 + OperatorRole string + StoreId int64 `json:"storeId"` +} +type StoreAreaListOut struct { + List []StoreArea + Total int +} diff --git a/internal/service/store.go b/internal/service/store.go index a4ed0fa..a294148 100644 --- a/internal/service/store.go +++ b/internal/service/store.go @@ -24,6 +24,9 @@ type ( DeleteIP(ctx context.Context, in *model.IPDeleteIn) (*model.IPDeleteOut, error) Detail(ctx context.Context, in *model.StoreDetailIn) (out *model.StoreDetailOut, err error) GetStoreMemberList(ctx context.Context, in *model.StoreMemberLevelsListIn) (out *model.StoreMemberLevelsListOut, err error) + GetStoreAreaList(ctx context.Context, in *model.StoreAreaListIn) (out *model.StoreAreaListOut, err error) + GetNetfeeSetting(ctx context.Context, in *model.GetNetfeeSettingIn) (out *model.StoreNetfeeAreaLevel, err error) + SaveNetfeeSetting(ctx context.Context, in *model.SaveNetfeeSettingIn) (out *model.SaveNetfeeSettingOut, err error) } ) diff --git a/utility/myCasbin/casbin.go b/utility/myCasbin/casbin.go index abde6e8..02b3945 100644 --- a/utility/myCasbin/casbin.go +++ b/utility/myCasbin/casbin.go @@ -95,6 +95,9 @@ func init() { { // 获取会员 enforcer.AddPolicy("store", "/x/store/memberLevel", "GET", "获取用户会员信息") + enforcer.AddPolicy("store", "/x/store/area", "GET", "获取门店区域列表") + enforcer.AddPolicy("store", "/x/store/netfeeSetting", "GET", "获取门店网费设置") + enforcer.AddPolicy("store", "/x/store/netfeeSetting", "POST", "修改门店网费设置") // 门店:修改 enforcer.AddPolicy("store", "/x/task/sync", "POST", "同步任务") // 奖励类型