补充AI下次时间接口异常入参与验证记录

This commit is contained in:
hello-dd-code
2026-02-28 16:24:04 +08:00
parent ec9517e248
commit c735b791cb
3 changed files with 87 additions and 1 deletions
+19 -1
View File
@@ -75,7 +75,11 @@ func (h *SmokeHandler) GetNextSmokeTime(c *gin.Context) {
return
}
mode := strings.ToLower(strings.TrimSpace(c.DefaultQuery("mode", "auto")))
mode, ok := resolveNextSmokeMode(c.Query("mode"))
if !ok {
c.JSON(http.StatusBadRequest, model.Error(http.StatusBadRequest, "mode 参数错误,应为 auto|ai|default"))
return
}
formatPtr := func(t *time.Time) string {
if t == nil {
@@ -194,6 +198,20 @@ func dateOnlyLocal(t time.Time) time.Time {
return time.Date(local.Year(), local.Month(), local.Day(), 0, 0, 0, 0, time.Local)
}
func resolveNextSmokeMode(raw string) (string, bool) {
mode := strings.ToLower(strings.TrimSpace(raw))
if mode == "" {
return "auto", true
}
switch mode {
case "auto", "ai", "default":
return mode, true
default:
return "", false
}
}
type nextSmokeDefaultResponse struct {
LastSmokeAt string `json:"last_smoke_at,omitempty"`
NextSmokeAt string `json:"next_smoke_at,omitempty"`