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,64 @@
// Code generated by ent, DO NOT EDIT.
package migrate
import (
"context"
"fmt"
"io"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql/schema"
)
var (
// WithGlobalUniqueID sets the universal ids options to the migration.
// If this option is enabled, ent migration will allocate a 1<<32 range
// for the ids of each entity (table).
// Note that this option cannot be applied on tables that already exist.
WithGlobalUniqueID = schema.WithGlobalUniqueID
// WithDropColumn sets the drop column option to the migration.
// If this option is enabled, ent migration will drop old columns
// that were used for both fields and edges. This defaults to false.
WithDropColumn = schema.WithDropColumn
// WithDropIndex sets the drop index option to the migration.
// If this option is enabled, ent migration will drop old indexes
// that were defined in the schema. This defaults to false.
// Note that unique constraints are defined using `UNIQUE INDEX`,
// and therefore, it's recommended to enable this option to get more
// flexibility in the schema changes.
WithDropIndex = schema.WithDropIndex
// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true.
WithForeignKeys = schema.WithForeignKeys
)
// Schema is the API for creating, migrating and dropping a schema.
type Schema struct {
drv dialect.Driver
}
// NewSchema creates a new schema client.
func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }
// Create creates all schema resources.
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
return Create(ctx, s, Tables, opts...)
}
// Create creates all table resources using the given schema driver.
func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error {
migrate, err := schema.NewMigrate(s.drv, opts...)
if err != nil {
return fmt.Errorf("ent/migrate: %w", err)
}
return migrate.Create(ctx, tables...)
}
// WriteTo writes the schema changes to w instead of running them against the database.
//
// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
// log.Fatal(err)
// }
func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error {
return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...)
}
@@ -0,0 +1,131 @@
// Code generated by ent, DO NOT EDIT.
package migrate
import (
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/dialect/sql/schema"
"entgo.io/ent/schema/field"
)
var (
// ShopInvitationsColumns holds the columns for the "shop_invitations" table.
ShopInvitationsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
{Name: "shop_id", Type: field.TypeInt64},
{Name: "player_id", Type: field.TypeInt64},
{Name: "status", Type: field.TypeString, Size: 20, Default: "pending"},
{Name: "invited_by", Type: field.TypeInt64},
{Name: "created_at", Type: field.TypeTime},
{Name: "responded_at", Type: field.TypeTime, Nullable: true},
}
// ShopInvitationsTable holds the schema information for the "shop_invitations" table.
ShopInvitationsTable = &schema.Table{
Name: "shop_invitations",
Columns: ShopInvitationsColumns,
PrimaryKey: []*schema.Column{ShopInvitationsColumns[0]},
Indexes: []*schema.Index{
{
Name: "shopinvitations_shop_id",
Unique: false,
Columns: []*schema.Column{ShopInvitationsColumns[1]},
},
{
Name: "shopinvitations_player_id",
Unique: false,
Columns: []*schema.Column{ShopInvitationsColumns[2]},
},
{
Name: "shopinvitations_player_id_status_created_at",
Unique: false,
Columns: []*schema.Column{ShopInvitationsColumns[2], ShopInvitationsColumns[3], ShopInvitationsColumns[5]},
},
{
Name: "shopinvitations_shop_id_status_created_at",
Unique: false,
Columns: []*schema.Column{ShopInvitationsColumns[1], ShopInvitationsColumns[3], ShopInvitationsColumns[5]},
},
},
}
// ShopPlayersColumns holds the columns for the "shop_players" table.
ShopPlayersColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
{Name: "shop_id", Type: field.TypeInt64},
{Name: "player_id", Type: field.TypeInt64},
{Name: "is_primary", Type: field.TypeBool, Nullable: true, Default: false},
{Name: "joined_at", Type: field.TypeTime},
{Name: "left_at", Type: field.TypeTime, Nullable: true},
}
// ShopPlayersTable holds the schema information for the "shop_players" table.
ShopPlayersTable = &schema.Table{
Name: "shop_players",
Columns: ShopPlayersColumns,
PrimaryKey: []*schema.Column{ShopPlayersColumns[0]},
Indexes: []*schema.Index{
{
Name: "shopplayers_shop_id_player_id",
Unique: true,
Columns: []*schema.Column{ShopPlayersColumns[1], ShopPlayersColumns[2]},
},
{
Name: "shopplayers_player_id",
Unique: false,
Columns: []*schema.Column{ShopPlayersColumns[2]},
},
{
Name: "shopplayers_shop_id_joined_at",
Unique: false,
Columns: []*schema.Column{ShopPlayersColumns[1], ShopPlayersColumns[4]},
},
},
}
// ShopsColumns holds the columns for the "shops" table.
ShopsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
{Name: "owner_id", Type: field.TypeInt64, Unique: true},
{Name: "name", Type: field.TypeString, Size: 200},
{Name: "banner", Type: field.TypeString, Nullable: true},
{Name: "description", Type: field.TypeString, Nullable: true},
{Name: "rating", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "decimal(3,2)"}},
{Name: "total_orders", Type: field.TypeInt, Nullable: true, Default: 0},
{Name: "player_count", Type: field.TypeInt, Nullable: true, Default: 0},
{Name: "commission_type", Type: field.TypeString, Size: 20, Default: "percentage"},
{Name: "commission_value", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "decimal(10,2)"}},
{Name: "allow_multi_shop", Type: field.TypeBool, Nullable: true, Default: false},
{Name: "allow_independent_orders", Type: field.TypeBool, Nullable: true, Default: true},
{Name: "dispatch_mode", Type: field.TypeString, Size: 20, Default: "manual"},
{Name: "announcements", Type: field.TypeJSON, Nullable: true},
{Name: "template_config", Type: field.TypeJSON, Nullable: true},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
}
// ShopsTable holds the schema information for the "shops" table.
ShopsTable = &schema.Table{
Name: "shops",
Columns: ShopsColumns,
PrimaryKey: []*schema.Column{ShopsColumns[0]},
}
// Tables holds all the tables in the schema.
Tables = []*schema.Table{
ShopInvitationsTable,
ShopPlayersTable,
ShopsTable,
}
)
func init() {
ShopInvitationsTable.Annotation = &entsql.Annotation{
Table: "shop_invitations",
}
ShopInvitationsTable.Annotation.Checks = map[string]string{
"chk_invitation_status": "status IN ('pending', 'accepted', 'rejected', 'cancelled')",
}
ShopsTable.Annotation = &entsql.Annotation{
Table: "shops",
}
ShopsTable.Annotation.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",
}
}