feat: blacklist api

This commit is contained in:
Simon Ding
2025-04-22 18:18:32 +08:00
parent 1a3807acc9
commit fdcf7f487c
16 changed files with 965 additions and 124 deletions

View File

@@ -4,7 +4,7 @@ package blacklist
import (
"fmt"
"polaris/ent/schema"
"time"
"entgo.io/ent/dialect/sql"
)
@@ -16,8 +16,14 @@ const (
FieldID = "id"
// FieldType holds the string denoting the type field in the database.
FieldType = "type"
// FieldValue holds the string denoting the value field in the database.
FieldValue = "value"
// FieldTorrentHash holds the string denoting the torrent_hash field in the database.
FieldTorrentHash = "torrent_hash"
// FieldTorrentName holds the string denoting the torrent_name field in the database.
FieldTorrentName = "torrent_name"
// FieldMediaID holds the string denoting the media_id field in the database.
FieldMediaID = "media_id"
// FieldCreateTime holds the string denoting the create_time field in the database.
FieldCreateTime = "create_time"
// FieldNotes holds the string denoting the notes field in the database.
FieldNotes = "notes"
// Table holds the table name of the blacklist in the database.
@@ -28,7 +34,10 @@ const (
var Columns = []string{
FieldID,
FieldType,
FieldValue,
FieldTorrentHash,
FieldTorrentName,
FieldMediaID,
FieldCreateTime,
FieldNotes,
}
@@ -43,13 +52,16 @@ func ValidColumn(column string) bool {
}
var (
// DefaultValue holds the default value on creation for the "value" field.
DefaultValue schema.BlacklistValue
// DefaultCreateTime holds the default value on creation for the "create_time" field.
DefaultCreateTime func() time.Time
)
// Type defines the type for the "type" enum field.
type Type string
// TypeTorrent is the default value of the Type enum.
const DefaultType = TypeTorrent
// Type values.
const (
TypeMedia Type = "media"
@@ -83,6 +95,26 @@ func ByType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldType, opts...).ToFunc()
}
// ByTorrentHash orders the results by the torrent_hash field.
func ByTorrentHash(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTorrentHash, opts...).ToFunc()
}
// ByTorrentName orders the results by the torrent_name field.
func ByTorrentName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTorrentName, opts...).ToFunc()
}
// ByMediaID orders the results by the media_id field.
func ByMediaID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMediaID, opts...).ToFunc()
}
// ByCreateTime orders the results by the create_time field.
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
}
// ByNotes orders the results by the notes field.
func ByNotes(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldNotes, opts...).ToFunc()

View File

@@ -4,6 +4,7 @@ package blacklist
import (
"polaris/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
)
@@ -53,6 +54,26 @@ func IDLTE(id int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLTE(FieldID, id))
}
// TorrentHash applies equality check predicate on the "torrent_hash" field. It's identical to TorrentHashEQ.
func TorrentHash(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldTorrentHash, v))
}
// TorrentName applies equality check predicate on the "torrent_name" field. It's identical to TorrentNameEQ.
func TorrentName(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldTorrentName, v))
}
// MediaID applies equality check predicate on the "media_id" field. It's identical to MediaIDEQ.
func MediaID(v int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldMediaID, v))
}
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
func CreateTime(v time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldCreateTime, v))
}
// Notes applies equality check predicate on the "notes" field. It's identical to NotesEQ.
func Notes(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldNotes, v))
@@ -78,6 +99,256 @@ func TypeNotIn(vs ...Type) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotIn(FieldType, vs...))
}
// TorrentHashEQ applies the EQ predicate on the "torrent_hash" field.
func TorrentHashEQ(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldTorrentHash, v))
}
// TorrentHashNEQ applies the NEQ predicate on the "torrent_hash" field.
func TorrentHashNEQ(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNEQ(FieldTorrentHash, v))
}
// TorrentHashIn applies the In predicate on the "torrent_hash" field.
func TorrentHashIn(vs ...string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldIn(FieldTorrentHash, vs...))
}
// TorrentHashNotIn applies the NotIn predicate on the "torrent_hash" field.
func TorrentHashNotIn(vs ...string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotIn(FieldTorrentHash, vs...))
}
// TorrentHashGT applies the GT predicate on the "torrent_hash" field.
func TorrentHashGT(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGT(FieldTorrentHash, v))
}
// TorrentHashGTE applies the GTE predicate on the "torrent_hash" field.
func TorrentHashGTE(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGTE(FieldTorrentHash, v))
}
// TorrentHashLT applies the LT predicate on the "torrent_hash" field.
func TorrentHashLT(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLT(FieldTorrentHash, v))
}
// TorrentHashLTE applies the LTE predicate on the "torrent_hash" field.
func TorrentHashLTE(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLTE(FieldTorrentHash, v))
}
// TorrentHashContains applies the Contains predicate on the "torrent_hash" field.
func TorrentHashContains(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldContains(FieldTorrentHash, v))
}
// TorrentHashHasPrefix applies the HasPrefix predicate on the "torrent_hash" field.
func TorrentHashHasPrefix(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldHasPrefix(FieldTorrentHash, v))
}
// TorrentHashHasSuffix applies the HasSuffix predicate on the "torrent_hash" field.
func TorrentHashHasSuffix(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldHasSuffix(FieldTorrentHash, v))
}
// TorrentHashIsNil applies the IsNil predicate on the "torrent_hash" field.
func TorrentHashIsNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldIsNull(FieldTorrentHash))
}
// TorrentHashNotNil applies the NotNil predicate on the "torrent_hash" field.
func TorrentHashNotNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotNull(FieldTorrentHash))
}
// TorrentHashEqualFold applies the EqualFold predicate on the "torrent_hash" field.
func TorrentHashEqualFold(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEqualFold(FieldTorrentHash, v))
}
// TorrentHashContainsFold applies the ContainsFold predicate on the "torrent_hash" field.
func TorrentHashContainsFold(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldContainsFold(FieldTorrentHash, v))
}
// TorrentNameEQ applies the EQ predicate on the "torrent_name" field.
func TorrentNameEQ(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldTorrentName, v))
}
// TorrentNameNEQ applies the NEQ predicate on the "torrent_name" field.
func TorrentNameNEQ(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNEQ(FieldTorrentName, v))
}
// TorrentNameIn applies the In predicate on the "torrent_name" field.
func TorrentNameIn(vs ...string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldIn(FieldTorrentName, vs...))
}
// TorrentNameNotIn applies the NotIn predicate on the "torrent_name" field.
func TorrentNameNotIn(vs ...string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotIn(FieldTorrentName, vs...))
}
// TorrentNameGT applies the GT predicate on the "torrent_name" field.
func TorrentNameGT(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGT(FieldTorrentName, v))
}
// TorrentNameGTE applies the GTE predicate on the "torrent_name" field.
func TorrentNameGTE(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGTE(FieldTorrentName, v))
}
// TorrentNameLT applies the LT predicate on the "torrent_name" field.
func TorrentNameLT(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLT(FieldTorrentName, v))
}
// TorrentNameLTE applies the LTE predicate on the "torrent_name" field.
func TorrentNameLTE(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLTE(FieldTorrentName, v))
}
// TorrentNameContains applies the Contains predicate on the "torrent_name" field.
func TorrentNameContains(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldContains(FieldTorrentName, v))
}
// TorrentNameHasPrefix applies the HasPrefix predicate on the "torrent_name" field.
func TorrentNameHasPrefix(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldHasPrefix(FieldTorrentName, v))
}
// TorrentNameHasSuffix applies the HasSuffix predicate on the "torrent_name" field.
func TorrentNameHasSuffix(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldHasSuffix(FieldTorrentName, v))
}
// TorrentNameIsNil applies the IsNil predicate on the "torrent_name" field.
func TorrentNameIsNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldIsNull(FieldTorrentName))
}
// TorrentNameNotNil applies the NotNil predicate on the "torrent_name" field.
func TorrentNameNotNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotNull(FieldTorrentName))
}
// TorrentNameEqualFold applies the EqualFold predicate on the "torrent_name" field.
func TorrentNameEqualFold(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEqualFold(FieldTorrentName, v))
}
// TorrentNameContainsFold applies the ContainsFold predicate on the "torrent_name" field.
func TorrentNameContainsFold(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldContainsFold(FieldTorrentName, v))
}
// MediaIDEQ applies the EQ predicate on the "media_id" field.
func MediaIDEQ(v int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldMediaID, v))
}
// MediaIDNEQ applies the NEQ predicate on the "media_id" field.
func MediaIDNEQ(v int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNEQ(FieldMediaID, v))
}
// MediaIDIn applies the In predicate on the "media_id" field.
func MediaIDIn(vs ...int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldIn(FieldMediaID, vs...))
}
// MediaIDNotIn applies the NotIn predicate on the "media_id" field.
func MediaIDNotIn(vs ...int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotIn(FieldMediaID, vs...))
}
// MediaIDGT applies the GT predicate on the "media_id" field.
func MediaIDGT(v int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGT(FieldMediaID, v))
}
// MediaIDGTE applies the GTE predicate on the "media_id" field.
func MediaIDGTE(v int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGTE(FieldMediaID, v))
}
// MediaIDLT applies the LT predicate on the "media_id" field.
func MediaIDLT(v int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLT(FieldMediaID, v))
}
// MediaIDLTE applies the LTE predicate on the "media_id" field.
func MediaIDLTE(v int) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLTE(FieldMediaID, v))
}
// MediaIDIsNil applies the IsNil predicate on the "media_id" field.
func MediaIDIsNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldIsNull(FieldMediaID))
}
// MediaIDNotNil applies the NotNil predicate on the "media_id" field.
func MediaIDNotNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotNull(FieldMediaID))
}
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
func CreateTimeEQ(v time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldCreateTime, v))
}
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
func CreateTimeNEQ(v time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNEQ(FieldCreateTime, v))
}
// CreateTimeIn applies the In predicate on the "create_time" field.
func CreateTimeIn(vs ...time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldIn(FieldCreateTime, vs...))
}
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
func CreateTimeNotIn(vs ...time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotIn(FieldCreateTime, vs...))
}
// CreateTimeGT applies the GT predicate on the "create_time" field.
func CreateTimeGT(v time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGT(FieldCreateTime, v))
}
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
func CreateTimeGTE(v time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldGTE(FieldCreateTime, v))
}
// CreateTimeLT applies the LT predicate on the "create_time" field.
func CreateTimeLT(v time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLT(FieldCreateTime, v))
}
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
func CreateTimeLTE(v time.Time) predicate.Blacklist {
return predicate.Blacklist(sql.FieldLTE(FieldCreateTime, v))
}
// CreateTimeIsNil applies the IsNil predicate on the "create_time" field.
func CreateTimeIsNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldIsNull(FieldCreateTime))
}
// CreateTimeNotNil applies the NotNil predicate on the "create_time" field.
func CreateTimeNotNil() predicate.Blacklist {
return predicate.Blacklist(sql.FieldNotNull(FieldCreateTime))
}
// NotesEQ applies the EQ predicate on the "notes" field.
func NotesEQ(v string) predicate.Blacklist {
return predicate.Blacklist(sql.FieldEQ(FieldNotes, v))