初始化导入 new-api 源码
This commit is contained in:
47
model/subscription_group.go
Normal file
47
model/subscription_group.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/QuantumNous/new-api/setting"
|
||||
)
|
||||
|
||||
const PrefillGroupTypeSubscriptionGroup = "subscription_group"
|
||||
|
||||
func ListSubscriptionDedicatedGroups() ([]string, error) {
|
||||
groups := setting.GetSubscriptionGroupsCopy()
|
||||
result := make([]string, 0, len(groups))
|
||||
for name := range groups {
|
||||
name = strings.TrimSpace(name)
|
||||
if name != "" {
|
||||
result = append(result, name)
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func GetSubscriptionDedicatedGroupSet() (map[string]struct{}, error) {
|
||||
groups := setting.GetSubscriptionGroupsCopy()
|
||||
result := make(map[string]struct{}, len(groups))
|
||||
for name := range groups {
|
||||
name = strings.TrimSpace(name)
|
||||
if name != "" {
|
||||
result[name] = struct{}{}
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func IsSubscriptionDedicatedGroup(group string) (bool, error) {
|
||||
group = strings.TrimSpace(group)
|
||||
if group == "" {
|
||||
return false, nil
|
||||
}
|
||||
return setting.IsSubscriptionGroup(group), nil
|
||||
}
|
||||
|
||||
// 历史实现会把 allowed_consume_groups 自动种成 subscription_group,导致"套餐允许消费分组"与
|
||||
// "订阅专属分组"语义混淆。现保留该入口仅做兼容空操作,避免启动迁移时报错,并停止自动污染分组语义。
|
||||
func EnsureSubscriptionDedicatedGroupsSeededFromPlans() error {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user