oms/backend/database/migrations/20261102000100-seed-external-print-platform-menu.js
liufumingren 969c68f5f9 feat(external-print): 新增外部打单平台与账号管理(接入店管家登录)
- 新增 external_print_platforms(平台基础资料,开发者维护)与 external_print_accounts(账号/密码/cookie/token/登录状态)
- 新增平台账号 CRUD、登录态检查、登录接口;店铺管理下新增「外部打单平台」菜单
- 平台服务按 code 独立存放于 app/lib/printPlatform(dgj.js 实现店管家登录与 GetUserInfo 登录态检查)
- 平台接口 401 自动记录账号登录状态,前端展示状态并支持检查/登录

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-02 18:02:34 +08:00

65 lines
1.9 KiB
JavaScript

'use strict';
/**
* 新增「外部打单平台」菜单:挂在「店铺管理」目录下,指向 views/ExternalPrintPlatform/Index.vue。
* 平台基础资料由开发者维护,本菜单主要用于维护外部打单账号。
* 按 name + parent_id 判重,可重复执行。
*/
const PARENT_NAME = '店铺管理';
const MENU = {
name: '外部打单平台',
type: 2,
path: '/external-print-platform',
icon: 'Printer',
permission: 'externalPrintAccount:list',
component: 'views/ExternalPrintPlatform/Index.vue',
sort: 70,
};
module.exports = {
async up(queryInterface) {
const sequelize = queryInterface.sequelize;
const [ parent ] = await sequelize.query(
'SELECT id FROM menus WHERE name = ? AND parent_id = 0 LIMIT 1',
{ replacements: [ PARENT_NAME ], type: sequelize.QueryTypes.SELECT }
);
if (!parent) {
// 父菜单不存在(异常数据)时跳过,避免挂错层级
return;
}
const parentId = Number(parent.id);
const [ exist ] = await sequelize.query(
'SELECT id FROM menus WHERE name = ? AND parent_id = ? LIMIT 1',
{ replacements: [ MENU.name, parentId ], type: sequelize.QueryTypes.SELECT }
);
if (exist) return;
await sequelize.query(
`INSERT INTO menus
(parent_id, name, type, path, icon, permission, component, sort, status, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, NOW(), NOW())`,
{
replacements: [
parentId,
MENU.name,
MENU.type,
MENU.path,
MENU.icon,
MENU.permission,
MENU.component,
MENU.sort,
],
}
);
},
async down(queryInterface) {
const sequelize = queryInterface.sequelize;
await sequelize.query('DELETE FROM menus WHERE name = ? AND path = ?', {
replacements: [ MENU.name, MENU.path ],
});
},
};