Sfoglia il codice sorgente

修改pom配置,引入开源的xiaoming swagger ui

Feick 5 anni fa
parent
commit
52a142db2e

+ 21 - 17
pom.xml

@@ -85,13 +85,13 @@
         <dependency>
             <groupId>io.springfox</groupId>
             <artifactId>springfox-swagger2</artifactId>
-            <version>2.8.0</version>
-        </dependency>
-        <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger-ui</artifactId>
-            <version>2.8.0</version>
+            <version>2.9.2</version>
         </dependency>
+<!--        <dependency>-->
+<!--            <groupId>io.springfox</groupId>-->
+<!--            <artifactId>springfox-swagger-ui</artifactId>-->
+<!--            <version>2.8.0</version>-->
+<!--        </dependency>-->
         <dependency>
             <groupId>com.google.code.gson</groupId>
             <artifactId>gson</artifactId>
@@ -153,20 +153,24 @@
 <!--            <version>2.4</version>-->
 <!--        </dependency>-->
         <!-- https://mvnrepository.com/artifact/org.freehep/freehep-graphicsio-emf -->
-        <dependency>
-            <groupId>org.freehep</groupId>
-            <artifactId>freehep-graphicsio-emf</artifactId>
-            <version>2.4</version>
-            <scope>test</scope>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>org.freehep</groupId>-->
+<!--            <artifactId>freehep-graphicsio-emf</artifactId>-->
+<!--            <version>2.4</version>-->
+<!--            <scope>test</scope>-->
+<!--        </dependency>-->
         <!-- https://mvnrepository.com/artifact/org.freehep/freehep-graphicsio-svg -->
+<!--        <dependency>-->
+<!--            <groupId>org.freehep</groupId>-->
+<!--            <artifactId>freehep-graphicsio-svg</artifactId>-->
+<!--            <version>2.4</version>-->
+<!--            <scope>test</scope>-->
+<!--        </dependency>-->
         <dependency>
-            <groupId>org.freehep</groupId>
-            <artifactId>freehep-graphicsio-svg</artifactId>
-            <version>2.4</version>
-            <scope>test</scope>
+            <groupId>com.github.xiaoymin</groupId>
+            <artifactId>swagger-bootstrap-ui</artifactId>
+            <version>1.9.6</version>
         </dependency>
-
     </dependencies>
 
     <build>

+ 7 - 5
src/main/java/com/yaoxiang/diagnosis/config/MvcConfig.java

@@ -3,13 +3,14 @@ package com.yaoxiang.diagnosis.config;
 
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
 @Configuration
 public class MvcConfig {
 
-//    @Resource
+    //    @Resource
     private UploadProperties uploadProperties;
 
     @Bean
@@ -19,13 +20,14 @@ public class MvcConfig {
             public void addViewControllers(ViewControllerRegistry registry) {
                 registry.addViewController("/").setViewName("index");
                 registry.addViewController("/app").setViewName("app");
-                registry.addViewController("/login").setViewName("login");
-                registry.addViewController("/hello").setViewName("hello");
+
+//                registry.addViewController("/login").setViewName("login");
+//                registry.addViewController("/hello").setViewName("hello");
             }
 
 //            public void addResourceHandlers(ResourceHandlerRegistry registry) {
-//                registry.addResourceHandler(uploadProperties.getUploadPattern())
-//                        .addResourceLocations("file:" + uploadProperties.getUploadLocation());
+//                registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
+//                registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
 //            }
         };
     }

+ 1 - 1
src/main/java/com/yaoxiang/diagnosis/config/Swagger2Config.java

@@ -29,7 +29,7 @@ public class Swagger2Config {
                 .apiInfo(apiInfo())
                 .select()
                 //选择controller包
-                .apis(RequestHandlerSelectors.basePackage("edu.math.diagnosis.controller"))
+                .apis(RequestHandlerSelectors.basePackage("com.yaoxiang.diagnosis.controller"))
                 .paths(PathSelectors.any())
                 .build();
     }

+ 3 - 2
src/main/java/com/yaoxiang/diagnosis/config/WebSecurityConfig.java

@@ -37,7 +37,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
 
     @Resource
     private UserService userService;
-//    @Resource
+    //    @Resource
     private UploadProperties uploadProperties;
 
     @Value("${web.loginPage:/login}")
@@ -122,7 +122,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
         http.headers().cacheControl().disable();
         http.headers().frameOptions().sameOrigin();
 
-        http.authorizeRequests().antMatchers("/").permitAll();
+        http.authorizeRequests().antMatchers("/", loginPage).permitAll();
         http.authorizeRequests().anyRequest().authenticated();
 //        http.formLogin().loginPage("/login").defaultSuccessUrl("/app", true).permitAll();
 
@@ -151,6 +151,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
         web.ignoring().antMatchers("/**/*.js", "/lang/*.json", "/**/*.css", "/**/*.map", "/**/*.png",
                 "/**/*.jpg", "/**/*.woff", "/**/*.ttf", "/*.ico");
         web.ignoring().antMatchers(permitUrls);
+        web.ignoring().antMatchers("/doc.html");
         web.ignoring().antMatchers("/open/**");
         web.ignoring().antMatchers("/v2/api-docs",//swagger api json
                 "/swagger-resources/configuration/ui",//用来获取支持的动作

+ 91 - 91
src/test/java/com/yaoxiang/diagnosis/service/EmfToSVG.java

@@ -1,93 +1,93 @@
-package com.yaoxiang.diagnosis.service;
-
-import org.freehep.graphicsbase.util.export.ExportFileType;
-import org.freehep.graphicsio.ImageConstants;
-import org.freehep.graphicsio.emf.EMFConverter;
-import org.freehep.graphicsio.emf.EMFInputStream;
-import org.freehep.graphicsio.emf.EMFPanel;
-import org.freehep.graphicsio.emf.EMFRenderer;
-import org.freehep.graphicsio.svg.SVGGraphics2D;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.List;
-import java.util.Properties;
-
-public class EmfToSVG extends EMFConverter {
-
-    public static void main(String[] args) {
-//        String[] file = new String[2];
-//        file[0] = "D:\\input.emf";
+//package com.yaoxiang.diagnosis.service;
 //
-//        if (file == null || file.length == 0 || file[0] == null || file[0].length() == 0) {
-//            System.out.println("usage: EMF2SVG imput.emf [output.svg]");
-//            return;
+//import org.freehep.graphicsbase.util.export.ExportFileType;
+//import org.freehep.graphicsio.ImageConstants;
+//import org.freehep.graphicsio.emf.EMFConverter;
+//import org.freehep.graphicsio.emf.EMFInputStream;
+//import org.freehep.graphicsio.emf.EMFPanel;
+//import org.freehep.graphicsio.emf.EMFRenderer;
+//import org.freehep.graphicsio.svg.SVGGraphics2D;
+//
+////import java.io.File;
+//import java.io.FileInputStream;
+//import java.util.List;
+//import java.util.Properties;
+//
+//public class EmfToSVG extends EMFConverter {
+//
+//    public static void main(String[] args) {
+////        String[] file = new String[2];
+////        file[0] = "D:\\input.emf";
+////
+////        if (file == null || file.length == 0 || file[0] == null || file[0].length() == 0) {
+////            System.out.println("usage: EMF2SVG imput.emf [output.svg]");
+////            return;
+////        }
+////        export(ImageConstants.SVG, file[0], file.length > 1 ? file[1] : null);
+//        export(ImageConstants.SVG,"image/aaa.emf","D:\\result.svg");
+//    }
+//
+//    protected static void export(String type, String srcFileName, String destFileName) {
+//        try {
+//            List<ExportFileType> exportFileTypes = ExportFileType.getExportFileTypes(type);
+//            if (exportFileTypes == null || exportFileTypes.size() == 0) {
+//                System.out.println(
+//                        type + " library is not available. check your classpath!");
+//                return;
+//            }
+//
+//            ExportFileType exportFileType = (ExportFileType) exportFileTypes.get(0);
+//
+//            // read the EMF file
+//            EMFRenderer emfRenderer = new EMFRenderer(
+//                    new EMFInputStream(
+//                            new FileInputStream(srcFileName)));
+//
+//            // create the destFileName,
+//            // replace or add the extension to the destFileName
+//            if (destFileName == null || destFileName.length() == 0) {
+//                // index of the beginning of the extension
+//                int lastPointIndex = srcFileName.lastIndexOf(".");
+//
+//                // to be sure that the point separates an extension
+//                // and is not part of a directory name
+//                int lastSeparator1Index = srcFileName.lastIndexOf("/");
+//                int lastSeparator2Index = srcFileName.lastIndexOf("\\");
+//
+//                if (lastSeparator1Index > lastPointIndex ||
+//                        lastSeparator2Index > lastPointIndex) {
+//                    destFileName = srcFileName + ".";
+//                } else if (lastPointIndex > -1) {
+//                    destFileName = srcFileName.substring(
+//                            0, lastPointIndex + 1);
+//                }
+//
+//                // add the extension
+//                destFileName += type.toLowerCase();
+//            }
+//
+//            // TODO there is no possibility to use Constants of base class!
+//            /* create SVG properties*/
+//            Properties p = new Properties();
+//            p.put(SVGGraphics2D.EMBED_FONTS, Boolean.toString(false));
+//            p.put(SVGGraphics2D.CLIP, Boolean.toString(true));
+//            p.put(SVGGraphics2D.COMPRESS, Boolean.toString(false));
+//            p.put(SVGGraphics2D.TEXT_AS_SHAPES, Boolean.toString(false));
+//            p.put(SVGGraphics2D.FOR, "Freehep EMF2SVG");
+//            p.put(SVGGraphics2D.TITLE, srcFileName);
+//
+//            EMFPanel emfPanel = new EMFPanel();
+//            emfPanel.setRenderer(emfRenderer);
+//
+//            // TODO why uses this classes components?!
+//            exportFileType.exportToFile(
+//                    new File(destFileName),
+//                    emfPanel,
+//                    emfPanel,
+//                    p,
+//                    "Freehep EMF converter");
+//        } catch (Exception e) {
+//            e.printStackTrace();
 //        }
-//        export(ImageConstants.SVG, file[0], file.length > 1 ? file[1] : null);
-        export(ImageConstants.SVG,"image/aaa.emf","D:\\result.svg");
-    }
-
-    protected static void export(String type, String srcFileName, String destFileName) {
-        try {
-            List<ExportFileType> exportFileTypes = ExportFileType.getExportFileTypes(type);
-            if (exportFileTypes == null || exportFileTypes.size() == 0) {
-                System.out.println(
-                        type + " library is not available. check your classpath!");
-                return;
-            }
-
-            ExportFileType exportFileType = (ExportFileType) exportFileTypes.get(0);
-
-            // read the EMF file
-            EMFRenderer emfRenderer = new EMFRenderer(
-                    new EMFInputStream(
-                            new FileInputStream(srcFileName)));
-
-            // create the destFileName,
-            // replace or add the extension to the destFileName
-            if (destFileName == null || destFileName.length() == 0) {
-                // index of the beginning of the extension
-                int lastPointIndex = srcFileName.lastIndexOf(".");
-
-                // to be sure that the point separates an extension
-                // and is not part of a directory name
-                int lastSeparator1Index = srcFileName.lastIndexOf("/");
-                int lastSeparator2Index = srcFileName.lastIndexOf("\\");
-
-                if (lastSeparator1Index > lastPointIndex ||
-                        lastSeparator2Index > lastPointIndex) {
-                    destFileName = srcFileName + ".";
-                } else if (lastPointIndex > -1) {
-                    destFileName = srcFileName.substring(
-                            0, lastPointIndex + 1);
-                }
-
-                // add the extension
-                destFileName += type.toLowerCase();
-            }
-
-            // TODO there is no possibility to use Constants of base class!
-            /* create SVG properties*/
-            Properties p = new Properties();
-            p.put(SVGGraphics2D.EMBED_FONTS, Boolean.toString(false));
-            p.put(SVGGraphics2D.CLIP, Boolean.toString(true));
-            p.put(SVGGraphics2D.COMPRESS, Boolean.toString(false));
-            p.put(SVGGraphics2D.TEXT_AS_SHAPES, Boolean.toString(false));
-            p.put(SVGGraphics2D.FOR, "Freehep EMF2SVG");
-            p.put(SVGGraphics2D.TITLE, srcFileName);
-
-            EMFPanel emfPanel = new EMFPanel();
-            emfPanel.setRenderer(emfRenderer);
-
-            // TODO why uses this classes components?!
-            exportFileType.exportToFile(
-                    new File(destFileName),
-                    emfPanel,
-                    emfPanel,
-                    p,
-                    "Freehep EMF converter");
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-}
+//    }
+//}