(c *gin.Context)
| 9 | ) |
| 10 | |
| 11 | func GetPricing(c *gin.Context) { |
| 12 | pricing := model.GetPricing() |
| 13 | userId, exists := c.Get("id") |
| 14 | usableGroup := map[string]string{} |
| 15 | groupRatio := map[string]float64{} |
| 16 | for s, f := range ratio_setting.GetGroupRatioCopy() { |
| 17 | groupRatio[s] = f |
| 18 | } |
| 19 | var group string |
| 20 | if exists { |
| 21 | user, err := model.GetUserCache(userId.(int)) |
| 22 | if err == nil { |
| 23 | group = user.Group |
| 24 | for g := range groupRatio { |
| 25 | ratio, ok := ratio_setting.GetGroupGroupRatio(group, g) |
| 26 | if ok { |
| 27 | groupRatio[g] = ratio |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | usableGroup = setting.GetUserUsableGroups(group) |
| 34 | // check groupRatio contains usableGroup |
| 35 | for group := range ratio_setting.GetGroupRatioCopy() { |
| 36 | if _, ok := usableGroup[group]; !ok { |
| 37 | delete(groupRatio, group) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | c.JSON(200, gin.H{ |
| 42 | "success": true, |
| 43 | "data": pricing, |
| 44 | "group_ratio": groupRatio, |
| 45 | "usable_group": usableGroup, |
| 46 | }) |
| 47 | } |
| 48 | |
| 49 | func ResetModelRatio(c *gin.Context) { |
| 50 | defaultStr := ratio_setting.DefaultModelRatio2JSONString() |
nothing calls this directly
no test coverage detected