diff --git a/policeSecurityServer/src/main/java/com/changhu/common/annotation/CheckOpenApi.java b/policeSecurityServer/src/main/java/com/changhu/common/annotation/CheckOpenApi.java deleted file mode 100644 index 18f25e1..0000000 --- a/policeSecurityServer/src/main/java/com/changhu/common/annotation/CheckOpenApi.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.changhu.common.annotation; - -import com.changhu.common.enums.OpenApiType; - -import java.lang.annotation.*; - -/** - * @author 20252 - * @createTime 2024/10/9 下午5:14 - * @desc 检查openApi - */ -@Target({ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface CheckOpenApi { - OpenApiType value(); -} diff --git a/policeSecurityServer/src/main/java/com/changhu/common/enums/OpenApiType.java b/policeSecurityServer/src/main/java/com/changhu/common/enums/OpenApiType.java deleted file mode 100644 index db2de04..0000000 --- a/policeSecurityServer/src/main/java/com/changhu/common/enums/OpenApiType.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.changhu.common.enums; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; -import java.util.List; - -/** - * @author 20252 - * @createTime 2024/10/9 下午5:10 - * @desc OpenApiType... - */ -@Getter -@AllArgsConstructor -public enum OpenApiType { - Information_on_enterprises_and_institutions("获取企事业单位信息", Arrays.asList("1fe0aaf3-45a4-4be3-a989-75e914a3f36e", "1fe0aaf3-45a4-a989-75e914a3f36e")), - data_view("数据总览", List.of("8da74bbf-c686-4393-b4ec-692091e6d381")); - - private final String desc; - private final List openApiKeys; -} diff --git a/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java b/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java index 5e17a88..250694a 100644 --- a/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java +++ b/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java @@ -1,8 +1,6 @@ package com.changhu.controller; -import com.changhu.common.annotation.CheckOpenApi; import com.changhu.common.annotation.JsonBody; -import com.changhu.common.enums.OpenApiType; import com.changhu.common.pojo.vo.SelectNodeVo; import com.changhu.pojo.dto.DataViewDTO; import com.changhu.pojo.dto.EnterprisesUnitDetailDTO; @@ -33,7 +31,6 @@ public class OpenController { private OpenApiService openApiService; @Operation(summary = "获取企事业单位列表") - @CheckOpenApi(value = OpenApiType.Information_on_enterprises_and_institutions) @GetMapping("/getEnterprisesUnit") public List> getEnterprisesUnit(@Schema(description = "代码") @RequestParam String code, @Schema(description = "等级") @RequestParam Integer level) { @@ -41,21 +38,18 @@ public class OpenController { } @Operation(summary = "企事业单位详情") - @CheckOpenApi(value = OpenApiType.Information_on_enterprises_and_institutions) @GetMapping("/enterprisesUnitDetailById") public EnterprisesUnitDetailDTO enterprisesUnitDetailById(@Schema(description = "企事业单位id") @RequestParam Long enterprisesUnitId) { return openApiService.enterprisesUnitDetailById(enterprisesUnitId); } @Operation(summary = "数据总览") - @CheckOpenApi(value = OpenApiType.data_view) @GetMapping("/dataView") public DataViewDTO dataView() { return openApiService.dataView(); } @Operation(summary = "保安单位使用情况统计") - @CheckOpenApi(value = OpenApiType.Information_on_enterprises_and_institutions) @GetMapping("/securityUnitUseStatistics") public List securityUnitUseStatistics(@Schema(description = "代码") @RequestParam String code, @Schema(description = "等级") @RequestParam Integer level) { @@ -63,7 +57,6 @@ public class OpenController { } @Operation(summary = "服务项目安保人员花名册") - @CheckOpenApi(value = OpenApiType.Information_on_enterprises_and_institutions) @GetMapping("/serviceProjectUserRoster") public List serviceProjectUserRoster(@Schema(description = "服务项目id") Long serviceProjectId) { return openApiService.serviceProjectUserRoster(serviceProjectId); diff --git a/policeSecurityServer/src/main/java/com/changhu/support/interceptor/OpenApiInterceptor.java b/policeSecurityServer/src/main/java/com/changhu/support/interceptor/OpenApiInterceptor.java deleted file mode 100644 index 7ce27fe..0000000 --- a/policeSecurityServer/src/main/java/com/changhu/support/interceptor/OpenApiInterceptor.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.changhu.support.interceptor; - -import cn.hutool.core.util.StrUtil; -import com.changhu.common.annotation.CheckOpenApi; -import com.changhu.common.exception.MessageException; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import lombok.extern.slf4j.Slf4j; -import org.jetbrains.annotations.NotNull; -import org.springframework.web.method.HandlerMethod; -import org.springframework.web.servlet.HandlerInterceptor; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * @author 20252 - * @createTime 2024/10/9 下午5:05 - * @desc OpenApiInterceptor... - */ -@Slf4j -public class OpenApiInterceptor implements HandlerInterceptor { - - @Override - public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler) { - if (handler instanceof HandlerMethod handlerMethod) { - String header = request.getHeader("X-API-KEY"); - if (StrUtil.isBlank(header)) { - throw new MessageException("请求头缺失"); - } - log.info("apiKey:{} {} 请求:{}", header, LocalDateTime.now(), request.getRequestURI()); - CheckOpenApi methodAnnotation = handlerMethod.getMethodAnnotation(CheckOpenApi.class); - if (methodAnnotation != null) { - List openApiKeys = methodAnnotation.value().getOpenApiKeys(); - if (!openApiKeys.contains(header)) { - throw new MessageException("openApiKey error!"); - } - } - } - return true; - } -} diff --git a/superManagement/.env.development b/superManagement/.env.development index 024b5f7..b98dba4 100644 --- a/superManagement/.env.development +++ b/superManagement/.env.development @@ -1,8 +1,7 @@ -VITE_APP_NAME=超级后台 +VITE_APP_NAME=保安管理 VITE_APP_ENV=development VITE_APP_PORT=1000 VITE_DROP_CONSOLE=false -VITE_APP_MODULE_NAME=superManagement # axios VITE_APP_BASE_API=/api diff --git a/superManagement/.env.production b/superManagement/.env.production index 3104a00..7ec8661 100644 --- a/superManagement/.env.production +++ b/superManagement/.env.production @@ -1,8 +1,7 @@ -VITE_APP_NAME=超级后台 +VITE_APP_NAME=保安管理 VITE_APP_ENV=production VITE_APP_PORT=1001 VITE_DROP_CONSOLE=true -VITE_APP_MODULE_NAME=superManagement # axios VITE_APP_BASE_API=/api diff --git a/superManagement/index.html b/superManagement/index.html index 28e4832..7899caa 100644 --- a/superManagement/index.html +++ b/superManagement/index.html @@ -6,7 +6,7 @@ - 超级后台 + 保安管理
diff --git a/superManagement/package.json b/superManagement/package.json index 8bce851..f46e523 100644 --- a/superManagement/package.json +++ b/superManagement/package.json @@ -1,6 +1,6 @@ { - "name": "supermanagement", - "appName": "超级后台", + "name": "super_management", + "appName": "保安管理", "private": true, "version": "1.0.0", "type": "module", diff --git a/superManagement/src/components/layout/Layout.vue b/superManagement/src/components/layout/Layout.vue index 09ce243..3bda2e1 100644 --- a/superManagement/src/components/layout/Layout.vue +++ b/superManagement/src/components/layout/Layout.vue @@ -7,10 +7,10 @@ collapsible >
-
超级后台
+
{{ appInfo.appName }}
@@ -40,6 +40,8 @@ import {ref} from "vue"; import LayoutHeader from "@/components/layout/header/LayoutHeader.vue"; import SystemMenus from "@/components/layout/SystemMenus.vue"; +const appInfo = __APP_INFO + const collapsed = ref(false); const keepAliveNames = ref([]) diff --git a/superManagement/src/global.d.ts b/superManagement/src/global.d.ts index 98d02b9..381a0ac 100644 --- a/superManagement/src/global.d.ts +++ b/superManagement/src/global.d.ts @@ -1,4 +1,9 @@ declare const __APP_ENV: ImportMetaEnv; +declare const __APP_INFO: { + moduleName: string, + appName: string, + version: string +} /** * 全局返回 diff --git a/superManagement/src/router/index.ts b/superManagement/src/router/index.ts index fb606fd..1ce2545 100644 --- a/superManagement/src/router/index.ts +++ b/superManagement/src/router/index.ts @@ -10,7 +10,7 @@ import {ROUTER_WHITE_LIST} from "@/config"; * createWebHashHistory: 路径带#号 这部分 URL 从未被发送到服务器,所以它不需要在服务器层面上进行任何特殊处理,影响SEO */ const router = createRouter({ - history: createWebHistory(__APP_ENV.VITE_APP_MODULE_NAME), + history: createWebHistory(__APP_INFO.moduleName), routes: [...staticRouter], strict: false, scrollBehavior: () => ({left: 0, top: 0}), diff --git a/superManagement/src/vite-env.d.ts b/superManagement/src/vite-env.d.ts index c061ab6..f79a3bd 100644 --- a/superManagement/src/vite-env.d.ts +++ b/superManagement/src/vite-env.d.ts @@ -6,8 +6,6 @@ interface ImportMetaEnv { readonly VITE_APP_ENV: 'development' | 'production'; // 启动端口 readonly VITE_APP_PORT: number; - // 模块名称 - readonly VITE_APP_MODULE_NAME: string; // axios readonly VITE_APP_BASE_API: string; diff --git a/superManagement/vite.config.ts b/superManagement/vite.config.ts index 6151972..c77fd50 100644 --- a/superManagement/vite.config.ts +++ b/superManagement/vite.config.ts @@ -4,6 +4,7 @@ import Components from 'unplugin-vue-components/vite'; import {AntDesignVueResolver} from 'unplugin-vue-components/resolvers'; import * as path from "node:path"; import vueJsx from '@vitejs/plugin-vue-jsx' +import {appName, version, name} from './package.json' const pathSrc = path.resolve(__dirname, 'src'); @@ -12,9 +13,14 @@ export default defineConfig(({mode}) => { const env: Record = loadEnv(mode, process.cwd(), '') return { define: { - __APP_ENV: JSON.stringify(env) + __APP_ENV: JSON.stringify(env), + __APP_INFO: JSON.stringify({ + moduleName: name, + appName, + version + }) }, - base: `/${env['VITE_APP_MODULE_NAME']}/`, + base: `/${name}/`, plugins: [ vue(), vueJsx(),