package schema import ( "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 Server struct { ent.Schema } func (Server) Fields() []ent.Field { return []ent.Field{ field.String("name"). Annotations(entsql.WithComments(true)). Comment("名称"), field.String("public_ip"). Annotations(entsql.WithComments(true)). Comment("公网ip"), field.String("private_ip"). Annotations(entsql.WithComments(true)). Comment("内网ip"), field.String("admin_port"). Annotations(entsql.WithComments(true)). Comment("管理端口")} } func (Server) Mixin() []ent.Mixin { return []ent.Mixin{ mixins.IDMixin{}, mixins.StatusMixin{}, localmixin.SoftDeleteMixin{}, } } func (Server) Indexes() []ent.Index { return []ent.Index{ index.Fields("name"), index.Fields("private_ip"), index.Fields("public_ip").Unique(), } } func (Server) Edges() []ent.Edge { return []ent.Edge{ edge.To("wxs", Wx.Type), } } func (Server) Annotations() []schema.Annotation { return []schema.Annotation{ entsql.WithComments(true), entsql.Annotation{Table: "server"}, } }