fix 修复填写的pid不能包含/的问题
All checks were successful
Build image / build (push) Successful in 2m36s

This commit is contained in:
timerzz 2024-12-02 14:11:28 +08:00
parent a4e217d17a
commit 3b321f099d

View File

@ -2,6 +2,7 @@ package server
import ( import (
"fmt" "fmt"
"net/url"
"strconv" "strconv"
"gitea.timerzz.com/kedaya_haitao/coach-spider/spider" "gitea.timerzz.com/kedaya_haitao/coach-spider/spider"
@ -50,31 +51,31 @@ func (s *SpiderSvc) FetchArticlePrice(ctx fiber.Ctx) error {
} }
func (s *SpiderSvc) FetchArticleDetail(ctx fiber.Ctx) error { func (s *SpiderSvc) FetchArticleDetail(ctx fiber.Ctx) error {
pid := ctx.Params("pid") pid, err := url.QueryUnescape(ctx.Params("pid"))
if pid == "" { if err != nil {
return fmt.Errorf("pid is empty") return err
} }
if err := s.ctl.FetchArticleDetail(ctx.Context(), pid); err != nil { if err = s.ctl.FetchArticleDetail(ctx.Context(), pid); err != nil {
return err return err
} }
return ctx.JSON(web.NewResponse("ok")) return ctx.JSON(web.NewResponse("ok"))
} }
func (s *SpiderSvc) FetchArticleAts(ctx fiber.Ctx) error { func (s *SpiderSvc) FetchArticleAts(ctx fiber.Ctx) error {
pid := ctx.Params("pid") pid, err := url.QueryUnescape(ctx.Params("pid"))
if pid == "" { if err != nil {
return fmt.Errorf("pid is empty") return err
} }
if err := s.ctl.FetchArticleAts(ctx.Context(), pid); err != nil { if err = s.ctl.FetchArticleAts(ctx.Context(), pid); err != nil {
return err return err
} }
return ctx.JSON(web.NewResponse("ok")) return ctx.JSON(web.NewResponse("ok"))
} }
func (s *SpiderSvc) GetArticleAts(ctx fiber.Ctx) error { func (s *SpiderSvc) GetArticleAts(ctx fiber.Ctx) error {
pid := ctx.Params("pid") pid, err := url.QueryUnescape(ctx.Params("pid"))
if pid == "" { if err != nil {
return fmt.Errorf("pid is empty") return err
} }
ats, err := s.ctl.GetArticleAts(ctx.Context(), pid) ats, err := s.ctl.GetArticleAts(ctx.Context(), pid)
if err != nil { if err != nil {