work_experience.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package schema
  2. import (
  3. "entgo.io/ent/schema/edge"
  4. "entgo.io/ent/schema/index"
  5. "wechat-api/ent/schema/localmixin"
  6. "entgo.io/ent"
  7. "entgo.io/ent/dialect/entsql"
  8. "entgo.io/ent/schema"
  9. "entgo.io/ent/schema/field"
  10. "github.com/suyuan32/simple-admin-common/orm/ent/mixins"
  11. )
  12. type WorkExperience struct {
  13. ent.Schema
  14. }
  15. func (WorkExperience) Fields() []ent.Field {
  16. return []ent.Field{
  17. field.Uint64("employee_id").Comment("employee_id | 员工ID"),
  18. field.Time("start_date").Comment("start_date | 开始时间"),
  19. field.Time("end_date").Comment("end_date | 结束时间"),
  20. field.String("company").Comment("company | 公司名"),
  21. field.Text("experience").Comment("experience | 工作内容"),
  22. field.Uint64("organization_id").Comment("organization_id | 租户ID"),
  23. }
  24. }
  25. func (WorkExperience) Mixin() []ent.Mixin {
  26. return []ent.Mixin{
  27. mixins.IDMixin{},
  28. localmixin.SoftDeleteMixin{},
  29. }
  30. }
  31. func (WorkExperience) Edges() []ent.Edge {
  32. return []ent.Edge{
  33. edge.From("employee", Employee.Type).
  34. Ref("em_work_experiences").
  35. Field("employee_id").
  36. Unique().
  37. Required(),
  38. }
  39. }
  40. func (WorkExperience) Indexes() []ent.Index {
  41. return []ent.Index{
  42. index.Fields("employee_id"),
  43. }
  44. }
  45. func (WorkExperience) Annotations() []schema.Annotation {
  46. return []schema.Annotation{
  47. entsql.WithComments(true),
  48. entsql.Annotation{Table: "work_experience"},
  49. }
  50. }