agent.go 13 KB

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