MCPcopy
hub / github.com/QuantumNous/new-api / GetUserGroups

Function GetUserGroups

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

Source from the content-addressed store, hash-verified

24}
25
26func 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}

Callers

nothing calls this directly

Calls 5

GetUserGroupFunction · 0.92
GetUserUsableGroupsFunction · 0.92
GetGroupRatioCopyFunction · 0.92
GetUserGroupRatioFunction · 0.92

Tested by

no test coverage detected