Browse Source

framework

SGTY 5 tháng trước cách đây
mục cha
commit
4edd44cf6c

+ 26 - 42
pom.xml

@@ -11,7 +11,11 @@
         <java.version>1.8</java.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-        <spring-boot.version>2.6.13</spring-boot.version>
+        <spring-boot.version>2.2.1.RELEASE</spring-boot.version>
+        <mybatis-plus-boot-starter.version>3.2.0</mybatis-plus-boot-starter.version>
+        <mybatis-spring-boot.version>2.1.1</mybatis-spring-boot.version>
+        <druid.version>1.1.21</druid.version>
+        <swagger.version>2.9.2</swagger.version>
     </properties>
     <dependencies>
         <dependency>
@@ -26,34 +30,55 @@
         <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>poi</artifactId>
+            <version>5.2.3</version>
         </dependency>
         <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>poi-ooxml</artifactId>
+            <version>5.2.3</version>
         </dependency>
         <dependency>
             <groupId>cn.hutool</groupId>
             <artifactId>hutool-all</artifactId>
+            <version>5.4.0</version>
         </dependency>
         <dependency>
             <groupId>us.codecraft</groupId>
             <artifactId>webmagic-core</artifactId>
+            <version>0.9.0</version>
         </dependency>
         <dependency>
             <groupId>us.codecraft</groupId>
             <artifactId>webmagic-extension</artifactId>
+            <version>0.9.0</version>
         </dependency>
         <dependency>
             <artifactId>fastjson</artifactId>
             <groupId>com.alibaba</groupId>
+            <version>1.2.83</version>
         </dependency>
         <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
+            <version>1.18.24</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>com.alibaba</groupId>
             <artifactId>easyexcel</artifactId>
+            <version>4.0.3</version>
+        </dependency>
+
+        <!--swagger-->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>${swagger.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>${swagger.version}</version>
         </dependency>
     </dependencies>
     <dependencyManagement>
@@ -65,47 +90,6 @@
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
-            <dependency>
-                <groupId>org.apache.poi</groupId>
-                <artifactId>poi</artifactId>
-                <version>5.2.3</version>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.poi</groupId>
-                <artifactId>poi-ooxml</artifactId>
-                <version>5.2.3</version>
-            </dependency>
-            <dependency>
-                <groupId>cn.hutool</groupId>
-                <artifactId>hutool-all</artifactId>
-                <version>5.4.0</version>
-            </dependency>
-            <dependency>
-                <groupId>us.codecraft</groupId>
-                <artifactId>webmagic-core</artifactId>
-                <version>0.9.0</version>
-            </dependency>
-            <dependency>
-                <groupId>us.codecraft</groupId>
-                <artifactId>webmagic-extension</artifactId>
-                <version>0.9.0</version>
-            </dependency>
-            <dependency>
-                <artifactId>fastjson</artifactId>
-                <groupId>com.alibaba</groupId>
-                <version>1.2.83</version>
-            </dependency>
-            <dependency>
-                <groupId>org.projectlombok</groupId>
-                <artifactId>lombok</artifactId>
-                <version>1.18.24</version>
-                <scope>provided</scope>
-            </dependency>
-            <dependency>
-                <groupId>com.alibaba</groupId>
-                <artifactId>easyexcel</artifactId>
-                <version>4.0.3</version>
-            </dependency>
         </dependencies>
     </dependencyManagement>
 

+ 2 - 1
src/main/java/com/qizhen/healsphere/ai/QizhenAssistant.java

@@ -52,7 +52,8 @@ public class QizhenAssistant {
 
     public static String getConversationId() {
         JSONObject json = new JSONObject();
-        json.put("app_id", "454b1634-91ad-4dde-9d2f-f9a3302fdcbe");
+        json.put("app_id", "894e7e0f-c7db-497c-a96f-a533f9230431");
+        //json.put("app_id", "454b1634-91ad-4dde-9d2f-f9a3302fdcbe");
         HttpRequest request = HttpUtil.createRequest(Method.POST, "https://qianfan.baidubce.com/v2/app/conversation")
                 .header("X-Appbuilder-Authorization", "Bearer bce-v3/ALTAK-MyGbNEA18oT3boS2nOga1/d8b5057f7842f59b2c64971d8d077fe724d0aed5")
                 .header("Content-Type", "application/json")

+ 71 - 0
src/main/java/com/qizhen/healsphere/config/SwaggerConfigurer.java

@@ -0,0 +1,71 @@
+package com.qizhen.healsphere.config;
+
+
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.ParameterBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.schema.ModelRef;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Contact;
+import springfox.documentation.service.Parameter;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @Description: Swagger配置类
+ * @author: gaodm
+ * @time: 2018/8/2 14:21
+ */
+@Configuration
+@ConditionalOnProperty(prefix = "swagger", value = { "enable" }, havingValue = "true")
+@EnableSwagger2
+public class SwaggerConfigurer {
+    /**
+     * 全局参数
+     *
+     * @return
+     */
+    private List<Parameter> parameter() {
+        List<Parameter> params = new ArrayList<>();
+        params.add(new ParameterBuilder().name("Authorization")
+                .description("Authorization Bearer token")
+                .modelRef(new ModelRef("string"))
+                .parameterType("header")
+                .required(false).build());
+        return params;
+    }
+
+
+    @Bean
+    public Docket sysApi() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                //.apiInfo(apiInfo())
+                .select()
+                .apis(RequestHandlerSelectors.basePackage("com.qizhen.healsphere.web"))
+                .paths(PathSelectors.any())
+                .build();
+                //.globalOperationParameters(parameter());
+        //.securitySchemes(newArrayList(oauth()))
+        // .securityContexts(newArrayList(securityContext()));
+    }
+
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+                .title("病历质控系统 api ")
+                .description("病历质控系统服务")
+                .termsOfServiceUrl("")
+                .contact(new Contact("diagbot","",""))
+                .version("1.0")
+                .build();
+    }
+
+}

+ 7 - 6
src/main/java/com/qizhen/healsphere/demos/web/BasicController.java

@@ -14,18 +14,19 @@
  * limitations under the License.
  */
 
-package com.qizhen.healsphere.demos.web;
+package com.qizhen.healsphere.web.demo;
 
+import io.swagger.annotations.Api;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
 
 /**
  * @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
  */
 @Controller
+@Api(value = "用户管理", tags = { "用户管理相关API" })
 public class BasicController {
 
     // http://127.0.0.1:8080/hello?name=lisi
@@ -48,7 +49,7 @@ public class BasicController {
     // http://127.0.0.1:8080/save_user?name=newName&age=11
     @RequestMapping("/save_user")
     @ResponseBody
-    public String saveUser(User u) {
+    public String saveUser(@RequestBody @Valid User u) {
         return "user will save: name=" + u.getName() + ", age=" + u.getAge();
     }
 

+ 1 - 1
src/main/java/com/qizhen/healsphere/demos/web/PathVariableController.java

@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.qizhen.healsphere.demos.web;
+package com.qizhen.healsphere.web.demo;
 
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.PathVariable;

+ 7 - 3
src/main/java/com/qizhen/healsphere/demos/web/User.java

@@ -14,15 +14,19 @@
  * limitations under the License.
  */
 
-package com.qizhen.healsphere.demos.web;
+package com.qizhen.healsphere.web.demo;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotBlank;
 
 /**
  * @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
  */
 public class User {
-
+    @NotBlank(message = "请输入姓名")
+    @ApiModelProperty("姓名")
     private String name;
-
     private Integer age;
 
     public String getName() {

src/main/resources/application.properties → src/main/resources/application.properties.bak


+ 7 - 0
src/main/resources/application.yml

@@ -0,0 +1,7 @@
+server:
+  port: 8080
+  max-http-header-size: 10MB
+
+swagger:
+  enable: true
+