mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-04 17:08:54 +08:00
refactor: db code
This commit is contained in:
@@ -4,10 +4,8 @@ import (
|
||||
"fmt"
|
||||
"polaris/engine"
|
||||
"polaris/ent"
|
||||
"polaris/ent/blacklist"
|
||||
"polaris/ent/episode"
|
||||
"polaris/ent/history"
|
||||
"polaris/ent/schema"
|
||||
"polaris/log"
|
||||
"polaris/pkg/utils"
|
||||
"strconv"
|
||||
@@ -124,19 +122,19 @@ func (s *Server) addTorrent2Blacklist(link string) error {
|
||||
if link == "" {
|
||||
return nil
|
||||
}
|
||||
if hash, err := utils.MagnetHash(link); err != nil {
|
||||
if _, err := utils.MagnetHash(link); err != nil {
|
||||
return err
|
||||
} else {
|
||||
item := ent.Blacklist{
|
||||
Type: blacklist.TypeTorrent,
|
||||
Value: schema.BlacklistValue{
|
||||
TorrentHash: hash,
|
||||
},
|
||||
}
|
||||
err := s.db.AddBlacklistItem(&item)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "add to db")
|
||||
}
|
||||
// item := ent.Blacklist{
|
||||
// Type: blacklist.TypeTorrent,
|
||||
// Value: schema.BlacklistValue{
|
||||
// TorrentHash: hash,
|
||||
// },
|
||||
// }
|
||||
// err := s.db.AddBlacklistItem(&item)
|
||||
// if err != nil {
|
||||
// return errors.Wrap(err, "add to db")
|
||||
// }
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func NewServer(db *db.Client) *Server {
|
||||
func NewServer(db db.Database) *Server {
|
||||
r := gin.Default()
|
||||
s := &Server{
|
||||
r: r,
|
||||
@@ -36,7 +36,7 @@ func NewServer(db *db.Client) *Server {
|
||||
|
||||
type Server struct {
|
||||
r *gin.Engine
|
||||
db *db.Client
|
||||
db db.Database
|
||||
core *engine.Engine
|
||||
language string
|
||||
jwtSerect string
|
||||
|
||||
Reference in New Issue
Block a user