agent.go 14 KB

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