12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- package schema
- import (
- "wechat-api/ent/custom_types"
- "wechat-api/ent/schema/localmixin"
- "entgo.io/ent"
- "entgo.io/ent/dialect/entsql"
- "entgo.io/ent/schema"
- "entgo.io/ent/schema/edge"
- "entgo.io/ent/schema/field"
- "entgo.io/ent/schema/index"
- "github.com/suyuan32/simple-admin-common/orm/ent/mixins"
- )
- type SopNode struct {
- ent.Schema
- }
- func (SopNode) Fields() []ent.Field {
- return []ent.Field{
- field.Uint64("stage_id").
- Annotations(entsql.WithComments(true)).
- Comment("阶段 ID"),
- field.Uint64("parent_id").
- Annotations(entsql.WithComments(true)).
- Comment("父节点 ID"),
- field.String("name").Default("").
- Annotations(entsql.WithComments(true)).
- Comment("节点名称"),
- field.Int("condition_type").Default(1).
- Annotations(entsql.WithComments(true)).
- Comment("触发条件类型 1 客户回复后触发 2 超时后触发"),
- field.JSON("condition_list", []string{}).Optional().
- Annotations(entsql.WithComments(true)).
- Comment("触发语义列表 当为空时则代表用户回复任意内容后触发"),
- field.Uint64("no_reply_condition").Default(0).
- Annotations(entsql.WithComments(true)).
- Comment("超时触发时间(分钟)"),
- field.String("no_reply_unit").Default("").
- Annotations(entsql.WithComments(true)).
- Comment("超时触发时间单位"),
- field.JSON("action_message", []custom_types.Action{}).Optional().
- Annotations(entsql.WithComments(true)).
- Comment("命中后发送的消息内容"),
- field.JSON("action_label_add", []uint64{}).Optional().
- Annotations(entsql.WithComments(true)).
- Comment("命中后需要打的标签"),
- field.JSON("action_label_del", []uint64{}).Optional().
- Annotations(entsql.WithComments(true)).
- Comment("命中后需要移除的标签"),
- field.JSON("action_forward", &custom_types.ActionForward{}).Optional().
- Annotations(entsql.WithComments(true)).
- Comment("命中后转发的消息"),
- }
- }
- func (SopNode) Mixin() []ent.Mixin {
- return []ent.Mixin{
- mixins.IDMixin{},
- mixins.StatusMixin{},
- localmixin.SoftDeleteMixin{},
- }
- }
- func (SopNode) Indexes() []ent.Index {
- return []ent.Index{
- index.Fields("name"),
- }
- }
- func (SopNode) Edges() []ent.Edge {
- return []ent.Edge{
- edge.From("sop_stage", SopStage.Type).
- Ref("stage_nodes").
- Unique().
- Field("stage_id").
- Required(),
- edge.To("node_messages", MessageRecords.Type),
- }
- }
- func (SopNode) Annotations() []schema.Annotation {
- return []schema.Annotation{
- entsql.WithComments(true),
- entsql.Annotation{Table: "sop_node"},
- }
- }
|