parent
a1145dec7d
commit
1fc0b98ae9
@ -0,0 +1,41 @@ |
||||
package com.share.help.config; |
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
import org.springframework.context.annotation.PropertySource; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
@Component |
||||
@PropertySource("classpath:application.yaml") |
||||
@ConfigurationProperties(prefix = "cros") |
||||
public class CrosConfig { |
||||
|
||||
private String pathPattern; |
||||
|
||||
private String allowedOrigins[]; |
||||
|
||||
private String allowedMethods[]; |
||||
|
||||
public String[] getAllowedOrigins() { |
||||
return allowedOrigins; |
||||
} |
||||
|
||||
public void setAllowedOrigins(String[] allowedOrigins) { |
||||
this.allowedOrigins = allowedOrigins; |
||||
} |
||||
|
||||
public String[] getAllowedMethods() { |
||||
return allowedMethods; |
||||
} |
||||
|
||||
public void setAllowedMethods(String[] allowedMethods) { |
||||
this.allowedMethods = allowedMethods; |
||||
} |
||||
|
||||
public String getPathPattern() { |
||||
return pathPattern; |
||||
} |
||||
|
||||
public void setPathPattern(String pathPattern) { |
||||
this.pathPattern = pathPattern; |
||||
} |
||||
} |
@ -1,30 +1,21 @@ |
||||
package com.share.help.config; |
||||
|
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
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.WebMvcConfigurer; |
||||
|
||||
@Configuration |
||||
public class CrosConfiguration { |
||||
public class CrosConfiguration implements WebMvcConfigurer { |
||||
|
||||
@Value("${cros.allow-origin}") |
||||
private String allowOrigin; |
||||
@Autowired |
||||
private CrosConfig crosConfig; |
||||
|
||||
@Bean |
||||
public FilterRegistrationBean<CorsFilter> corsFilter() { |
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); |
||||
CorsConfiguration config = new CorsConfiguration(); |
||||
config.setAllowCredentials(true); |
||||
config.addAllowedOrigin(allowOrigin); |
||||
config.addAllowedHeader("*"); |
||||
config.addAllowedMethod("*"); |
||||
source.registerCorsConfiguration("/api/**", config); |
||||
FilterRegistrationBean<CorsFilter> bean = new FilterRegistrationBean<>(new CorsFilter(source)); |
||||
bean.setOrder(0); |
||||
return bean; |
||||
@Override |
||||
public void addCorsMappings(CorsRegistry registry) { |
||||
registry.addMapping(crosConfig.getPathPattern()). |
||||
allowedOrigins(crosConfig.getAllowedOrigins()). |
||||
allowedMethods(crosConfig.getAllowedMethods()). |
||||
allowCredentials(true); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,22 @@ |
||||
package com.share.help.form.manager; |
||||
|
||||
public class ActiveUserRes { |
||||
private String userId; |
||||
private Integer count; |
||||
|
||||
public String getUserId() { |
||||
return userId; |
||||
} |
||||
|
||||
public void setUserId(String userId) { |
||||
this.userId = userId; |
||||
} |
||||
|
||||
public Integer getCount() { |
||||
return count; |
||||
} |
||||
|
||||
public void setCount(Integer count) { |
||||
this.count = count; |
||||
} |
||||
} |
@ -0,0 +1,36 @@ |
||||
package com.share.help.form.manager; |
||||
|
||||
/** |
||||
* 管理员修改活动信息表单 |
||||
*/ |
||||
public class UpdateActivityForm { |
||||
private Long activityId; |
||||
|
||||
private String title; |
||||
|
||||
private String content; |
||||
|
||||
public Long getActivityId() { |
||||
return activityId; |
||||
} |
||||
|
||||
public void setActivityId(Long activityId) { |
||||
this.activityId = activityId; |
||||
} |
||||
|
||||
public String getTitle() { |
||||
return title; |
||||
} |
||||
|
||||
public void setTitle(String title) { |
||||
this.title = title; |
||||
} |
||||
|
||||
public String getContent() { |
||||
return content; |
||||
} |
||||
|
||||
public void setContent(String content) { |
||||
this.content = content; |
||||
} |
||||
} |
Loading…
Reference in new issue