From 771dac470c075d9553a4d499600f1d666e0a5559 Mon Sep 17 00:00:00 2001 From: luozhun <2025254074@qq.com> Date: Wed, 20 Nov 2024 10:29:36 +0800 Subject: [PATCH 01/12] =?UTF-8?q?feat(security):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=AD=BE=E5=90=8D=E9=AA=8C=E8=AF=81=E5=8A=9F=E8=83=BD=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=80=E6=94=BE=E5=B9=B3=E5=8F=B0=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 BodyWrapperFilter 和 CustomHttpServletRequestWrapper 类,用于获取请求体内容- 实现 SignInterceptor 类,添加签名验证功能 - 更新 OpenApiInterceptor,增加请求头缺失异常处理 - 修改 SecurityUnitUseStatisticsDTO,添加 policeUnitId 字段- 更新 OpenApiMapper.xml,增加 policeUnitId 字段映射- 修改前端 openPlatform 组件,演示签名生成和请求过程 - 引入 js-md5 依赖,用于生成 MD5 签名 --- .../dto/SecurityUnitUseStatisticsDTO.java | 2 + .../support/filter/BodyWrapperFilter.java | 29 +++++ .../CustomHttpServletRequestWrapper.java | 65 ++++++++++ .../interceptor/OpenApiInterceptor.java | 4 + .../support/interceptor/SignInterceptor.java | 122 ++++++++++++++++++ .../main/resources/mapper/OpenApiMapper.xml | 1 + superManagement/package.json | 1 + .../src/views/openPlatform/index.vue | 55 +++++--- 8 files changed, 258 insertions(+), 21 deletions(-) create mode 100644 policeSecurityServer/src/main/java/com/changhu/support/filter/BodyWrapperFilter.java create mode 100644 policeSecurityServer/src/main/java/com/changhu/support/filter/CustomHttpServletRequestWrapper.java create mode 100644 policeSecurityServer/src/main/java/com/changhu/support/interceptor/SignInterceptor.java diff --git a/policeSecurityServer/src/main/java/com/changhu/pojo/dto/SecurityUnitUseStatisticsDTO.java b/policeSecurityServer/src/main/java/com/changhu/pojo/dto/SecurityUnitUseStatisticsDTO.java index 738f06d..185ba4b 100644 --- a/policeSecurityServer/src/main/java/com/changhu/pojo/dto/SecurityUnitUseStatisticsDTO.java +++ b/policeSecurityServer/src/main/java/com/changhu/pojo/dto/SecurityUnitUseStatisticsDTO.java @@ -16,6 +16,8 @@ import lombok.Data; public class SecurityUnitUseStatisticsDTO { @Schema(description = "服务项目id") private Long serviceProjectId; + @Schema(description = "公安单位id") + private Long policeUnitId; @Schema(description = "公安单位名称") private String policeUnitName; @Schema(description = "保安单位名称") diff --git a/policeSecurityServer/src/main/java/com/changhu/support/filter/BodyWrapperFilter.java b/policeSecurityServer/src/main/java/com/changhu/support/filter/BodyWrapperFilter.java new file mode 100644 index 0000000..2acfb14 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/support/filter/BodyWrapperFilter.java @@ -0,0 +1,29 @@ +package com.changhu.support.filter; + +import jakarta.servlet.*; +import jakarta.servlet.http.HttpServletRequest; +import lombok.extern.slf4j.Slf4j; + +import java.io.IOException; + +/** + * @author 20252 + * @createTime 2024/11/19 下午3:07 + * @desc BodyWrapperFilter... + */ +@Slf4j +public class BodyWrapperFilter implements Filter { + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { + ServletRequest requestWrapper = null; + if (servletRequest instanceof HttpServletRequest) { + requestWrapper = new CustomHttpServletRequestWrapper((HttpServletRequest) servletRequest); + } + if (requestWrapper == null) { + filterChain.doFilter(servletRequest, servletResponse); + } else { + filterChain.doFilter(requestWrapper, servletResponse); + } + + } +} diff --git a/policeSecurityServer/src/main/java/com/changhu/support/filter/CustomHttpServletRequestWrapper.java b/policeSecurityServer/src/main/java/com/changhu/support/filter/CustomHttpServletRequestWrapper.java new file mode 100644 index 0000000..a4c11ba --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/support/filter/CustomHttpServletRequestWrapper.java @@ -0,0 +1,65 @@ +package com.changhu.support.filter; + +import jakarta.servlet.ReadListener; +import jakarta.servlet.ServletInputStream; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequestWrapper; + +import java.io.*; +import java.nio.charset.StandardCharsets; + +/** + * @author 20252 + * @createTime 2024/11/19 下午3:12 + * @desc CustomHttpServletRequestWrapper... + */ +public class CustomHttpServletRequestWrapper extends HttpServletRequestWrapper { + private final byte[] body; + + public CustomHttpServletRequestWrapper(HttpServletRequest request) throws IOException { + super(request); + BufferedReader reader = request.getReader(); + try (StringWriter writer = new StringWriter()) { + int read; + char[] buf = new char[1024 * 8]; + while ((read = reader.read(buf)) != -1) { + writer.write(buf, 0, read); + } + this.body = writer.getBuffer().toString().getBytes(); + } + } + + public String getBody() { + return new String(body, StandardCharsets.UTF_8); + } + + @Override + public ServletInputStream getInputStream() { + final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body); + return new ServletInputStream() { + @Override + public boolean isFinished() { + return false; + } + + @Override + public boolean isReady() { + return false; + } + + @Override + public void setReadListener(ReadListener readListener) { + } + + @Override + public int read() { + return byteArrayInputStream.read(); + } + }; + } + + @Override + public BufferedReader getReader() { + return new BufferedReader(new InputStreamReader(this.getInputStream())); + } +} diff --git a/policeSecurityServer/src/main/java/com/changhu/support/interceptor/OpenApiInterceptor.java b/policeSecurityServer/src/main/java/com/changhu/support/interceptor/OpenApiInterceptor.java index e0cc567..99340ff 100644 --- a/policeSecurityServer/src/main/java/com/changhu/support/interceptor/OpenApiInterceptor.java +++ b/policeSecurityServer/src/main/java/com/changhu/support/interceptor/OpenApiInterceptor.java @@ -1,5 +1,6 @@ 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; @@ -23,6 +24,9 @@ public class OpenApiInterceptor implements HandlerInterceptor { @Override public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler) { String header = request.getHeader("X-API-KEY"); + if (StrUtil.isBlank(header)) { + throw new MessageException("请求头缺失"); + } log.info("apiKey:{} {} 请求:{}", header, LocalDateTime.now(), request.getRequestURI()); if (handler instanceof HandlerMethod handlerMethod) { CheckOpenApi methodAnnotation = handlerMethod.getMethodAnnotation(CheckOpenApi.class); diff --git a/policeSecurityServer/src/main/java/com/changhu/support/interceptor/SignInterceptor.java b/policeSecurityServer/src/main/java/com/changhu/support/interceptor/SignInterceptor.java new file mode 100644 index 0000000..4e78e36 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/support/interceptor/SignInterceptor.java @@ -0,0 +1,122 @@ +package com.changhu.support.interceptor; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.URLUtil; +import cn.hutool.crypto.digest.MD5; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson2.TypeReference; +import com.baomidou.mybatisplus.extension.toolkit.Db; +import com.changhu.common.db.enums.IsEnable; +import com.changhu.common.exception.MessageException; +import com.changhu.common.utils.IpUtil; +import com.changhu.pojo.entity.AccessKeys; +import com.changhu.support.filter.CustomHttpServletRequestWrapper; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NotNull; +import org.springframework.web.servlet.HandlerInterceptor; + +import java.nio.charset.StandardCharsets; +import java.time.LocalDateTime; +import java.util.*; + +/** + * @author 20252 + * @createTime 2024/11/19 下午1:58 + * @desc SignInterceptor... + */ +@Slf4j +public class SignInterceptor implements HandlerInterceptor { + + private static final String ACCESS_KEY = "access-key";//调用者身份唯一标识 + private static final String TIMESTAMP = "time-stamp";//时间戳 + private static final String SIGN = "sign";//签名 + + @Override + public boolean preHandle(@NotNull HttpServletRequest request, + @NotNull HttpServletResponse response, + @NotNull Object handler) throws Exception { + String ip = IpUtil.getIp(request); + try { + checkSign(request); + } catch (MessageException e) { + log.error("开放接口访问失败:{} 访问时间:{} IP:{} 访问接口:{} ", e.getMessage(), LocalDateTime.now(), ip, request.getRequestURI()); + throw e; + } + + + return true; + } + + private void checkSign(HttpServletRequest request) throws MessageException { + + String accessKey = request.getHeader(ACCESS_KEY); + String timestamp = request.getHeader(TIMESTAMP); + String sign = request.getHeader(SIGN); + + if (StrUtil.isBlank(accessKey) || StrUtil.isBlank(timestamp) || StrUtil.isBlank(sign)) { + throw new MessageException("请求体缺失"); + } + + AccessKeys accessKeyEntity = Db.lambdaQuery(AccessKeys.class) + .eq(AccessKeys::getAccessKey, accessKey) + .oneOpt() + .orElseThrow(() -> new MessageException("无效的accessKey")); + + if (IsEnable.FALSE.equals(accessKeyEntity.getIsEnable())) { + throw new MessageException("无效的accessKey"); + } + + List allowedResources = Optional.ofNullable(accessKeyEntity.getAllowedResources()).orElseThrow(() -> new MessageException("暂无允许访问的资源")); + if (!allowedResources.contains(request.getRequestURI())) { + throw new MessageException("无效的请求资源"); + } + + Map hashMap = new HashMap<>(); + //添加请求url参数 + Map map = HttpUtil.decodeParamMap(request.getQueryString(), StandardCharsets.UTF_8); + if (!map.isEmpty()) { + hashMap.putAll(map); + } + + hashMap.put(ACCESS_KEY, accessKey); + hashMap.put(TIMESTAMP, timestamp); + //添加body参数 + CustomHttpServletRequestWrapper c = (CustomHttpServletRequestWrapper) request; + Optional.ofNullable(new TypeReference>() { + }.parseObject(c.getBody())).ifPresent(hashMap::putAll); + + String nowSign = generatedSign(hashMap, accessKeyEntity.getSecretKey()); + if (!sign.equals(nowSign)) { + throw new MessageException("签名错误"); + } + } + + /** + * 获取签名 + * + * @param map 参数结果 + * @param secretKey 密钥 + * @return 签名字符串 + */ + private String generatedSign(Map map, String secretKey) { + List> infoIds = new ArrayList<>(map.entrySet()); + infoIds.sort(Map.Entry.comparingByKey()); + + StringBuilder sb = new StringBuilder(); + for (Map.Entry m : infoIds) { + if (null == m.getValue() || StrUtil.isNotBlank(m.getValue().toString())) { + sb.append(m.getKey()).append("=").append(URLUtil.encodeAll(m.getValue().toString())).append("&"); + } + } + sb.append("secret-key=").append(secretKey); + return MD5.create().digestHex(sb.toString()).toUpperCase(); + } + + public static void main(String[] args) { + String str1 = "access-key=w2wzi0wefmmo6s735z2el8tfzitya5gj&addr=%E6%B9%96%E5%8D%97%E7%9C%81%E9%95%BF%E6%B2%99%E5%B8%82&age=14&name=zhangsan&time-stamp=1732067854476&secret-key=db1b5214-02ee-497f-957c-88323b4351bf"; + String str2 = "access-key=w2wzi0wefmmo6s735z2el8tfzitya5gj&addr=%E6%B9%96%E5%8D%97%E7%9C%81%E9%95%BF%E6%B2%99%E5%B8%82&age=14&name=zhangsan&time-stamp=1732067854476&secret-key=db1b5214-02ee-497f-957c-88323b4351bf"; + } + +} diff --git a/policeSecurityServer/src/main/resources/mapper/OpenApiMapper.xml b/policeSecurityServer/src/main/resources/mapper/OpenApiMapper.xml index a792d43..645e7cb 100644 --- a/policeSecurityServer/src/main/resources/mapper/OpenApiMapper.xml +++ b/policeSecurityServer/src/main/resources/mapper/OpenApiMapper.xml @@ -37,6 +37,7 @@ + WITH security_user_counts AS ( + SELECT + service_project_id, + COUNT(1) AS securityUserTotal, + SUM(IF(security_number != '', 1, 0)) AS haveCardSecurityUserCount + FROM + security_user + WHERE delete_flag = 0 + GROUP BY service_project_id ) select - sp.snow_flake_id as 'serviceProjectId', - pu.snow_flake_id as 'policeUnitId', - pu.name as 'policeUnitName', - su.name as 'securityUnitName', - sp.name as 'serviceProjectName', - sp.type as 'type', - sp.two_type as 'twoType', - sp.outsource_name as 'outsourceName', - count(suu.snow_flake_id) as 'securityUserTotal', - SUM(IF(suu.security_number != '', 1, 0)) as 'haveCardSecurityUserCount', - sp.is_filing as 'isFiling', - sp.id_number, - su.legal_person_info as 'securityUnitLegalPersonInfo', - mpu.name as 'serviceProjectManagerName', - mpu.telephone as 'serviceProjectManagerTelephone', + eu.snow_flake_id as 'enterprisesUnitId', + eu.name as 'enterprisesUnitName', ad1.name as 'provinceName', ad2.name as 'cityName', ad3.name as 'districtsName', - ad4.name as 'streetName' - from police_unit pu + ad4.name as 'streetName', + eu.address as 'address', + pu.snow_flake_id as 'policeUnitId', + pu.name as 'policeUnitName', + su.snow_flake_id as 'securityUnitId', + su.name as 'securityUnitName', + su.legal_person_info as 'securityUnitLegalPersonInfo', + mpu.name as 'serviceProjectManagerName', + mpu.telephone as 'serviceProjectManagerTelephone', + json_arrayagg( + json_object( + 'snowFlakeId', sp.snow_flake_id, + 'name', sp.name, + 'type', sp.type, + 'twoType', sp.two_type, + 'outsourceName', sp.outsource_name, + 'isFiling', sp.is_filing, + 'idNumber', sp.id_number, + 'securityUserTotal', suc.securityUserTotal, + 'haveCardSecurityUserCount', suc.haveCardSecurityUserCount + )) as 'serviceProjectList' + from + police_unit pu join enterprises_unit eu on pu.snow_flake_id = eu.police_unit_id and eu.delete_flag = 0 join service_project sp on eu.snow_flake_id = sp.enterprises_unit_id and sp.delete_flag = 0 join security_unit su on sp.security_unit_id = su.snow_flake_id and su.delete_flag = 0 LEFT join mini_program_user mpu on sp.project_manager_mini_program_user_id = mpu.snow_flake_id - LEFT join security_user suu on suu.service_project_id = sp.snow_flake_id and suu.delete_flag = 0 left join administrative_division ad1 on eu.province = ad1.code and ad1.delete_flag = 0 left join administrative_division ad2 on eu.city = ad2.code and ad2.delete_flag = 0 left join administrative_division ad3 on eu.districts = ad3.code and ad3.delete_flag = 0 left join administrative_division ad4 on eu.street = ad4.code and ad4.delete_flag = 0 - - where pu.delete_flag = 0 + left JOIN security_user_counts suc ON sp.snow_flake_id = suc.service_project_id + where + pu.delete_flag = 0 and eu.province = #{code} @@ -85,8 +106,8 @@ and eu.snow_flake_id = -1 - group by sp.snow_flake_id - order by sp.create_time desc + group by eu.snow_flake_id + order by eu.create_time desc - { const accessKey = "w2wzi0wefmmo6s735z2el8tfzitya5gj" const secretKey = "db1b5214-02ee-497f-957c-88323b4351bf" const now = Date.now() - // const params = { - // name: 'zhangsan', - // age: 14, - // addr: '湖南省长沙市' - // } - - // const sign = generatedSign(params, now, accessKey, secretKey) - - // const headers = { - // 'Access-Key': accessKey, - // 'Time-Stamp': now, - // 'Sign': sign - // } - // axios.get('http://127.0.0.1:8765/open/dataView', { - // params, - // headers - // }) - - const params2 = { + const params = { code: 'SSP001', level: 5 } - const sign2 = generatedSign(params2, now, accessKey, secretKey) + const sign = generatedSign(params, now, accessKey, secretKey) const headers2 = { 'Access-Key': accessKey, 'Time-Stamp': now, - 'Sign': sign2 + 'Sign': sign } + console.log(headers2); axios.get('http://127.0.0.1:8765/open/dataView', { - params: params2, + params: params, headers: { ...headers2 } From a2819042dfb5173c6f181280c704497b732480c2 Mon Sep 17 00:00:00 2001 From: luozhun <2025254074@qq.com> Date: Thu, 21 Nov 2024 10:06:30 +0800 Subject: [PATCH 09/12] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E9=85=8D=E7=BD=AE=E5=92=8C=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了 OpenController 中的 @CheckOpenApi 注解 - 更新了 Layout 组件中的标题和 logo 属性 - 修改了路由配置,使用 __APP_INFO.moduleName 替代 __APP_ENV.VITE_APP_MODULE_NAME - 更新了全局类型定义,增加了 __APP_INFO 对象 - 调整了 Vite 环境变量配置,移除了 VITE_APP_MODULE_NAME - 更新了项目名称和版本号 --- .../common/annotation/CheckOpenApi.java | 17 -------- .../com/changhu/common/enums/OpenApiType.java | 22 ---------- .../changhu/controller/OpenController.java | 7 ---- .../interceptor/OpenApiInterceptor.java | 42 ------------------- superManagement/.env.development | 3 +- superManagement/.env.production | 3 +- superManagement/index.html | 2 +- superManagement/package.json | 4 +- .../src/components/layout/Layout.vue | 6 ++- superManagement/src/global.d.ts | 5 +++ superManagement/src/router/index.ts | 2 +- superManagement/src/vite-env.d.ts | 2 - superManagement/vite.config.ts | 10 ++++- 13 files changed, 23 insertions(+), 102 deletions(-) delete mode 100644 policeSecurityServer/src/main/java/com/changhu/common/annotation/CheckOpenApi.java delete mode 100644 policeSecurityServer/src/main/java/com/changhu/common/enums/OpenApiType.java delete mode 100644 policeSecurityServer/src/main/java/com/changhu/support/interceptor/OpenApiInterceptor.java 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(), From 67d19a0885abbe6753f792da5533a935ab42f6d7 Mon Sep 17 00:00:00 2001 From: luozhun <2025254074@qq.com> Date: Thu, 21 Nov 2024 10:12:05 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- superManagement/Jenkinsfile | 12 ++++++------ superManagement/vite.config.ts | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/superManagement/Jenkinsfile b/superManagement/Jenkinsfile index 701910b..8fec2d7 100644 --- a/superManagement/Jenkinsfile +++ b/superManagement/Jenkinsfile @@ -32,13 +32,13 @@ pipeline { remote.password = "${password}" } sshCommand remote: remote, command: 'pwd=$(pwd) echo "ssh连接成功!当前工作目录:$(pwd)"' - sshCommand remote: remote, command: 'echo "删除:superManagement..."' - sshRemove remote: remote, path: '/home/app/apps/1panel/apps/openresty/openresty/www/sites/policeSecurityServer/index/superManagement' - sshCommand remote: remote, command: 'echo "删除:superManagement成功!"' + sshCommand remote: remote, command: 'echo "删除:super_management..."' + sshRemove remote: remote, path: '/home/app/apps/1panel/apps/openresty/openresty/www/sites/policeSecurityServer/index/super_management' + sshCommand remote: remote, command: 'echo "删除:super_management成功!"' - sshCommand remote: remote, command: 'echo "将构建的superManagement发送到服务器..."' - sshPut remote: remote, from: '/var/jenkins_home/workspace/警保联动-超级后台/superManagement/superManagement', into: '/home/app/apps/1panel/apps/openresty/openresty/www/sites/policeSecurityServer/index' - sshCommand remote: remote, command: 'echo "superManagement发送成功!"' + sshCommand remote: remote, command: 'echo "将构建的super_management发送到服务器..."' + sshPut remote: remote, from: '/var/jenkins_home/workspace/警保联动-超级后台/superManagement/super_management', into: '/home/app/apps/1panel/apps/openresty/openresty/www/sites/policeSecurityServer/index' + sshCommand remote: remote, command: 'echo "super_management发送成功!"' } } } diff --git a/superManagement/vite.config.ts b/superManagement/vite.config.ts index c77fd50..03c2a9e 100644 --- a/superManagement/vite.config.ts +++ b/superManagement/vite.config.ts @@ -4,7 +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' +import {appName, version, name as moduleName} from './package.json' const pathSrc = path.resolve(__dirname, 'src'); @@ -15,12 +15,12 @@ export default defineConfig(({mode}) => { define: { __APP_ENV: JSON.stringify(env), __APP_INFO: JSON.stringify({ - moduleName: name, + moduleName, appName, version }) }, - base: `/${name}/`, + base: `/${moduleName}/`, plugins: [ vue(), vueJsx(), @@ -49,7 +49,7 @@ export default defineConfig(({mode}) => { } }, build: { - outDir: env['VITE_APP_MODULE_NAME'], + outDir: moduleName, target: 'modules', chunkSizeWarningLimit: 1500, minify: 'terser', From 5bb44b0dc2fa34db89495c4c75e1e836969f4f19 Mon Sep 17 00:00:00 2001 From: luozhun <2025254074@qq.com> Date: Thu, 21 Nov 2024 10:55:12 +0800 Subject: [PATCH 11/12] =?UTF-8?q?refactor(open-api):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E5=AE=89=E4=BF=9D=E4=BA=BA=E5=91=98=E8=8A=B1=E5=90=8D=E5=86=8C?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改接口名称,支持事业单位和服务项目的安保人员花名册查询 - 新增枚举类 EnterPrisesUnitOrServiceProjectType 表示查询类型 - 更新 mapper 和 service层相应方法 - 重命名相关 DTO 类 --- .../controller/AccessKeysController.java | 20 ---------------- .../changhu/controller/OpenController.java | 12 ++++++---- .../com/changhu/mapper/OpenApiMapper.java | 9 ++++--- ...terDTO.java => SecurityUserRosterDTO.java} | 4 ++-- .../EnterprisesUnitOrServiceProjectType.java | 16 +++++++++++++ .../com/changhu/service/OpenApiService.java | 8 ++++--- .../service/impl/OpenApiServiceImpl.java | 7 +++--- .../main/resources/mapper/OpenApiMapper.xml | 24 +++++++++++++------ 8 files changed, 55 insertions(+), 45 deletions(-) rename policeSecurityServer/src/main/java/com/changhu/pojo/dto/{ServiceProjectSecurityUserRosterDTO.java => SecurityUserRosterDTO.java} (91%) create mode 100644 policeSecurityServer/src/main/java/com/changhu/pojo/params/EnterprisesUnitOrServiceProjectType.java diff --git a/policeSecurityServer/src/main/java/com/changhu/controller/AccessKeysController.java b/policeSecurityServer/src/main/java/com/changhu/controller/AccessKeysController.java index 5b3efb4..f532e46 100644 --- a/policeSecurityServer/src/main/java/com/changhu/controller/AccessKeysController.java +++ b/policeSecurityServer/src/main/java/com/changhu/controller/AccessKeysController.java @@ -2,7 +2,6 @@ package com.changhu.controller; import cn.hutool.core.annotation.AnnotationUtil; import cn.hutool.core.lang.Dict; -import com.alibaba.fastjson2.JSON; import com.changhu.common.annotation.CheckUserType; import com.changhu.common.annotation.JsonBody; import com.changhu.common.db.enums.UserType; @@ -67,23 +66,4 @@ public class AccessKeysController { return accessKeysService.list(); } - public static void main(String[] args) { - Class openControllerClass = OpenController.class; - RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(openControllerClass, RequestMapping.class); - String controllerPath = requestMapping.value()[0]; - - List> method = Arrays.stream(openControllerClass.getMethods()) - .filter(m -> AnnotationUtil.hasAnnotation(m, RequestMapping.class)) - .map(m -> { - Operation operation = m.getAnnotation(Operation.class); - RequestMapping mReq = AnnotatedElementUtils.findMergedAnnotation(m, RequestMapping.class); - return SelectNodeVo.builder() - .value(controllerPath + mReq.value()[0]) - .label(operation.summary()) - .extData(Dict.of("method", mReq.method())) - .build(); - }) - .toList(); - method.forEach(i -> System.out.println(JSON.toJSONString(i))); - } } diff --git a/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java b/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java index 250694a..fc81c3a 100644 --- a/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java +++ b/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java @@ -5,7 +5,8 @@ import com.changhu.common.pojo.vo.SelectNodeVo; import com.changhu.pojo.dto.DataViewDTO; import com.changhu.pojo.dto.EnterprisesUnitDetailDTO; import com.changhu.pojo.dto.SecurityUnitUseStatisticsDTO; -import com.changhu.pojo.dto.ServiceProjectSecurityUserRosterDTO; +import com.changhu.pojo.dto.SecurityUserRosterDTO; +import com.changhu.pojo.params.EnterprisesUnitOrServiceProjectType; import com.changhu.service.OpenApiService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Schema; @@ -56,10 +57,11 @@ public class OpenController { return openApiService.securityUnitUseStatistics(code, level); } - @Operation(summary = "服务项目安保人员花名册") - @GetMapping("/serviceProjectUserRoster") - public List serviceProjectUserRoster(@Schema(description = "服务项目id") Long serviceProjectId) { - return openApiService.serviceProjectUserRoster(serviceProjectId); + @Operation(summary = "安保人员花名册") + @GetMapping("/securityUserRoster") + public List securityUserRoster(@Schema(description = "事业单位或服务项目id") Long id, + @Schema(description = "类型") EnterprisesUnitOrServiceProjectType type) { + return openApiService.securityUserRoster(id, type); } } diff --git a/policeSecurityServer/src/main/java/com/changhu/mapper/OpenApiMapper.java b/policeSecurityServer/src/main/java/com/changhu/mapper/OpenApiMapper.java index 0155597..6ea93e8 100644 --- a/policeSecurityServer/src/main/java/com/changhu/mapper/OpenApiMapper.java +++ b/policeSecurityServer/src/main/java/com/changhu/mapper/OpenApiMapper.java @@ -2,7 +2,8 @@ package com.changhu.mapper; import com.changhu.common.pojo.vo.SelectNodeVo; import com.changhu.pojo.dto.SecurityUnitUseStatisticsDTO; -import com.changhu.pojo.dto.ServiceProjectSecurityUserRosterDTO; +import com.changhu.pojo.dto.SecurityUserRosterDTO; +import com.changhu.pojo.params.EnterprisesUnitOrServiceProjectType; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -38,9 +39,7 @@ public interface OpenApiMapper { /** * 获取服务人员花名册 - * - * @param serviceProjectId 服务项目id - * @return 结果 */ - List serviceProjectUserRoster(@Param("serviceProjectId") Long serviceProjectId); + List securityUserRoster(@Param("id") Long id, + @Param("type") EnterprisesUnitOrServiceProjectType type); } diff --git a/policeSecurityServer/src/main/java/com/changhu/pojo/dto/ServiceProjectSecurityUserRosterDTO.java b/policeSecurityServer/src/main/java/com/changhu/pojo/dto/SecurityUserRosterDTO.java similarity index 91% rename from policeSecurityServer/src/main/java/com/changhu/pojo/dto/ServiceProjectSecurityUserRosterDTO.java rename to policeSecurityServer/src/main/java/com/changhu/pojo/dto/SecurityUserRosterDTO.java index e923057..1f5ad27 100644 --- a/policeSecurityServer/src/main/java/com/changhu/pojo/dto/ServiceProjectSecurityUserRosterDTO.java +++ b/policeSecurityServer/src/main/java/com/changhu/pojo/dto/SecurityUserRosterDTO.java @@ -9,10 +9,10 @@ import lombok.Data; /** * @author 20252 * @createTime 2024/11/18 上午10:43 - * @desc ServiceProjectSecurityUserRosterDTO... + * @desc SecurityUserRosterDTO... */ @Data -public class ServiceProjectSecurityUserRosterDTO { +public class SecurityUserRosterDTO { @Schema(description = "id") private Long snowFlakeId; @Schema(description = "名称") diff --git a/policeSecurityServer/src/main/java/com/changhu/pojo/params/EnterprisesUnitOrServiceProjectType.java b/policeSecurityServer/src/main/java/com/changhu/pojo/params/EnterprisesUnitOrServiceProjectType.java new file mode 100644 index 0000000..f6c7190 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/pojo/params/EnterprisesUnitOrServiceProjectType.java @@ -0,0 +1,16 @@ +package com.changhu.pojo.params; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author 20252 + * @createTime 2024/11/21 上午10:35 + * @desc EnterprisesUnitOrServiceProjectType... + */ +@Getter +@AllArgsConstructor +public enum EnterprisesUnitOrServiceProjectType { + ENTERPRISES_UNIT, + SERVICE_PROJECT +} diff --git a/policeSecurityServer/src/main/java/com/changhu/service/OpenApiService.java b/policeSecurityServer/src/main/java/com/changhu/service/OpenApiService.java index 48a4a72..41b8be9 100644 --- a/policeSecurityServer/src/main/java/com/changhu/service/OpenApiService.java +++ b/policeSecurityServer/src/main/java/com/changhu/service/OpenApiService.java @@ -4,7 +4,8 @@ import com.changhu.common.pojo.vo.SelectNodeVo; import com.changhu.pojo.dto.DataViewDTO; import com.changhu.pojo.dto.EnterprisesUnitDetailDTO; import com.changhu.pojo.dto.SecurityUnitUseStatisticsDTO; -import com.changhu.pojo.dto.ServiceProjectSecurityUserRosterDTO; +import com.changhu.pojo.dto.SecurityUserRosterDTO; +import com.changhu.pojo.params.EnterprisesUnitOrServiceProjectType; import java.util.List; @@ -50,8 +51,9 @@ public interface OpenApiService { /** * 服务项目安保人员花名册 * - * @param serviceProjectId 服务项目id + * @param id 事业单位服务项目id + * @param type 类型 * @return 花名册 */ - List serviceProjectUserRoster(Long serviceProjectId); + List securityUserRoster(Long id, EnterprisesUnitOrServiceProjectType type); } diff --git a/policeSecurityServer/src/main/java/com/changhu/service/impl/OpenApiServiceImpl.java b/policeSecurityServer/src/main/java/com/changhu/service/impl/OpenApiServiceImpl.java index a7063e4..6f18a87 100644 --- a/policeSecurityServer/src/main/java/com/changhu/service/impl/OpenApiServiceImpl.java +++ b/policeSecurityServer/src/main/java/com/changhu/service/impl/OpenApiServiceImpl.java @@ -12,7 +12,8 @@ import com.changhu.module.miniProgram.pojo.entity.SecurityUser; import com.changhu.pojo.dto.DataViewDTO; import com.changhu.pojo.dto.EnterprisesUnitDetailDTO; import com.changhu.pojo.dto.SecurityUnitUseStatisticsDTO; -import com.changhu.pojo.dto.ServiceProjectSecurityUserRosterDTO; +import com.changhu.pojo.dto.SecurityUserRosterDTO; +import com.changhu.pojo.params.EnterprisesUnitOrServiceProjectType; import com.changhu.service.OpenApiService; import com.changhu.support.mybatisplus.pojo.entity.BaseEntity; import lombok.SneakyThrows; @@ -103,7 +104,7 @@ public class OpenApiServiceImpl implements OpenApiService { } @Override - public List serviceProjectUserRoster(Long serviceProjectId) { - return openApiMapper.serviceProjectUserRoster(serviceProjectId); + public List securityUserRoster(Long id, EnterprisesUnitOrServiceProjectType type) { + return openApiMapper.securityUserRoster(id, type); } } diff --git a/policeSecurityServer/src/main/resources/mapper/OpenApiMapper.xml b/policeSecurityServer/src/main/resources/mapper/OpenApiMapper.xml index af35578..5727ae3 100644 --- a/policeSecurityServer/src/main/resources/mapper/OpenApiMapper.xml +++ b/policeSecurityServer/src/main/resources/mapper/OpenApiMapper.xml @@ -105,8 +105,8 @@ group by eu.snow_flake_id order by eu.create_time desc - select su.snow_flake_id, su.name, su.sex, @@ -116,12 +116,22 @@ eu.name as 'enterprisesUnitName', suu.name as 'securityUnitName', su.security_number - from enterprises_unit eu - left join service_project sp on sp.enterprises_unit_id = eu.snow_flake_id and sp.delete_flag = 0 - left join security_user su on su.service_project_id = sp.snow_flake_id and su.delete_flag = 0 - left join security_unit suu on su.security_unit_id = suu.snow_flake_id and suu.delete_flag = 0 + from enterprises_unit eu + LEFT JOIN service_project sp ON sp.enterprises_unit_id = eu.snow_flake_id AND sp.delete_flag = 0 + JOIN security_user su ON su.service_project_id = sp.snow_flake_id AND su.delete_flag = 0 + LEFT JOIN security_unit suu ON su.security_unit_id = suu.snow_flake_id AND suu.delete_flag = 0 where eu.delete_flag = 0 - and sp.snow_flake_id = #{serviceProjectId} + + + and eu.snow_flake_id = #{id} + + + and sp.snow_flake_id = #{id} + + + and eu.snow_flake_id = -1 + + order by su.create_time desc \ No newline at end of file From 00c6b0409f7d7ff6789fdabe53d55c561f93bf69 Mon Sep 17 00:00:00 2001 From: luozhun <2025254074@qq.com> Date: Thu, 21 Nov 2024 14:16:22 +0800 Subject: [PATCH 12/12] =?UTF-8?q?refactor(superManagement):=20=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E8=B6=85=E7=BA=A7=E5=90=8E=E5=8F=B0=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E5=B1=95=E7=A4=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 MapVisionParams 类用于地图视野参数 - 移除 EnterprisesUnitController 中的 mapPoint 方法 - 新增 SuperIndexController、SuperIndexMapper 和 SuperIndexService - 更新 SecurityUnitUseStatisticsDTO,添加省市区街道编码字段 - 优化 SignInterceptor 中的签名生成和验证逻辑 - 更新 OpenApiMapper.xml,移除冗余的删除标志条件 - 重构 MapContainer组件,移除初始化地图样式- 更新路由配置,移除数据总览菜单项 - 重命名 EnterprisesUnitInfoWindowContent 组件 - 重构数据总览页面,改为在首页展示地图信息 --- .../common/pojo/params/MapVisionParams.java | 22 ++++ .../controller/EnterprisesUnitController.java | 7 -- .../controller/SuperIndexController.java | 34 ++++++ .../mapper/SuperIndexMapper.java | 12 ++ .../service/SuperIndexService.java | 9 ++ .../service/impl/SuperIndexServiceImpl.java | 13 ++ .../dto/SecurityUnitUseStatisticsDTO.java | 8 ++ .../support/interceptor/SignInterceptor.java | 26 ++-- .../mapper/CkAssessmentRecordMapper.xml | 4 +- .../main/resources/mapper/OpenApiMapper.xml | 4 + .../src/components/aMap/MapContainer.vue | 1 - superManagement/src/config/index.ts | 7 -- .../views/{data/dataOverview.ts => index.ts} | 0 .../EnterprisesUnitInfoWindowContent.vue | 2 +- .../src/views/data/dataOverview.vue | 112 ------------------ superManagement/src/views/index.vue | 103 +++++++++++++++- .../src/views/openPlatform/index.vue | 4 +- 17 files changed, 217 insertions(+), 151 deletions(-) create mode 100644 policeSecurityServer/src/main/java/com/changhu/common/pojo/params/MapVisionParams.java create mode 100644 policeSecurityServer/src/main/java/com/changhu/module/superManagement/controller/SuperIndexController.java create mode 100644 policeSecurityServer/src/main/java/com/changhu/module/superManagement/mapper/SuperIndexMapper.java create mode 100644 policeSecurityServer/src/main/java/com/changhu/module/superManagement/service/SuperIndexService.java create mode 100644 policeSecurityServer/src/main/java/com/changhu/module/superManagement/service/impl/SuperIndexServiceImpl.java rename superManagement/src/types/views/{data/dataOverview.ts => index.ts} (100%) rename superManagement/src/views/{data => }/components/EnterprisesUnitInfoWindowContent.vue (94%) delete mode 100644 superManagement/src/views/data/dataOverview.vue diff --git a/policeSecurityServer/src/main/java/com/changhu/common/pojo/params/MapVisionParams.java b/policeSecurityServer/src/main/java/com/changhu/common/pojo/params/MapVisionParams.java new file mode 100644 index 0000000..4842296 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/common/pojo/params/MapVisionParams.java @@ -0,0 +1,22 @@ +package com.changhu.common.pojo.params; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.locationtech.jts.geom.Point; + +/** + * @author 20252 + * @createTime 2024/11/21 上午11:18 + * @desc MapVisionParams... + */ +@Data +public class MapVisionParams { + @Schema(description = "左上角") + private Point upperLeft; + @Schema(description = "右上角") + private Point upperRight; + @Schema(description = "左下角") + private Point lowerLeft; + @Schema(description = "右下角") + private Point lowerRight; +} diff --git a/policeSecurityServer/src/main/java/com/changhu/module/management/controller/EnterprisesUnitController.java b/policeSecurityServer/src/main/java/com/changhu/module/management/controller/EnterprisesUnitController.java index 54ea62d..0159312 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/management/controller/EnterprisesUnitController.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/management/controller/EnterprisesUnitController.java @@ -6,7 +6,6 @@ import com.changhu.common.annotation.JsonBody; import com.changhu.common.db.enums.UserType; import com.changhu.common.exception.MessageException; import com.changhu.common.pojo.vo.SelectNodeVo; -import com.changhu.module.management.pojo.entity.EnterprisesUnit; import com.changhu.module.management.pojo.params.EnterprisesUnitSaveOrUpdateParams; import com.changhu.module.management.pojo.queryParams.EnterprisesUnitPagerQueryParams; import com.changhu.module.management.pojo.vo.EnterprisesUnitPagerVo; @@ -64,10 +63,4 @@ public class EnterprisesUnitController { return enterprisesUnitService.queryListByAdministrativeDivisionCodes(administrativeDivisionCodes); } - @Operation(summary = "企事业单位地图点位") - @GetMapping("/mapPoint") - public List mapPoint() { - return enterprisesUnitService.list(); - } - } diff --git a/policeSecurityServer/src/main/java/com/changhu/module/superManagement/controller/SuperIndexController.java b/policeSecurityServer/src/main/java/com/changhu/module/superManagement/controller/SuperIndexController.java new file mode 100644 index 0000000..46193f1 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/module/superManagement/controller/SuperIndexController.java @@ -0,0 +1,34 @@ +package com.changhu.module.superManagement.controller; + +import com.baomidou.mybatisplus.extension.toolkit.Db; +import com.changhu.common.annotation.JsonBody; +import com.changhu.module.management.pojo.entity.EnterprisesUnit; +import com.changhu.module.superManagement.service.SuperIndexService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +import java.util.List; + +/** + * @author 20252 + * @createTime 2024/11/21 上午11:31 + * @desc SuperIndexController... + */ +@JsonBody +@Tag(name = "超级后台首页") +@RequestMapping("/super/index") +public class SuperIndexController { + + @Autowired + private SuperIndexService superIndexService; + + @Operation(summary = "企事业单位地图点位") + @GetMapping("/mapPoint") + public List mapPoint() { + return Db.lambdaQuery(EnterprisesUnit.class).list(); + } + +} diff --git a/policeSecurityServer/src/main/java/com/changhu/module/superManagement/mapper/SuperIndexMapper.java b/policeSecurityServer/src/main/java/com/changhu/module/superManagement/mapper/SuperIndexMapper.java new file mode 100644 index 0000000..02d546e --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/module/superManagement/mapper/SuperIndexMapper.java @@ -0,0 +1,12 @@ +package com.changhu.module.superManagement.mapper; + +import org.apache.ibatis.annotations.Mapper; + +/** + * @author 20252 + * @createTime 2024/11/21 上午11:32 + * @desc SuperIndexMapper... + */ +@Mapper +public interface SuperIndexMapper { +} diff --git a/policeSecurityServer/src/main/java/com/changhu/module/superManagement/service/SuperIndexService.java b/policeSecurityServer/src/main/java/com/changhu/module/superManagement/service/SuperIndexService.java new file mode 100644 index 0000000..acd631a --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/module/superManagement/service/SuperIndexService.java @@ -0,0 +1,9 @@ +package com.changhu.module.superManagement.service; + +/** + * @author 20252 + * @createTime 2024/11/21 上午11:31 + * @desc SuperIndexService... + */ +public interface SuperIndexService { +} diff --git a/policeSecurityServer/src/main/java/com/changhu/module/superManagement/service/impl/SuperIndexServiceImpl.java b/policeSecurityServer/src/main/java/com/changhu/module/superManagement/service/impl/SuperIndexServiceImpl.java new file mode 100644 index 0000000..ba7c7b4 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/module/superManagement/service/impl/SuperIndexServiceImpl.java @@ -0,0 +1,13 @@ +package com.changhu.module.superManagement.service.impl; + +import com.changhu.module.superManagement.service.SuperIndexService; +import org.springframework.stereotype.Service; + +/** + * @author 20252 + * @createTime 2024/11/21 上午11:31 + * @desc SuperIndexServiceImpl... + */ +@Service +public class SuperIndexServiceImpl implements SuperIndexService { +} diff --git a/policeSecurityServer/src/main/java/com/changhu/pojo/dto/SecurityUnitUseStatisticsDTO.java b/policeSecurityServer/src/main/java/com/changhu/pojo/dto/SecurityUnitUseStatisticsDTO.java index ad95b65..edea21e 100644 --- a/policeSecurityServer/src/main/java/com/changhu/pojo/dto/SecurityUnitUseStatisticsDTO.java +++ b/policeSecurityServer/src/main/java/com/changhu/pojo/dto/SecurityUnitUseStatisticsDTO.java @@ -20,12 +20,20 @@ public class SecurityUnitUseStatisticsDTO { private Long enterprisesUnitId; @Schema(description = "事业单位名称") private String enterprisesUnitName; + @Schema(description = "省编码") + private String province; @Schema(description = "省") private String provinceName; + @Schema(description = "市编码") + private String city; @Schema(description = "市") private String cityName; + @Schema(description = "区/县编码") + private String districts; @Schema(description = "区/县") private String districtsName; + @Schema(description = "街道编码") + private String street; @Schema(description = "街道") private String streetName; @Schema(description = "事业单位详细地址") diff --git a/policeSecurityServer/src/main/java/com/changhu/support/interceptor/SignInterceptor.java b/policeSecurityServer/src/main/java/com/changhu/support/interceptor/SignInterceptor.java index 5b668bd..ec6be4b 100644 --- a/policeSecurityServer/src/main/java/com/changhu/support/interceptor/SignInterceptor.java +++ b/policeSecurityServer/src/main/java/com/changhu/support/interceptor/SignInterceptor.java @@ -4,7 +4,7 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.URLUtil; import cn.hutool.crypto.digest.MD5; import cn.hutool.http.HttpUtil; -import com.alibaba.fastjson2.TypeReference; +import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.extension.toolkit.Db; import com.changhu.common.db.enums.IsEnable; import com.changhu.common.exception.MessageException; @@ -67,7 +67,7 @@ public class SignInterceptor implements HandlerInterceptor { .orElseThrow(() -> new MessageException("无效的accessKey")); if (IsEnable.FALSE.equals(accessKeyEntity.getIsEnable())) { - throw new MessageException("无效的accessKey"); + throw new MessageException("accessKey已禁用"); } if (accessKeyEntity.getEffectiveTime() > 0 && System.currentTimeMillis() - Long.parseLong(timestamp) > accessKeyEntity.getEffectiveTime()) { @@ -80,20 +80,17 @@ public class SignInterceptor implements HandlerInterceptor { } Map hashMap = new HashMap<>(); - //添加请求url参数 - Map map = HttpUtil.decodeParamMap(request.getQueryString(), StandardCharsets.UTF_8); - if (!map.isEmpty()) { - hashMap.putAll(map); - } - hashMap.put(ACCESS_KEY, accessKey); hashMap.put(TIMESTAMP, timestamp); + //添加请求url参数 + Optional.ofNullable(HttpUtil.decodeParamMap(request.getQueryString(), StandardCharsets.UTF_8)) + .ifPresent(hashMap::putAll); //添加body参数 - CustomHttpServletRequestWrapper c = (CustomHttpServletRequestWrapper) request; - Optional.ofNullable(new TypeReference>() { - }.parseObject(c.getBody())).ifPresent(hashMap::putAll); - + Optional.ofNullable(JSON.>parseObject(((CustomHttpServletRequestWrapper) request).getBody(), Map.class)) + .ifPresent(hashMap::putAll); + //生成签名 String nowSign = generatedSign(hashMap, accessKeyEntity.getSecretKey()); + //比对签名 if (!sign.equals(nowSign)) { throw new MessageException("签名错误"); } @@ -118,9 +115,4 @@ public class SignInterceptor implements HandlerInterceptor { return MD5.create().digestHex(str).toUpperCase(); } - public static void main(String[] args) { - String str1 = "Access-Key=w2wzi0wefmmo6s735z2el8tfzitya5gj&addr=%E6%B9%96%E5%8D%97%E7%9C%81%E9%95%BF%E6%B2%99%E5%B8%82&age=14&name=zhangsan&Time-Stamp=1732084303463&Secret-Key=db1b5214-02ee-497f-957c-88323b4351bf"; - String str2 = "Access-Key=w2wzi0wefmmo6s735z2el8tfzitya5gj&addr=%E6%B9%96%E5%8D%97%E7%9C%81%E9%95%BF%E6%B2%99%E5%B8%82&age=14&name=zhangsan&Time-Stamp=1732084303463&Secret-Key=db1b5214-02ee-497f-957c-88323b4351bf"; - } - } diff --git a/policeSecurityServer/src/main/resources/mapper/CkAssessmentRecordMapper.xml b/policeSecurityServer/src/main/resources/mapper/CkAssessmentRecordMapper.xml index bd2c55f..a15893a 100644 --- a/policeSecurityServer/src/main/resources/mapper/CkAssessmentRecordMapper.xml +++ b/policeSecurityServer/src/main/resources/mapper/CkAssessmentRecordMapper.xml @@ -14,8 +14,8 @@ from ck_assessment_record car left join enterprises_unit eu on car.enterprises_unit_id = eu.snow_flake_id and eu.delete_flag = 0 left join ck_project cp on car.ck_project_id = cp.snow_flake_id and cp.delete_flag = 0 - left join mini_program_user mpu on mpu.identity = 'police' and car.create_by = mpu.snow_flake_id and mpu.delete_flag = 0 - left join police_unit pu on mpu.unit_id = pu.snow_flake_id and pu.delete_flag = 0 + left join mini_program_user mpu on mpu.identity = 'police' and car.create_by = mpu.snow_flake_id + left join police_unit pu on mpu.unit_id = pu.snow_flake_id left join ck_assessment_record_details card on car.snow_flake_id = card.ck_assessment_record_id and card.delete_flag = 0 left join ck_standard cs on card.ck_standard_id = cs.snow_flake_id where car.delete_flag = 0 diff --git a/policeSecurityServer/src/main/resources/mapper/OpenApiMapper.xml b/policeSecurityServer/src/main/resources/mapper/OpenApiMapper.xml index 5727ae3..4cfb5da 100644 --- a/policeSecurityServer/src/main/resources/mapper/OpenApiMapper.xml +++ b/policeSecurityServer/src/main/resources/mapper/OpenApiMapper.xml @@ -47,6 +47,10 @@ select eu.snow_flake_id as 'enterprisesUnitId', eu.name as 'enterprisesUnitName', + eu.province, + eu.city, + eu.districts, + eu.street, ad1.name as 'provinceName', ad2.name as 'cityName', ad3.name as 'districtsName', diff --git a/superManagement/src/components/aMap/MapContainer.vue b/superManagement/src/components/aMap/MapContainer.vue index a945b0b..a7a5dd9 100644 --- a/superManagement/src/components/aMap/MapContainer.vue +++ b/superManagement/src/components/aMap/MapContainer.vue @@ -19,7 +19,6 @@ const props = withDefaults(defineProps(), { viewMode: "3D", // 初始化地图级别 zoom: 11, - mapStyle: 'amap://styles/darkblue' } } }) diff --git a/superManagement/src/config/index.ts b/superManagement/src/config/index.ts index 6a32f84..25b5a20 100644 --- a/superManagement/src/config/index.ts +++ b/superManagement/src/config/index.ts @@ -52,13 +52,6 @@ export const SYSTEM_MENUS: SystemMenu[] = [ component: () => import('@/views/unitManage/securityUnit/index.vue') } ] - }, { - title: '数据总览', - name: 'dataOverview', - path: '/dataOverview', - type: 'menu', - isFull: true, - component: () => import('@/views/data/dataOverview.vue') }, { title: '开放平台', name: 'openPlatform', diff --git a/superManagement/src/types/views/data/dataOverview.ts b/superManagement/src/types/views/index.ts similarity index 100% rename from superManagement/src/types/views/data/dataOverview.ts rename to superManagement/src/types/views/index.ts diff --git a/superManagement/src/views/data/components/EnterprisesUnitInfoWindowContent.vue b/superManagement/src/views/components/EnterprisesUnitInfoWindowContent.vue similarity index 94% rename from superManagement/src/views/data/components/EnterprisesUnitInfoWindowContent.vue rename to superManagement/src/views/components/EnterprisesUnitInfoWindowContent.vue index f43361a..92225d6 100644 --- a/superManagement/src/views/data/components/EnterprisesUnitInfoWindowContent.vue +++ b/superManagement/src/views/components/EnterprisesUnitInfoWindowContent.vue @@ -11,7 +11,7 @@ - - diff --git a/superManagement/src/views/index.vue b/superManagement/src/views/index.vue index 9c1e237..db20aa5 100644 --- a/superManagement/src/views/index.vue +++ b/superManagement/src/views/index.vue @@ -1,13 +1,112 @@ diff --git a/superManagement/src/views/openPlatform/index.vue b/superManagement/src/views/openPlatform/index.vue index d9320f0..1dbc3aa 100644 --- a/superManagement/src/views/openPlatform/index.vue +++ b/superManagement/src/views/openPlatform/index.vue @@ -129,8 +129,8 @@ const a = () => { const secretKey = "db1b5214-02ee-497f-957c-88323b4351bf" const now = Date.now() const params = { - code: 'SSP001', - level: 5 + id: "1855852231820054528", + type: 'ENTERPRISES_UNIT' } const sign = generatedSign(params, now, accessKey, secretKey) const headers2 = {