Refactor: Remove deprecated gRPC service files and implement new API structure

- Deleted old gRPC service definitions in `game_grpc.pb.go` and `public.go`.
- Added new API server implementations for objectstory, player, and shop services.
- Introduced configuration files for new APIs in `etc/*.yaml`.
- Created main entry points for each service in `objectstory.go`, `player.go`, and `shop.go`.
- Removed unused user update handler and user API files.
- Added utility functions for context management and HTTP header parsing.
- Introduced PostgreSQL backup configuration in `backup/postgreSql.yaml`.
This commit is contained in:
wwweww
2026-02-28 18:35:56 +08:00
parent d2f33b4b96
commit 19cc7a778c
349 changed files with 42548 additions and 1453 deletions
+20 -20
View File
@@ -1,33 +1,33 @@
CREATE TABLE wallet_transactions (
id BIGINT PRIMARY KEY,
user_id BIGINT NOT NULL,
type VARCHAR(20) NOT NULL,
amount DECIMAL(12,2) NOT NULL,
balance_after DECIMAL(12,2) NOT NULL,
description VARCHAR(500) NOT NULL,
order_id BIGINT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
search_text TEXT GENERATED ALWAYS AS (
type || ' ' || description
) STORED,
CREATE TABLE wallet_transactions
(
id BIGINT PRIMARY KEY,
user_id BIGINT NOT NULL,
type VARCHAR(20) NOT NULL,
amount DECIMAL(12, 2) NOT NULL,
balance_after DECIMAL(12, 2) NOT NULL,
description VARCHAR(500) NOT NULL,
order_id BIGINT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
search_text TEXT GENERATED ALWAYS AS (
type || ' ' || description
) STORED,
CONSTRAINT chk_transaction_type CHECK (type IN ('topup', 'payment', 'income', 'withdrawal', 'refund'))
CONSTRAINT chk_transaction_type CHECK (type IN ('topup', 'payment', 'income', 'withdrawal', 'refund'))
);
-- 基础索引
CREATE INDEX idx_transactions_user ON wallet_transactions(user_id, created_at DESC);
CREATE INDEX idx_transactions_order ON wallet_transactions(order_id) WHERE order_id IS NOT NULL;
CREATE INDEX idx_transactions_type ON wallet_transactions(user_id, type, created_at DESC);
CREATE INDEX idx_transactions_user ON wallet_transactions (user_id, created_at DESC);
CREATE INDEX idx_transactions_order ON wallet_transactions (order_id) WHERE order_id IS NOT NULL;
CREATE INDEX idx_transactions_type ON wallet_transactions (user_id, type, created_at DESC);
-- 三元组索引用于交易描述搜索
CREATE INDEX idx_transactions_search_trgm ON wallet_transactions USING gin(search_text gin_trgm_ops);
-- 复合索引优化用户交易查询
CREATE INDEX idx_transactions_user_type_created ON wallet_transactions(user_id, type, created_at DESC);
CREATE INDEX idx_transactions_user_type_created ON wallet_transactions (user_id, type, created_at DESC);
-- 时间范围索引 (用于统计)
CREATE INDEX idx_transactions_created_amount ON wallet_transactions(created_at DESC, amount);
CREATE INDEX idx_transactions_created_amount ON wallet_transactions (created_at DESC, amount);
-- 订单关联索引
CREATE INDEX idx_transactions_order_type ON wallet_transactions(order_id, type)
WHERE order_id IS NOT NULL;
CREATE INDEX idx_transactions_order_type ON wallet_transactions (order_id, type) WHERE order_id IS NOT NULL;
+12 -10
View File
@@ -1,17 +1,19 @@
CREATE TABLE wallets (
user_id BIGINT PRIMARY KEY,
balance DECIMAL(12,2) NOT NULL DEFAULT 0.00,
frozen_balance DECIMAL(12,2) NOT NULL DEFAULT 0.00,
version INT NOT NULL DEFAULT 1, -- 必须使用乐观锁
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CREATE TABLE wallets
(
user_id BIGINT PRIMARY KEY,
balance DECIMAL(12, 2) NOT NULL DEFAULT 0.00,
frozen_balance DECIMAL(12, 2) NOT NULL DEFAULT 0.00,
version INT NOT NULL DEFAULT 1, -- 必须使用乐观锁
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT chk_balance_non_negative CHECK (balance >= 0),
CONSTRAINT chk_frozen_non_negative CHECK (frozen_balance >= 0)
CONSTRAINT chk_balance_non_negative CHECK (balance >= 0),
CONSTRAINT chk_frozen_non_negative CHECK (frozen_balance >= 0)
);
CREATE INDEX idx_wallets_updated ON wallets(updated_at DESC);
CREATE INDEX idx_wallets_updated ON wallets (updated_at DESC);
CREATE TRIGGER trigger_wallets_updated_at
BEFORE UPDATE ON wallets
BEFORE UPDATE
ON wallets
FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();