agent.go 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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. // FieldDatasetID holds the string denoting the dataset_id field in the database.
  33. FieldDatasetID = "dataset_id"
  34. // FieldCollectionID holds the string denoting the collection_id field in the database.
  35. FieldCollectionID = "collection_id"
  36. // EdgeWxAgent holds the string denoting the wx_agent edge name in mutations.
  37. EdgeWxAgent = "wx_agent"
  38. // EdgeTokenAgent holds the string denoting the token_agent edge name in mutations.
  39. EdgeTokenAgent = "token_agent"
  40. // Table holds the table name of the agent in the database.
  41. Table = "agent"
  42. // WxAgentTable is the table that holds the wx_agent relation/edge.
  43. WxAgentTable = "wx"
  44. // WxAgentInverseTable is the table name for the Wx entity.
  45. // It exists in this package in order to avoid circular dependency with the "wx" package.
  46. WxAgentInverseTable = "wx"
  47. // WxAgentColumn is the table column denoting the wx_agent relation/edge.
  48. WxAgentColumn = "agent_id"
  49. // TokenAgentTable is the table that holds the token_agent relation/edge.
  50. TokenAgentTable = "token"
  51. // TokenAgentInverseTable is the table name for the Token entity.
  52. // It exists in this package in order to avoid circular dependency with the "token" package.
  53. TokenAgentInverseTable = "token"
  54. // TokenAgentColumn is the table column denoting the token_agent relation/edge.
  55. TokenAgentColumn = "agent_id"
  56. )
  57. // Columns holds all SQL columns for agent fields.
  58. var Columns = []string{
  59. FieldID,
  60. FieldCreatedAt,
  61. FieldUpdatedAt,
  62. FieldDeletedAt,
  63. FieldName,
  64. FieldRole,
  65. FieldStatus,
  66. FieldBackground,
  67. FieldExamples,
  68. FieldOrganizationID,
  69. FieldDatasetID,
  70. FieldCollectionID,
  71. }
  72. // ValidColumn reports if the column name is valid (part of the table columns).
  73. func ValidColumn(column string) bool {
  74. for i := range Columns {
  75. if column == Columns[i] {
  76. return true
  77. }
  78. }
  79. return false
  80. }
  81. // Note that the variables below are initialized by the runtime
  82. // package on the initialization of the application. Therefore,
  83. // it should be imported in the main as follows:
  84. //
  85. // import _ "wechat-api/ent/runtime"
  86. var (
  87. Hooks [1]ent.Hook
  88. Interceptors [1]ent.Interceptor
  89. // DefaultCreatedAt holds the default value on creation for the "created_at" field.
  90. DefaultCreatedAt func() time.Time
  91. // DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
  92. DefaultUpdatedAt func() time.Time
  93. // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
  94. UpdateDefaultUpdatedAt func() time.Time
  95. // NameValidator is a validator for the "name" field. It is called by the builders before save.
  96. NameValidator func(string) error
  97. // DefaultStatus holds the default value on creation for the "status" field.
  98. DefaultStatus int
  99. // StatusValidator is a validator for the "status" field. It is called by the builders before save.
  100. StatusValidator func(int) error
  101. // DefaultBackground holds the default value on creation for the "background" field.
  102. DefaultBackground string
  103. // DefaultExamples holds the default value on creation for the "examples" field.
  104. DefaultExamples string
  105. // OrganizationIDValidator is a validator for the "organization_id" field. It is called by the builders before save.
  106. OrganizationIDValidator func(uint64) error
  107. // DefaultDatasetID holds the default value on creation for the "dataset_id" field.
  108. DefaultDatasetID string
  109. // DatasetIDValidator is a validator for the "dataset_id" field. It is called by the builders before save.
  110. DatasetIDValidator func(string) error
  111. // DefaultCollectionID holds the default value on creation for the "collection_id" field.
  112. DefaultCollectionID string
  113. // CollectionIDValidator is a validator for the "collection_id" field. It is called by the builders before save.
  114. CollectionIDValidator func(string) error
  115. )
  116. // OrderOption defines the ordering options for the Agent queries.
  117. type OrderOption func(*sql.Selector)
  118. // ByID orders the results by the id field.
  119. func ByID(opts ...sql.OrderTermOption) OrderOption {
  120. return sql.OrderByField(FieldID, opts...).ToFunc()
  121. }
  122. // ByCreatedAt orders the results by the created_at field.
  123. func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
  124. return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
  125. }
  126. // ByUpdatedAt orders the results by the updated_at field.
  127. func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
  128. return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
  129. }
  130. // ByDeletedAt orders the results by the deleted_at field.
  131. func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
  132. return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
  133. }
  134. // ByName orders the results by the name field.
  135. func ByName(opts ...sql.OrderTermOption) OrderOption {
  136. return sql.OrderByField(FieldName, opts...).ToFunc()
  137. }
  138. // ByRole orders the results by the role field.
  139. func ByRole(opts ...sql.OrderTermOption) OrderOption {
  140. return sql.OrderByField(FieldRole, opts...).ToFunc()
  141. }
  142. // ByStatus orders the results by the status field.
  143. func ByStatus(opts ...sql.OrderTermOption) OrderOption {
  144. return sql.OrderByField(FieldStatus, opts...).ToFunc()
  145. }
  146. // ByBackground orders the results by the background field.
  147. func ByBackground(opts ...sql.OrderTermOption) OrderOption {
  148. return sql.OrderByField(FieldBackground, opts...).ToFunc()
  149. }
  150. // ByExamples orders the results by the examples field.
  151. func ByExamples(opts ...sql.OrderTermOption) OrderOption {
  152. return sql.OrderByField(FieldExamples, opts...).ToFunc()
  153. }
  154. // ByOrganizationID orders the results by the organization_id field.
  155. func ByOrganizationID(opts ...sql.OrderTermOption) OrderOption {
  156. return sql.OrderByField(FieldOrganizationID, opts...).ToFunc()
  157. }
  158. // ByDatasetID orders the results by the dataset_id field.
  159. func ByDatasetID(opts ...sql.OrderTermOption) OrderOption {
  160. return sql.OrderByField(FieldDatasetID, opts...).ToFunc()
  161. }
  162. // ByCollectionID orders the results by the collection_id field.
  163. func ByCollectionID(opts ...sql.OrderTermOption) OrderOption {
  164. return sql.OrderByField(FieldCollectionID, opts...).ToFunc()
  165. }
  166. // ByWxAgentCount orders the results by wx_agent count.
  167. func ByWxAgentCount(opts ...sql.OrderTermOption) OrderOption {
  168. return func(s *sql.Selector) {
  169. sqlgraph.OrderByNeighborsCount(s, newWxAgentStep(), opts...)
  170. }
  171. }
  172. // ByWxAgent orders the results by wx_agent terms.
  173. func ByWxAgent(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
  174. return func(s *sql.Selector) {
  175. sqlgraph.OrderByNeighborTerms(s, newWxAgentStep(), append([]sql.OrderTerm{term}, terms...)...)
  176. }
  177. }
  178. // ByTokenAgentCount orders the results by token_agent count.
  179. func ByTokenAgentCount(opts ...sql.OrderTermOption) OrderOption {
  180. return func(s *sql.Selector) {
  181. sqlgraph.OrderByNeighborsCount(s, newTokenAgentStep(), opts...)
  182. }
  183. }
  184. // ByTokenAgent orders the results by token_agent terms.
  185. func ByTokenAgent(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
  186. return func(s *sql.Selector) {
  187. sqlgraph.OrderByNeighborTerms(s, newTokenAgentStep(), append([]sql.OrderTerm{term}, terms...)...)
  188. }
  189. }
  190. func newWxAgentStep() *sqlgraph.Step {
  191. return sqlgraph.NewStep(
  192. sqlgraph.From(Table, FieldID),
  193. sqlgraph.To(WxAgentInverseTable, FieldID),
  194. sqlgraph.Edge(sqlgraph.O2M, false, WxAgentTable, WxAgentColumn),
  195. )
  196. }
  197. func newTokenAgentStep() *sqlgraph.Step {
  198. return sqlgraph.NewStep(
  199. sqlgraph.From(Table, FieldID),
  200. sqlgraph.To(TokenAgentInverseTable, FieldID),
  201. sqlgraph.Edge(sqlgraph.O2M, false, TokenAgentTable, TokenAgentColumn),
  202. )
  203. }