agent.go 13 KB

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