You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ntool-biz/core/orm/nent/mixins/status.go

30 lines
665 B
Go

2 years ago
package mixins
import (
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/mixin"
"git.noahlan.cn/noahlan/ntool-biz/core/orm/nent/types"
)
// StatusMixin implements the ent.Mixin for sharing
// status fields with package schemas.
type StatusMixin struct {
// We embed the `mixin.Schema` to avoid
// implementing the rest of the methods.
mixin.Schema
}
func (StatusMixin) Fields() []ent.Field {
return []ent.Field{
field.Enum("status").
Default(string(types.StatusNormal)).
SchemaType(map[string]string{
dialect.MySQL: "varchar(32)",
}).
GoType(types.Status("")).
Comment("Status | 状态"),
}
}