xusonglin 5 роки тому
батько
коміт
c249116283

+ 2 - 0
src/main/java/com/jkcredit/sysnews/SysNewsApplication.java

@@ -1,11 +1,13 @@
 package com.jkcredit.sysnews;
 
+import com.jkcredit.sysnews.config.ApplicationProperties;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import springfox.documentation.swagger2.annotations.EnableSwagger2;
 
 @SpringBootApplication
+@EnableConfigurationProperties(ApplicationProperties.class)
 public class SysNewsApplication {
 
     public static void main(String[] args) {

+ 31 - 0
src/main/java/com/jkcredit/sysnews/config/CorsConfig.java

@@ -0,0 +1,31 @@
+package com.jkcredit.sysnews.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+
+/**
+ * @description:
+ * @author: xusonglin
+ * @create: 2020/3/5 13:42
+ * @version: V1.0
+ **/
+@Configuration
+public class CorsConfig {
+    private CorsConfiguration buildConfig() {
+        CorsConfiguration corsConfiguration = new CorsConfiguration();
+        corsConfiguration.addAllowedOrigin("*"); //允许任何域名
+        corsConfiguration.addAllowedHeader("*"); //允许任何头
+        corsConfiguration.addAllowedMethod("*"); //允许任何方法
+        return corsConfiguration;
+    }
+
+    @Bean
+    public CorsFilter corsFilter() {
+        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+        source.registerCorsConfiguration("/**", buildConfig()); //注册
+        return new CorsFilter(source);
+    }
+}

+ 6 - 1
src/main/java/com/jkcredit/sysnews/service/newsArticle/NewsArticleServiceImpl.java

@@ -108,7 +108,12 @@ public class NewsArticleServiceImpl extends BaseService implements NewsArticleSe
             if (!StringUtils.isBlank(newsArticleDto.getContent())) {
                 newsArticlePo.setContent(newsArticleDto.getContent());
             }
-            if (newsArticleDto.getPhotoId() != null) {
+            if (newsArticleDto.getPhoto() != null) {
+                try {
+
+                } catch (ServiceException e) {
+
+                }
                 photoService.deletePhoto(newsArticlePo.getPhotoId());
                 newsArticlePo.setPhotoId(newsArticleDto.getPhotoId());
             }