refactor(push): clean up legacy push_config and w_push_events hardcoded insertions

- Remove ConfigKeyPushConfig and delete legacy push_config query logic from EventTrigger.Trigger.
- Simplify the push event notification dispatching engine to rely purely on database custom channels.
- Remove w_push_events hardcoded INSERT statement from migration files, letting SyncEvents handle default event registration.
- Rewrite unit tests to use model.PushChannel instead of push_config.
This commit is contained in:
ryan
2026-06-16 08:54:32 +08:00
parent e50e600bc8
commit ff60f1c699
8 changed files with 37 additions and 217 deletions
@@ -1,27 +0,0 @@
-- +goose Up
INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at)
VALUES (
'push_config',
'[]',
'system',
0,
'通知推送渠道配置',
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP
) ON CONFLICT (key) DO NOTHING;
INSERT INTO w_push_events (event_key, name, channels, targets, template, enabled, created_at, updated_at)
VALUES (
'admin_login',
'管理员登录',
'[]',
'[]',
'{"title": "管理员登录提醒", "content": "管理员 {{user.username}} 于 {{time}} 从 IP: {{ip}} 登录成功。", "level": "INFO"}',
false,
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP
) ON CONFLICT (event_key) DO NOTHING;
-- +goose Down
DELETE FROM w_system_configs WHERE key = 'push_config';
DELETE FROM w_push_events WHERE event_key = 'admin_login';
@@ -0,0 +1,5 @@
-- +goose Up
DELETE FROM w_system_configs WHERE key = 'push_config';
DELETE FROM w_push_events WHERE event_key = 'admin_login';
-- +goose Down
@@ -1,27 +0,0 @@
-- +goose Up
INSERT OR IGNORE INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at)
VALUES (
'push_config',
'[]',
'system',
0,
'通知推送渠道配置',
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP
);
INSERT OR IGNORE INTO w_push_events (event_key, name, channels, targets, template, enabled, created_at, updated_at)
VALUES (
'admin_login',
'管理员登录',
'[]',
'[]',
'{"title": "管理员登录提醒", "content": "管理员 {{user.username}} 于 {{time}} 从 IP: {{ip}} 登录成功。", "level": "INFO"}',
false,
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP
);
-- +goose Down
DELETE FROM w_system_configs WHERE key = 'push_config';
DELETE FROM w_push_events WHERE event_key = 'admin_login';
@@ -0,0 +1,5 @@
-- +goose Up
DELETE FROM w_system_configs WHERE key = 'push_config';
DELETE FROM w_push_events WHERE event_key = 'admin_login';
-- +goose Down
+1 -1
View File
@@ -17,7 +17,7 @@ import (
"gorm.io/gorm"
)
const expectedMigratedSystemConfigCount = 32
const expectedMigratedSystemConfigCount = 31
func TestMigrateInitializesSQLiteDatabase(t *testing.T) {
sqliteDB, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{