diff --git a/collect_information/src/pages/projectManager/index/index.vue b/collect_information/src/pages/projectManager/index/index.vue index 7455202..d44d09a 100644 --- a/collect_information/src/pages/projectManager/index/index.vue +++ b/collect_information/src/pages/projectManager/index/index.vue @@ -3,7 +3,7 @@ - + @@ -30,7 +30,7 @@ import Taro from "@tarojs/taro"; import icon from '@/assets/images/project.png' import './index.scss' -const list = ref(['https://storage.360buyimg.com/jdc-article/NutUItaro34.jpg',]) +const list = ref(['/assets/images/01.png',]) const swiperRef = ref() //轮播图 const subModuleList = ref([ { diff --git a/policeSecurityServer/src/main/java/com/changhu/common/annotation/CheckOpenApi.java b/policeSecurityServer/src/main/java/com/changhu/common/annotation/CheckOpenApi.java new file mode 100644 index 0000000..18f25e1 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/common/annotation/CheckOpenApi.java @@ -0,0 +1,17 @@ +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 new file mode 100644 index 0000000..370b5a2 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/common/enums/OpenApiType.java @@ -0,0 +1,21 @@ +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")); + + private final String desc; + private final List openApiKeys; +} diff --git a/policeSecurityServer/src/main/java/com/changhu/common/utils/JavaClassToTsUtil.java b/policeSecurityServer/src/main/java/com/changhu/common/utils/JavaClassToTsUtil.java index c4ded54..059ce7a 100644 --- a/policeSecurityServer/src/main/java/com/changhu/common/utils/JavaClassToTsUtil.java +++ b/policeSecurityServer/src/main/java/com/changhu/common/utils/JavaClassToTsUtil.java @@ -52,8 +52,16 @@ public class JavaClassToTsUtil { * @return ts类型 */ private static String convertJavaTypeToTS(Class type) { - Set> stringList = Set.of(String.class); - Set> boolList = Set.of(Boolean.class, boolean.class); + Set> stringList = Set.of( + String.class, + LocalDateTime.class, + LocalDate.class, + LocalTime.class + ); + Set> boolList = Set.of( + Boolean.class, + boolean.class + ); Set> numberList = Set.of( Integer.class, int.class, Double.class, double.class, @@ -63,15 +71,12 @@ public class JavaClassToTsUtil { BigDecimal.class, Byte.class, byte.class ); - Set> dateList = Set.of(LocalDateTime.class, LocalDate.class, LocalTime.class); if (stringList.contains(type)) { return "string"; } else if (boolList.contains(type)) { return "boolean"; } else if (numberList.contains(type)) { return "number"; - } else if (dateList.contains(type)) { - return "Dayjs"; } else { return "unsupported"; } diff --git a/policeSecurityServer/src/main/java/com/changhu/config/WebConfig.java b/policeSecurityServer/src/main/java/com/changhu/config/WebConfig.java index 8e7b4cb..35c4e95 100644 --- a/policeSecurityServer/src/main/java/com/changhu/config/WebConfig.java +++ b/policeSecurityServer/src/main/java/com/changhu/config/WebConfig.java @@ -3,9 +3,11 @@ package com.changhu.config; import cn.dev33.satoken.interceptor.SaInterceptor; import cn.dev33.satoken.stp.StpUtil; import com.changhu.support.interceptor.JsonBodyInterceptor; +import com.changhu.support.interceptor.OpenApiInterceptor; import com.changhu.support.interceptor.UserTypeInterceptor; import org.jetbrains.annotations.NotNull; import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -25,6 +27,7 @@ public class WebConfig implements WebMvcConfigurer { public WebConfig() { whiteList.add("/common/**"); + whiteList.add("/open/**"); whiteList.add("/test/**"); whiteList.add("/login"); whiteList.add("/logout"); @@ -55,6 +58,20 @@ public class WebConfig implements WebMvcConfigurer { registry.addInterceptor(new JsonBodyInterceptor()); // 注册clientType 拦截器 用于校验当前用户是否匹配操作客户端 registry.addInterceptor(new UserTypeInterceptor()); + // 注册开放接口 拦截器 用于校验第三方是否携带指定apiKey + registry.addInterceptor(new OpenApiInterceptor()) + .addPathPatterns("/open/**"); + } + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOriginPatterns("*") + .allowedMethods("GET", "POST", "OPTION", "PUT", "DELETE") + .allowedHeaders("Content-Type", "X-Requested-With", "accept", "Origin", "Access-Control-Request-Method", + "Access-Control-Request-Headers", "Authorization","Token","*") + .allowCredentials(true) + .maxAge(3600); } @Override diff --git a/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java b/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java new file mode 100644 index 0000000..8ec4b5a --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java @@ -0,0 +1,47 @@ +package com.changhu.controller; + +import cn.hutool.core.util.IdUtil; +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.EnterprisesUnitDetailDTO; +import com.changhu.service.OpenApiService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Schema; +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 org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * @author 20252 + * @createTime 2024/10/9 下午5:02 + * @desc 可以给第三方对接的controller + */ +@Tag(name = "开放接口") +@JsonBody +@RequestMapping("/open") +public class OpenController { + + @Autowired + 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) { + return openApiService.getEnterprisesUnit(code, level); + } + + @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); + } +} diff --git a/policeSecurityServer/src/main/java/com/changhu/module/management/mapper/ServiceProjectMapper.java b/policeSecurityServer/src/main/java/com/changhu/module/management/mapper/ServiceProjectMapper.java index f1af734..a9a22a8 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/management/mapper/ServiceProjectMapper.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/management/mapper/ServiceProjectMapper.java @@ -6,6 +6,8 @@ import com.changhu.module.management.pojo.entity.ServiceProject; import com.changhu.module.management.pojo.queryParams.ServiceProjectPagerQueryParams; import com.changhu.module.management.pojo.vo.ServiceProjectPagerVo; import com.changhu.module.miniProgram.pojo.vo.IndexServiceProjectListVo; +import com.changhu.pojo.dto.EnterprisesUnitDetailDTO; +import com.changhu.pojo.dto.ServiceProjectDTO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -36,4 +38,12 @@ public interface ServiceProjectMapper extends BaseMapper { */ List getServiceProjectList(@Param("policeUnitId") Long policeUnitId, @Param("projectManagerMiniProgramUserId") Long projectManagerMiniProgramUserId); + + /** + * 获取企事业单位下的服务项目 + * + * @param enterprisesUnitId 企事业单位id + * @return 服务项目列表 + */ + List getServiceProjectByEnterprisesUnitId(@Param("enterprisesUnitId") Long enterprisesUnitId); } diff --git a/policeSecurityServer/src/main/java/com/changhu/module/management/service/ServiceProjectService.java b/policeSecurityServer/src/main/java/com/changhu/module/management/service/ServiceProjectService.java index 75ce667..8c9db18 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/management/service/ServiceProjectService.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/management/service/ServiceProjectService.java @@ -6,8 +6,12 @@ import com.changhu.module.management.pojo.entity.ServiceProject; import com.changhu.module.management.pojo.params.ServiceProjectSaveOrUpdateParams; import com.changhu.module.management.pojo.queryParams.ServiceProjectPagerQueryParams; import com.changhu.module.management.pojo.vo.ServiceProjectPagerVo; +import com.changhu.pojo.dto.EnterprisesUnitDetailDTO; +import com.changhu.pojo.dto.ServiceProjectDTO; import com.changhu.support.mybatisplus.pojo.params.PageParams; +import java.util.List; + /** * service_project (服务项目) 服务类 * author: luozhun @@ -29,4 +33,12 @@ public interface ServiceProjectService extends IService { * @param params 参数 */ void saveOrUpdate(ServiceProjectSaveOrUpdateParams params); + + /** + * 获取企事业单位下的服务项目 + * + * @param enterprisesUnitId 企事业单位id + * @return 服务项目列表 + */ + List getServiceProjectByEnterprisesUnitId(Long enterprisesUnitId); } diff --git a/policeSecurityServer/src/main/java/com/changhu/module/management/service/impl/ServiceProjectServiceImpl.java b/policeSecurityServer/src/main/java/com/changhu/module/management/service/impl/ServiceProjectServiceImpl.java index 150b684..d4e6e80 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/management/service/impl/ServiceProjectServiceImpl.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/management/service/impl/ServiceProjectServiceImpl.java @@ -11,9 +11,13 @@ import com.changhu.module.management.pojo.params.ServiceProjectSaveOrUpdateParam import com.changhu.module.management.pojo.queryParams.ServiceProjectPagerQueryParams; import com.changhu.module.management.pojo.vo.ServiceProjectPagerVo; import com.changhu.module.management.service.ServiceProjectService; +import com.changhu.pojo.dto.EnterprisesUnitDetailDTO; +import com.changhu.pojo.dto.ServiceProjectDTO; import com.changhu.support.mybatisplus.pojo.params.PageParams; import org.springframework.stereotype.Service; +import java.util.List; + /** * service_project (服务项目) 服务实现类 * author: luozhun @@ -36,4 +40,9 @@ public class ServiceProjectServiceImpl extends ServiceImpl getServiceProjectByEnterprisesUnitId(Long enterprisesUnitId) { + return baseMapper.getServiceProjectByEnterprisesUnitId(enterprisesUnitId); + } } diff --git a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/entity/SecurityUser.java b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/entity/SecurityUser.java index 76e5d91..d0b0a8c 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/entity/SecurityUser.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/entity/SecurityUser.java @@ -3,6 +3,7 @@ package com.changhu.module.miniProgram.pojo.entity; import java.io.Serial; import java.io.Serializable; +import com.changhu.common.db.enums.Sex; import com.changhu.support.mybatisplus.pojo.entity.BaseEntity; import lombok.Data; import lombok.AllArgsConstructor; @@ -56,7 +57,7 @@ public class SecurityUser extends BaseEntity implements Serializable { /** * 性别 */ - private Integer sex; + private Sex sex; /** * 籍贯 diff --git a/policeSecurityServer/src/main/java/com/changhu/pojo/dto/EnterprisesUnitDetailDTO.java b/policeSecurityServer/src/main/java/com/changhu/pojo/dto/EnterprisesUnitDetailDTO.java new file mode 100644 index 0000000..096f36b --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/pojo/dto/EnterprisesUnitDetailDTO.java @@ -0,0 +1,43 @@ +package com.changhu.pojo.dto; + +import cn.hutool.core.util.DesensitizedUtil; +import com.changhu.common.annotation.Desensitized; +import com.changhu.common.db.enums.IsOrNot; +import com.changhu.common.db.enums.ServiceProjectType; +import com.changhu.common.db.enums.Sex; +import com.changhu.module.management.pojo.model.ContactPersonInfo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * @author 20252 + * @createTime 2024/10/10 上午9:13 + * @desc EnterprisesUnitDetailDTO... + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class EnterprisesUnitDetailDTO { + @Schema(description = "企事业单位id") + private Long snowFlakeId; + @Schema(description = "名字") + private String name; + @Schema(description = "地址") + private String address; + @Schema(description = "联系人") + private ContactPersonInfo contactPersonInfo; + @Schema(description = "备注") + private String remark; + @Schema(description = "创建时间") + private LocalDateTime createTime; + + @Schema(description = "服务项目列表") + private List serviceProjectList; +} diff --git a/policeSecurityServer/src/main/java/com/changhu/pojo/dto/ServiceProjectDTO.java b/policeSecurityServer/src/main/java/com/changhu/pojo/dto/ServiceProjectDTO.java new file mode 100644 index 0000000..7a10a63 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/pojo/dto/ServiceProjectDTO.java @@ -0,0 +1,110 @@ +package com.changhu.pojo.dto; + +import com.alibaba.fastjson2.annotation.JSONField; +import com.changhu.common.db.enums.IsOrNot; +import com.changhu.common.db.enums.ServiceProjectType; +import com.changhu.common.db.enums.Sex; +import com.changhu.module.management.pojo.model.LegalPersonInfo; +import com.changhu.support.fastjson2.serializer.MinioPrefixSerializer; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * @author 20252 + * @createTime 2024/10/10 上午9:35 + * @desc ServiceProjectDTO... + */ +@Data +public class ServiceProjectDTO { + @Schema(description = "服务项目id") + private Long snowFlakeId; + @Schema(description = "项目经理信息") + private ProjectManagerInfo projectManagerInfo; + @Schema(description = "保安单位信息") + private SecurityUnitInfo securityUnitInfo; + @Schema(description = "名字") + private String name; + @Schema(description = "类型") + private ServiceProjectType type; + @Schema(description = "是否自招保安") + private IsOrNot isRecruitSecurity; + @Schema(description = "保安证号") + private String idNumber; + @Schema(description = "服务面积") + private Double serviceArea; + @Schema(description = "楼栋数量") + private Integer buildingTotal; + @Schema(description = "户数") + private Integer houseTotal; + @Schema(description = "工作人员数量") + private Integer staffTotal; + @Schema(description = "保安人员数量") + private Integer securityUserTotal; + @Schema(description = "备注") + private String remark; + @Schema(description = "创建时间") + private LocalDateTime createTime; + + @Schema(description = "保安人员列表") + private List securityUserList; + + @Data + static class SecurityUnitInfo { + @Schema(description = "保安单位名称") + private String name; + @Schema(description = "统一社会编码") + private String socialCode; + @JSONField(serializeUsing = MinioPrefixSerializer.class) + @Schema(description = "营业执照") + private String businessLicense; + @Schema(description = "法人信息") + private LegalPersonInfo legalPersonInfo; + @Schema(description = "详细地址") + private String address; + @Schema(description = "公司性质") + private String nature; + } + + @Data + static class ProjectManagerInfo { + @Schema(description = "名称") + private String name; + @Schema(description = "性别") + private Sex sex; + @Schema(description = "手机号") + private String telephone; + @Schema(description = "身份证") + private String idCard; + } + + @Data + static class SecurityUserInfo { + @Schema(description = "id") + private Long snowFlakeId; + @Schema(description = "名字") + private String name; + @Schema(description = "手机号") + private String telephone; + @Schema(description = "工作岗位") + private String workPost; + @Schema(description = "性别") + private Sex sex; + @Schema(description = "户籍地") + private String nativePlace; + @Schema(description = "身份证") + private String idCard; + @Schema(description = "出身日期") + private java.time.LocalDate dateOfBirth; + @Schema(description = "保安证号") + private String securityNumber; + @Schema(description = "家庭住址") + private String homeAddress; + @Schema(description = "备注") + private String remark; + @Schema(description = "创建时间") + private String createTime; + } +} diff --git a/policeSecurityServer/src/main/java/com/changhu/service/OpenApiService.java b/policeSecurityServer/src/main/java/com/changhu/service/OpenApiService.java new file mode 100644 index 0000000..cb97c56 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/service/OpenApiService.java @@ -0,0 +1,30 @@ +package com.changhu.service; + +import com.changhu.common.pojo.vo.SelectNodeVo; +import com.changhu.pojo.dto.EnterprisesUnitDetailDTO; + +import java.util.List; + +/** + * @author 20252 + * @createTime 2024/10/9 下午5:28 + * @desc 开放接口 + */ +public interface OpenApiService { + /** + * 获取企事业单位列表 + * + * @param code 行政区划代码 + * @param level 行政区划等级 + * @return 企事业单位列表 + */ + List> getEnterprisesUnit(String code, Integer level); + + /** + * 企事业单位详情 + * + * @param enterprisesUnitId 单位id + * @return 企事业单位详情 + */ + EnterprisesUnitDetailDTO enterprisesUnitDetailById(Long enterprisesUnitId); +} diff --git a/policeSecurityServer/src/main/java/com/changhu/service/impl/OpenApiServiceImpl.java b/policeSecurityServer/src/main/java/com/changhu/service/impl/OpenApiServiceImpl.java new file mode 100644 index 0000000..88a3bf4 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/service/impl/OpenApiServiceImpl.java @@ -0,0 +1,60 @@ +package com.changhu.service.impl; + +import com.baomidou.mybatisplus.extension.toolkit.Db; +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.service.ServiceProjectService; +import com.changhu.pojo.dto.EnterprisesUnitDetailDTO; +import com.changhu.pojo.dto.ServiceProjectDTO; +import com.changhu.service.OpenApiService; +import com.changhu.support.mybatisplus.pojo.entity.BaseEntity; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author 20252 + * @createTime 2024/10/9 下午5:29 + * @desc OpenApiServiceImpl... + */ +@Service +public class OpenApiServiceImpl implements OpenApiService { + + @Autowired + private ServiceProjectService serviceProjectService; + + @Override + public List> getEnterprisesUnit(String code, Integer level) { + return Db.lambdaQuery(EnterprisesUnit.class) + .eq(level == 1, EnterprisesUnit::getProvince, code) + .eq(level == 2, EnterprisesUnit::getCity, code) + .eq(level == 3, EnterprisesUnit::getDistricts, code) + .eq(level == 4, EnterprisesUnit::getStreet, code) + .list() + .stream() + .map(item -> SelectNodeVo.builder() + .value(item.getSnowFlakeId()) + .label(item.getName()) + .build()) + .toList(); + } + + @Override + public EnterprisesUnitDetailDTO enterprisesUnitDetailById(Long enterprisesUnitId) { + return Db.lambdaQuery(EnterprisesUnit.class) + .eq(BaseEntity::getSnowFlakeId, enterprisesUnitId) + .oneOpt() + .map(item -> EnterprisesUnitDetailDTO.builder() + .snowFlakeId(item.getSnowFlakeId()) + .name(item.getName()) + .address(item.getAddress()) + .contactPersonInfo(item.getContactPersonInfo()) + .remark(item.getRemark()) + .serviceProjectList(serviceProjectService.getServiceProjectByEnterprisesUnitId(item.getSnowFlakeId())) + .createTime(item.getCreateTime()) + .build()) + .orElseThrow(() -> new MessageException("企事业单位不存在")); + } +} diff --git a/policeSecurityServer/src/main/java/com/changhu/support/fastjson2/serializer/MinioPrefixSerializer.java b/policeSecurityServer/src/main/java/com/changhu/support/fastjson2/serializer/MinioPrefixSerializer.java new file mode 100644 index 0000000..5142540 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/support/fastjson2/serializer/MinioPrefixSerializer.java @@ -0,0 +1,27 @@ +package com.changhu.support.fastjson2.serializer; + +import cn.hutool.extra.spring.SpringUtil; +import com.alibaba.fastjson2.JSONWriter; +import com.alibaba.fastjson2.writer.ObjectWriter; + +import java.lang.reflect.Type; + +/** + * @author 20252 + * @createTime 2024/10/10 下午3:19 + * @desc MinioPrefixSerializer... + */ +public class MinioPrefixSerializer implements ObjectWriter { + + private final String minioPrefix = SpringUtil.getProperty("minio.url"); + + public static final MinioPrefixSerializer instance = new MinioPrefixSerializer(); + + private MinioPrefixSerializer() { + } + + @Override + public void write(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) { + jsonWriter.writeString(minioPrefix + object); + } +} diff --git a/policeSecurityServer/src/main/java/com/changhu/support/interceptor/OpenApiInterceptor.java b/policeSecurityServer/src/main/java/com/changhu/support/interceptor/OpenApiInterceptor.java new file mode 100644 index 0000000..e0cc567 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/support/interceptor/OpenApiInterceptor.java @@ -0,0 +1,38 @@ +package com.changhu.support.interceptor; + +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) { + String header = request.getHeader("X-API-KEY"); + log.info("apiKey:{} {} 请求:{}", header, LocalDateTime.now(), request.getRequestURI()); + if (handler instanceof HandlerMethod handlerMethod) { + 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/policeSecurityServer/src/main/resources/env/dev/application.yml b/policeSecurityServer/src/main/resources/env/dev/application.yml index b52c328..ac28684 100644 --- a/policeSecurityServer/src/main/resources/env/dev/application.yml +++ b/policeSecurityServer/src/main/resources/env/dev/application.yml @@ -23,7 +23,7 @@ knife4j: spring: application: # 服务名称 - name: managementDevServer + name: policeSecurityDevServer servlet: multipart: # 设置单个文件最大大小为500MB @@ -116,7 +116,7 @@ logging: config: classpath:conf/log4j2.xml minio: - url: http://118.253.177.137:9000 + url: https://www.hnjinglian.cn:9000 accessKey: admin secretKey: lonsung301 bucketName: police-security-dev diff --git a/policeSecurityServer/src/main/resources/env/prod/application.yml b/policeSecurityServer/src/main/resources/env/prod/application.yml index 6130758..8a3d696 100644 --- a/policeSecurityServer/src/main/resources/env/prod/application.yml +++ b/policeSecurityServer/src/main/resources/env/prod/application.yml @@ -1,5 +1,5 @@ server: - port: 8090 + port: 8765 springdoc: swagger-ui: @@ -23,10 +23,7 @@ knife4j: spring: application: # 服务名称 - name: managementProdServer - mvc: - # 如果找不到对应的handler 就抛出404异常 - throw-exception-if-no-handler-found: true + name: policeSecurityProdServer servlet: multipart: # 设置单个文件最大大小为500MB @@ -42,9 +39,9 @@ spring: datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://172.10.10.238:3306/management_prod?serverTimezone=Asia/Shanghai&allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false - username: management_prod - password: lonsung301 + url: jdbc:mysql://118.253.177.137:3306/police_security_dev?serverTimezone=Asia/Shanghai&allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + username: police_security_dev + password: GejDeCNj3ZBSNxSP # druid 连接池管理 druid: # 初始化时建立物理连接的个数 @@ -91,17 +88,12 @@ spring: cache: type: redis cache-names: common - mail: - host: smtp.qq.com - port: 587 - username: 2025254074@qq.com - password: vgkvmhlwfogucbfd data: redis: database: 0 - password: lonsung301 + password: redis_csPDNr port: 6380 - host: 172.10.10.238 + host: 118.253.177.137 timeout: 10s lettuce: pool: @@ -124,10 +116,10 @@ logging: config: classpath:conf/log4j2.xml minio: - url: http://172.10.10.238:9000 + url: https://www.hnjinglian.cn:9000 accessKey: admin secretKey: lonsung301 - bucketName: management-prod + bucketName: police-security-dev sa-token: # token 名称(同时也是 cookie 名称) @@ -146,6 +138,16 @@ sa-token: is-log: true # 是否尝试从 cookie 里读取 token is-read-cookie: false + # jwt秘钥 + jwt-secret-key: a29216f8-cd60-4e96-89c5-ab6012159052 + +wx: + miniapp: + #微信小程序的appid + appid: wx0acd1c4fcf94bdd3 + #微信小程序的Secret + secret: 4b700dbacb42ef258537ddc61d964a17 + msgDataFormat: JSON project: env: prod diff --git a/policeSecurityServer/src/main/resources/mapper/ServiceProjectMapper.xml b/policeSecurityServer/src/main/resources/mapper/ServiceProjectMapper.xml index c770498..dbe90f9 100644 --- a/policeSecurityServer/src/main/resources/mapper/ServiceProjectMapper.xml +++ b/policeSecurityServer/src/main/resources/mapper/ServiceProjectMapper.xml @@ -82,4 +82,56 @@ group by eu.snow_flake_id order by any_value(sp.create_time) desc; + + + + + +