scores 主键改用 UUID v7

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
fish
2026-05-03 15:02:08 +08:00
parent 220f4acc45
commit 961ab8224e
4 changed files with 5 additions and 10 deletions

View File

@@ -32,12 +32,7 @@ func (d *Deps) ListScores(w http.ResponseWriter, r *http.Request) {
}
func (d *Deps) GetScore(w http.ResponseWriter, r *http.Request) {
idStr := chi.URLParam(r, "id")
id, err := strconv.ParseInt(idStr, 10, 64)
if err != nil {
writeErr(w, http.StatusBadRequest, "invalid id")
return
}
id := chi.URLParam(r, "id")
row, err := d.Futures.GetScore(id)
if err != nil {
writeErr(w, http.StatusNotFound, err.Error())

View File

@@ -29,7 +29,7 @@ func OpenFutures(databaseURL string) (*FuturesStore, error) {
func (s *FuturesStore) Close() error { return s.db.Close() }
type Score struct {
ID int64 `json:"id"`
ID string `json:"id"`
TsCode string `json:"ts_code"`
TradeDate string `json:"trade_date"`
Close float64 `json:"close"`
@@ -91,7 +91,7 @@ func (s *FuturesStore) ListScores(f ScoreFilter) ([]Score, error) {
return out, rows.Err()
}
func (s *FuturesStore) GetScore(id int64) (*Score, error) {
func (s *FuturesStore) GetScore(id string) (*Score, error) {
row := s.db.QueryRow(`SELECT id, ts_code, trade_date, close, oi, oi_chg, short_term, medium_term,
long_term, composite, signal, detail_json, created_at FROM scores WHERE id = ?`, id)
var x Score