package service import ( "gitea.timerzz.com/kedaya_haitao/common/pkg/web" "gitea.timerzz.com/kedaya_haitao/common/structs/storage" "github.com/gofiber/fiber/v3" "gorm.io/gorm" ) type Tracer struct { storage *storage.Storage } func NewTracer(storage *storage.Storage) *Tracer { return &Tracer{ storage: storage, } } func (s *Tracer) Registry(r fiber.Router) { api := r.Group("/api/v2") api.Get("tracers", s.List) } func (s *Tracer) List(c fiber.Ctx) error { var q storage.GetProviderArticleQuery if err := c.Bind().Query(&q); err != nil { return err } q.TraceAtsNotNull = true var query = storage.NewPageListQuery(&q) if err := c.Bind().Query(query); err != nil { return err } articles, total, err := s.storage.ProviderArticle().List(*query, func(db *gorm.DB) *gorm.DB { db = db.Preload("HistoryAts") return db }) if err != nil { return err } return c.JSON(web.NewResponse(web.NewListResponse(total, articles))) }