MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / GetUserGroups

Function GetUserGroups

controller/group.go:24–50  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

22}
23
24func 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}

Callers

nothing calls this directly

Calls 5

GetUserGroupFunction · 0.92
GetGroupRatioCopyFunction · 0.92
GetUserUsableGroupsFunction · 0.92
GroupInUserUsableGroupsFunction · 0.92

Tested by

no test coverage detected