diff --git a/.gitea/workflows/salon-sit-deploy.yml b/.gitea/workflows/salon-sit-deploy.yml index 30a98167..8c0abafe 100644 --- a/.gitea/workflows/salon-sit-deploy.yml +++ b/.gitea/workflows/salon-sit-deploy.yml @@ -15,6 +15,7 @@ jobs: WEB_TARGET_PORT: 22 WEB_TARGET_USER: root SALON_PROD_SSH_PASSWORD: ${{ secrets.SALON_PROD_SSH_PASSWORD }} + MESSAGEHUB_ACCESS_TOKEN: ${{ secrets.MESSAGEHUB_SIT_ACCESS_TOKEN }} WEB_REMOTE_DIR: /opt/jc-salon-frontend-sit steps: - name: 从内网 Gitea 检出代码 @@ -75,6 +76,18 @@ jobs: {"Name":"salon-web-sit","Host":"${WEB_TARGET_HOST}","Port":${WEB_TARGET_PORT},"User":"${WEB_TARGET_USER}","Purpose":"Salon SIT NGINX","Environment":"sit"} ] JSON + - name: 写入 MessageHub 运行时 Token + shell: bash + env: + SALON_PROD_SSH_PASSWORD: ${{ secrets.SALON_PROD_SSH_PASSWORD }} + MESSAGEHUB_ACCESS_TOKEN: ${{ secrets.MESSAGEHUB_SIT_ACCESS_TOKEN }} + run: | + set -euo pipefail + test -n "$SALON_PROD_SSH_PASSWORD" + test -n "$MESSAGEHUB_ACCESS_TOKEN" + printf 'MESSAGEHUB_ACCESS_TOKEN=%s\n' "$MESSAGEHUB_ACCESS_TOKEN" | + SSHPASS="$SALON_PROD_SSH_PASSWORD" sshpass -e ssh -o StrictHostKeyChecking=no -p 22 root@192.168.10.106 \ + 'install -d -m 700 /etc/sysconfig /etc/systemd/system/jc-salon-core-sit.service.d; install -m 600 /dev/stdin /etc/sysconfig/jc-salon-messagehub; printf "[Service]\\nEnvironmentFile=/etc/sysconfig/jc-salon-messagehub\\n" | install -m 644 /dev/stdin /etc/systemd/system/jc-salon-core-sit.service.d/messagehub.conf; systemctl daemon-reload' - name: 自动发布 Salon SIT shell: pwsh env: diff --git a/JC-ArtList-WeChat/utils/config.js b/JC-ArtList-WeChat/utils/config.js index 60785d4a..0a970d5f 100644 --- a/JC-ArtList-WeChat/utils/config.js +++ b/JC-ArtList-WeChat/utils/config.js @@ -123,7 +123,7 @@ const DEFAULT_DOMAINS = { local: 'http://127.0.0.1:80', tunnel: 'https://yunail.art', 'dev-remote': 'https://yunail.art', - trial: 'https://yunail.art', + trial: 'https://sit.yunail.art', release: 'https://yunail.art' } @@ -140,7 +140,7 @@ const DOMAIN_MAP = { * Purpose: DEFAULT_DEVELOP_TARGET supports config.js by holding or executing the default develop target page or API role. * Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow. */ -const DEFAULT_DEVELOP_TARGET = IS_DEVTOOLS ? 'local' : 'dev-remote' +const DEFAULT_DEVELOP_TARGET = 'local' /** * Purpose: DEVELOP_TARGET supports config.js by holding or executing the develop target page or API role. * Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow. diff --git a/JC-ArtList-WeChat/utils/config.local.example.js b/JC-ArtList-WeChat/utils/config.local.example.js index 14b0cd41..292e1e73 100644 --- a/JC-ArtList-WeChat/utils/config.local.example.js +++ b/JC-ArtList-WeChat/utils/config.local.example.js @@ -9,7 +9,7 @@ module.exports = { local: 'http://127.0.0.1:80', tunnel: 'https://yunail.art', 'dev-remote': 'https://yunail.art', - trial: 'https://yunail.art', + trial: 'https://sit.yunail.art', release: 'https://yunail.art' } } diff --git a/JC-Salon-Core/src/main/java/com/xiaowang/jacyucloudsalon/core/modules/integration/service/impl/MessageHubClientServiceImpl.java b/JC-Salon-Core/src/main/java/com/xiaowang/jacyucloudsalon/core/modules/integration/service/impl/MessageHubClientServiceImpl.java index 01b2f593..81b0af44 100644 --- a/JC-Salon-Core/src/main/java/com/xiaowang/jacyucloudsalon/core/modules/integration/service/impl/MessageHubClientServiceImpl.java +++ b/JC-Salon-Core/src/main/java/com/xiaowang/jacyucloudsalon/core/modules/integration/service/impl/MessageHubClientServiceImpl.java @@ -1,11 +1,11 @@ package com.xiaowang.jacyucloudsalon.core.modules.integration.service.impl; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; import com.xiaowang.jacyucloudsalon.core.config.BrandProperties; import com.xiaowang.jacyucloudsalon.core.modules.integration.entity.MessageHubPushConfigDO; import com.xiaowang.jacyucloudsalon.core.modules.integration.service.MessageHubClientService; import com.xiaowang.jacyucloudsalon.core.modules.integration.service.MessageHubPushConfigService; -import com.xiaowang.jacyucloudsalon.core.support.id.TimeOrderedSnowflakeIdGenerator; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.core.Message; @@ -13,8 +13,13 @@ import org.springframework.amqp.core.MessageBuilder; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; +import org.springframework.web.client.RestTemplate; import java.nio.charset.StandardCharsets; import java.util.HashMap; @@ -35,14 +40,11 @@ public class MessageHubClientServiceImpl implements MessageHubClientService { * Variable `rabbitTemplate`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls. */ private final RabbitTemplate rabbitTemplate; + private final RestTemplate restTemplate; /** * Variable `objectMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls. */ private final ObjectMapper objectMapper; - /** - * Variable `snowflakeIdGenerator`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls. - */ - private final TimeOrderedSnowflakeIdGenerator snowflakeIdGenerator; /** * Variable `messageHubPushConfigService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls. */ @@ -52,6 +54,18 @@ public class MessageHubClientServiceImpl implements MessageHubClientService { */ private final BrandProperties brandProperties; + @Value("${messagehub.client.base-url:http://192.168.10.107:8080}") + private String messageHubBaseUrl; + + @Value("${messagehub.client.access-token:}") + private String messageHubAccessToken; + + @Value("${messagehub.client.ingress-exchange:messagehub.ingress.exchange}") + private String ingressExchange; + + @Value("${messagehub.client.ingress-routing-key:message.send}") + private String ingressRoutingKey; + @Value("${messagehub.client.sms-queue:smsQueue}") /** * Purpose: smsQueue supports MessageHubClientServiceImpl.java by holding or executing the sms queue business role. @@ -59,7 +73,7 @@ public class MessageHubClientServiceImpl implements MessageHubClientService { */ private String smsQueue; - @Value("${messagehub.client.source-system:fingertipdesigner}") + @Value("${messagehub.client.source-system:jayucloud-salon}") /** * Purpose: sourceSystem supports MessageHubClientServiceImpl.java by holding or executing the source system business role. * Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state. @@ -110,7 +124,8 @@ public class MessageHubClientServiceImpl implements MessageHubClientService { public void sendSmsVerificationCode(String sceneCode, String phone, String code) { try { MessageHubPushConfigDO config = messageHubPushConfigService.getEnabledConfig(sceneCode); - String messageId = snowflakeIdGenerator.nextIdString(); + String resolvedSourceSystem = resolveSourceSystem(config); + String messageId = reserveMessageId(resolvedSourceSystem); Map messageBody = buildSmsMessageBody(config, sceneCode, phone, code, messageId); String jsonBody = objectMapper.writeValueAsString(messageBody); Message message = MessageBuilder @@ -120,16 +135,68 @@ public class MessageHubClientServiceImpl implements MessageHubClientService { .setMessageId(messageId) .build(); - String queueName = config == null ? smsQueue : config.getQueueName(); - rabbitTemplate.convertAndSend(queueName, message); - log.info("短信验证码消息已投递到 MessageHub,sceneCode: {}, phone: {}, queue: {}, sourceSystem: {}, templateCode: {}", - sceneCode, phone, queueName, messageBody.get("sourceSystem"), messageBody.get("templateCode")); + message.getMessageProperties().setHeader("X-MessageHub-Access-Token", requireAccessToken()); + rabbitTemplate.send(ingressExchange, ingressRoutingKey, message); + log.info("短信验证码消息已投递到 MessageHub,sceneCode: {}, phone: {}, exchange: {}, sourceSystem: {}, templateCode: {}", + sceneCode, phone, ingressExchange, messageBody.get("sourceSystem"), messageBody.get("templateCode")); } catch (Exception exception) { log.error("发送短信验证码失败", exception); throw new RuntimeException("发送短信验证码失败: " + exception.getMessage(), exception); } } + private String reserveMessageId(String resolvedSourceSystem) throws Exception { + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + headers.set("X-MessageHub-Access-Token", requireAccessToken()); + Map requestBody = Map.of("sourceSystem", resolvedSourceSystem); + ResponseEntity response = restTemplate.postForEntity( + requireBaseUrl() + "/api/v1/messages/ids", + new HttpEntity<>(requestBody, headers), + JsonNode.class); + if (!response.getStatusCode().is2xxSuccessful() || response.getBody() == null) { + throw new IllegalStateException("MessageHub 预留消息 ID 失败,HTTP 状态: " + response.getStatusCode().value()); + } + JsonNode body = response.getBody(); + if (body.path("code").asInt(-1) != 0) { + throw new IllegalStateException("MessageHub 预留消息 ID 失败,响应码: " + body.path("code").asInt(-1) + + ",原因: " + body.path("message").asText("未知错误")); + } + String messageId = body.path("data").path("messageId").asText(""); + if (!StringUtils.hasText(messageId)) { + throw new IllegalStateException("MessageHub 预留消息 ID 响应缺少 data.messageId"); + } + return messageId; + } + + private String resolveSourceSystem(MessageHubPushConfigDO config) { + if (config != null && StringUtils.hasText(config.getSourceSystem())) { + return config.getSourceSystem(); + } + return requireSourceSystem(); + } + + private String requireBaseUrl() { + if (!StringUtils.hasText(messageHubBaseUrl)) { + throw new IllegalStateException("未配置 messagehub.client.base-url"); + } + return messageHubBaseUrl.replaceAll("/$", ""); + } + + private String requireAccessToken() { + if (!StringUtils.hasText(messageHubAccessToken)) { + throw new IllegalStateException("未配置 messagehub.client.access-token"); + } + return messageHubAccessToken; + } + + private String requireSourceSystem() { + if (!StringUtils.hasText(sourceSystem)) { + throw new IllegalStateException("未配置 messagehub.client.source-system"); + } + return sourceSystem; + } + /** * Run business method `buildSmsMessageBody`. * Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result. @@ -152,7 +219,7 @@ public class MessageHubClientServiceImpl implements MessageHubClientService { messageBody.put("templateCode", config == null ? verifyTemplateCode : config.getTemplateCode()); messageBody.put("sourceSystem", config == null ? sourceSystem : config.getSourceSystem()); messageBody.put("uniqueId", messageId); - messageBody.put("sendMethod", StringUtils.hasText(resolvedSendMethod) ? resolvedSendMethod : "OTHER"); + messageBody.put("platformParams", Map.of("sendMethod", StringUtils.hasText(resolvedSendMethod) ? resolvedSendMethod : "OTHER")); if (config != null && config.getChannelId() != null) { messageBody.put("channelId", config.getChannelId()); } diff --git a/JC-Salon-Frontend/src/config/admin-navigation.ts b/JC-Salon-Frontend/src/config/admin-navigation.ts index d2fe3531..32f2b0a4 100644 --- a/JC-Salon-Frontend/src/config/admin-navigation.ts +++ b/JC-Salon-Frontend/src/config/admin-navigation.ts @@ -24,9 +24,9 @@ export const ADMIN_DASHBOARD_PATH = '/admin/dashboard' export const adminNavigationItems: AdminNavigationItem[] = [ { path: ADMIN_HOME_PATH, iconKey: 'home', label: '首页', permissionCode: '' }, - { path: ADMIN_DASHBOARD_PATH, iconKey: 'dashboard', label: '仪表盘', permissionCode: 'dashboard:view' }, - { path: '/admin/users', iconKey: 'user', label: '用户管理', permissionCode: 'user:view' }, + { path: '/admin/users', iconKey: 'user', label: '店长账号', permissionCode: 'user:view' }, { path: '/admin/shops', iconKey: 'home', label: '店铺管理', permissionCode: 'shop:view' }, + { path: '/admin/settings', iconKey: 'tool', label: '系统设置', permissionCode: 'messagehub:config:manage' }, { path: '/admin/profile', iconKey: 'user', label: '个人设置', permissionCode: '' } ] diff --git a/JC-Salon-Frontend/src/router/index.ts b/JC-Salon-Frontend/src/router/index.ts index a8822bf5..221dc1d0 100644 --- a/JC-Salon-Frontend/src/router/index.ts +++ b/JC-Salon-Frontend/src/router/index.ts @@ -8,12 +8,13 @@ import { } from '@/utils/admin-auth-bootstrap' const pageNames = [ - ['', 'HomeView', 'admin', undefined], ['dashboard', 'DashboardView', 'admin-dashboard', 'dashboard:view'], + ['', 'HomeView', 'admin', undefined], ['users', 'UsersView', 'admin-users', 'user:view'], ['shops', 'ShopsView', 'admin-shops', 'shop:view'], - ['profile', 'ProfileView', 'admin-profile', undefined] + ['profile', 'ProfileView', 'admin-profile', undefined], ['settings', 'SystemSettingsView', 'admin-settings', 'messagehub:config:manage'] ] as const const routes = [ + { path: '/', redirect: '/admin' }, { path: '/admin/login', name: 'admin-login', component: () => import('../views/admin/AdminLoginView.vue'), meta: { requiresAuth: false, isAdmin: true, hideNav: true } }, { path: '/admin', component: () => import('../views/admin/AdminLayout.vue'), meta: { requiresAuth: true, isAdmin: true, hideNav: true }, @@ -21,7 +22,7 @@ const routes = [ path, name, component: () => import(`../views/admin/${view}.vue`), meta: { requiresAuth: true, isAdmin: true, hideNav: true, permissionCode } })) }, - { path: '/:pathMatch(.*)*', name: 'not-found', component: () => import('../views/NotFoundView.vue'), meta: { requiresAuth: false, isAdmin: true, hideNav: true } } + { path: '/:pathMatch(.*)*', name: 'not-found', component: () => import('../views/NotFoundView.vue'), meta: { requiresAuth: false, isAdmin: false, hideNav: true } } ] const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes }) diff --git a/JC-Salon-Frontend/src/views/NotFoundView.vue b/JC-Salon-Frontend/src/views/NotFoundView.vue index 49a083ed..da138b88 100644 --- a/JC-Salon-Frontend/src/views/NotFoundView.vue +++ b/JC-Salon-Frontend/src/views/NotFoundView.vue @@ -12,11 +12,11 @@ {{ BRAND_CONFIG.appName }}
404

这页去做护理了

-

您访问的页面不存在或已被删除,我们带您回到首页继续浏览作品。

+

您访问的页面不存在或已被删除,我们将在 5 秒后返回上一页。

- 将在 {{ countdown }} 秒后自动跳转到首页... + 将在 {{ countdown }} 秒后返回上一页...

- 立即前往首页 + 返回上一页 @@ -53,16 +53,20 @@ const handleBackClick = () => { router.back() return } - router.push('/home') + router.replace('/admin/login') } -/** redirectToHome is a local helper used by this page script. */ -const redirectToHome = () => { +/** redirectToLogin 将无历史来源的访问导回管理端登录页。 */ +const redirectToLogin = () => { clearRedirectTimer() - router.push('/home') + router.replace('/admin/login') } onMounted(() => { + if (window.history.length <= 1) { + redirectToLogin() + return + } timer = window.setInterval(() => { if (countdown.value > 0) { countdown.value-- @@ -70,7 +74,7 @@ onMounted(() => { if (timer) { clearInterval(timer) } - redirectToHome() + handleBackClick() } }, 1000) }) diff --git a/JC-Salon-Frontend/src/views/admin/HomeView.vue b/JC-Salon-Frontend/src/views/admin/HomeView.vue index 8f39c049..4d562f65 100644 --- a/JC-Salon-Frontend/src/views/admin/HomeView.vue +++ b/JC-Salon-Frontend/src/views/admin/HomeView.vue @@ -154,7 +154,6 @@ import { computed, onBeforeUnmount, onMounted, ref } from 'vue' import { useRouter } from 'vue-router' import { - DashboardOutlined, HomeOutlined, SafetyCertificateOutlined, UserOutlined @@ -231,16 +230,9 @@ const quickActions = computed(() => { return [] } const actions = [ - { - key: 'dashboard', - title: '仪表盘', - path: '/admin/dashboard', - icon: DashboardOutlined, - permissionCode: 'dashboard:view' - }, { key: 'users', - title: '用户管理', + title: '店长账号', path: '/admin/users', icon: UserOutlined, permissionCode: 'user:view' diff --git a/JC-Salon-Frontend/src/views/admin/ShopsView.vue b/JC-Salon-Frontend/src/views/admin/ShopsView.vue index d82f45d7..a00154f3 100644 --- a/JC-Salon-Frontend/src/views/admin/ShopsView.vue +++ b/JC-Salon-Frontend/src/views/admin/ShopsView.vue @@ -103,7 +103,7 @@ @change="(checked: any) => handleStatusChange(record, checked === true)" /> -