feat(backend): add user custom attributes system
Add a flexible user attribute system that allows admins to define custom fields for users (text, textarea, number, email, url, date, select, multi_select types). - Add Ent schemas for UserAttributeDefinition and UserAttributeValue - Add service layer with validation logic - Add repository layer with batch operations support - Add admin API endpoints for CRUD and reorder operations - Add batch API for loading attribute values for multiple users - Add database migration (018_user_attributes.sql) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
327
backend/ent/userattributevalue/where.go
Normal file
327
backend/ent/userattributevalue/where.go
Normal file
@@ -0,0 +1,327 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package userattributevalue
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"github.com/Wei-Shaw/sub2api/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||
func UpdatedAt(v time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
|
||||
func UserID(v int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldEQ(FieldUserID, v))
|
||||
}
|
||||
|
||||
// AttributeID applies equality check predicate on the "attribute_id" field. It's identical to AttributeIDEQ.
|
||||
func AttributeID(v int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldEQ(FieldAttributeID, v))
|
||||
}
|
||||
|
||||
// Value applies equality check predicate on the "value" field. It's identical to ValueEQ.
|
||||
func Value(v string) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldEQ(FieldValue, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||
func CreatedAtNEQ(v time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldNEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||
func CreatedAtIn(vs ...time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||
func CreatedAtNotIn(vs ...time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||
func CreatedAtGT(v time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldGT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||
func CreatedAtGTE(v time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldGTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||
func CreatedAtLT(v time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldLT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||
func CreatedAtLTE(v time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldLTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||
func UpdatedAtEQ(v time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||
func UpdatedAtNEQ(v time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||
func UpdatedAtIn(vs ...time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||
func UpdatedAtNotIn(vs ...time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||
func UpdatedAtGT(v time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldGT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||
func UpdatedAtGTE(v time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldGTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||
func UpdatedAtLT(v time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldLT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||
func UpdatedAtLTE(v time.Time) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldLTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UserIDEQ applies the EQ predicate on the "user_id" field.
|
||||
func UserIDEQ(v int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldEQ(FieldUserID, v))
|
||||
}
|
||||
|
||||
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
|
||||
func UserIDNEQ(v int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldNEQ(FieldUserID, v))
|
||||
}
|
||||
|
||||
// UserIDIn applies the In predicate on the "user_id" field.
|
||||
func UserIDIn(vs ...int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldIn(FieldUserID, vs...))
|
||||
}
|
||||
|
||||
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
|
||||
func UserIDNotIn(vs ...int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldNotIn(FieldUserID, vs...))
|
||||
}
|
||||
|
||||
// AttributeIDEQ applies the EQ predicate on the "attribute_id" field.
|
||||
func AttributeIDEQ(v int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldEQ(FieldAttributeID, v))
|
||||
}
|
||||
|
||||
// AttributeIDNEQ applies the NEQ predicate on the "attribute_id" field.
|
||||
func AttributeIDNEQ(v int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldNEQ(FieldAttributeID, v))
|
||||
}
|
||||
|
||||
// AttributeIDIn applies the In predicate on the "attribute_id" field.
|
||||
func AttributeIDIn(vs ...int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldIn(FieldAttributeID, vs...))
|
||||
}
|
||||
|
||||
// AttributeIDNotIn applies the NotIn predicate on the "attribute_id" field.
|
||||
func AttributeIDNotIn(vs ...int64) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldNotIn(FieldAttributeID, vs...))
|
||||
}
|
||||
|
||||
// ValueEQ applies the EQ predicate on the "value" field.
|
||||
func ValueEQ(v string) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldEQ(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueNEQ applies the NEQ predicate on the "value" field.
|
||||
func ValueNEQ(v string) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldNEQ(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueIn applies the In predicate on the "value" field.
|
||||
func ValueIn(vs ...string) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldIn(FieldValue, vs...))
|
||||
}
|
||||
|
||||
// ValueNotIn applies the NotIn predicate on the "value" field.
|
||||
func ValueNotIn(vs ...string) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldNotIn(FieldValue, vs...))
|
||||
}
|
||||
|
||||
// ValueGT applies the GT predicate on the "value" field.
|
||||
func ValueGT(v string) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldGT(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueGTE applies the GTE predicate on the "value" field.
|
||||
func ValueGTE(v string) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldGTE(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueLT applies the LT predicate on the "value" field.
|
||||
func ValueLT(v string) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldLT(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueLTE applies the LTE predicate on the "value" field.
|
||||
func ValueLTE(v string) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldLTE(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueContains applies the Contains predicate on the "value" field.
|
||||
func ValueContains(v string) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldContains(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueHasPrefix applies the HasPrefix predicate on the "value" field.
|
||||
func ValueHasPrefix(v string) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldHasPrefix(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueHasSuffix applies the HasSuffix predicate on the "value" field.
|
||||
func ValueHasSuffix(v string) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldHasSuffix(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueEqualFold applies the EqualFold predicate on the "value" field.
|
||||
func ValueEqualFold(v string) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldEqualFold(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueContainsFold applies the ContainsFold predicate on the "value" field.
|
||||
func ValueContainsFold(v string) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.FieldContainsFold(FieldValue, v))
|
||||
}
|
||||
|
||||
// HasUser applies the HasEdge predicate on the "user" edge.
|
||||
func HasUser() predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates).
|
||||
func HasUserWith(preds ...predicate.User) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(func(s *sql.Selector) {
|
||||
step := newUserStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// HasDefinition applies the HasEdge predicate on the "definition" edge.
|
||||
func HasDefinition() predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, DefinitionTable, DefinitionColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasDefinitionWith applies the HasEdge predicate on the "definition" edge with a given conditions (other predicates).
|
||||
func HasDefinitionWith(preds ...predicate.UserAttributeDefinition) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(func(s *sql.Selector) {
|
||||
step := newDefinitionStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.UserAttributeValue) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.UserAttributeValue) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.UserAttributeValue) predicate.UserAttributeValue {
|
||||
return predicate.UserAttributeValue(sql.NotPredicates(p))
|
||||
}
|
||||
Reference in New Issue
Block a user