fix: api descript
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/lib/pq"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
var playerDefaultRating = decimal.RequireFromString("5.00")
|
||||
|
||||
// Players holds the schema definition for the Players entity.
|
||||
type Players struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the Players.
|
||||
func (Players) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int64("id").Immutable().Unique(),
|
||||
field.Int64("user_id").Unique(),
|
||||
field.String("status").MaxLen(20).Default("offline"),
|
||||
field.Int("gender").Unique(),
|
||||
field.Other("rating", decimal.Decimal{}).
|
||||
Optional().
|
||||
Default(playerDefaultRating).
|
||||
SchemaType(map[string]string{
|
||||
dialect.Postgres: "decimal(3,2)",
|
||||
}),
|
||||
field.Int("total_orders").Optional().Default(0),
|
||||
field.Int("completed_orders").Optional().Default(0),
|
||||
field.Int64("shop_id").Optional().Nillable(),
|
||||
field.Strings("tags").Optional().Default([]string{}),
|
||||
field.Other("games", pq.Int64Array{}).
|
||||
Optional().
|
||||
Default(pq.Int64Array{}).
|
||||
SchemaType(map[string]string{
|
||||
dialect.Postgres: "bigint[]",
|
||||
}),
|
||||
field.Time("created_at").Default(time.Now).Immutable(),
|
||||
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Players.
|
||||
func (Players) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
var (
|
||||
decFive = decimal.RequireFromString("5.00")
|
||||
)
|
||||
|
||||
// PlayerServices holds the schema definition for the PlayerServices entity.
|
||||
type PlayerServices struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Annotations of the PlayerServices.
|
||||
func (PlayerServices) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{
|
||||
entsql.Annotation{
|
||||
Table: "player_services",
|
||||
Checks: map[string]string{
|
||||
"chk_price_positive": "price > 0",
|
||||
"chk_service_rating": "rating >= 0 AND rating <= 5",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the PlayerServices.
|
||||
func (PlayerServices) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int64("id").Immutable().Unique(),
|
||||
field.Int64("player_id"),
|
||||
field.Int64("game_id"),
|
||||
field.String("title").MaxLen(200),
|
||||
field.String("description").Optional().Nillable(),
|
||||
field.Other("price", decimal.Decimal{}).
|
||||
SchemaType(map[string]string{
|
||||
dialect.Postgres: "decimal(10,2)",
|
||||
}),
|
||||
field.String("unit").MaxLen(20),
|
||||
field.String("rank_range").MaxLen(100).Optional().Nillable(),
|
||||
field.Strings("availability").Optional().Default([]string{}),
|
||||
field.Other("rating", decimal.Decimal{}).
|
||||
Default(decFive).
|
||||
SchemaType(map[string]string{
|
||||
dialect.Postgres: "decimal(3,2)",
|
||||
}),
|
||||
field.Bool("is_active").Optional().Default(true),
|
||||
field.Time("created_at").Default(time.Now).Immutable(),
|
||||
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the PlayerServices.
|
||||
func (PlayerServices) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user