mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-26 02:34:58 +08:00
feat: remove blacklist api
This commit is contained in:
3
db/db.go
3
db/db.go
@@ -757,3 +757,6 @@ func (c *client) AddTorrent2Blacklist(hash, name string, mediaId int) error {
|
|||||||
func (c *client) GetTorrentBlacklist() (ent.Blacklists, error) {
|
func (c *client) GetTorrentBlacklist() (ent.Blacklists, error) {
|
||||||
return c.ent.Blacklist.Query().Where(blacklist.TypeEQ(blacklist.TypeTorrent)).All(context.Background())
|
return c.ent.Blacklist.Query().Where(blacklist.TypeEQ(blacklist.TypeTorrent)).All(context.Background())
|
||||||
}
|
}
|
||||||
|
func (c *client) DeleteTorrentBlacklist(id int) error {
|
||||||
|
return c.ent.Blacklist.DeleteOneID(id).Exec(context.Background())
|
||||||
|
}
|
||||||
@@ -42,6 +42,7 @@ type Database interface {
|
|||||||
|
|
||||||
AddTorrent2Blacklist(hash, name string, mediaId int) error
|
AddTorrent2Blacklist(hash, name string, mediaId int) error
|
||||||
GetTorrentBlacklist() (ent.Blacklists, error)
|
GetTorrentBlacklist() (ent.Blacklists, error)
|
||||||
|
DeleteTorrentBlacklist(id int) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type Settings interface {
|
type Settings interface {
|
||||||
|
|||||||
@@ -135,6 +135,20 @@ func (s *Server) GetAllBlacklistItems(c *gin.Context) (interface{}, error) {
|
|||||||
}
|
}
|
||||||
return list, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
|
func (s *Server) RemoveBlacklistItem(c *gin.Context) (interface{}, error) {
|
||||||
|
id := c.Param("id")
|
||||||
|
if id == "" {
|
||||||
|
return nil, fmt.Errorf("id is empty")
|
||||||
|
}
|
||||||
|
idInt, err := strconv.Atoi(id)
|
||||||
|
if err!= nil {
|
||||||
|
return nil, fmt.Errorf("id is not int: %v", id)
|
||||||
|
}
|
||||||
|
if err := s.db.DeleteTorrentBlacklist(idInt); err!= nil {
|
||||||
|
return nil, errors.Wrap(err, "db")
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Server) GetMediaDownloadHistory(c *gin.Context) (interface{}, error) {
|
func (s *Server) GetMediaDownloadHistory(c *gin.Context) (interface{}, error) {
|
||||||
var ids = c.Param("id")
|
var ids = c.Param("id")
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ func (s *Server) Serve() error {
|
|||||||
activity.POST("/delete", HttpHandler(s.RemoveActivity))
|
activity.POST("/delete", HttpHandler(s.RemoveActivity))
|
||||||
activity.GET("/media/:id", HttpHandler(s.GetMediaDownloadHistory))
|
activity.GET("/media/:id", HttpHandler(s.GetMediaDownloadHistory))
|
||||||
activity.GET("/blacklist", HttpHandler(s.GetAllBlacklistItems))
|
activity.GET("/blacklist", HttpHandler(s.GetAllBlacklistItems))
|
||||||
|
activity.DELETE("/blacklist/:id", HttpHandler(s.RemoveBlacklistItem))
|
||||||
//activity.GET("/torrents", HttpHandler(s.GetAllTorrents))
|
//activity.GET("/torrents", HttpHandler(s.GetAllTorrents))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user