Backend • model/model_meta.go – Added `EnableGroups []string` to Model struct – fillModelExtra now populates EnableGroups • model/model_groups.go – New helper `GetModelEnableGroups` (reuses Pricing cache) • model/pricing_refresh.go – Added `RefreshPricing()` to force immediate cache rebuild • controller/model_meta.go – `GetAllModelsMeta` & `SearchModelsMeta` call `model.RefreshPricing()` before querying, ensuring groups / endpoints are up-to-date Frontend • ModelsColumnDefs.js – Added `renderGroups` util and “可用分组” table column displaying color-coded tags Result Admins can now see which user groups can access each model, and any ability/group changes are reflected instantly without the previous 1-minute delay.
13 lines
371 B
Go
13 lines
371 B
Go
package model
|
|
|
|
// GetModelEnableGroups 返回指定模型名称可用的用户分组列表。
|
|
// 复用缓存的定价映射,避免额外的数据库查询。
|
|
func GetModelEnableGroups(modelName string) []string {
|
|
for _, p := range GetPricing() {
|
|
if p.ModelName == modelName {
|
|
return p.EnableGroup
|
|
}
|
|
}
|
|
return make([]string, 0)
|
|
}
|