42 lines
949 B
Go
42 lines
949 B
Go
package schema
|
|
|
|
import (
|
|
"likedream-goframe/internal/ent/schema/mix"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/schema/edge"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// CpLeave holds the schema definition for the CpLeave entity.
|
|
type CpLeave struct {
|
|
ent.Schema
|
|
}
|
|
|
|
// Fields of the CpLeave.
|
|
func (CpLeave) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.Int64("cp_user_id"),
|
|
field.Int64("user_id"),
|
|
field.String("leave_id").NotEmpty(),
|
|
field.String("title").NotEmpty(),
|
|
field.Enum("status").Values("done", "fail"),
|
|
field.Enum("type").Values("report", "apply"),
|
|
field.Text("desc").Optional(),
|
|
}
|
|
}
|
|
|
|
// Edges of the CpTask.
|
|
func (CpLeave) Edges() []ent.Edge {
|
|
return []ent.Edge{
|
|
edge.From("cp_user", CpUser.Type).Ref("cp_leave").Field("cp_user_id").Unique().Required(),
|
|
edge.From("sys_user", SysUser.Type).Ref("cp_leave").Field("user_id").Unique().Required(),
|
|
}
|
|
}
|
|
|
|
func (CpLeave) Mixin() []ent.Mixin {
|
|
return []ent.Mixin{
|
|
mix.MixinTime{},
|
|
}
|
|
}
|