sop_node.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. "entgo.io/ent/schema/index"
  9. "github.com/suyuan32/simple-admin-common/orm/ent/mixins"
  10. "github.com/suyuan32/simple-admin-job/ent/custom_types"
  11. )
  12. type SopNode struct {
  13. ent.Schema
  14. }
  15. func (SopNode) Fields() []ent.Field {
  16. return []ent.Field{
  17. field.Uint64("stage_id").
  18. Annotations(entsql.WithComments(true)).
  19. Comment("阶段 ID"),
  20. field.Uint64("parent_id").
  21. Annotations(entsql.WithComments(true)).
  22. Comment("父节点 ID"),
  23. field.String("name").Default("").
  24. Annotations(entsql.WithComments(true)).
  25. Comment("节点名称"),
  26. field.Int("condition_type").Default(1).
  27. Annotations(entsql.WithComments(true)).
  28. Comment("触发条件类型 1 客户回复后触发 2 超时后触发"),
  29. field.JSON("condition_list", []string{}).Optional().
  30. Annotations(entsql.WithComments(true)).
  31. Comment("触发语义列表 当为空时则代表用户回复任意内容后触发"),
  32. field.Uint64("no_reply_condition").Default(0).
  33. Annotations(entsql.WithComments(true)).
  34. Comment("超时触发时间(分钟)"),
  35. field.JSON("action_message", []custom_types.Action{}).Optional().
  36. Annotations(entsql.WithComments(true)).
  37. Comment("命中后发送的消息内容"),
  38. field.JSON("action_label", []uint64{}).Optional().
  39. Annotations(entsql.WithComments(true)).
  40. Comment("命中后需要打的标签"),
  41. field.Time("deleted_at").
  42. Optional().
  43. Comment("Delete Time | 删除日期").
  44. Annotations(entsql.WithComments(true)),
  45. }
  46. }
  47. func (SopNode) Mixin() []ent.Mixin {
  48. return []ent.Mixin{
  49. mixins.IDMixin{},
  50. mixins.StatusMixin{},
  51. }
  52. }
  53. func (SopNode) Indexes() []ent.Index {
  54. return []ent.Index{
  55. index.Fields("name"),
  56. }
  57. }
  58. func (SopNode) Edges() []ent.Edge {
  59. return []ent.Edge{
  60. edge.From("sop_stage", SopStage.Type).
  61. Ref("stage_nodes").
  62. Unique().
  63. Field("stage_id").
  64. Required(),
  65. edge.To("node_messages", MessageRecords.Type),
  66. }
  67. }
  68. func (SopNode) Annotations() []schema.Annotation {
  69. return []schema.Annotation{entsql.Annotation{Table: "sop_node"}}
  70. }