Преглед изворни кода

Merge branch 'develop-v3.0.0' of http://39.106.8.246:3003/FM-dev/fm-basics into develop-v3.0.0

lijie пре 4 година
родитељ
комит
2c3c2de3f4

+ 4 - 0
fm-common/src/main/java/com/persagy/fm/common/constant/PageQueryConstants.java

@@ -15,4 +15,8 @@ public class PageQueryConstants {
      * 默认查询10条
      */
     public static final int DEFAULT_SIZE = 10;
+    /**
+     * list参数的最大size
+     */
+    public static final int PARAM_MAX_SIZE = 100;
 }

+ 1 - 1
fm-common/src/main/java/com/persagy/fm/common/model/dto/EnumQueryDTO.java

@@ -16,8 +16,8 @@ import javax.validation.constraints.NotNull;
 @Data
 @ApiModel
 public class EnumQueryDTO {
-    @NotNull(message = "枚举类型不能为空")
 
+    @NotNull(message = "枚举类型不能为空")
     @ApiModelProperty("枚举类型")
     private String type;
 }

+ 24 - 14
fm-common/src/main/java/com/persagy/fm/common/model/dto/PageDTO.java

@@ -1,27 +1,26 @@
 package com.persagy.fm.common.model.dto;
 
+import com.persagy.fm.common.constant.PageQueryConstants;
+import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import net.minidev.json.annotate.JsonIgnore;
 
-import javax.validation.constraints.NotNull;
 import java.util.List;
 
 /**
- * @description: 分页条件
- * @author: lixing
- * @company: Persagy Technology Co.,Ltd
- * @since: 2020/10/13 3:23 下午
- * @version: V1.0
- **/
+ * 分页条件
+ *
+ * @author lixing
+ * @version V1.0 2021/4/29 2:57 下午
+ */
 @Data
+@ApiModel
 public class PageDTO {
-    @ApiModelProperty(value = "当前页数", required = true)
-    @NotNull(message = "当前页数不能为空")
+    @ApiModelProperty(value = "当前页数")
     private Integer page;
 
-    @ApiModelProperty(value = "每页条数", required = true)
-    @NotNull(message = "每页条数不能为空")
+    @ApiModelProperty(value = "每页条数")
     private Integer size;
     @ApiModelProperty(value = "排序方式")
     private List<Sort> orders;
@@ -31,10 +30,21 @@ public class PageDTO {
     private Integer startIndex;
 
     public Integer getStartIndex() {
-        if (page == null || size == null) {
-            return 0;
+        return (getPage() - 1) * getSize();
+    }
+
+    public Integer getPage() {
+        if (this.page == null) {
+            return PageQueryConstants.DEFAULT_PAGE;
+        }
+        return this.page;
+    }
+
+    public Integer getSize() {
+        if (this.size == null) {
+            return PageQueryConstants.DEFAULT_SIZE;
         }
-        return (page -1) * size;
+        return this.size;
     }
 }
 

+ 1 - 1
fm-common/src/main/java/com/persagy/fm/common/model/vo/DuplicateVO.java

@@ -11,7 +11,7 @@ import lombok.Data;
  * @version V1.0 2021/4/7 7:36 下午
  **/
 @Data
-@ApiModel("是否重复VO类")
+@ApiModel
 public class DuplicateVO {
     @ApiModelProperty("是否重复")
     private Boolean duplicate;

+ 1 - 1
fm-common/src/main/java/com/persagy/fm/common/model/vo/EnumVO.java

@@ -14,7 +14,7 @@ import org.checkerframework.checker.units.qual.K;
  **/
 @Data
 @JsonInclude(JsonInclude.Include.NON_NULL)
-@ApiModel("枚举VO类")
+@ApiModel
 public class EnumVO {
     @ApiModelProperty(value = "键")
     private String key;

+ 7 - 2
fm-common/src/main/java/com/persagy/fm/common/response/CommonResult.java

@@ -1,11 +1,12 @@
 package com.persagy.fm.common.response;
 
 import com.fasterxml.jackson.annotation.JsonInclude;
-import com.persagy.common.enums.ResponseCode;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import static com.persagy.common.enums.ResponseCode.A00000;
+
 /**
  * 服务调用消息结果
  * @author Charlie Yu
@@ -30,7 +31,7 @@ public class CommonResult<T> {
      * 构造方法
      */
     public CommonResult(){
-        this(ResponseCode.A00000.getCode(), ResponseCode.A00000.getDesc());
+        this(A00000.getCode(), A00000.getDesc());
     }
 
     /**
@@ -53,4 +54,8 @@ public class CommonResult<T> {
         this.respMsg = respMsg;
         this.content = content;
     }
+
+    public static <T> CommonResult<T> success(T t) {
+        return  new CommonResult<>(A00000.getCode(), A00000.getDesc(),t);
+    }
 }

+ 10 - 0
fm-package/README.md

@@ -0,0 +1,10 @@
+fm-package 包版本管理
+============ 
+
+说明
+---------------
+应用服务打包的pom依赖
+- 支持config拷贝
+
+最新变化
+---------------

+ 31 - 0
fm-package/pom.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>fm-parent</artifactId>
+        <groupId>com.persagy</groupId>
+        <version>3.0.0</version>
+        <relativePath>../fm-parent</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>fm-package</artifactId>
+    <packaging>pom</packaging>
+
+    <!-- 插件配置 -->
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-source-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <mainClass>com.persagy.ServerApplication</mainClass>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 2 - 0
fm-parent/README.md

@@ -3,6 +3,8 @@ fm-parent 包版本管理
 
 说明
 ---------------
+公共依赖的pom
+- 生成代码jar包的组件继承此pom。应用服务应继承fm-package。
 
 最新变化
 ---------------

+ 74 - 70
fm-parent/pom.xml

@@ -27,6 +27,7 @@
         <fm.version>3.0.0</fm.version>
         <platform.version>1.0.0</platform.version>
         <mybatis-plus.version>3.3.1</mybatis-plus.version>
+        <dynamic-datasource.version>3.3.2</dynamic-datasource.version>
         <tomcat-jdbc.version>9.0.31</tomcat-jdbc.version>
         <HikariCP.version>3.2.0</HikariCP.version>
         <mysql.version>8.0.15</mysql.version>
@@ -35,7 +36,12 @@
         <spring-data.version>2.1.17.RELEASE</spring-data.version>
         <spring-data-jpa.version>2.0.11.RELEASE</spring-data-jpa.version>
         <mapstruct.version>1.2.0.Final</mapstruct.version>
-        <druid-spring-boot-starter.version>1.1.22</druid-spring-boot-starter.version>
+        <druid.version>1.1.22</druid.version>
+        <!-- Plugins -->
+        <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
+        <spring-boot-maven-plugin.version>2.4.3</spring-boot-maven-plugin.version>
+        <maven-source-plugin.version>3.0.1</maven-source-plugin.version>
+        <maven-resources-plugin.version>3.0.2</maven-resources-plugin.version>
     </properties>
 
     <dependencyManagement>
@@ -52,6 +58,16 @@
             </dependency>
             <dependency>
                 <groupId>com.persagy</groupId>
+                <artifactId>fm-mybatis</artifactId>
+                <version>${fm.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>com.persagy</groupId>
+                <artifactId>fm-translate</artifactId>
+                <version>${fm.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>com.persagy</groupId>
                 <artifactId>integrated-common-core</artifactId>
                 <version>${platform.version}</version>
             </dependency>
@@ -81,6 +97,11 @@
                 <artifactId>mybatis-plus-boot-starter</artifactId>
                 <version>${mybatis-plus.version}</version>
             </dependency>
+            <dependency>
+                <groupId>com.baomidou</groupId>
+                <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
+                <version>${dynamic-datasource.version}</version>
+            </dependency>
             <!-- mapstruct 优雅的进行bean与dto的转换 -->
             <dependency>
                 <groupId>org.mapstruct</groupId>
@@ -96,7 +117,7 @@
             <dependency>
                 <groupId>com.alibaba</groupId>
                 <artifactId>druid-spring-boot-starter</artifactId>
-                <version>${druid-spring-boot-starter.version}</version>
+                <version>${druid.version}</version>
             </dependency>
             <!-- 以下是数据库连接池版本管理,建议使用provided方式引入-->
             <dependency>
@@ -218,108 +239,91 @@
 
     <!-- 插件配置 -->
     <build>
+        <finalName>${project.artifactId}</finalName>
         <pluginManagement>
             <plugins>
                 <!-- compiler插件, 设定JDK版本 -->
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-compiler-plugin</artifactId>
-                    <version>3.7.0</version>
+                    <version>${maven-compiler-plugin.version}</version>
                     <configuration>
                         <source>${java.version}</source>
                         <target>${java.version}</target>
+                        <encoding>UTF-8</encoding>
+                        <skip>true</skip>
                         <showWarnings>true</showWarnings>
                     </configuration>
                 </plugin>
-                <!-- resource插件 -->
-                <plugin>
-                    <groupId>org.apache.maven.plugins</groupId>
-                    <artifactId>maven-resources-plugin</artifactId>
-                    <version>3.0.2</version>
-                </plugin>
-
-                <!-- test插件, 仅测试名称为*Test的类, 使用支持分组测试的surefire-junit47 driver -->
                 <plugin>
-                    <groupId>org.apache.maven.plugins</groupId>
-                    <artifactId>maven-surefire-plugin</artifactId>
-                    <version>2.20.1</version>
-                    <configuration>
-                        <includes>
-                            <include>**/*Test.java</include>
-                            <include>**/*Test.scala</include>
-                        </includes>
-                        <skipTests>true</skipTests>
-                    </configuration>
-                    <dependencies>
-                        <dependency>
-                            <groupId>org.apache.maven.surefire</groupId>
-                            <artifactId>surefire-junit4</artifactId>
-                            <version>2.18.1</version>
-                        </dependency>
-                    </dependencies>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-maven-plugin</artifactId>
+                    <version>${spring-boot-maven-plugin.version}</version>
                 </plugin>
-
-                <!-- war打包插件, 设定war包名称不带版本号 -->
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
-                    <artifactId>maven-war-plugin</artifactId>
-                    <version>3.2.3</version>
+                    <artifactId>maven-source-plugin</artifactId>
+                    <version>${maven-source-plugin.version}</version>
                     <configuration>
-                        <warName>${project.artifactId}${fm.version}</warName>
-                        <failOnMissingWebXml>false</failOnMissingWebXml>
+                        <attach>true</attach>
                     </configuration>
-                </plugin>
-
-                <!-- jar打包相关插件 -->
-                <plugin>
-                    <groupId>org.apache.maven.plugins</groupId>
-                    <artifactId>maven-jar-plugin</artifactId>
-                    <version>3.1.0</version>
                     <executions>
                         <execution>
+                            <phase>compile</phase>
                             <goals>
-                                <goal>test-jar</goal>
+                                <goal>jar</goal>
                             </goals>
                         </execution>
                     </executions>
-                    <configuration>
-                        <archive>
-                            <manifest>
-                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
-                            </manifest>
-                        </archive>
-                    </configuration>
                 </plugin>
+                <!-- resource插件 -->
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
-                    <artifactId>maven-source-plugin</artifactId>
-                    <version>3.0.1</version>
-                    <configuration>
-                        <attach>true</attach>
-                    </configuration>
+                    <artifactId>maven-resources-plugin</artifactId>
+                    <version>${maven-resources-plugin.version}</version>
                     <executions>
                         <execution>
-                            <phase>compile</phase>
+                            <id>copy-resources</id>
+                            <phase>package</phase>
                             <goals>
-                                <goal>jar</goal>
+                                <goal>copy-resources</goal>
                             </goals>
+                            <configuration>
+                                <resources>
+                                    <resource>
+                                        <directory>src/main/resources/</directory>
+                                        <includes>
+                                            <include>**/*.yml</include>
+                                        </includes>
+                                    </resource>
+                                    <resource>
+                                        <directory>${project.build.directory}</directory>
+                                        <includes>
+                                            <include>**/version.txt</include>
+                                        </includes>
+                                    </resource>
+                                </resources>
+                                <outputDirectory>${project.build.directory}/config</outputDirectory>
+                            </configuration>
+                        </execution>
+                        <!--拷贝启动脚本-->
+                        <execution>
+                            <id>copy-version</id>
+                            <phase>package</phase>
+                            <goals>
+                                <goal>copy-resources</goal>
+                            </goals>
+                            <configuration>
+                                <resources>
+                                    <resource>
+                                        <directory>src/script</directory>
+                                    </resource>
+                                </resources>
+                                <outputDirectory>${project.build.directory}</outputDirectory>
+                            </configuration>
                         </execution>
                     </executions>
                 </plugin>
-
-                <!-- clean插件 -->
-                <plugin>
-                    <groupId>org.apache.maven.plugins</groupId>
-                    <artifactId>maven-clean-plugin</artifactId>
-                    <version>3.0.0</version>
-                </plugin>
-
-                <!-- install插件 -->
-                <plugin>
-                    <groupId>org.apache.maven.plugins</groupId>
-                    <artifactId>maven-install-plugin</artifactId>
-                    <version>2.5.2</version>
-                </plugin>
             </plugins>
         </pluginManagement>
         <plugins>

+ 1 - 0
pom.xml

@@ -26,5 +26,6 @@
         <module>fm-translate</module>
         <module>fm-mybatis</module>
         <module>fm-screw</module>
+        <module>fm-package</module>
     </modules>
 </project>