"chore(data): 移除b.csv测试数据文件"
This commit is contained in:
|
Can't render this file because it is too large.
|
31
help/mock生成用户.sql
Normal file
31
help/mock生成用户.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
INSERT INTO base_sys_user (
|
||||
"createTime",
|
||||
"updateTime",
|
||||
deleted_at,
|
||||
"departmentId",
|
||||
username,
|
||||
password,
|
||||
"headImg",
|
||||
email,
|
||||
remark
|
||||
) SELECT
|
||||
-- 过去90天内的随机创建时间
|
||||
CURRENT_TIMESTAMP - (random() * 90 * 86400 || ' seconds')::interval,
|
||||
-- updateTime初始与createTime一致
|
||||
CURRENT_TIMESTAMP - (random() * 90 * 86400 || ' seconds')::interval,
|
||||
NULL, -- 未删除
|
||||
-- 随机部门ID(1-100)
|
||||
floor(random() * 100) + 1,
|
||||
-- 随机用户名(mock_前缀+8位随机串)
|
||||
CONCAT('mock_', SUBSTRING(md5(random()::text), 1, 8)),
|
||||
md5('123456'), -- 固定密码
|
||||
'https://example.com/headimg/default.png', -- 统一默认头像
|
||||
-- 随机邮箱(mock_前缀+8位随机串+随机域名)
|
||||
CONCAT(
|
||||
'mock_',
|
||||
SUBSTRING(md5(random()::text), 1, 8),
|
||||
'@',
|
||||
(array['qq.com', '163.com', 'gmail.com'])[floor(random()*3)+1]
|
||||
),
|
||||
'批量生成的测试用户'
|
||||
FROM generate_series(1, 1000); -- 10万条
|
||||
10
help/查询在线时长.sql
Normal file
10
help/查询在线时长.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
SELECT
|
||||
player_id,
|
||||
(data->>'online_time')::int AS online_time
|
||||
FROM "player_info"
|
||||
-- 替换?操作符,用jsonb_exists函数判断online_time字段是否存在
|
||||
WHERE
|
||||
jsonb_exists(data, 'online_time') -- 等价于 data ? 'online_time',无占位符冲突
|
||||
AND (data->>'online_time')::int > 0
|
||||
-- 按在线时间降序排序
|
||||
ORDER BY online_time DESC;
|
||||
9
help/给经验池增加.sql
Normal file
9
help/给经验池增加.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
UPDATE "player_info"
|
||||
SET data = jsonb_set(
|
||||
data,
|
||||
'{exp_pool}',
|
||||
-- 直接复用查询中的计算逻辑,确保结果一致
|
||||
to_jsonb(COALESCE((data->>'exp_pool')::int, 0) + 50000000),
|
||||
true -- 字段不存在时自动初始化为10
|
||||
)
|
||||
WHERE player_id = 10001;
|
||||
Reference in New Issue
Block a user