From 466798d1aadfbfa762ec7bb5584eabab56c1220a Mon Sep 17 00:00:00 2001 From: panqihua Date: Fri, 10 Feb 2023 00:03:18 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E8=AE=BE=E7=BD=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/PlatformConfigController.java | 30 +++++++++++++++++++ .../src/main/resources/application.yml | 2 +- .../ruoyi/common/enums/PlatformConfig.java | 23 ++++++++++++++ .../framework/config/SecurityConfig.java | 16 +++++----- 4 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/platform/config/PlatformConfigController.java create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/enums/PlatformConfig.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/platform/config/PlatformConfigController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/platform/config/PlatformConfigController.java new file mode 100644 index 0000000..f92efd0 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/platform/config/PlatformConfigController.java @@ -0,0 +1,30 @@ +package com.ruoyi.web.controller.platform.config; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.PlatformConfig; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.domain.SysConfig; +import com.ruoyi.system.service.ISysConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static com.ruoyi.common.core.domain.AjaxResult.success; + +/** + * 平台设置 + */ +@RestController +@RequestMapping("/platform/config") +public class PlatformConfigController { + @Autowired + private ISysConfigService configService; + + @GetMapping("{config}") + public AjaxResult config(@PathVariable PlatformConfig config) { + SysConfig _config = configService.selectConfigById(config.getConfigId()); + return success(StringUtils.format("{}获取成功", _config.getConfigName()), _config.getConfigValue()); + } +} diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index a6d9b4c..6bdbd6a 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -126,6 +126,6 @@ xss: # 过滤开关 enabled: true # 排除链接(多个用逗号分隔) - excludes: /system/notice + excludes: /system/notice,/system/config # 匹配链接 urlPatterns: /system/*,/monitor/*,/tool/* diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/PlatformConfig.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/PlatformConfig.java new file mode 100644 index 0000000..b7fd438 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/PlatformConfig.java @@ -0,0 +1,23 @@ +package com.ruoyi.common.enums; + +/** + * 平台设置 + */ +public enum PlatformConfig { + //用户协议 + userAgreement(100L), + //隐私政策 + privacyPolicy(101L), + //短信验证码配置 + smsTime(102L); + + private final Long configId; + + PlatformConfig(Long configId) { + this.configId = configId; + } + + public Long getConfigId() { + return configId; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index bdb7199..f0af627 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -1,5 +1,9 @@ package com.ruoyi.framework.config; +import com.ruoyi.framework.config.properties.PermitAllUrlProperties; +import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter; +import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl; +import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.http.HttpMethod; @@ -15,14 +19,10 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.security.web.authentication.logout.LogoutFilter; import org.springframework.web.filter.CorsFilter; -import com.ruoyi.framework.config.properties.PermitAllUrlProperties; -import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter; -import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl; -import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl; /** * spring security配置 - * + * * @author ruoyi */ @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) @@ -33,7 +33,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter */ @Autowired private UserDetailsService userDetailsService; - + /** * 认证失败处理类 */ @@ -51,7 +51,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter */ @Autowired private JwtAuthenticationTokenFilter authenticationTokenFilter; - + /** * 跨域过滤器 */ @@ -115,6 +115,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter // 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() + //平台设置 + .antMatchers("/platform/config/**").permitAll() // 除上面外的所有请求全部需要鉴权认证 .anyRequest().authenticated() .and()