task_log.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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/edge"
  7. "entgo.io/ent/schema/field"
  8. "time"
  9. )
  10. // TaskLog holds the schema definition for the TaskLog entity.
  11. type TaskLog struct {
  12. ent.Schema
  13. }
  14. // Fields of the TaskLog.
  15. func (TaskLog) Fields() []ent.Field {
  16. return []ent.Field{
  17. field.Uint64("id"),
  18. field.Time("started_at").Immutable().
  19. Default(time.Now).
  20. Comment("Task Started Time | 任务启动时间").
  21. Annotations(entsql.WithComments(true)),
  22. field.Time("finished_at").Comment("Task Finished Time | 任务完成时间").
  23. Annotations(entsql.WithComments(true)),
  24. field.Uint8("result").Comment("The Task Process Result | 任务执行结果").
  25. Annotations(entsql.WithComments(true)),
  26. }
  27. }
  28. // Edges of the TaskLog.
  29. func (TaskLog) Edges() []ent.Edge {
  30. return []ent.Edge{
  31. edge.From("tasks", Task.Type).Ref("task_logs").Unique(),
  32. }
  33. }
  34. func (TaskLog) Annotations() []schema.Annotation {
  35. return []schema.Annotation{
  36. entsql.Annotation{Table: "sys_task_logs"},
  37. }
  38. }