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.
30 lines
665 B
Go
30 lines
665 B
Go
1 year 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 | 状态"),
|
||
|
}
|
||
|
}
|