-- ============================================================================= -- scense 初始化种子数据(全新库必备) -- ddl.sql 只建表结构;本脚本种入:默认机构 / 角色 / 权限 / 超管。 -- 幂等:全部 INSERT IGNORE,重跑不重复。 -- ============================================================================= USE scense; -- ── 默认机构(平台自身,org_type=owner)── INSERT IGNORE INTO organization (id, orgname, alias_name, org_type, parentid, del_flg) VALUES ('0', '唤景平台', 'scense', 'owner', NULL, '0'); -- ── 内置角色 ── -- any/anonymous:匿名访问;logined:登录态;owner.superuser:超级管理员 INSERT IGNORE INTO role (id, orgtypeid, role, rolelabel, name) VALUES ('any', '0', 'any', 'Anonymous', 'any'), ('anonymous', '0', NULL, NULL, NULL), ('logined', '0', NULL, NULL, NULL), ('owner.superuser','0', 'superuser', '超级管理员', 'superuser'); -- ── 权限(permission)── -- any:健康检查 + 登录页所需静态资源/登录端点(否则连登录页都打不开) -- owner.superuser:/** 全放行 INSERT IGNORE INTO permission (id, name, ptype, path, title) VALUES ('perm-healthz', 'healthz', 'url', '/healthz', '健康检查'), ('perm-any-bricks', 'bricks', 'url', '/bricks/**', 'bricks 前端资源'), ('perm-any-i18n', 'i18n', 'url', '/i18n/**', 'i18n 资源'), ('perm-any-index', 'index', 'url', '/index.ui', '入口页'), ('perm-any-root', 'root', 'url', '/', '根路径'), ('perm-any-uplogin', 'up_login', 'url', '/rbac/user/up_login.dspy','账号密码登录'), ('perm-any-loginui', 'login_ui', 'url', '/rbac/user/login.ui', '登录页'), ('perm-super-all', 'all', 'url', '/**', '超级管理员全放行'); -- ── 角色-权限绑定(rolepermission)── INSERT IGNORE INTO rolepermission (id, roleid, permid) VALUES ('rp-healthz', 'any', 'perm-healthz'), ('rp-any-bricks', 'any', 'perm-any-bricks'), ('rp-any-i18n', 'any', 'perm-any-i18n'), ('rp-any-index', 'any', 'perm-any-index'), ('rp-any-root', 'any', 'perm-any-root'), ('rp-any-uplogin', 'any', 'perm-any-uplogin'), ('rp-any-loginui', 'any', 'perm-any-loginui'), ('rp-super-all', 'owner.superuser', 'perm-super-all'); -- ── 超级管理员 ── -- 密码 Aa@123456,经 password_encode(rc4, key=scense_test_env_key) 加密 INSERT IGNORE INTO users (id, username, password, orgid, nick_name, user_status) VALUES ('user-01', 'admin', 'QUZVcXg5V1p1STMybG5Ia2/sxzz9580bgw==', '0', 'Admin', '0'); INSERT IGNORE INTO userrole (id, userid, roleid) VALUES ('ur-admin-super', 'user-01', 'owner.superuser'); -- 提交(防 MDL 锁阻塞后续 DDL) COMMIT;