2023-05-13 14:45:23 +08:00
|
|
|
-- SPDX-License-Identifier: GPL-3.0-or-later
|
2023-04-09 13:35:35 +08:00
|
|
|
|
2023-05-13 14:45:23 +08:00
|
|
|
-- 用户基本信息
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS userinfo (
|
2022-04-30 15:27:56 +08:00
|
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
|
|
name VARCHAR(255),
|
|
|
|
password CHAR(64),
|
2022-12-18 12:52:52 +08:00
|
|
|
salt CHAR(8),
|
2022-04-30 15:27:56 +08:00
|
|
|
avatar VARCHAR(64),
|
|
|
|
lastLoginIp VARCHAR(64),
|
|
|
|
banned BOOLEAN
|
2022-03-24 21:23:42 +08:00
|
|
|
);
|
|
|
|
|
2023-05-13 14:45:23 +08:00
|
|
|
CREATE TABLE IF NOT EXISTS banip (
|
2022-04-30 15:27:56 +08:00
|
|
|
ip VARCHAR(64)
|
2022-03-24 21:23:42 +08:00
|
|
|
);
|
2023-05-13 14:45:23 +08:00
|
|
|
|
2023-07-12 20:35:05 +08:00
|
|
|
CREATE TABLE IF NOT EXISTS uuidinfo (
|
|
|
|
id INTEGER PRIMARY KEY,
|
|
|
|
uuid VARCHAR(32)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS banuuid (
|
|
|
|
uuid VARCHAR(32)
|
|
|
|
);
|
|
|
|
|
2023-05-13 14:45:23 +08:00
|
|
|
-- 胜率相关
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS winRate (
|
|
|
|
id INTEGER,
|
|
|
|
general VARCHAR(20),
|
|
|
|
mode VARCHAR(16),
|
|
|
|
win INTEGER,
|
|
|
|
lose INTEGER,
|
|
|
|
draw INTEGER,
|
|
|
|
PRIMARY KEY (id, general, mode)
|
|
|
|
);
|
|
|
|
|
2023-06-16 23:04:31 +08:00
|
|
|
CREATE TABLE IF NOT EXISTS runRate (
|
|
|
|
id INTEGER,
|
|
|
|
mode VARCHAR(16),
|
|
|
|
run INTEGER,
|
|
|
|
PRIMARY KEY (id, mode)
|
|
|
|
);
|
|
|
|
|
2023-05-13 14:45:23 +08:00
|
|
|
CREATE VIEW IF NOT EXISTS playerWinRate AS
|
|
|
|
SELECT winRate.id, name, mode,
|
|
|
|
SUM(win) AS 'win',
|
|
|
|
SUM(lose) AS 'lose',
|
|
|
|
SUM(draw) AS 'draw',
|
|
|
|
SUM(win + lose + draw) AS 'total',
|
|
|
|
ROUND(SUM(win) * 1.0 / (SUM(win + lose + draw) * 1.0) * 100, 2)
|
|
|
|
AS 'winRate'
|
|
|
|
FROM winRate, userinfo
|
|
|
|
WHERE winRate.id = userinfo.id
|
|
|
|
GROUP BY winRate.id, mode;
|
|
|
|
|
|
|
|
CREATE VIEW IF NOT EXISTS generalWinRate AS
|
|
|
|
SELECT general, mode,
|
|
|
|
SUM(win) AS 'win',
|
|
|
|
SUM(lose) AS 'lose',
|
|
|
|
SUM(draw) AS 'draw',
|
|
|
|
SUM(win + lose + draw) AS 'total',
|
|
|
|
ROUND(SUM(win) * 1.0 / (SUM(win + lose + draw) * 1.0) * 100, 2)
|
|
|
|
AS 'winRate'
|
|
|
|
FROM winRate GROUP BY general, mode;
|