fix: api descript

This commit is contained in:
wwweww
2026-02-28 05:33:16 +08:00
parent 5930fb0dde
commit d2f33b4b96
243 changed files with 37065 additions and 780 deletions
@@ -0,0 +1,56 @@
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// ShopInvitations holds the schema definition for the ShopInvitations entity.
type ShopInvitations struct {
ent.Schema
}
// Annotations of the ShopInvitations.
func (ShopInvitations) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{
Table: "shop_invitations",
Checks: map[string]string{
"chk_invitation_status": "status IN ('pending', 'accepted', 'rejected', 'cancelled')",
},
},
}
}
// Fields of the ShopInvitations.
func (ShopInvitations) Fields() []ent.Field {
return []ent.Field{
field.Int64("id").Immutable().Unique(),
field.Int64("shop_id"),
field.Int64("player_id"),
field.String("status").MaxLen(20).Default("pending"),
field.Int64("invited_by"),
field.Time("created_at").Default(time.Now).Immutable(),
field.Time("responded_at").Optional().Nillable(),
}
}
// Indexes of the ShopInvitations.
func (ShopInvitations) Indexes() []ent.Index {
return []ent.Index{
index.Fields("shop_id"),
index.Fields("player_id"),
index.Fields("player_id", "status", "created_at"),
index.Fields("shop_id", "status", "created_at"),
}
}
// Edges of the ShopInvitations.
func (ShopInvitations) Edges() []ent.Edge {
return nil
}
@@ -0,0 +1,40 @@
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// ShopPlayers holds the schema definition for the ShopPlayers entity.
type ShopPlayers struct {
ent.Schema
}
// Fields of the ShopPlayers.
func (ShopPlayers) Fields() []ent.Field {
return []ent.Field{
field.Int64("id").Immutable().Unique(),
field.Int64("shop_id"),
field.Int64("player_id"),
field.Bool("is_primary").Optional().Default(false),
field.Time("joined_at").Default(time.Now).Immutable(),
field.Time("left_at").Optional().Nillable(),
}
}
// Indexes of the ShopPlayers.
func (ShopPlayers) Indexes() []ent.Index {
return []ent.Index{
index.Fields("shop_id", "player_id").Unique(),
index.Fields("player_id"),
index.Fields("shop_id", "joined_at"),
}
}
// Edges of the ShopPlayers.
func (ShopPlayers) Edges() []ent.Edge {
return nil
}
@@ -0,0 +1,69 @@
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 shopDefaultRating = decimal.RequireFromString("5.00")
// Shops holds the schema definition for the Shops entity.
type Shops struct {
ent.Schema
}
// Annotations of the Shops.
func (Shops) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{
Table: "shops",
Checks: map[string]string{
"chk_commission_type": "commission_type IN ('fixed', 'percentage')",
"chk_dispatch_mode": "dispatch_mode IN ('manual', 'auto')",
"chk_rating_range": "rating >= 0 AND rating <= 5",
},
},
}
}
// Fields of the Shops.
func (Shops) Fields() []ent.Field {
return []ent.Field{
field.Int64("id").Immutable().Unique(),
field.Int64("owner_id").Unique(),
field.String("name").MaxLen(200),
field.String("banner").Optional().Nillable(),
field.String("description").Optional().Nillable(),
field.Other("rating", decimal.Decimal{}).
Optional().
Default(shopDefaultRating).
SchemaType(map[string]string{
dialect.Postgres: "decimal(3,2)",
}),
field.Int("total_orders").Optional().Default(0),
field.Int("player_count").Optional().Default(0),
field.String("commission_type").MaxLen(20).Default("percentage"),
field.Other("commission_value", decimal.Decimal{}).
SchemaType(map[string]string{
dialect.Postgres: "decimal(10,2)",
}),
field.Bool("allow_multi_shop").Optional().Default(false),
field.Bool("allow_independent_orders").Optional().Default(true),
field.String("dispatch_mode").MaxLen(20).Default("manual"),
field.Strings("announcements").Optional().Default([]string{}),
field.JSON("template_config", map[string]any{}).Optional(),
field.Time("created_at").Default(time.Now).Immutable(),
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now),
}
}
// Edges of the Shops.
func (Shops) Edges() []ent.Edge {
return nil
}