agent.go 9.7 KB

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