新增数据重置功能:管理员可一键清空所有行情数据,需输入确认文字防误操作

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
fish
2026-05-04 23:20:07 +08:00
parent 7b6732488a
commit fa5fa07ef6
6 changed files with 72 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package handlers
import (
"fmt"
"io"
"net/http"
"time"
)
func (d *Deps) AdminResetData(w http.ResponseWriter, r *http.Request) {
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Post(d.TushareURL+"/api/v1/admin/reset-data", "application/json", nil)
if err != nil {
writeErr(w, http.StatusBadGateway, fmt.Sprintf("tushare service unavailable: %v", err))
return
}
defer resp.Body.Close()
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(resp.StatusCode)
_, _ = io.Copy(w, resp.Body)
}