将 LocalDateTime 迁移到 orm

This commit is contained in:
2025-05-10 15:00:03 +08:00
parent 3140d35a95
commit 37e6e58816
39 changed files with 414 additions and 425 deletions

View File

@@ -4,9 +4,9 @@ import (
"context"
"encoding/json"
"fmt"
"platform/pkg/orm"
"platform/pkg/testutil"
"platform/web/auth"
"platform/web/core"
g "platform/web/globals"
"platform/web/models"
"reflect"
@@ -110,7 +110,7 @@ func Test_cache(t *testing.T) {
// 准备测试数据
now := time.Now()
expiration := core.LocalDateTime(now.Add(24 * time.Hour))
expiration := orm.LocalDateTime(now.Add(24 * time.Hour))
testChannels := []*models.Channel{
{
@@ -342,7 +342,7 @@ func Test_channelService_CreateChannel(t *testing.T) {
ResourceID: 1,
Type: 1,
Live: 180,
Expire: core.LocalDateTime(time.Now().AddDate(1, 0, 0)),
Expire: orm.LocalDateTime(time.Now().AddDate(1, 0, 0)),
DailyLimit: 10000,
}
db.Exec("delete from resource_pss where true")
@@ -845,7 +845,7 @@ func Test_channelService_CreateChannel(t *testing.T) {
ResourceID: 2,
Type: 1,
Live: 180,
Expire: core.LocalDateTime(time.Now().AddDate(1, 0, 0)),
Expire: orm.LocalDateTime(time.Now().AddDate(1, 0, 0)),
DailyLimit: 10000,
}
db.Create(resourcePss2)
@@ -915,7 +915,7 @@ func Test_channelService_CreateChannel(t *testing.T) {
ProxyID: 1,
ProxyPort: int32(i + 10000),
UserID: 101,
Expiration: core.LocalDateTime(expr),
Expiration: orm.LocalDateTime(expr),
}
}
db.CreateInBatches(channels, 1000)
@@ -1041,9 +1041,9 @@ func Test_channelService_RemoveChannels(t *testing.T) {
// 创建通道
channels := []models.Channel{
{ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 3, UserID: 101, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 3, UserID: 101, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))},
}
// 保存预设数据
@@ -1155,9 +1155,9 @@ func Test_channelService_RemoveChannels(t *testing.T) {
// 创建通道
channels := []models.Channel{
{ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 3, UserID: 101, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 3, UserID: 101, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))},
}
// 保存预设数据
@@ -1269,9 +1269,9 @@ func Test_channelService_RemoveChannels(t *testing.T) {
// 创建通道
channels := []models.Channel{
{ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 3, UserID: 102, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 3, UserID: 102, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))},
}
// 保存预设数据