48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
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
|
||
}
|