新增模块促使两个SpringBoot 服务之间联系
This commit is contained in:
parent
cf2b9300c4
commit
e51d2019f5
@ -25,6 +25,7 @@
|
|||||||
<!-- <module>yskj-module-erp</module>-->
|
<!-- <module>yskj-module-erp</module>-->
|
||||||
<!-- <module>yskj-module-ai</module>-->
|
<!-- <module>yskj-module-ai</module>-->
|
||||||
<module>yskj-module-acdr</module>
|
<module>yskj-module-acdr</module>
|
||||||
|
<module>yskj-module-contact</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<name>${project.artifactId}</name>
|
<name>${project.artifactId}</name>
|
||||||
|
@ -123,6 +123,7 @@ public class YskjWebSecurityConfigurerAdapter {
|
|||||||
|
|
||||||
// 获得 @PermitAll 带来的 URL 列表,免登录
|
// 获得 @PermitAll 带来的 URL 列表,免登录
|
||||||
Multimap<HttpMethod, String> permitAllUrls = getPermitAllUrlsFromAnnotations();
|
Multimap<HttpMethod, String> permitAllUrls = getPermitAllUrlsFromAnnotations();
|
||||||
|
System.out.println(permitAllUrls);
|
||||||
// 设置每个请求的权限
|
// 设置每个请求的权限
|
||||||
httpSecurity
|
httpSecurity
|
||||||
// ①:全局共享规则
|
// ①:全局共享规则
|
||||||
@ -140,7 +141,7 @@ public class YskjWebSecurityConfigurerAdapter {
|
|||||||
.requestMatchers(securityProperties.getPermitAllUrls().toArray(new String[0])).permitAll()
|
.requestMatchers(securityProperties.getPermitAllUrls().toArray(new String[0])).permitAll()
|
||||||
// 1.3 设置 App API 无需认证
|
// 1.3 设置 App API 无需认证
|
||||||
.requestMatchers(buildAppApi("/**")).permitAll()
|
.requestMatchers(buildAppApi("/**")).permitAll()
|
||||||
.requestMatchers("/pet/**").permitAll()
|
.requestMatchers("/admin-api/contact/**").permitAll()
|
||||||
)
|
)
|
||||||
// ②:每个项目的自定义规则
|
// ②:每个项目的自定义规则
|
||||||
.authorizeHttpRequests(c -> authorizeRequestsCustomizers.forEach(customizer -> customizer.customize(c)))
|
.authorizeHttpRequests(c -> authorizeRequestsCustomizers.forEach(customizer -> customizer.customize(c)))
|
||||||
|
94
acdr-admin/yskj-module-contact/pom.xml
Normal file
94
acdr-admin/yskj-module-contact/pom.xml
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>yskj-module-contact</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<modules>
|
||||||
|
<module>yskj-module-contact-api</module>
|
||||||
|
<module>yskj-module-contact-biz</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
这个模块用于与其他的Web 项目进行联系
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-module-acdr-api</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Web 相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-spring-boot-starter-biz-tenant</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Web 相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- DB 相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-spring-boot-starter-mybatis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Job 相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-spring-boot-starter-job</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Test 测试相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-spring-boot-starter-test</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-spring-boot-starter-excel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-module-infra-biz</artifactId>
|
||||||
|
<version>2.1.0-snapshot</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-module-contact</artifactId>
|
||||||
|
<version>2.1.0-snapshot</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>yskj-module-contact-api</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,80 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-module-contact</artifactId>
|
||||||
|
<version>2.1.0-snapshot</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>yskj-module-contact-biz</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-module-acdr-api</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Web 相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-spring-boot-starter-biz-tenant</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Web 相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- DB 相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-spring-boot-starter-mybatis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Job 相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-spring-boot-starter-job</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Test 测试相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-spring-boot-starter-test</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-spring-boot-starter-excel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-spring-boot-starter-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,50 @@
|
|||||||
|
package cn.yskj.linghe.module.contact.controller.admin;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import cn.yskj.linghe.framework.common.pojo.CommonResult;
|
||||||
|
import cn.yskj.linghe.module.infra.controller.admin.file.vo.file.FileUploadReqVO;
|
||||||
|
import cn.yskj.linghe.module.infra.service.file.FileService;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import static cn.yskj.linghe.framework.common.exception.enums.GlobalErrorCodeConstants.FORBIDDEN;
|
||||||
|
import static cn.yskj.linghe.framework.common.pojo.CommonResult.error;
|
||||||
|
import static cn.yskj.linghe.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
@Tag(name = "开放模块,开放文件上传给其他应用")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/contact/file")
|
||||||
|
@Validated
|
||||||
|
public class FileContactController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FileService fileService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private StringRedisTemplate stringRedisTemplate;
|
||||||
|
|
||||||
|
@PostMapping("/upload")
|
||||||
|
@Operation(summary = "上传文件", description = "模式一:后端上传文件")
|
||||||
|
public CommonResult<String> uploadFile(FileUploadReqVO uploadReqVO) throws Exception {
|
||||||
|
String key = stringRedisTemplate.opsForValue().get("backstage-contact");
|
||||||
|
Assert.notNull(key);
|
||||||
|
// 原始储存的密码会出现 ""linghe2024"" 这种情况
|
||||||
|
String keyNew = key.replaceAll("\"", "");
|
||||||
|
if (!keyNew.equals("linghe2024")) {
|
||||||
|
return error(FORBIDDEN.getCode(), "方法未认证");
|
||||||
|
}
|
||||||
|
MultipartFile file = uploadReqVO.getFile();
|
||||||
|
String path = uploadReqVO.getPath();
|
||||||
|
return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -6,8 +6,10 @@ import cn.yskj.linghe.module.infra.controller.app.file.vo.AppFileUploadReqVO;
|
|||||||
import cn.yskj.linghe.module.infra.service.file.FileService;
|
import cn.yskj.linghe.module.infra.service.file.FileService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.security.PermitAll;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
@ -128,6 +128,12 @@
|
|||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.yskj.dev</groupId>
|
||||||
|
<artifactId>yskj-module-contact-biz</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
Loading…
Reference in New Issue
Block a user