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
-49
View File
@@ -1,49 +0,0 @@
CREATE TABLE player_services (
id BIGINT PRIMARY KEY,
player_id BIGINT NOT NULL REFERENCES players(id),
game_id BIGINT NOT NULL,
title VARCHAR(200) NOT NULL,
description TEXT,
price DECIMAL(10,2) NOT NULL,
unit VARCHAR(20) NOT NULL,
rank_range VARCHAR(100),
availability TEXT[] DEFAULT ARRAY[]::TEXT[],
rating DECIMAL(3,2) DEFAULT 5.00,
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT chk_price_positive CHECK (price > 0),
CONSTRAINT chk_service_rating CHECK (rating >= 0 AND rating <= 5)
);
-- 基础索引
CREATE INDEX idx_services_player ON player_services(player_id) WHERE is_active = TRUE;
CREATE INDEX idx_services_game ON player_services(game_id) WHERE is_active = TRUE;
CREATE INDEX idx_services_price ON player_services(price);
-- 三元组索引用于服务标题模糊搜索
CREATE INDEX idx_services_title_trgm ON player_services USING gin(title gin_trgm_ops)
WHERE is_active = TRUE;
-- 全文搜索索引
CREATE INDEX idx_services_fulltext ON player_services USING gin(
to_tsvector('simple', title || ' ' || coalesce(description, ''))
) WHERE is_active = TRUE;
-- 复合索引优化价格区间查询
CREATE INDEX idx_services_game_price ON player_services(game_id, price, rating DESC)
WHERE is_active = TRUE;
-- 打手+游戏复合索引
CREATE INDEX idx_services_player_game ON player_services(player_id, game_id)
WHERE is_active = TRUE;
-- GIN 索引优化时间段查询
CREATE INDEX idx_services_availability ON player_services USING gin(availability)
WHERE is_active = TRUE;
CREATE TRIGGER trigger_services_updated_at
BEFORE UPDATE ON player_services
FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();
-40
View File
@@ -1,40 +0,0 @@
CREATE TABLE players
(
id BIGINT PRIMARY KEY,
CREATE TABLE players (
id BIGINT PRIMARY KEY,
user_id BIGINT NOT NULL UNIQUE,
status VARCHAR(20) NOT NULL DEFAULT 'offline',
rating DECIMAL(3,2) DEFAULT 5.00,
total_orders INT DEFAULT 0,
completed_orders INT DEFAULT 0,
-- [注意] 此字段为冗余缓存,通过消息队列与 shop_players 表保持一致
shop_id BIGINT,
tags TEXT[] DEFAULT ARRAY[]::TEXT[],
games BIGINT[] DEFAULT ARRAY[]::BIGINT[],
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
-- 基础索引
CREATE INDEX idx_players_user ON players (user_id);
CREATE INDEX idx_players_shop ON players (shop_id) WHERE shop_id IS NOT NULL;
CREATE INDEX idx_players_status ON players (status);
CREATE INDEX idx_players_rating ON players (rating DESC);
-- 复合索引优化多条件筛选
CREATE INDEX idx_players_status_rating ON players (status, rating DESC) WHERE status IN ('available', 'busy');
-- GIN 索引优化数组查询
CREATE INDEX idx_players_games_gin ON players USING gin(games);
CREATE INDEX idx_players_tags_gin ON players USING gin(tags);
-- 店铺+状态复合索引
CREATE INDEX idx_players_shop_status ON players (shop_id, status, rating DESC) WHERE shop_id IS NOT NULL;
-- CREATE TRIGGER trigger_players_updated_at
-- BEFORE UPDATE
-- ON players
-- FOR EACH ROW
-- EXECUTE FUNCTION update_updated_at_column();
-49
View File
@@ -1,49 +0,0 @@
CREATE TABLE shops (
id BIGINT PRIMARY KEY,
owner_id BIGINT NOT NULL UNIQUE,
name VARCHAR(200) NOT NULL,
banner TEXT,
description TEXT,
rating DECIMAL(3,2) DEFAULT 5.00,
total_orders INT DEFAULT 0,
player_count INT DEFAULT 0,
commission_type VARCHAR(20) NOT NULL DEFAULT 'percentage',
commission_value DECIMAL(10,2) NOT NULL,
allow_multi_shop BOOLEAN DEFAULT FALSE,
allow_independent_orders BOOLEAN DEFAULT TRUE,
dispatch_mode VARCHAR(20) NOT NULL DEFAULT 'manual',
announcements TEXT[] DEFAULT ARRAY[]::TEXT[],
template_config JSONB,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT chk_commission_type CHECK (commission_type IN ('fixed', 'percentage')),
CONSTRAINT chk_dispatch_mode CHECK (dispatch_mode IN ('manual', 'auto')),
CONSTRAINT chk_rating_range CHECK (rating >= 0 AND rating <= 5)
);
-- 基础索引
CREATE INDEX idx_shops_owner ON shops(owner_id);
CREATE INDEX idx_shops_rating ON shops(rating DESC);
-- 三元组索引用于店铺名称模糊搜索
CREATE INDEX idx_shops_name_trgm ON shops USING gin(name gin_trgm_ops);
-- 全文搜索索引
CREATE INDEX idx_shops_fulltext ON shops USING gin(
to_tsvector('simple', name || ' ' || coalesce(description, ''))
);
-- 复合索引优化排序查询
CREATE INDEX idx_shops_rating_orders ON shops(rating DESC, total_orders DESC);
-- 公告数组索引
CREATE INDEX idx_shops_announcements ON shops USING gin(announcements);
-- JSONB 索引优化模板配置查询
CREATE INDEX idx_shops_template ON shops USING gin(template_config);
CREATE TRIGGER trigger_shops_updated_at
BEFORE UPDATE ON shops
FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();
-17
View File
@@ -1,17 +0,0 @@
CREATE TABLE shop_invitations (
id BIGINT PRIMARY KEY,
shop_id BIGINT NOT NULL REFERENCES shops(id),
player_id BIGINT NOT NULL,
status VARCHAR(20) NOT NULL DEFAULT 'pending',
invited_by BIGINT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
responded_at TIMESTAMPTZ,
CONSTRAINT chk_invitation_status CHECK (status IN ('pending', 'accepted', 'rejected', 'cancelled')),
UNIQUE(shop_id, player_id, status) WHERE status = 'pending'
);
CREATE INDEX idx_invitations_shop ON shop_invitations(shop_id);
CREATE INDEX idx_invitations_player ON shop_invitations(player_id) WHERE status = 'pending';
CREATE INDEX idx_invitations_player_status ON shop_invitations(player_id, status, created_at DESC);
CREATE INDEX idx_invitations_shop_status ON shop_invitations(shop_id, status, created_at DESC);
-21
View File
@@ -1,21 +0,0 @@
CREATE TABLE shop_players
(
shop_id BIGINT NOT NULL REFERENCES shops (id),
player_id BIGINT NOT NULL,
-- [新增] 标记是否为主店铺。用于个人主页展示和 players.shop_id 缓存源
is_primary BOOLEAN DEFAULT FALSE,
joined_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
left_at TIMESTAMPTZ, -- 软删除,表示已离职
PRIMARY KEY (shop_id, player_id)
);
-- 索引
CREATE INDEX idx_shop_players_player ON shop_players (player_id) WHERE left_at IS NULL;
CREATE INDEX idx_shop_players_shop_active ON shop_players (shop_id, joined_at DESC) WHERE left_at IS NULL;
-- [新增] 唯一索引:确保一个打手同一时间只能有一个主店铺
CREATE UNIQUE INDEX idx_shop_players_one_primary
ON shop_players (player_id) WHERE is_primary = TRUE AND left_at IS NULL;