compapi_asynctask.go 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package schema
  2. import (
  3. "entgo.io/ent"
  4. "entgo.io/ent/dialect/entsql"
  5. "entgo.io/ent/schema"
  6. "entgo.io/ent/schema/field"
  7. "entgo.io/ent/schema/index"
  8. "github.com/suyuan32/simple-admin-common/orm/ent/mixins"
  9. )
  10. // CompapiJob holds the schema definition for the CompapiJob entity.
  11. type CompapiAsynctask struct {
  12. ent.Schema
  13. }
  14. // Fields of the CompapiJob.
  15. func (CompapiAsynctask) Fields() []ent.Field {
  16. return []ent.Field{
  17. field.String("auth_token").Annotations(entsql.WithComments(true)).Comment("发起请求者的授权token"),
  18. field.String("event_type").Default("fastgpt").Annotations(entsql.WithComments(true)).Comment("请求目标类型"),
  19. field.String("chat_id").Optional().Default("").Annotations(entsql.WithComments(true)).Comment("会话ID"),
  20. field.Int8("workid_idx").Optional().Default(0).Annotations(entsql.WithComments(true)).Comment("workId在字典中的索引值"),
  21. field.String("openai_base").Annotations(entsql.WithComments(true)).Comment("待请求的大模型服务地址"),
  22. field.String("openai_key").Annotations(entsql.WithComments(true)).Comment("待请求的大模型服务密钥授权token"),
  23. field.String("request_raw").Annotations(entsql.WithComments(true)).Comment("请求参数结构字符串"),
  24. field.String("response_raw").Optional().Default("").Annotations(entsql.WithComments(true)).Comment("请求响应结构字符串"),
  25. field.String("callback_url").MaxLen(255).Annotations(entsql.WithComments(true)).Comment("异步执行回调地址"),
  26. //field.Int8("dist_status").Optional().Default(0).Annotations(entsql.WithComments(true)).Comment("dist status | 分发状态 0 未 1 已"),
  27. //field.Time("dist_at").Optional().Annotations(entsql.WithComments(true)).Comment("Dist Time | 分发时间"),
  28. field.Int8("task_status").Optional().Default(10).Annotations(entsql.WithComments(true)).Comment("callback_status | 任务完成状态 10 任务就绪 20 请求API完成 30 请求回调完成 60 任务暂停 70 任务失败"),
  29. field.Int8("retry_count").Optional().Default(0).Annotations(entsql.WithComments(true)).Comment("retry count | 重试次数"),
  30. field.String("last_error").Optional().Default("").Annotations(entsql.WithComments(true)).Comment("最后一次出错信息"),
  31. }
  32. }
  33. func (CompapiAsynctask) Mixin() []ent.Mixin {
  34. return []ent.Mixin{
  35. mixins.IDMixin{},
  36. }
  37. }
  38. func (CompapiAsynctask) Indexes() []ent.Index {
  39. return []ent.Index{
  40. //index.Fields("dist_status"),
  41. index.Fields("task_status"),
  42. }
  43. }
  44. func (CompapiAsynctask) Edges() []ent.Edge { return []ent.Edge{} }
  45. func (CompapiAsynctask) Annotations() []schema.Annotation {
  46. return []schema.Annotation{
  47. entsql.WithComments(true),
  48. entsql.Annotation{Table: "compapi_asynctask"},
  49. }
  50. }