chore: do some work

This commit is contained in:
Simon Ding
2024-07-06 10:59:30 +08:00
parent c703552267
commit 7d9dc17f87
14 changed files with 245 additions and 23 deletions

View File

@@ -3,6 +3,8 @@
package series
import (
"time"
"entgo.io/ent/dialect/sql"
)
@@ -25,6 +27,8 @@ const (
FieldPath = "path"
// FieldPosterPath holds the string denoting the poster_path field in the database.
FieldPosterPath = "poster_path"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// Table holds the table name of the series in the database.
Table = "series"
)
@@ -39,6 +43,7 @@ var Columns = []string{
FieldOverview,
FieldPath,
FieldPosterPath,
FieldCreatedAt,
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -51,6 +56,11 @@ func ValidColumn(column string) bool {
return false
}
var (
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt time.Time
)
// OrderOption defines the ordering options for the Series queries.
type OrderOption func(*sql.Selector)
@@ -93,3 +103,8 @@ func ByPath(opts ...sql.OrderTermOption) OrderOption {
func ByPosterPath(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPosterPath, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}

View File

@@ -4,6 +4,7 @@ package series
import (
"polaris/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
)
@@ -88,6 +89,11 @@ func PosterPath(v string) predicate.Series {
return predicate.Series(sql.FieldEQ(FieldPosterPath, v))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.Series {
return predicate.Series(sql.FieldEQ(FieldCreatedAt, v))
}
// TmdbIDEQ applies the EQ predicate on the "tmdb_id" field.
func TmdbIDEQ(v int) predicate.Series {
return predicate.Series(sql.FieldEQ(FieldTmdbID, v))
@@ -538,6 +544,46 @@ func PosterPathContainsFold(v string) predicate.Series {
return predicate.Series(sql.FieldContainsFold(FieldPosterPath, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.Series {
return predicate.Series(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.Series {
return predicate.Series(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.Series {
return predicate.Series(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.Series {
return predicate.Series(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.Series {
return predicate.Series(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.Series {
return predicate.Series(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.Series {
return predicate.Series(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.Series {
return predicate.Series(sql.FieldLTE(FieldCreatedAt, v))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.Series) predicate.Series {
return predicate.Series(sql.AndPredicates(predicates...))