补充AI下次时间接口异常入参与验证记录
This commit is contained in:
@@ -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"`
|
||||
|
||||
Reference in New Issue
Block a user