employee.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 Employee struct {
  13. ent.Schema
  14. }
  15. func (Employee) Fields() []ent.Field {
  16. return []ent.Field{
  17. field.String("title").MaxLen(255).Comment("title | 标题"),
  18. field.String("avatar").MaxLen(1000).Comment("avatar | 头像"),
  19. field.String("tags").MaxLen(255).Comment("tags | 个人标签"),
  20. field.Int("hire_count").Positive().Default(0).Comment("hire_count | 被雇佣次数"),
  21. field.Int("service_count").Positive().Default(0).Comment("service_count | 已服务次数"),
  22. field.Int("achievement_count").Positive().Default(0).Comment("achievement_count | 业绩单数"),
  23. field.String("intro").MaxLen(1000).Default("").Comment("intro | 个人介绍"),
  24. field.String("estimate").MaxLen(1000).Default("").Comment("estimate | 自我评价"),
  25. field.String("skill").MaxLen(1000).Default("").Comment("skill | 技能卡"),
  26. field.String("ability_type").Default("").Comment("ability_type | 能力类型"),
  27. field.String("scene").Default("").Comment("scene | 使用场景"),
  28. field.String("switch_in").Default("").Comment("switch_in | 支持介入"),
  29. field.String("video_url").MaxLen(1000).Default("").Comment("video_url | 视频地址"),
  30. field.Uint64("organization_id").Positive().Comment("organization_id | 租户ID"),
  31. field.Uint64("category_id").Positive().Comment("category_id | 分类ID"),
  32. field.String("api_base").Default("").Comment("api_base"),
  33. field.String("api_key").Default("").Comment("api_key"),
  34. field.String("ai_info").Optional().Comment("AI信息"),
  35. field.Int("is_vip").Default(0).Comment("是否VIP:0-否 1-是"),
  36. }
  37. }
  38. func (Employee) Mixin() []ent.Mixin {
  39. return []ent.Mixin{
  40. mixins.IDMixin{},
  41. localmixin.SoftDeleteMixin{},
  42. }
  43. }
  44. func (Employee) Edges() []ent.Edge {
  45. return []ent.Edge{
  46. edge.To("em_work_experiences", WorkExperience.Type),
  47. edge.To("em_tutorial", Tutorial.Type),
  48. }
  49. }
  50. func (Employee) Indexes() []ent.Index {
  51. return []ent.Index{
  52. index.Fields("organization_id"),
  53. }
  54. }
  55. func (Employee) Annotations() []schema.Annotation {
  56. return []schema.Annotation{
  57. entsql.WithComments(true),
  58. entsql.Annotation{Table: "employee"},
  59. }
  60. }