重构项目结构,将 orm 和 rds 包迁移到 web/globals

This commit is contained in:
2025-05-10 16:59:41 +08:00
parent 37e6e58816
commit d256359681
60 changed files with 363 additions and 349 deletions

View File

@@ -2,8 +2,8 @@ package services
import (
"context"
"platform/pkg/orm"
"platform/web/models"
g "platform/web/globals"
m "platform/web/models"
)
type NodeServiceErr string
@@ -16,7 +16,7 @@ var Node = &nodeService{}
type nodeService struct{}
func (s *nodeService) Filter(ctx context.Context, userId int32, count int, config ...NodeFilterConfig) ([]*models.Node, error) {
func (s *nodeService) Filter(ctx context.Context, userId int32, count int, config ...NodeFilterConfig) ([]*m.Node, error) {
_config := NodeFilterConfig{}
if len(config) > 0 {
_config = config[0]
@@ -26,7 +26,7 @@ func (s *nodeService) Filter(ctx context.Context, userId int32, count int, confi
// 静态条件:省,市,运营商
// 排序方式1.分配给该用户的次数 2.分配给全部用户的次数 3.todo 节点的健康状态
var nodes []*FilteredNode
orm.DB.Raw(filterSqlRaw, userId, _config.Isp, _config.Prov, _config.City).
g.DB.Raw(filterSqlRaw, userId, _config.Isp, _config.Prov, _config.City).
Limit(count).
Find(&nodes)