proxy.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. // Code generated by ent, DO NOT EDIT.
  2. package proxy
  3. import (
  4. "time"
  5. "entgo.io/ent"
  6. "entgo.io/ent/dialect/sql"
  7. "entgo.io/ent/dialect/sql/sqlgraph"
  8. )
  9. const (
  10. // Label holds the string label denoting the proxy type in the database.
  11. Label = "proxy"
  12. // FieldID holds the string denoting the id field in the database.
  13. FieldID = "id"
  14. // FieldCreatedAt holds the string denoting the created_at field in the database.
  15. FieldCreatedAt = "created_at"
  16. // FieldUpdatedAt holds the string denoting the updated_at field in the database.
  17. FieldUpdatedAt = "updated_at"
  18. // FieldDeletedAt holds the string denoting the deleted_at field in the database.
  19. FieldDeletedAt = "deleted_at"
  20. // FieldName holds the string denoting the name field in the database.
  21. FieldName = "name"
  22. // FieldProtocol holds the string denoting the protocol field in the database.
  23. FieldProtocol = "protocol"
  24. // FieldHost holds the string denoting the host field in the database.
  25. FieldHost = "host"
  26. // FieldPort holds the string denoting the port field in the database.
  27. FieldPort = "port"
  28. // FieldUsername holds the string denoting the username field in the database.
  29. FieldUsername = "username"
  30. // FieldPassword holds the string denoting the password field in the database.
  31. FieldPassword = "password"
  32. // FieldStatus holds the string denoting the status field in the database.
  33. FieldStatus = "status"
  34. // FieldExpiresAt holds the string denoting the expires_at field in the database.
  35. FieldExpiresAt = "expires_at"
  36. // FieldFallbackMode holds the string denoting the fallback_mode field in the database.
  37. FieldFallbackMode = "fallback_mode"
  38. // FieldBackupProxyID holds the string denoting the backup_proxy_id field in the database.
  39. FieldBackupProxyID = "backup_proxy_id"
  40. // FieldExpiryWarnDays holds the string denoting the expiry_warn_days field in the database.
  41. FieldExpiryWarnDays = "expiry_warn_days"
  42. // EdgeAccounts holds the string denoting the accounts edge name in mutations.
  43. EdgeAccounts = "accounts"
  44. // EdgePrimaryProxies holds the string denoting the primary_proxies edge name in mutations.
  45. EdgePrimaryProxies = "primary_proxies"
  46. // EdgeBackupProxy holds the string denoting the backup_proxy edge name in mutations.
  47. EdgeBackupProxy = "backup_proxy"
  48. // Table holds the table name of the proxy in the database.
  49. Table = "proxies"
  50. // AccountsTable is the table that holds the accounts relation/edge.
  51. AccountsTable = "accounts"
  52. // AccountsInverseTable is the table name for the Account entity.
  53. // It exists in this package in order to avoid circular dependency with the "account" package.
  54. AccountsInverseTable = "accounts"
  55. // AccountsColumn is the table column denoting the accounts relation/edge.
  56. AccountsColumn = "proxy_id"
  57. // PrimaryProxiesTable is the table that holds the primary_proxies relation/edge.
  58. PrimaryProxiesTable = "proxies"
  59. // PrimaryProxiesColumn is the table column denoting the primary_proxies relation/edge.
  60. PrimaryProxiesColumn = "backup_proxy_id"
  61. // BackupProxyTable is the table that holds the backup_proxy relation/edge.
  62. BackupProxyTable = "proxies"
  63. // BackupProxyColumn is the table column denoting the backup_proxy relation/edge.
  64. BackupProxyColumn = "backup_proxy_id"
  65. )
  66. // Columns holds all SQL columns for proxy fields.
  67. var Columns = []string{
  68. FieldID,
  69. FieldCreatedAt,
  70. FieldUpdatedAt,
  71. FieldDeletedAt,
  72. FieldName,
  73. FieldProtocol,
  74. FieldHost,
  75. FieldPort,
  76. FieldUsername,
  77. FieldPassword,
  78. FieldStatus,
  79. FieldExpiresAt,
  80. FieldFallbackMode,
  81. FieldBackupProxyID,
  82. FieldExpiryWarnDays,
  83. }
  84. // ValidColumn reports if the column name is valid (part of the table columns).
  85. func ValidColumn(column string) bool {
  86. for i := range Columns {
  87. if column == Columns[i] {
  88. return true
  89. }
  90. }
  91. return false
  92. }
  93. // Note that the variables below are initialized by the runtime
  94. // package on the initialization of the application. Therefore,
  95. // it should be imported in the main as follows:
  96. //
  97. // import _ "github.com/Wei-Shaw/sub2api/ent/runtime"
  98. var (
  99. Hooks [1]ent.Hook
  100. Interceptors [1]ent.Interceptor
  101. // DefaultCreatedAt holds the default value on creation for the "created_at" field.
  102. DefaultCreatedAt func() time.Time
  103. // DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
  104. DefaultUpdatedAt func() time.Time
  105. // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
  106. UpdateDefaultUpdatedAt func() time.Time
  107. // NameValidator is a validator for the "name" field. It is called by the builders before save.
  108. NameValidator func(string) error
  109. // ProtocolValidator is a validator for the "protocol" field. It is called by the builders before save.
  110. ProtocolValidator func(string) error
  111. // HostValidator is a validator for the "host" field. It is called by the builders before save.
  112. HostValidator func(string) error
  113. // UsernameValidator is a validator for the "username" field. It is called by the builders before save.
  114. UsernameValidator func(string) error
  115. // PasswordValidator is a validator for the "password" field. It is called by the builders before save.
  116. PasswordValidator func(string) error
  117. // DefaultStatus holds the default value on creation for the "status" field.
  118. DefaultStatus string
  119. // StatusValidator is a validator for the "status" field. It is called by the builders before save.
  120. StatusValidator func(string) error
  121. // DefaultFallbackMode holds the default value on creation for the "fallback_mode" field.
  122. DefaultFallbackMode string
  123. // FallbackModeValidator is a validator for the "fallback_mode" field. It is called by the builders before save.
  124. FallbackModeValidator func(string) error
  125. // DefaultExpiryWarnDays holds the default value on creation for the "expiry_warn_days" field.
  126. DefaultExpiryWarnDays int
  127. )
  128. // OrderOption defines the ordering options for the Proxy queries.
  129. type OrderOption func(*sql.Selector)
  130. // ByID orders the results by the id field.
  131. func ByID(opts ...sql.OrderTermOption) OrderOption {
  132. return sql.OrderByField(FieldID, opts...).ToFunc()
  133. }
  134. // ByCreatedAt orders the results by the created_at field.
  135. func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
  136. return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
  137. }
  138. // ByUpdatedAt orders the results by the updated_at field.
  139. func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
  140. return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
  141. }
  142. // ByDeletedAt orders the results by the deleted_at field.
  143. func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
  144. return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
  145. }
  146. // ByName orders the results by the name field.
  147. func ByName(opts ...sql.OrderTermOption) OrderOption {
  148. return sql.OrderByField(FieldName, opts...).ToFunc()
  149. }
  150. // ByProtocol orders the results by the protocol field.
  151. func ByProtocol(opts ...sql.OrderTermOption) OrderOption {
  152. return sql.OrderByField(FieldProtocol, opts...).ToFunc()
  153. }
  154. // ByHost orders the results by the host field.
  155. func ByHost(opts ...sql.OrderTermOption) OrderOption {
  156. return sql.OrderByField(FieldHost, opts...).ToFunc()
  157. }
  158. // ByPort orders the results by the port field.
  159. func ByPort(opts ...sql.OrderTermOption) OrderOption {
  160. return sql.OrderByField(FieldPort, opts...).ToFunc()
  161. }
  162. // ByUsername orders the results by the username field.
  163. func ByUsername(opts ...sql.OrderTermOption) OrderOption {
  164. return sql.OrderByField(FieldUsername, opts...).ToFunc()
  165. }
  166. // ByPassword orders the results by the password field.
  167. func ByPassword(opts ...sql.OrderTermOption) OrderOption {
  168. return sql.OrderByField(FieldPassword, opts...).ToFunc()
  169. }
  170. // ByStatus orders the results by the status field.
  171. func ByStatus(opts ...sql.OrderTermOption) OrderOption {
  172. return sql.OrderByField(FieldStatus, opts...).ToFunc()
  173. }
  174. // ByExpiresAt orders the results by the expires_at field.
  175. func ByExpiresAt(opts ...sql.OrderTermOption) OrderOption {
  176. return sql.OrderByField(FieldExpiresAt, opts...).ToFunc()
  177. }
  178. // ByFallbackMode orders the results by the fallback_mode field.
  179. func ByFallbackMode(opts ...sql.OrderTermOption) OrderOption {
  180. return sql.OrderByField(FieldFallbackMode, opts...).ToFunc()
  181. }
  182. // ByBackupProxyID orders the results by the backup_proxy_id field.
  183. func ByBackupProxyID(opts ...sql.OrderTermOption) OrderOption {
  184. return sql.OrderByField(FieldBackupProxyID, opts...).ToFunc()
  185. }
  186. // ByExpiryWarnDays orders the results by the expiry_warn_days field.
  187. func ByExpiryWarnDays(opts ...sql.OrderTermOption) OrderOption {
  188. return sql.OrderByField(FieldExpiryWarnDays, opts...).ToFunc()
  189. }
  190. // ByAccountsCount orders the results by accounts count.
  191. func ByAccountsCount(opts ...sql.OrderTermOption) OrderOption {
  192. return func(s *sql.Selector) {
  193. sqlgraph.OrderByNeighborsCount(s, newAccountsStep(), opts...)
  194. }
  195. }
  196. // ByAccounts orders the results by accounts terms.
  197. func ByAccounts(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
  198. return func(s *sql.Selector) {
  199. sqlgraph.OrderByNeighborTerms(s, newAccountsStep(), append([]sql.OrderTerm{term}, terms...)...)
  200. }
  201. }
  202. // ByPrimaryProxiesCount orders the results by primary_proxies count.
  203. func ByPrimaryProxiesCount(opts ...sql.OrderTermOption) OrderOption {
  204. return func(s *sql.Selector) {
  205. sqlgraph.OrderByNeighborsCount(s, newPrimaryProxiesStep(), opts...)
  206. }
  207. }
  208. // ByPrimaryProxies orders the results by primary_proxies terms.
  209. func ByPrimaryProxies(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
  210. return func(s *sql.Selector) {
  211. sqlgraph.OrderByNeighborTerms(s, newPrimaryProxiesStep(), append([]sql.OrderTerm{term}, terms...)...)
  212. }
  213. }
  214. // ByBackupProxyField orders the results by backup_proxy field.
  215. func ByBackupProxyField(field string, opts ...sql.OrderTermOption) OrderOption {
  216. return func(s *sql.Selector) {
  217. sqlgraph.OrderByNeighborTerms(s, newBackupProxyStep(), sql.OrderByField(field, opts...))
  218. }
  219. }
  220. func newAccountsStep() *sqlgraph.Step {
  221. return sqlgraph.NewStep(
  222. sqlgraph.From(Table, FieldID),
  223. sqlgraph.To(AccountsInverseTable, FieldID),
  224. sqlgraph.Edge(sqlgraph.O2M, true, AccountsTable, AccountsColumn),
  225. )
  226. }
  227. func newPrimaryProxiesStep() *sqlgraph.Step {
  228. return sqlgraph.NewStep(
  229. sqlgraph.From(Table, FieldID),
  230. sqlgraph.To(Table, FieldID),
  231. sqlgraph.Edge(sqlgraph.O2M, true, PrimaryProxiesTable, PrimaryProxiesColumn),
  232. )
  233. }
  234. func newBackupProxyStep() *sqlgraph.Step {
  235. return sqlgraph.NewStep(
  236. sqlgraph.From(Table, FieldID),
  237. sqlgraph.To(Table, FieldID),
  238. sqlgraph.Edge(sqlgraph.M2O, false, BackupProxyTable, BackupProxyColumn),
  239. )
  240. }