Compare commits

...
1 Commits
Author SHA1 Message Date
lik efd4e4444c refactor(app): appId wxapp-escort-admin 更名为 wxapp_companion
与陪诊师小程序工程名对齐;同步注册表、配置白名单、脚本示例与测试。数据库 user_app / user_identity / user.app 旧字段已同步迁移。
2026-11-10 16:33:35 +08:00
9 changed files with 13 additions and 13 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
"appid": "wxf73c79e16837af07", "appid": "wxf73c79e16837af07",
"secret": "5a061d65f4d35d19e62e83b98f6c63cf" "secret": "5a061d65f4d35d19e62e83b98f6c63cf"
}, },
"wxapp-escort-admin": { "wxapp_companion": {
"appid": "wxf94dd97b91af09a2", "appid": "wxf94dd97b91af09a2",
"secret": "79ba226684740830af0029763d3045f0" "secret": "79ba226684740830af0029763d3045f0"
}, },
+2 -2
View File
@@ -18,7 +18,7 @@ export const APP_CONFIG_SCHEMAS = {
}), }),
}), }),
"wxapp-escort-admin": Joi.object({ "wxapp_companion": Joi.object({
pageSize: Joi.number().integer().min(10).max(200), pageSize: Joi.number().integer().min(10).max(200),
defaultFilter: Joi.string().valid("all", "pending", "done"), defaultFilter: Joi.string().valid("all", "pending", "done"),
soundAlert: Joi.boolean(), soundAlert: Joi.boolean(),
@@ -40,7 +40,7 @@ export const APP_CONFIG_DEFAULTS = {
language: "zh-CN", language: "zh-CN",
notifications: { orderStatus: true, marketing: false }, notifications: { orderStatus: true, marketing: false },
}, },
"wxapp-escort-admin": { "wxapp_companion": {
pageSize: 100, pageSize: 100,
defaultFilter: "all", defaultFilter: "all",
soundAlert: true, soundAlert: true,
+2 -2
View File
@@ -11,14 +11,14 @@ import config from "../conf.json" with { type: "json" };
*/ */
export const APP_REGISTRY = { export const APP_REGISTRY = {
"wxapp-escort": { platform: "weixin", provider: "weixin-mini" }, "wxapp-escort": { platform: "weixin", provider: "weixin-mini" },
"wxapp-escort-admin": { platform: "weixin", provider: "weixin-mini" }, "wxapp_companion": { platform: "weixin", provider: "weixin-mini" },
"ttapp-escort": { platform: "douyin", provider: "douyin-mini" }, "ttapp-escort": { platform: "douyin", provider: "douyin-mini" },
"web-escort-admin": { platform: "weixin", provider: "weixin-web" }, "web-escort-admin": { platform: "weixin", provider: "weixin-web" },
tcm: { platform: "web", provider: "password" }, tcm: { platform: "web", provider: "password" },
}; };
// 管理端应用:任一应用内的 admin 都视为管理端管理员 // 管理端应用:任一应用内的 admin 都视为管理端管理员
export const ADMIN_APP_IDS = ["wxapp-escort-admin", "web-escort-admin"]; export const ADMIN_APP_IDS = ["wxapp_companion", "web-escort-admin"];
// 本阶段只做固定角色白名单,不引入自定义 RBAC // 本阶段只做固定角色白名单,不引入自定义 RBAC
export const GRANTABLE_ROLES = ["user", "admin"]; export const GRANTABLE_ROLES = ["user", "admin"];
+1 -1
View File
@@ -77,7 +77,7 @@ async function main() {
user.meta = { ...(user.meta || {}), updatetime: Date.now() }; user.meta = { ...(user.meta || {}), updatetime: Date.now() };
} }
// 只授予 Web 后台这一个应用的 admin,不动小程序端(wxapp-escort-admin)的身份 // 只授予 Web 后台这一个应用的 admin,不动小程序端(wxapp_companion)的身份
user.app = user.app || {}; user.app = user.app || {};
user.app[WEB_ADMIN_APP] = { user.app[WEB_ADMIN_APP] = {
...(user.app[WEB_ADMIN_APP] || {}), ...(user.app[WEB_ADMIN_APP] || {}),
+2 -2
View File
@@ -7,8 +7,8 @@
* node scripts/grant_admin.js <userId> <appId> [roles] * node scripts/grant_admin.js <userId> <appId> [roles]
* *
* 示例: * 示例:
* node scripts/grant_admin.js 66f0... wxapp-escort-admin admin * node scripts/grant_admin.js 66f0... wxapp_companion admin
* node scripts/grant_admin.js 66f0... wxapp-escort-admin admin,user * node scripts/grant_admin.js 66f0... wxapp_companion admin,user
* *
* 同时写 user_app 与旧 app 字段,保证重构后的鉴权和 api/health 都能识别。 * 同时写 user_app 与旧 app 字段,保证重构后的鉴权和 api/health 都能识别。
*/ */
+1 -1
View File
@@ -177,7 +177,7 @@ describe('用户接口集成测试', () => {
.send({ mobile: testMobile, passwd: testPasswd, appId }); .send({ mobile: testMobile, passwd: testPasswd, appId });
const admin1 = await login('web-escort-admin'); const admin1 = await login('web-escort-admin');
const wx = await login('wxapp-escort-admin'); const wx = await login('wxapp_companion');
assert.equal(admin1.body.code, 0, admin1.body.msg); assert.equal(admin1.body.code, 0, admin1.body.msg);
assert.equal(wx.body.code, 0, wx.body.msg); assert.equal(wx.body.code, 0, wx.body.msg);
const admin1Token = admin1.body.data.user.security.token; const admin1Token = admin1.body.data.user.security.token;
+1 -1
View File
@@ -53,7 +53,7 @@ describe('resolveConfig', () => {
}); });
it('兼容 Map 存储', () => { it('兼容 Map 存储', () => {
const config = resolveConfig('wxapp-escort-admin', new Map([['pageSize', 50]])); const config = resolveConfig('wxapp_companion', new Map([['pageSize', 50]]));
assert.equal(config.pageSize, 50); assert.equal(config.pageSize, 50);
assert.equal(config.soundAlert, true); assert.equal(config.soundAlert, true);
}); });
+1 -1
View File
@@ -23,7 +23,7 @@ describe('APP_REGISTRY', () => {
}); });
it('管理端应用与可授权角色配置正确', () => { it('管理端应用与可授权角色配置正确', () => {
assert.ok(ADMIN_APP_IDS.includes('wxapp-escort-admin')); assert.ok(ADMIN_APP_IDS.includes('wxapp_companion'));
assert.ok(ADMIN_APP_IDS.includes('web-escort-admin')); assert.ok(ADMIN_APP_IDS.includes('web-escort-admin'));
assert.deepEqual(GRANTABLE_ROLES, ['user', 'admin']); assert.deepEqual(GRANTABLE_ROLES, ['user', 'admin']);
}); });
+2 -2
View File
@@ -6,7 +6,7 @@ import { APP } from '../app.js';
import { DBModel } from '../models/index.js'; import { DBModel } from '../models/index.js';
import { hashToken } from '../utils/crypto.js'; import { hashToken } from '../utils/crypto.js';
const ADMIN_APP = 'wxapp-escort-admin'; const ADMIN_APP = 'wxapp_companion';
const WEB_ADMIN_APP = 'web-escort-admin'; const WEB_ADMIN_APP = 'web-escort-admin';
const CONSUMER_APP = 'wxapp-escort'; const CONSUMER_APP = 'wxapp-escort';
@@ -135,7 +135,7 @@ describe('管理端权限', () => {
it('A 应用 user + B 应用 admin:按应用逐条判角色,必须放行', async () => { it('A 应用 user + B 应用 admin:按应用逐条判角色,必须放行', async () => {
// 典型画像:先登录小程序管理端(自动 ["user"]),后被授予 Web 后台 ["admin"]。 // 典型画像:先登录小程序管理端(自动 ["user"]),后被授予 Web 后台 ["admin"]。
// wxapp-escort-admin 排序在 web-escort-admin 之前,只取第一条判角色会误拒。 // wxapp_companion 排序在 web-escort-admin 之前,只取第一条判角色会误拒。
const mixed = await createUser(nextMobile(), '混合角色管理员'); const mixed = await createUser(nextMobile(), '混合角色管理员');
await addMembership(mixed.user._id, ADMIN_APP, ['user']); await addMembership(mixed.user._id, ADMIN_APP, ['user']);
await addMembership(mixed.user._id, WEB_ADMIN_APP, ['admin']); await addMembership(mixed.user._id, WEB_ADMIN_APP, ['admin']);