add movie download history

This commit is contained in:
Simon Ding
2024-07-23 19:01:24 +08:00
parent d2439480c8
commit 11f7b51eb5
6 changed files with 247 additions and 110 deletions

View File

@@ -1,6 +1,7 @@
package server
import (
"fmt"
"polaris/ent"
"polaris/ent/episode"
"polaris/log"
@@ -72,3 +73,15 @@ func (s *Server) RemoveActivity(c *gin.Context) (interface{}, error) {
log.Infof("history record successful deleted: %v", his.SourceTitle)
return nil, nil
}
func (s *Server) GetMediaDownloadHistory(c *gin.Context) (interface{}, error) {
var ids = c.Param("id")
id, err := strconv.Atoi(ids)
if err != nil {
return nil, fmt.Errorf("id is not correct: %v", ids)
}
his, err := s.db.GetDownloadHistory(id)
if err != nil {
return nil, errors.Wrap(err, "db")
}
return his, nil
}

View File

@@ -62,6 +62,7 @@ func (s *Server) Serve() error {
{
activity.GET("/", HttpHandler(s.GetAllActivities))
activity.DELETE("/:id", HttpHandler(s.RemoveActivity))
activity.GET("/media/:id", HttpHandler(s.GetMediaDownloadHistory))
}
tv := api.Group("/media")