agent.go 12 KB

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