修改用户反馈信息,新增系统奖励
This commit is contained in:
@ -75,7 +75,7 @@ type ListStoreRewardRes struct {
|
||||
|
||||
// UpdateSystemRewardReq 更新系统奖励请求
|
||||
type UpdateSystemRewardReq struct {
|
||||
g.Meta `path:"/reward/system/{id}" method:"put" tags:"Reward" summary:"更新系统奖励"`
|
||||
g.Meta `path:"/reward/system" method:"put" tags:"Reward" summary:"更新系统奖励"`
|
||||
Id uint64 `v:"required|min:1#奖励ID不能为空|奖励ID无效" json:"id" dc:"奖励ID"`
|
||||
RewardTypeId int64 `v:"required|min:1#奖励类型ID不能为空|奖励类型ID无效" json:"rewardTypeId" dc:"奖励类型ID"`
|
||||
Name string `v:"required|length:1,100#奖励名称不能为空|奖励名称长度为1-100" json:"name" dc:"奖励名称"`
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
"server/internal/controller/auth"
|
||||
"server/internal/controller/feedback"
|
||||
"server/internal/controller/merchant"
|
||||
"server/internal/controller/reward"
|
||||
"server/internal/controller/rewardType"
|
||||
"server/internal/controller/role"
|
||||
"server/internal/controller/upload"
|
||||
@ -42,6 +43,7 @@ var (
|
||||
rewardType.NewV1(),
|
||||
feedback.NewV1(),
|
||||
user.NewV1(),
|
||||
reward.NewV1(),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@ -2,13 +2,25 @@ package reward
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/reward/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) CreateSystemReward(ctx context.Context, req *v1.CreateSystemRewardReq) (res *v1.CreateSystemRewardRes, err error) {
|
||||
return nil, gerror.NewCode(gcode.CodeNotImplemented)
|
||||
out, err := service.Reward().CreateSystemReward(ctx, &model.RewardCreateIn{
|
||||
Description: req.Description,
|
||||
ExpireAt: req.ExpireAt,
|
||||
Name: req.Name,
|
||||
RewardTypeID: req.RewardTypeId,
|
||||
StartAt: req.StartAt,
|
||||
Status: req.Status,
|
||||
Stock: req.Stock,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.CreateSystemRewardRes{Id: out.Id}, nil
|
||||
}
|
||||
|
||||
@ -2,13 +2,21 @@ package reward
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/reward/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) DeleteSystemReward(ctx context.Context, req *v1.DeleteSystemRewardReq) (res *v1.DeleteSystemRewardRes, err error) {
|
||||
return nil, gerror.NewCode(gcode.CodeNotImplemented)
|
||||
|
||||
out, err := service.Reward().DeleteSystemReward(ctx, &model.RewardDeleteIn{
|
||||
ID: int64(req.Id),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.DeleteSystemRewardRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -2,13 +2,26 @@ package reward
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/reward/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ListSystemReward(ctx context.Context, req *v1.ListSystemRewardReq) (res *v1.ListSystemRewardRes, err error) {
|
||||
return nil, gerror.NewCode(gcode.CodeNotImplemented)
|
||||
|
||||
out, err := service.Reward().ListSystemReward(ctx, &model.RewardListIn{
|
||||
Name: req.Name,
|
||||
Page: req.Page,
|
||||
Size: req.PageSize,
|
||||
Status: req.Status,
|
||||
RewardTypeID: req.RewardTypeId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ListSystemRewardRes{
|
||||
List: out.List,
|
||||
Total: out.Total,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -2,13 +2,26 @@ package reward
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/reward/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) UpdateSystemReward(ctx context.Context, req *v1.UpdateSystemRewardReq) (res *v1.UpdateSystemRewardRes, err error) {
|
||||
return nil, gerror.NewCode(gcode.CodeNotImplemented)
|
||||
|
||||
out, err := service.Reward().UpdateSystemReward(ctx, &model.RewardUpdateIn{
|
||||
ID: int64(req.Id),
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
StartAt: req.StartAt,
|
||||
ExpireAt: req.ExpireAt,
|
||||
Status: req.Status,
|
||||
Stock: req.Stock,
|
||||
RewardTypeID: req.RewardTypeId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.UpdateSystemRewardRes{Success: out.Success}, nil
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ 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.
|
||||
}
|
||||
|
||||
// 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,
|
||||
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.
|
||||
|
||||
@ -16,6 +16,7 @@ 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.
|
||||
}
|
||||
|
||||
// FeedbacksColumns defines and stores column names for the table feedbacks.
|
||||
@ -31,7 +32,7 @@ type FeedbacksColumns struct {
|
||||
UpdatedAt string // 反馈更新时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
StoreId string // 门店唯一 id
|
||||
MerchatId string // 商户唯一 id
|
||||
MerchantId string // 商户唯一 id
|
||||
}
|
||||
|
||||
// feedbacksColumns holds the columns for the table feedbacks.
|
||||
@ -47,15 +48,16 @@ var feedbacksColumns = FeedbacksColumns{
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
StoreId: "store_id",
|
||||
MerchatId: "merchat_id",
|
||||
MerchantId: "merchant_id",
|
||||
}
|
||||
|
||||
// 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,
|
||||
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.
|
||||
|
||||
@ -16,6 +16,7 @@ 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.
|
||||
}
|
||||
|
||||
// MerchantAdminsColumns defines and stores column names for the table merchant_admins.
|
||||
@ -59,11 +60,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,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +91,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.
|
||||
|
||||
@ -16,6 +16,7 @@ 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.
|
||||
}
|
||||
|
||||
// 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,
|
||||
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.
|
||||
|
||||
@ -16,6 +16,7 @@ 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.
|
||||
}
|
||||
|
||||
// RewardTypesColumns defines and stores column names for the table reward_types.
|
||||
@ -43,11 +44,12 @@ var rewardTypesColumns = RewardTypesColumns{
|
||||
}
|
||||
|
||||
// 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,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +75,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.
|
||||
|
||||
@ -16,6 +16,7 @@ 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.
|
||||
}
|
||||
|
||||
// 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,
|
||||
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.
|
||||
|
||||
@ -16,6 +16,7 @@ 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.
|
||||
}
|
||||
|
||||
// RolesColumns defines and stores column names for the table roles.
|
||||
@ -45,11 +46,12 @@ var rolesColumns = RolesColumns{
|
||||
}
|
||||
|
||||
// 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,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +77,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.
|
||||
|
||||
@ -16,6 +16,7 @@ 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.
|
||||
}
|
||||
|
||||
// StoreAdminsColumns defines and stores column names for the table store_admins.
|
||||
@ -55,11 +56,12 @@ var storeAdminsColumns = StoreAdminsColumns{
|
||||
}
|
||||
|
||||
// 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,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,7 +87,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.
|
||||
|
||||
@ -16,6 +16,7 @@ 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.
|
||||
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,
|
||||
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.
|
||||
|
||||
@ -16,6 +16,7 @@ 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.
|
||||
}
|
||||
|
||||
// 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,
|
||||
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.
|
||||
|
||||
@ -16,6 +16,7 @@ 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.
|
||||
}
|
||||
|
||||
// UsersColumns defines and stores column names for the table users.
|
||||
@ -59,11 +60,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,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +91,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.
|
||||
|
||||
@ -35,7 +35,7 @@ func (s *sFeedback) List(ctx context.Context, in *model.FeedbackIn) (out *model.
|
||||
// 判断角色
|
||||
if in.Role == consts.MerchantRoleCode {
|
||||
m = m.Where(do.Feedbacks{
|
||||
MerchatId: in.OperatorId,
|
||||
MerchantId: in.OperatorId,
|
||||
})
|
||||
} else if in.Role == consts.StoreRoleCode {
|
||||
m = m.Where(do.Feedbacks{
|
||||
@ -87,7 +87,7 @@ func (s *sFeedback) Create(ctx context.Context, in *model.FeedbackCreateIn) (out
|
||||
FeedbackType: in.FeedbackType,
|
||||
UserId: in.OperatorId,
|
||||
StoreId: in.StoreId,
|
||||
MerchatId: in.MerchantId,
|
||||
MerchantId: in.MerchantId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -45,7 +45,7 @@ func (s *sReward) CreateSystemReward(ctx context.Context, in *model.RewardCreate
|
||||
RewardTypeId: in.RewardTypeID,
|
||||
RewardScope: consts.SystemReward, // 系统奖励
|
||||
Name: in.Name,
|
||||
Code: "",
|
||||
Code: "xmax",
|
||||
Description: in.Description,
|
||||
Status: in.Status,
|
||||
Stock: in.Stock,
|
||||
@ -139,7 +139,28 @@ func (s *sReward) CreateStoreReward(ctx context.Context, in *model.RewardCreateI
|
||||
|
||||
// ListSystemReward 查询系统奖励列表
|
||||
func (s *sReward) ListSystemReward(ctx context.Context, in *model.RewardListIn) (out *model.RewardListOut, err error) {
|
||||
return
|
||||
m := dao.Rewards.Ctx(ctx)
|
||||
|
||||
// 构建查询条件
|
||||
if in.Name != "" {
|
||||
m = m.WhereLike(dao.Rewards.Columns().Name, "%"+in.Name+"%")
|
||||
}
|
||||
|
||||
if in.RewardTypeID != 0 {
|
||||
m = m.Where(do.Rewards{RewardTypeId: in.RewardTypeID})
|
||||
}
|
||||
|
||||
list := make([]model.Reward, 0)
|
||||
var total int
|
||||
err = m.Page(in.Page, in.Size).Where(do.Rewards{RewardScope: 1, Status: in.Status}).OrderDesc(dao.Rewards.Columns().CreatedAt).OrderDesc(dao.Rewards.Columns().Id).ScanAndCount(&list, &total, false)
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询系统奖励失败")
|
||||
}
|
||||
|
||||
return &model.RewardListOut{
|
||||
List: list,
|
||||
Total: total,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ListStoreReward 查询门店奖励列表
|
||||
@ -201,7 +222,28 @@ func (s *sReward) ListStoreReward(ctx context.Context, in *model.RewardListIn) (
|
||||
|
||||
// UpdateSystemReward 更新系统奖励
|
||||
func (s *sReward) UpdateSystemReward(ctx context.Context, in *model.RewardUpdateIn) (out *model.UpdateOut, err error) {
|
||||
return
|
||||
exist, err := dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: in.ID}).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询该奖励失败")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.Params.Sub("该奖励不存在")
|
||||
}
|
||||
|
||||
_, err = dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: in.ID, RewardScope: 1}).Update(do.Rewards{
|
||||
RewardTypeId: in.RewardTypeID,
|
||||
Name: in.Name,
|
||||
Description: in.Description,
|
||||
Status: in.Status,
|
||||
Stock: in.Stock,
|
||||
StartAt: in.StartAt,
|
||||
ExpireAt: in.ExpireAt,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("更新奖励失败")
|
||||
}
|
||||
return &model.UpdateOut{Success: true}, nil
|
||||
}
|
||||
|
||||
// UpdateStoreReward 更新门店奖励
|
||||
@ -295,7 +337,22 @@ func (s *sReward) UpdateStoreReward(ctx context.Context, in *model.RewardUpdateI
|
||||
|
||||
// DeleteSystemReward 删除系统奖励
|
||||
func (s *sReward) DeleteSystemReward(ctx context.Context, in *model.RewardDeleteIn) (out *model.DeleteOut, err error) {
|
||||
return
|
||||
|
||||
exist, err := dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: in.ID}).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询该奖励失败")
|
||||
}
|
||||
|
||||
if !exist {
|
||||
return nil, ecode.Params.Sub("该奖励不存在")
|
||||
}
|
||||
|
||||
_, err = dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: in.ID}).Delete()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("删除奖励失败")
|
||||
}
|
||||
|
||||
return &model.DeleteOut{Success: true}, nil
|
||||
}
|
||||
|
||||
// DeleteStoreReward 删除门店奖励
|
||||
|
||||
@ -23,5 +23,5 @@ type Feedbacks struct {
|
||||
UpdatedAt *gtime.Time // 反馈更新时间
|
||||
DeletedAt *gtime.Time // 软删除时间戳
|
||||
StoreId interface{} // 门店唯一 id
|
||||
MerchatId interface{} // 商户唯一 id
|
||||
MerchantId interface{} // 商户唯一 id
|
||||
}
|
||||
|
||||
@ -21,5 +21,5 @@ type Feedbacks struct {
|
||||
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
|
||||
MerchatId int64 `json:"merchatId" orm:"merchat_id" description:"商户唯一 id"` // 商户唯一 id
|
||||
MerchantId int64 `json:"merchantId" orm:"merchant_id" description:"商户唯一 id"` // 商户唯一 id
|
||||
}
|
||||
|
||||
@ -7,18 +7,18 @@ import (
|
||||
|
||||
type Feedback struct {
|
||||
g.Meta `orm:"table:feedback"`
|
||||
Id int64 `json:"id" dc:"ID" orm:"id,primary"`
|
||||
UserId int64 `json:"user_id" dc:"用户ID" orm:"user_id"`
|
||||
Title string `json:"title" dc:"反馈标题" orm:"title"`
|
||||
Content string `json:"content" dc:"反馈内容" orm:"content"`
|
||||
FeedbackType int `json:"feedback_type" dc:"反馈类型" orm:"feedback_type"`
|
||||
Status int `json:"status" dc:"状态:1=已处理,2=未处理" orm:"status"`
|
||||
Reply string `json:"reply" dc:"管理员回复" orm:"reply"`
|
||||
CreateTime *gtime.Time `json:"create_time" dc:"创建时间" orm:"create_time"`
|
||||
UpdateTime *gtime.Time `json:"update_time" dc:"更新时间" orm:"update_time"`
|
||||
DeleteTime *gtime.Time `json:"delete_time" dc:"删除时间" orm:"delete_time"`
|
||||
StoreId int64 `json:"store_id" dc:"店铺ID" orm:"store_id"`
|
||||
MerchantId int64 `json:"merchant_id" dc:"商户ID" orm:"merchant_id"`
|
||||
Id int64 `json:"id" orm:"id" description:"反馈唯一标识符"` // 反馈唯一标识符
|
||||
UserId int64 `json:"userId" orm:"user_id" description:"提交者用户ID"` // 提交者用户ID
|
||||
Title string `json:"title" orm:"title" description:"反馈标题"` // 反馈标题
|
||||
Content string `json:"content" orm:"content" description:"反馈内容"` // 反馈内容
|
||||
FeedbackType int `json:"feedbackType" orm:"feedback_type" description:"反馈类型:1=BUG,2=建议,3=投诉,4=其他"` // 反馈类型:1=BUG,2=建议,3=投诉,4=其他
|
||||
Status int `json:"status" orm:"status" description:"处理状态:1=待处理,2=处理中,3=已处理,4=已驳回"` // 处理状态:1=待处理,2=处理中,3=已处理,4=已驳回
|
||||
Reply string `json:"reply" orm:"reply" 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:"软删除时间戳"` // 软删除时间戳
|
||||
StoreId int64 `json:"storeId" orm:"store_id" description:"门店唯一 id"` // 门店唯一 id
|
||||
MerchantId int64 `json:"merchantId" orm:"merchant_id" description:"商户唯一 id"` // 商户唯一 id
|
||||
}
|
||||
|
||||
type FeedbackIn struct {
|
||||
|
||||
@ -93,6 +93,11 @@ func init() {
|
||||
enforcer.AddPolicy("admin", "/x/merchant", "GET", "管理员获取商户列表")
|
||||
enforcer.AddPolicy("admin", "/x/merchant/audit", "POST", "管理员审核商户申请")
|
||||
|
||||
// 奖励
|
||||
enforcer.AddPolicy("admin", "/x/reward/system", "POST", "管理员创建系统奖励")
|
||||
enforcer.AddPolicy("admin", "/x/reward/system", "GET", "管理员获取系统奖励列表")
|
||||
enforcer.AddPolicy("admin", "/x/reward/system/*", "DELETE", "管理员删除系统单个奖励")
|
||||
enforcer.AddPolicy("admin", "/x/reward/system", "PUT", "管理员修改单个系统奖励")
|
||||
}
|
||||
instance = &myCasbin{Enforcer: enforcer}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user