(c *gin.Context)
| 24 | } |
| 25 | |
| 26 | func GetUserGroups(c *gin.Context) { |
| 27 | usableGroups := make(map[string]map[string]interface{}) |
| 28 | userGroup := "" |
| 29 | userId := c.GetInt("id") |
| 30 | userGroup, _ = model.GetUserGroup(userId, false) |
| 31 | userUsableGroups := service.GetUserUsableGroups(userGroup) |
| 32 | for groupName, _ := range ratio_setting.GetGroupRatioCopy() { |
| 33 | // UserUsableGroups contains the groups that the user can use |
| 34 | if desc, ok := userUsableGroups[groupName]; ok { |
| 35 | usableGroups[groupName] = map[string]interface{}{ |
| 36 | "ratio": service.GetUserGroupRatio(userGroup, groupName), |
| 37 | "desc": desc, |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | if _, ok := userUsableGroups["auto"]; ok { |
| 42 | usableGroups["auto"] = map[string]interface{}{ |
| 43 | "ratio": "自动", |
| 44 | "desc": setting.GetUsableGroupDescription("auto"), |
| 45 | } |
| 46 | } |
| 47 | c.JSON(http.StatusOK, gin.H{ |
| 48 | "success": true, |
| 49 | "message": "", |
| 50 | "data": usableGroups, |
| 51 | }) |
| 52 | } |
nothing calls this directly
no test coverage detected