diff --git a/acdr-admin/pom.xml b/acdr-admin/pom.xml index 6e1c1f8a..4e14e25a 100644 --- a/acdr-admin/pom.xml +++ b/acdr-admin/pom.xml @@ -25,6 +25,7 @@ yskj-module-acdr + yskj-module-contact ${project.artifactId} diff --git a/acdr-admin/yskj-framework/yskj-spring-boot-starter-security/src/main/java/cn/yskj/linghe/framework/security/config/YskjWebSecurityConfigurerAdapter.java b/acdr-admin/yskj-framework/yskj-spring-boot-starter-security/src/main/java/cn/yskj/linghe/framework/security/config/YskjWebSecurityConfigurerAdapter.java index e4bba626..1d228fa9 100644 --- a/acdr-admin/yskj-framework/yskj-spring-boot-starter-security/src/main/java/cn/yskj/linghe/framework/security/config/YskjWebSecurityConfigurerAdapter.java +++ b/acdr-admin/yskj-framework/yskj-spring-boot-starter-security/src/main/java/cn/yskj/linghe/framework/security/config/YskjWebSecurityConfigurerAdapter.java @@ -123,6 +123,7 @@ public class YskjWebSecurityConfigurerAdapter { // 获得 @PermitAll 带来的 URL 列表,免登录 Multimap permitAllUrls = getPermitAllUrlsFromAnnotations(); + System.out.println(permitAllUrls); // 设置每个请求的权限 httpSecurity // ①:全局共享规则 @@ -140,7 +141,7 @@ public class YskjWebSecurityConfigurerAdapter { .requestMatchers(securityProperties.getPermitAllUrls().toArray(new String[0])).permitAll() // 1.3 设置 App API 无需认证 .requestMatchers(buildAppApi("/**")).permitAll() - .requestMatchers("/pet/**").permitAll() + .requestMatchers("/admin-api/contact/**").permitAll() ) // ②:每个项目的自定义规则 .authorizeHttpRequests(c -> authorizeRequestsCustomizers.forEach(customizer -> customizer.customize(c))) diff --git a/acdr-admin/yskj-module-contact/pom.xml b/acdr-admin/yskj-module-contact/pom.xml new file mode 100644 index 00000000..13bf6162 --- /dev/null +++ b/acdr-admin/yskj-module-contact/pom.xml @@ -0,0 +1,94 @@ + + + 4.0.0 + + cn.yskj.dev + yskj + ${revision} + + + yskj-module-contact + pom + + yskj-module-contact-api + yskj-module-contact-biz + + + + 17 + 17 + UTF-8 + + + + 这个模块用于与其他的Web 项目进行联系 + + + + + cn.yskj.dev + yskj-module-acdr-api + ${revision} + + + + + cn.yskj.dev + yskj-spring-boot-starter-web + + + + org.projectlombok + lombok + provided + + + + cn.yskj.dev + yskj-spring-boot-starter-biz-tenant + + + + + cn.yskj.dev + yskj-spring-boot-starter-security + + + + + cn.yskj.dev + yskj-spring-boot-starter-mybatis + + + + + cn.yskj.dev + yskj-spring-boot-starter-job + + + + + cn.yskj.dev + yskj-spring-boot-starter-test + + + + cn.hutool + hutool-all + + + + cn.yskj.dev + yskj-spring-boot-starter-excel + + + cn.yskj.dev + yskj-module-infra-biz + 2.1.0-snapshot + compile + + + + diff --git a/acdr-admin/yskj-module-contact/yskj-module-contact-api/pom.xml b/acdr-admin/yskj-module-contact/yskj-module-contact-api/pom.xml new file mode 100644 index 00000000..d3e103e3 --- /dev/null +++ b/acdr-admin/yskj-module-contact/yskj-module-contact-api/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + cn.yskj.dev + yskj-module-contact + 2.1.0-snapshot + + + yskj-module-contact-api + + + 17 + 17 + UTF-8 + + + + + cn.yskj.dev + yskj-common + + + + diff --git a/acdr-admin/yskj-module-contact/yskj-module-contact-biz/pom.xml b/acdr-admin/yskj-module-contact/yskj-module-contact-biz/pom.xml new file mode 100644 index 00000000..9da0aad1 --- /dev/null +++ b/acdr-admin/yskj-module-contact/yskj-module-contact-biz/pom.xml @@ -0,0 +1,80 @@ + + + 4.0.0 + + cn.yskj.dev + yskj-module-contact + 2.1.0-snapshot + + + yskj-module-contact-biz + + + 17 + 17 + UTF-8 + + + + + cn.yskj.dev + yskj-module-acdr-api + ${revision} + + + + + cn.yskj.dev + yskj-spring-boot-starter-web + + + + org.projectlombok + lombok + provided + + + + cn.yskj.dev + yskj-spring-boot-starter-biz-tenant + + + + + cn.yskj.dev + yskj-spring-boot-starter-security + + + + + cn.yskj.dev + yskj-spring-boot-starter-mybatis + + + + + cn.yskj.dev + yskj-spring-boot-starter-job + + + + + cn.yskj.dev + yskj-spring-boot-starter-test + + + + cn.yskj.dev + yskj-spring-boot-starter-excel + + + + cn.yskj.dev + yskj-spring-boot-starter-redis + + + + + diff --git a/acdr-admin/yskj-module-contact/yskj-module-contact-biz/src/main/java/cn/yskj/linghe/module/contact/controller/admin/FileContactController.java b/acdr-admin/yskj-module-contact/yskj-module-contact-biz/src/main/java/cn/yskj/linghe/module/contact/controller/admin/FileContactController.java new file mode 100644 index 00000000..f6518ed8 --- /dev/null +++ b/acdr-admin/yskj-module-contact/yskj-module-contact-biz/src/main/java/cn/yskj/linghe/module/contact/controller/admin/FileContactController.java @@ -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 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()))); + } + +} diff --git a/acdr-admin/yskj-module-infra/yskj-module-infra-biz/src/main/java/cn/yskj/linghe/module/infra/controller/app/file/AppFileController.java b/acdr-admin/yskj-module-infra/yskj-module-infra-biz/src/main/java/cn/yskj/linghe/module/infra/controller/app/file/AppFileController.java index d76b04ce..7e897fae 100644 --- a/acdr-admin/yskj-module-infra/yskj-module-infra-biz/src/main/java/cn/yskj/linghe/module/infra/controller/app/file/AppFileController.java +++ b/acdr-admin/yskj-module-infra/yskj-module-infra-biz/src/main/java/cn/yskj/linghe/module/infra/controller/app/file/AppFileController.java @@ -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 io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.security.PermitAll; import lombok.extern.slf4j.Slf4j; 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.RequestMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/acdr-admin/yskj-server/pom.xml b/acdr-admin/yskj-server/pom.xml index 42d6be9b..93691b2f 100644 --- a/acdr-admin/yskj-server/pom.xml +++ b/acdr-admin/yskj-server/pom.xml @@ -128,6 +128,12 @@ ${revision} + + cn.yskj.dev + yskj-module-contact-biz + ${revision} + +