mirror of
https://github.com/simon-ding/polaris.git
synced 2026-04-21 19:27:30 +08:00
feat: episode status
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
package episode
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
@@ -24,6 +26,8 @@ const (
|
||||
FieldOverview = "overview"
|
||||
// FieldAirDate holds the string denoting the air_date field in the database.
|
||||
FieldAirDate = "air_date"
|
||||
// FieldStatus holds the string denoting the status field in the database.
|
||||
FieldStatus = "status"
|
||||
// FieldFileInStorage holds the string denoting the file_in_storage field in the database.
|
||||
FieldFileInStorage = "file_in_storage"
|
||||
// EdgeSeries holds the string denoting the series edge name in mutations.
|
||||
@@ -48,6 +52,7 @@ var Columns = []string{
|
||||
FieldTitle,
|
||||
FieldOverview,
|
||||
FieldAirDate,
|
||||
FieldStatus,
|
||||
FieldFileInStorage,
|
||||
}
|
||||
|
||||
@@ -61,6 +66,33 @@ func ValidColumn(column string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Status defines the type for the "status" enum field.
|
||||
type Status string
|
||||
|
||||
// StatusMissing is the default value of the Status enum.
|
||||
const DefaultStatus = StatusMissing
|
||||
|
||||
// Status values.
|
||||
const (
|
||||
StatusMissing Status = "missing"
|
||||
StatusDownloading Status = "downloading"
|
||||
StatusDownloaded Status = "downloaded"
|
||||
)
|
||||
|
||||
func (s Status) String() string {
|
||||
return string(s)
|
||||
}
|
||||
|
||||
// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save.
|
||||
func StatusValidator(s Status) error {
|
||||
switch s {
|
||||
case StatusMissing, StatusDownloading, StatusDownloaded:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("episode: invalid enum value for status field: %q", s)
|
||||
}
|
||||
}
|
||||
|
||||
// OrderOption defines the ordering options for the Episode queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
@@ -99,6 +131,11 @@ func ByAirDate(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldAirDate, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByStatus orders the results by the status field.
|
||||
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldStatus, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByFileInStorage orders the results by the file_in_storage field.
|
||||
func ByFileInStorage(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldFileInStorage, opts...).ToFunc()
|
||||
|
||||
@@ -394,6 +394,26 @@ func AirDateContainsFold(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldContainsFold(FieldAirDate, v))
|
||||
}
|
||||
|
||||
// StatusEQ applies the EQ predicate on the "status" field.
|
||||
func StatusEQ(v Status) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldEQ(FieldStatus, v))
|
||||
}
|
||||
|
||||
// StatusNEQ applies the NEQ predicate on the "status" field.
|
||||
func StatusNEQ(v Status) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldNEQ(FieldStatus, v))
|
||||
}
|
||||
|
||||
// StatusIn applies the In predicate on the "status" field.
|
||||
func StatusIn(vs ...Status) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldIn(FieldStatus, vs...))
|
||||
}
|
||||
|
||||
// StatusNotIn applies the NotIn predicate on the "status" field.
|
||||
func StatusNotIn(vs ...Status) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldNotIn(FieldStatus, vs...))
|
||||
}
|
||||
|
||||
// FileInStorageEQ applies the EQ predicate on the "file_in_storage" field.
|
||||
func FileInStorageEQ(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldEQ(FieldFileInStorage, v))
|
||||
|
||||
Reference in New Issue
Block a user