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

Function DeleteHistoryLogs

controller/log.go:148–183  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

146}
147
148func DeleteHistoryLogs(c *gin.Context) {
149 // 获取开始和结束时间戳参数
150 startTimestamp, _ := strconv.ParseInt(c.Query("start_timestamp"), 10, 64)
151 endTimestamp, _ := strconv.ParseInt(c.Query("end_timestamp"), 10, 64)
152
153 // 兼容旧的target_timestamp参数
154 if startTimestamp == 0 && endTimestamp == 0 {
155 targetTimestamp, _ := strconv.ParseInt(c.Query("target_timestamp"), 10, 64)
156 if targetTimestamp != 0 {
157 // 如果只提供了target_timestamp,则将其作为结束时间,开始时间为0(删除该时间之前的所有日志)
158 endTimestamp = targetTimestamp
159 }
160 }
161
162 // 验证参数
163 if startTimestamp == 0 && endTimestamp == 0 {
164 c.JSON(http.StatusOK, gin.H{
165 "success": false,
166 "message": "start timestamp or end timestamp is required",
167 })
168 return
169 }
170
171 // 调用模型层函数删除日志
172 count, err := model.DeleteLogsByTimeRange(c.Request.Context(), startTimestamp, endTimestamp, 100)
173 if err != nil {
174 common.ApiError(c, err)
175 return
176 }
177 c.JSON(http.StatusOK, gin.H{
178 "success": true,
179 "message": "",
180 "data": count,
181 })
182 return
183}

Callers

nothing calls this directly

Calls 2

DeleteLogsByTimeRangeFunction · 0.92
ApiErrorFunction · 0.92

Tested by

no test coverage detected