label_log.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. type LabelLog struct {
  11. ent.Schema
  12. }
  13. func (LabelLog) Fields() []ent.Field {
  14. return []ent.Field{
  15. field.String("label_name").Default("").Annotations(entsql.WithComments(true)).Comment("标签名称"),
  16. field.Int("label_id").Default(0).Annotations(entsql.WithComments(true)).Comment("三方平台标签id"),
  17. field.String("wx_id").Default("").Annotations(entsql.WithComments(true)).Comment("微信ID"),
  18. field.Uint64("organization_id").Optional().Default(1).Comment("机构 ID").Annotations(entsql.WithComments(true)),
  19. }
  20. }
  21. func (LabelLog) Mixin() []ent.Mixin {
  22. return []ent.Mixin{
  23. mixins.IDMixin{},
  24. }
  25. }
  26. func (LabelLog) Indexes() []ent.Index {
  27. return []ent.Index{
  28. index.Fields("label_id", "wx_id", "organization_id").Unique().StorageKey("idx_org_label"),
  29. }
  30. }
  31. func (LabelLog) Edges() []ent.Edge {
  32. return []ent.Edge{}
  33. }
  34. func (LabelLog) Annotations() []schema.Annotation {
  35. return []schema.Annotation{
  36. entsql.WithComments(true),
  37. entsql.Annotation{Table: "label_log"},
  38. }
  39. }