"chore(data): 移除b.csv测试数据文件"

This commit is contained in:
1
2025-12-21 18:22:07 +00:00
parent 38f51a5111
commit f9d7f0ea68
7 changed files with 50 additions and 0 deletions

View File

Can't render this file because it is too large.

31
help/mock生成用户.sql Normal file
View 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, -- 未删除
-- 随机部门ID1-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万条

View 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;

View 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;