2023-06-11 03:08:16 +00:00
|
|
|
package common
|
|
|
|
|
|
|
|
import "encoding/json"
|
|
|
|
|
|
|
|
var GroupRatio = map[string]float64{
|
|
|
|
"default": 1,
|
|
|
|
"vip": 1,
|
|
|
|
"svip": 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
func GroupRatio2JSONString() string {
|
|
|
|
jsonBytes, err := json.Marshal(GroupRatio)
|
|
|
|
if err != nil {
|
2023-06-22 02:59:01 +00:00
|
|
|
SysError("error marshalling model ratio: " + err.Error())
|
2023-06-11 03:08:16 +00:00
|
|
|
}
|
|
|
|
return string(jsonBytes)
|
|
|
|
}
|
|
|
|
|
|
|
|
func UpdateGroupRatioByJSONString(jsonStr string) error {
|
2023-06-12 01:11:48 +00:00
|
|
|
GroupRatio = make(map[string]float64)
|
2023-06-11 03:08:16 +00:00
|
|
|
return json.Unmarshal([]byte(jsonStr), &GroupRatio)
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetGroupRatio(name string) float64 {
|
|
|
|
ratio, ok := GroupRatio[name]
|
|
|
|
if !ok {
|
2023-06-22 02:59:01 +00:00
|
|
|
SysError("group ratio not found: " + name)
|
2023-06-11 03:08:16 +00:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
return ratio
|
|
|
|
}
|