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