From dcfcd036de8e8dae3a7688ffb8d65e775a6dd924 Mon Sep 17 00:00:00 2001 From: shanshanzhong Date: Sun, 8 Mar 2026 22:37:58 -0700 Subject: [PATCH] x --- .../database/02140_subscribe_new_user_only.down.sql | 12 ++++++++++++ .../database/02140_subscribe_new_user_only.up.sql | 12 ++++++++++++ .../logic/admin/payment/getPaymentMethodListLogic.go | 6 +++--- internal/model/payment/model.go | 6 +++--- internal/model/payment/payment.go | 6 +++--- 5 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 initialize/migrate/database/02140_subscribe_new_user_only.down.sql create mode 100644 initialize/migrate/database/02140_subscribe_new_user_only.up.sql diff --git a/initialize/migrate/database/02140_subscribe_new_user_only.down.sql b/initialize/migrate/database/02140_subscribe_new_user_only.down.sql new file mode 100644 index 0000000..f704169 --- /dev/null +++ b/initialize/migrate/database/02140_subscribe_new_user_only.down.sql @@ -0,0 +1,12 @@ +-- Revert: remove new_user_only column from subscribe table +SET @column_exists = (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.COLUMNS + WHERE TABLE_SCHEMA = DATABASE() + AND TABLE_NAME = 'subscribe' + AND COLUMN_NAME = 'new_user_only'); +SET @sql = IF(@column_exists > 0, + 'ALTER TABLE `subscribe` DROP COLUMN `new_user_only`', + 'SELECT 1'); +PREPARE stmt FROM @sql; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; diff --git a/initialize/migrate/database/02140_subscribe_new_user_only.up.sql b/initialize/migrate/database/02140_subscribe_new_user_only.up.sql new file mode 100644 index 0000000..6f95f32 --- /dev/null +++ b/initialize/migrate/database/02140_subscribe_new_user_only.up.sql @@ -0,0 +1,12 @@ +-- Add new_user_only column to subscribe table +SET @column_exists = (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.COLUMNS + WHERE TABLE_SCHEMA = DATABASE() + AND TABLE_NAME = 'subscribe' + AND COLUMN_NAME = 'new_user_only'); +SET @sql = IF(@column_exists = 0, + 'ALTER TABLE `subscribe` ADD COLUMN `new_user_only` tinyint(1) DEFAULT 0 COMMENT ''New user only: allow purchase within 24h of registration, once per user'' AFTER `quota`', + 'SELECT 1'); +PREPARE stmt FROM @sql; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; diff --git a/internal/logic/admin/payment/getPaymentMethodListLogic.go b/internal/logic/admin/payment/getPaymentMethodListLogic.go index ef987f3..fa959fd 100644 --- a/internal/logic/admin/payment/getPaymentMethodListLogic.go +++ b/internal/logic/admin/payment/getPaymentMethodListLogic.go @@ -32,9 +32,9 @@ func NewGetPaymentMethodListLogic(ctx context.Context, svcCtx *svc.ServiceContex func (l *GetPaymentMethodListLogic) GetPaymentMethodList(req *types.GetPaymentMethodListRequest) (resp *types.GetPaymentMethodListResponse, err error) { total, list, err := l.svcCtx.PaymentModel.FindListByPage(l.ctx, req.Page, req.Size, &payment.Filter{ - Search: req.Search, - Mark: req.Platform, - Enable: req.Enable, + Search: req.Search, + Platform: req.Platform, + Enable: req.Enable, }) if err != nil { l.Errorw("find payment method list error", logger.Field("error", err.Error())) diff --git a/internal/model/payment/model.go b/internal/model/payment/model.go index d8d0de1..0d7bc71 100644 --- a/internal/model/payment/model.go +++ b/internal/model/payment/model.go @@ -56,8 +56,8 @@ func (m *customPaymentModel) FindListByPage(ctx context.Context, page, size int, if req.Enable != nil { conn = conn.Where("`enable` = ?", *req.Enable) } - if req.Mark != "" { - conn = conn.Where("`mark` = ?", req.Mark) + if req.Platform != "" { + conn = conn.Where("`platform` = ?", req.Platform) } if req.Search != "" { conn = conn.Where("`name` LIKE ?", "%"+req.Search+"%") @@ -72,7 +72,7 @@ func (m *customPaymentModel) FindListByPage(ctx context.Context, page, size int, func (m *customPaymentModel) FindListByPlatform(ctx context.Context, platform string) ([]*Payment, error) { var resp []*Payment err := m.QueryNoCacheCtx(ctx, &resp, func(conn *gorm.DB, v interface{}) error { - return conn.Model(&Payment{}).Where("mark = ?", platform).Find(v).Error + return conn.Model(&Payment{}).Where("platform = ?", platform).Find(v).Error }) return resp, err } diff --git a/internal/model/payment/payment.go b/internal/model/payment/payment.go index f08d3e8..72bf007 100644 --- a/internal/model/payment/payment.go +++ b/internal/model/payment/payment.go @@ -34,9 +34,9 @@ func (l *Payment) BeforeDelete(_ *gorm.DB) (err error) { } type Filter struct { - Mark string - Enable *bool - Search string + Platform string + Enable *bool + Search string } type StripeConfig struct {