mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-09-18 10:04:55 +08:00
feat(bat): 补全工作流校验与调度过滤
新增 parse clear-cache 和 i18n validate,补齐 schedule 的作用域过滤与单轮执行上限,并将列表过滤参数暴露给 bat-api dashboard。同步 RPC、OpenAPI、用户文档和回归测试。 Refs #43
This commit is contained in:
+23
-1
@@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"bat-api/internal/backendrpc"
|
||||
@@ -161,7 +162,12 @@ func (s *Server) handleAdminSchedules(w http.ResponseWriter, r *http.Request) {
|
||||
writeErrorJSON(w, http.StatusServiceUnavailable, "schedule_backend_unavailable", "Rust bat schedule backend is unavailable")
|
||||
return
|
||||
}
|
||||
result, err := backend.ScheduleList(r.Context())
|
||||
params, err := scheduleListParams(r)
|
||||
if err != nil {
|
||||
writeErrorJSON(w, http.StatusBadRequest, "invalid_schedule_query", err.Error())
|
||||
return
|
||||
}
|
||||
result, err := backend.ScheduleList(r.Context(), params)
|
||||
if err != nil {
|
||||
s.writeControlBackendError(w, "schedule-list", err)
|
||||
return
|
||||
@@ -174,6 +180,22 @@ func (s *Server) handleAdminSchedules(w http.ResponseWriter, r *http.Request) {
|
||||
writeNoStoreJSON(w, http.StatusOK, result)
|
||||
}
|
||||
|
||||
func scheduleListParams(r *http.Request) (backendrpc.ScheduleListParams, error) {
|
||||
query := r.URL.Query()
|
||||
params := backendrpc.ScheduleListParams{
|
||||
ID: query.Get("id"),
|
||||
Group: query.Get("group"),
|
||||
}
|
||||
if raw := query.Get("enabled"); raw != "" {
|
||||
enabled, err := strconv.ParseBool(raw)
|
||||
if err != nil {
|
||||
return backendrpc.ScheduleListParams{}, errors.New("enabled must be a boolean")
|
||||
}
|
||||
params.Enabled = &enabled
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (s *Server) handleAdminScheduleControl(w http.ResponseWriter, r *http.Request, action string) {
|
||||
backend, ok := s.backend.(ScheduleBackend)
|
||||
if !ok || backend == nil {
|
||||
|
||||
Reference in New Issue
Block a user