agent.go 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. // Code generated by ent, DO NOT EDIT.
  2. package agent
  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 agent type in the database.
  11. Label = "agent"
  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. // FieldRole holds the string denoting the role field in the database.
  23. FieldRole = "role"
  24. // FieldStatus holds the string denoting the status field in the database.
  25. FieldStatus = "status"
  26. // FieldBackground holds the string denoting the background field in the database.
  27. FieldBackground = "background"
  28. // FieldExamples holds the string denoting the examples field in the database.
  29. FieldExamples = "examples"
  30. // FieldOrganizationID holds the string denoting the organization_id field in the database.
  31. FieldOrganizationID = "organization_id"
  32. // EdgeWxAgent holds the string denoting the wx_agent edge name in mutations.
  33. EdgeWxAgent = "wx_agent"
  34. // Table holds the table name of the agent in the database.
  35. Table = "agent"
  36. // WxAgentTable is the table that holds the wx_agent relation/edge.
  37. WxAgentTable = "wx"
  38. // WxAgentInverseTable is the table name for the Wx entity.
  39. // It exists in this package in order to avoid circular dependency with the "wx" package.
  40. WxAgentInverseTable = "wx"
  41. // WxAgentColumn is the table column denoting the wx_agent relation/edge.
  42. WxAgentColumn = "agent_id"
  43. )
  44. // Columns holds all SQL columns for agent fields.
  45. var Columns = []string{
  46. FieldID,
  47. FieldCreatedAt,
  48. FieldUpdatedAt,
  49. FieldDeletedAt,
  50. FieldName,
  51. FieldRole,
  52. FieldStatus,
  53. FieldBackground,
  54. FieldExamples,
  55. FieldOrganizationID,
  56. }
  57. // ValidColumn reports if the column name is valid (part of the table columns).
  58. func ValidColumn(column string) bool {
  59. for i := range Columns {
  60. if column == Columns[i] {
  61. return true
  62. }
  63. }
  64. return false
  65. }
  66. // Note that the variables below are initialized by the runtime
  67. // package on the initialization of the application. Therefore,
  68. // it should be imported in the main as follows:
  69. //
  70. // import _ "wechat-api/ent/runtime"
  71. var (
  72. Hooks [1]ent.Hook
  73. Interceptors [1]ent.Interceptor
  74. // DefaultCreatedAt holds the default value on creation for the "created_at" field.
  75. DefaultCreatedAt func() time.Time
  76. // DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
  77. DefaultUpdatedAt func() time.Time
  78. // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
  79. UpdateDefaultUpdatedAt func() time.Time
  80. // NameValidator is a validator for the "name" field. It is called by the builders before save.
  81. NameValidator func(string) error
  82. // RoleValidator is a validator for the "role" field. It is called by the builders before save.
  83. RoleValidator func(string) error
  84. // DefaultStatus holds the default value on creation for the "status" field.
  85. DefaultStatus int
  86. // StatusValidator is a validator for the "status" field. It is called by the builders before save.
  87. StatusValidator func(int) error
  88. // BackgroundValidator is a validator for the "background" field. It is called by the builders before save.
  89. BackgroundValidator func(string) error
  90. // ExamplesValidator is a validator for the "examples" field. It is called by the builders before save.
  91. ExamplesValidator func(string) error
  92. // OrganizationIDValidator is a validator for the "organization_id" field. It is called by the builders before save.
  93. OrganizationIDValidator func(uint64) error
  94. )
  95. // OrderOption defines the ordering options for the Agent queries.
  96. type OrderOption func(*sql.Selector)
  97. // ByID orders the results by the id field.
  98. func ByID(opts ...sql.OrderTermOption) OrderOption {
  99. return sql.OrderByField(FieldID, opts...).ToFunc()
  100. }
  101. // ByCreatedAt orders the results by the created_at field.
  102. func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
  103. return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
  104. }
  105. // ByUpdatedAt orders the results by the updated_at field.
  106. func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
  107. return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
  108. }
  109. // ByDeletedAt orders the results by the deleted_at field.
  110. func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
  111. return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
  112. }
  113. // ByName orders the results by the name field.
  114. func ByName(opts ...sql.OrderTermOption) OrderOption {
  115. return sql.OrderByField(FieldName, opts...).ToFunc()
  116. }
  117. // ByRole orders the results by the role field.
  118. func ByRole(opts ...sql.OrderTermOption) OrderOption {
  119. return sql.OrderByField(FieldRole, opts...).ToFunc()
  120. }
  121. // ByStatus orders the results by the status field.
  122. func ByStatus(opts ...sql.OrderTermOption) OrderOption {
  123. return sql.OrderByField(FieldStatus, opts...).ToFunc()
  124. }
  125. // ByBackground orders the results by the background field.
  126. func ByBackground(opts ...sql.OrderTermOption) OrderOption {
  127. return sql.OrderByField(FieldBackground, opts...).ToFunc()
  128. }
  129. // ByExamples orders the results by the examples field.
  130. func ByExamples(opts ...sql.OrderTermOption) OrderOption {
  131. return sql.OrderByField(FieldExamples, opts...).ToFunc()
  132. }
  133. // ByOrganizationID orders the results by the organization_id field.
  134. func ByOrganizationID(opts ...sql.OrderTermOption) OrderOption {
  135. return sql.OrderByField(FieldOrganizationID, opts...).ToFunc()
  136. }
  137. // ByWxAgentCount orders the results by wx_agent count.
  138. func ByWxAgentCount(opts ...sql.OrderTermOption) OrderOption {
  139. return func(s *sql.Selector) {
  140. sqlgraph.OrderByNeighborsCount(s, newWxAgentStep(), opts...)
  141. }
  142. }
  143. // ByWxAgent orders the results by wx_agent terms.
  144. func ByWxAgent(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
  145. return func(s *sql.Selector) {
  146. sqlgraph.OrderByNeighborTerms(s, newWxAgentStep(), append([]sql.OrderTerm{term}, terms...)...)
  147. }
  148. }
  149. func newWxAgentStep() *sqlgraph.Step {
  150. return sqlgraph.NewStep(
  151. sqlgraph.From(Table, FieldID),
  152. sqlgraph.To(WxAgentInverseTable, FieldID),
  153. sqlgraph.Edge(sqlgraph.O2M, false, WxAgentTable, WxAgentColumn),
  154. )
  155. }