Commit 978704ef authored by 赵啸非's avatar 赵啸非

添加站点授权

parent 21712f0c
package com.mortals.xhx.base.framework.config; package com.mortals.xhx.base.framework.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
...@@ -12,6 +16,25 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; ...@@ -12,6 +16,25 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration @Configuration
public class CorsConfig implements WebMvcConfigurer { public class CorsConfig implements WebMvcConfigurer {
@Bean
public CorsFilter corsFilter(){
//初始化配置对象
CorsConfiguration configuration = new CorsConfiguration();
//允许跨域访问的域名
configuration.addAllowedOrigin("*");
// configuration.setAllowCredentials(true); //运行携带cookie
configuration.addAllowedMethod("*"); //代表所有请求方法
configuration.addAllowedHeader("*"); //允许携带任何头信息
//初始化cors配置源对象
UrlBasedCorsConfigurationSource configurationSource=new UrlBasedCorsConfigurationSource();
configurationSource.registerCorsConfiguration("/**",configuration);
//返回CorSfilter实例,参数
return new CorsFilter(configurationSource);
}
@Override @Override
public void addCorsMappings(CorsRegistry registry) { public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**") registry.addMapping("/**")
......
...@@ -122,18 +122,18 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic ...@@ -122,18 +122,18 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
/** /**
* 站点授权 * 站点授权
* @param query
* @return * @return
*/ */
@PostMapping(value = "siteAuth") @PostMapping(value = "siteAuth")
public String siteAuth(@RequestBody UserEntityExt query) { public String siteAuth(@RequestBody UserEntityExt entityExt) {
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
Map<String, Object> model = new HashMap<>(); Map<String, Object> model = new HashMap<>();
String busiDesc = this.getModuleDesc() + "站点授权"; String busiDesc = this.getModuleDesc() + "站点授权";
try { try {
//String retStr = this.service.getFlatSitesByAreaIds(query, getContext()); this.service.siteAuth(entityExt,getContext());
recordSysLog(request, busiDesc + "【成功】"); recordSysLog(request, busiDesc + "【成功】");
//return retStr; ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_MSG, "授权成功!");
} catch (Exception e) { } catch (Exception e) {
log.error("查询站点信息错误", e); log.error("查询站点信息错误", e);
this.doException(request, busiDesc, model, e); this.doException(request, busiDesc, model, e);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment