MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / DefaultSettings

Function DefaultSettings

server/handles/setting.go:96–134  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

94}
95
96func 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
136func DeleteSetting(c *gin.Context) {
137 key := c.Query("key")

Callers

nothing calls this directly

Calls 3

InitialSettingsFunction · 0.92
SuccessRespFunction · 0.92
ErrorRespFunction · 0.92

Tested by

no test coverage detected