agent.go 11 KB

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