From 4b183aa7fccd2cf14b6fd539c95c5a5a8e370159 Mon Sep 17 00:00:00 2001 From: "agent.develop" Date: Fri, 28 Aug 2026 17:01:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20bricks=20dist=20mkdir+=E4=BA=A7=E7=89=A9?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=EF=BC=9B=E7=A7=8D=E5=AD=90=E8=84=9A=E6=9C=AC?= =?UTF-8?q?(=E6=9C=BA=E6=9E=84/=E8=A7=92=E8=89=B2/=E6=9D=83=E9=99=90/?= =?UTF-8?q?=E8=B6=85=E7=AE=A1)=EF=BC=9Brbac/appbase=E8=BD=AF=E9=93=BE?= =?UTF-8?q?=EF=BC=9Bconfig=20database=E2=86=92db?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.sh | 14 ++++++++++++- conf/config.json | 4 ++-- scripts/seed.sql | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 scripts/seed.sql diff --git a/build.sh b/build.sh index 9327adb..731ae35 100755 --- a/build.sh +++ b/build.sh @@ -66,18 +66,24 @@ for m in ${FOUNDATION_PKGS} ${BUSINESS_MODULES}; do done echo "==> [3/9] bricks frontend build + symlink" +# dist/ 不入 git(gitignore),clone 后必须本地构建;内层 build.sh 用 cat 拼接,无需 node +mkdir -p pkgs/bricks/dist if [ ! -f "pkgs/bricks/dist/bricks.js" ]; then (cd pkgs/bricks/bricks && bash build.sh) || { echo "ERROR: bricks build failed" >&2; exit 1; } fi +[ -s "pkgs/bricks/dist/bricks.js" ] || { echo "ERROR: bricks.js missing/empty after build" >&2; exit 1; } mkdir -p wwwroot ln -sfn "../pkgs/bricks/dist" "wwwroot/bricks" -echo "==> [4/9] database + foundation/initial tables" +echo "==> [4/9] database + foundation/initial tables + seed" mysql -h "${DB_HOST}" -P "${DB_PORT}" -u "${DB_USER}" -p"${DB_PASSWORD}" \ -e "CREATE DATABASE IF NOT EXISTS ${DB_NAME} CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" \ || { echo "ERROR: create database failed" >&2; exit 1; } mysql -h "${DB_HOST}" -P "${DB_PORT}" -u "${DB_USER}" -p"${DB_PASSWORD}" "${DB_NAME}" \ < "${APP_SRC_DIR}/scripts/ddl.sql" || { echo "ERROR: ddl.sql failed" >&2; exit 1; } +# 种子:默认机构/角色/权限/超管(全新库无此数据则一切请求 401) +mysql -h "${DB_HOST}" -P "${DB_PORT}" -u "${DB_USER}" -p"${DB_PASSWORD}" "${DB_NAME}" \ + < "${APP_SRC_DIR}/scripts/seed.sql" || { echo "ERROR: seed.sql failed" >&2; exit 1; } echo "==> [5/9] i18n merge" mkdir -p wwwroot/i18n/zh wwwroot/i18n/en @@ -119,6 +125,12 @@ for m in ${BUSINESS_MODULES}; do || { echo "ERROR: ${m} dbloader failed" >&2; exit 1; } fi done +# 基础模块的 wwwroot 也要软链(rbac 登录页、appbase 页面),否则登录页 404 +for m in appbase rbac; do + if [ -d "pkgs/${m}/wwwroot" ]; then + ln -sfn "../pkgs/${m}/wwwroot" "wwwroot/${m}" + fi +done echo "==> [7/9] sync app code + runtime dirs" for d in app conf scripts wwwroot; do diff --git a/conf/config.json b/conf/config.json index 75a9cb1..0022383 100644 --- a/conf/config.json +++ b/conf/config.json @@ -19,8 +19,8 @@ "port": 3306, "user": "test", "password": "Kj2wTl+LYpPtDSk3B01U7w==", - "database": "scense", - "charset": "utf8mb4" + "charset": "utf8mb4", + "db": "scense" } } }, diff --git a/scripts/seed.sql b/scripts/seed.sql new file mode 100644 index 0000000..7ae3d6f --- /dev/null +++ b/scripts/seed.sql @@ -0,0 +1,53 @@ +-- ============================================================================= +-- 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;