promocode.go 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. // Code generated by ent, DO NOT EDIT.
  2. package promocode
  3. import (
  4. "time"
  5. "entgo.io/ent/dialect/sql"
  6. "entgo.io/ent/dialect/sql/sqlgraph"
  7. )
  8. const (
  9. // Label holds the string label denoting the promocode type in the database.
  10. Label = "promo_code"
  11. // FieldID holds the string denoting the id field in the database.
  12. FieldID = "id"
  13. // FieldCode holds the string denoting the code field in the database.
  14. FieldCode = "code"
  15. // FieldBonusAmount holds the string denoting the bonus_amount field in the database.
  16. FieldBonusAmount = "bonus_amount"
  17. // FieldMaxUses holds the string denoting the max_uses field in the database.
  18. FieldMaxUses = "max_uses"
  19. // FieldUsedCount holds the string denoting the used_count field in the database.
  20. FieldUsedCount = "used_count"
  21. // FieldStatus holds the string denoting the status field in the database.
  22. FieldStatus = "status"
  23. // FieldExpiresAt holds the string denoting the expires_at field in the database.
  24. FieldExpiresAt = "expires_at"
  25. // FieldNotes holds the string denoting the notes field in the database.
  26. FieldNotes = "notes"
  27. // FieldCreatedAt holds the string denoting the created_at field in the database.
  28. FieldCreatedAt = "created_at"
  29. // FieldUpdatedAt holds the string denoting the updated_at field in the database.
  30. FieldUpdatedAt = "updated_at"
  31. // EdgeUsageRecords holds the string denoting the usage_records edge name in mutations.
  32. EdgeUsageRecords = "usage_records"
  33. // Table holds the table name of the promocode in the database.
  34. Table = "promo_codes"
  35. // UsageRecordsTable is the table that holds the usage_records relation/edge.
  36. UsageRecordsTable = "promo_code_usages"
  37. // UsageRecordsInverseTable is the table name for the PromoCodeUsage entity.
  38. // It exists in this package in order to avoid circular dependency with the "promocodeusage" package.
  39. UsageRecordsInverseTable = "promo_code_usages"
  40. // UsageRecordsColumn is the table column denoting the usage_records relation/edge.
  41. UsageRecordsColumn = "promo_code_id"
  42. )
  43. // Columns holds all SQL columns for promocode fields.
  44. var Columns = []string{
  45. FieldID,
  46. FieldCode,
  47. FieldBonusAmount,
  48. FieldMaxUses,
  49. FieldUsedCount,
  50. FieldStatus,
  51. FieldExpiresAt,
  52. FieldNotes,
  53. FieldCreatedAt,
  54. FieldUpdatedAt,
  55. }
  56. // ValidColumn reports if the column name is valid (part of the table columns).
  57. func ValidColumn(column string) bool {
  58. for i := range Columns {
  59. if column == Columns[i] {
  60. return true
  61. }
  62. }
  63. return false
  64. }
  65. var (
  66. // CodeValidator is a validator for the "code" field. It is called by the builders before save.
  67. CodeValidator func(string) error
  68. // DefaultBonusAmount holds the default value on creation for the "bonus_amount" field.
  69. DefaultBonusAmount float64
  70. // DefaultMaxUses holds the default value on creation for the "max_uses" field.
  71. DefaultMaxUses int
  72. // DefaultUsedCount holds the default value on creation for the "used_count" field.
  73. DefaultUsedCount int
  74. // DefaultStatus holds the default value on creation for the "status" field.
  75. DefaultStatus string
  76. // StatusValidator is a validator for the "status" field. It is called by the builders before save.
  77. StatusValidator func(string) error
  78. // DefaultCreatedAt holds the default value on creation for the "created_at" field.
  79. DefaultCreatedAt func() time.Time
  80. // DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
  81. DefaultUpdatedAt func() time.Time
  82. // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
  83. UpdateDefaultUpdatedAt func() time.Time
  84. )
  85. // OrderOption defines the ordering options for the PromoCode queries.
  86. type OrderOption func(*sql.Selector)
  87. // ByID orders the results by the id field.
  88. func ByID(opts ...sql.OrderTermOption) OrderOption {
  89. return sql.OrderByField(FieldID, opts...).ToFunc()
  90. }
  91. // ByCode orders the results by the code field.
  92. func ByCode(opts ...sql.OrderTermOption) OrderOption {
  93. return sql.OrderByField(FieldCode, opts...).ToFunc()
  94. }
  95. // ByBonusAmount orders the results by the bonus_amount field.
  96. func ByBonusAmount(opts ...sql.OrderTermOption) OrderOption {
  97. return sql.OrderByField(FieldBonusAmount, opts...).ToFunc()
  98. }
  99. // ByMaxUses orders the results by the max_uses field.
  100. func ByMaxUses(opts ...sql.OrderTermOption) OrderOption {
  101. return sql.OrderByField(FieldMaxUses, opts...).ToFunc()
  102. }
  103. // ByUsedCount orders the results by the used_count field.
  104. func ByUsedCount(opts ...sql.OrderTermOption) OrderOption {
  105. return sql.OrderByField(FieldUsedCount, opts...).ToFunc()
  106. }
  107. // ByStatus orders the results by the status field.
  108. func ByStatus(opts ...sql.OrderTermOption) OrderOption {
  109. return sql.OrderByField(FieldStatus, opts...).ToFunc()
  110. }
  111. // ByExpiresAt orders the results by the expires_at field.
  112. func ByExpiresAt(opts ...sql.OrderTermOption) OrderOption {
  113. return sql.OrderByField(FieldExpiresAt, opts...).ToFunc()
  114. }
  115. // ByNotes orders the results by the notes field.
  116. func ByNotes(opts ...sql.OrderTermOption) OrderOption {
  117. return sql.OrderByField(FieldNotes, opts...).ToFunc()
  118. }
  119. // ByCreatedAt orders the results by the created_at field.
  120. func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
  121. return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
  122. }
  123. // ByUpdatedAt orders the results by the updated_at field.
  124. func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
  125. return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
  126. }
  127. // ByUsageRecordsCount orders the results by usage_records count.
  128. func ByUsageRecordsCount(opts ...sql.OrderTermOption) OrderOption {
  129. return func(s *sql.Selector) {
  130. sqlgraph.OrderByNeighborsCount(s, newUsageRecordsStep(), opts...)
  131. }
  132. }
  133. // ByUsageRecords orders the results by usage_records terms.
  134. func ByUsageRecords(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
  135. return func(s *sql.Selector) {
  136. sqlgraph.OrderByNeighborTerms(s, newUsageRecordsStep(), append([]sql.OrderTerm{term}, terms...)...)
  137. }
  138. }
  139. func newUsageRecordsStep() *sqlgraph.Step {
  140. return sqlgraph.NewStep(
  141. sqlgraph.From(Table, FieldID),
  142. sqlgraph.To(UsageRecordsInverseTable, FieldID),
  143. sqlgraph.Edge(sqlgraph.O2M, false, UsageRecordsTable, UsageRecordsColumn),
  144. )
  145. }