1.增加获取平台设置接口

master
panqihua 2 years ago
parent 198eab375e
commit 466798d1aa
  1. 30
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/platform/config/PlatformConfigController.java
  2. 2
      ruoyi-admin/src/main/resources/application.yml
  3. 23
      ruoyi-common/src/main/java/com/ruoyi/common/enums/PlatformConfig.java
  4. 10
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.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());
}
}

@ -126,6 +126,6 @@ xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice
excludes: /system/notice,/system/config
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*

@ -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;
}
}

@ -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,10 +19,6 @@ 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配置
@ -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()

Loading…
Cancel
Save