Files
bl/help/mock生成用户.sql

31 lines
952 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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万条