(c *gin.Context)
| 94 | } |
| 95 | |
| 96 | func DefaultSettings(c *gin.Context) { |
| 97 | groupStr := c.Query("group") |
| 98 | groupsStr := c.Query("groups") |
| 99 | settings := data.InitialSettings() |
| 100 | if groupsStr == "" && groupStr == "" { |
| 101 | for i := range settings { |
| 102 | (&settings[i]).Index = uint(i) |
| 103 | } |
| 104 | common.SuccessResp(c, settings) |
| 105 | } else { |
| 106 | var groupStrings []string |
| 107 | if groupsStr != "" { |
| 108 | groupStrings = strings.Split(groupsStr, ",") |
| 109 | } else { |
| 110 | groupStrings = append(groupStrings, groupStr) |
| 111 | } |
| 112 | var groups []int |
| 113 | for _, str := range groupStrings { |
| 114 | group, err := strconv.Atoi(str) |
| 115 | if err != nil { |
| 116 | common.ErrorResp(c, err, 400) |
| 117 | return |
| 118 | } |
| 119 | groups = append(groups, group) |
| 120 | } |
| 121 | sort.Ints(groups) |
| 122 | var resultItems []model.SettingItem |
| 123 | for _, group := range groups { |
| 124 | for i := range settings { |
| 125 | item := settings[i] |
| 126 | if group == item.Group { |
| 127 | item.Index = uint(i) |
| 128 | resultItems = append(resultItems, item) |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | common.SuccessResp(c, resultItems) |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | func DeleteSetting(c *gin.Context) { |
| 137 | key := c.Query("key") |
nothing calls this directly
no test coverage detected