Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/jiwei/jw2.0 into dev

LiTaohong 7 years ago
parent
commit
8d78529297

+ 10 - 0
base/common-swagger/pom.xml

@ -28,5 +28,15 @@
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-staticdocs</artifactId>
            <version>2.6.1</version>
        </dependency>
        <dependency>
            <groupId>io.github.swagger2markup</groupId>
            <artifactId>swagger2markup</artifactId>
            <version>1.3.2</version>
        </dependency>
    </dependencies>
</project>

+ 37 - 0
base/common-swagger/src/main/java/com/yihu/base/config/DefaultSwaggerConfig.java

@ -1,5 +1,11 @@
package com.yihu.jw.config;
import io.github.swagger2markup.GroupBy;
import io.github.swagger2markup.Language;
import io.github.swagger2markup.Swagger2MarkupConfig;
import io.github.swagger2markup.Swagger2MarkupConverter;
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder;
import io.github.swagger2markup.markup.builder.MarkupLanguage;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@ -8,6 +14,10 @@ import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import static com.google.common.base.Predicates.or;
import static springfox.documentation.builders.PathSelectors.regex;
@ -43,5 +53,32 @@ public class DefaultSwaggerConfig {
        return apiInfo;
    }
    /**
     * 生成html文章专用
     *
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        String groupName="system";
        // String groupName="iot";
        URL remoteSwaggerFile = new URL("http://127.0.0.1:8080//v2/api-docs?group="+groupName);
        Path outputFile = Paths.get("open-api/build/"+groupName);
        Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
                .withMarkupLanguage(MarkupLanguage.ASCIIDOC)
                .withOutputLanguage(Language.ZH)
                .withPathsGroupedBy(GroupBy.TAGS)
                .withGeneratedExamples()
                .withoutInlineSchema()
                .withBasePathPrefix()
                .build();
        Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(remoteSwaggerFile)
                .withConfig(config)
                .build();
        converter.toFile(outputFile);
    }
}

+ 4 - 0
common/common-rest-model/pom.xml

@ -15,6 +15,10 @@
    <version>1.0.0</version>
    <dependencies>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-swagger</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-util</artifactId>

+ 17 - 11
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/Envelop.java

@ -1,6 +1,9 @@
package com.yihu.jw.restmodel.common;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.yihu.jw.restmodel.common.base.BaseEnvelop;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
@ -20,30 +23,33 @@ import java.util.List;
 * @author llh
 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Envelop implements Serializable {
@ApiModel(value = "ListResult", description = "通用的实体")
public class Envelop<T> extends BaseEnvelop implements Serializable {
    private static final long serialVersionUID = 2076324875575488461L;
    @ApiModelProperty("每页大小 默认10")
    private int pageSize = 10;
    @ApiModelProperty("当前页")
    private int currPage;
    @ApiModelProperty("总共多少页")
    private int totalPage;
    @ApiModelProperty("总共多少数据")
    private int totalCount;
    private List detailModelList;
    @ApiModelProperty("列表内容")
    private List<T> detailModelList;
    private Object obj;
    @ApiModelProperty("内容")
    private T obj;
    private String errorMsg;
    private String successMsg;
    public Object getObj() {
    public T getObj() {
        return obj;
    }
    public void setObj(Object obj) {
    public void setObj(T obj) {
        this.obj = obj;
    }
@ -55,11 +61,11 @@ public class Envelop implements Serializable {
        this.totalCount = totalCount;
    }
    public List getDetailModelList() {
    public List<T> getDetailModelList() {
        return detailModelList;
    }
    public void setDetailModelList(List detailModelList) {
    public void setDetailModelList(List<T> detailModelList) {
        this.detailModelList = detailModelList;
    }

+ 43 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/EnvelopList.java

@ -0,0 +1,43 @@
package com.yihu.jw.restmodel.common;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.yihu.jw.restmodel.common.base.BaseEnvelop;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
/**
 * 信封对象,封装REST接口的返回值内容。包括:
 * - 页码
 * - 页大小
 * - 错误消息
 * - 错误代码
 * - 对象模型
 * <p>
 * 信封对象的返回场景:
 * - API使用者确实无法访问返回头,即一些语言库无法处理HTTP的响应消息,这时候需要以这种形式提供返回值。
 * - API需要支持交叉域请求(通过JSONP)。
 *
 * @author llh
 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@ApiModel(value = "ListResult", description = "获取实体列表返回定义")
public class EnvelopList<T> extends BaseEnvelop implements Serializable {
    @ApiModelProperty("列表内容")
    private List<T> detailModelList;
    public EnvelopList(String errorMsg, String successMsg) {
        super(errorMsg, successMsg);
    }
    public List<T> getDetailModelList() {
        return detailModelList;
    }
    public void setDetailModelList(List<T> detailModelList) {
        this.detailModelList = detailModelList;
    }
}

+ 38 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/EnvelopObj.java

@ -0,0 +1,38 @@
package com.yihu.jw.restmodel.common;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.yihu.jw.restmodel.common.base.BaseEnvelop;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
 * 信封对象,封装REST接口的返回值内容。包括:
 * - 页码
 * - 页大小
 * - 错误消息
 * - 错误代码
 * - 对象模型
 * <p>
 * 信封对象的返回场景:
 * - API使用者确实无法访问返回头,即一些语言库无法处理HTTP的响应消息,这时候需要以这种形式提供返回值。
 * - API需要支持交叉域请求(通过JSONP)。
 *
 * @author llh
 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@ApiModel(description = "获取单个实体信息返回")
public class EnvelopObj<T> extends BaseEnvelop implements Serializable {
    @ApiModelProperty("内容")
    private T obj;
    public T getObj() {
        return obj;
    }
    public void setObj(T obj) {
        this.obj = obj;
    }
}

+ 136 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/EnvelopPage.java

@ -0,0 +1,136 @@
package com.yihu.jw.restmodel.common;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.yihu.jw.restmodel.common.base.BaseEnvelop;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
/**
 * 信封对象,封装REST接口的返回值内容。包括:
 * - 页码
 * - 页大小
 * - 错误消息
 * - 错误代码
 * - 对象模型
 * <p>
 * 信封对象的返回场景:
 * - API使用者确实无法访问返回头,即一些语言库无法处理HTTP的响应消息,这时候需要以这种形式提供返回值。
 * - API需要支持交叉域请求(通过JSONP)。
 *
 * @author llh
 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@ApiModel(value = "PageResult<T>", description = "分页查询返回")
public class EnvelopPage<T> extends BaseEnvelop implements Serializable {
    private static final long serialVersionUID = 2076324875575488461L;
    @ApiModelProperty("每页大小 默认10")
    private int pageSize = 10;
    @ApiModelProperty("当前页")
    private int currPage;
    @ApiModelProperty("总共多少页")
    private int totalPage;
    @ApiModelProperty("总共多少数据")
    private int totalCount;
    @ApiModelProperty("所有满足条件的实体")
    private List<T> detailModelList;
    public int getTotalCount() {
        return totalCount;
    }
    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }
    public List<T> getDetailModelList() {
        return detailModelList;
    }
    public void setDetailModelList(List<T> detailModelList) {
        this.detailModelList = detailModelList;
    }
    public String getErrorMsg() {
        return errorMsg;
    }
    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }
    public int getPageSize() {
        return pageSize;
    }
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
    public int getCurrPage() {
        return currPage;
    }
    public void setCurrPage(int currPage) {
        this.currPage = currPage;
    }
    public int getTotalPage() {
        if (totalCount % pageSize == 0) {
            totalPage = totalCount / pageSize;
        } else {
            totalPage = totalCount / pageSize + 1;
        }
        return totalPage;
    }
    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }
    public String getSuccessMsg() {
        return successMsg;
    }
    public void setSuccessMsg(String successMsg) {
        this.successMsg = successMsg;
    }
    public static EnvelopPage getSuccess(String message) {
        EnvelopPage envelop = new EnvelopPage();
        envelop.setSuccessMsg(message);
        return envelop;
    }
    public static EnvelopPage getSuccessListWithPage(String message, List detailModelList, int page, int size, Long count) {
        EnvelopPage envelop = new EnvelopPage();
        envelop.setSuccessMsg(message);
        envelop.setPageSize(size);
        envelop.setDetailModelList(detailModelList);
        envelop.setCurrPage(page);
        envelop.setTotalCount(count.intValue());
        return envelop;
    }
    public static EnvelopPage getError(String message, int errorCode) {
        EnvelopPage envelop = new EnvelopPage();
        envelop.setErrorMsg(message);
        return envelop;
    }
    public static EnvelopPage getSuccessList(String message, List objList) {
        EnvelopPage envelop = new EnvelopPage();
        envelop.setSuccessMsg(message);
        envelop.setDetailModelList(objList);
        return envelop;
    }
}

+ 46 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/base/BaseEnvelop.java

@ -0,0 +1,46 @@
package com.yihu.jw.restmodel.common.base;
/**
 * Created by chenweida on 2018/1/16.
 */
public class BaseEnvelop {
    protected String errorCode;
    protected String errorMsg;
    protected String successMsg;
    public BaseEnvelop() {
    }
    public BaseEnvelop(String errorCode, String errorMsg) {
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }
    public String getErrorMsg() {
        return errorMsg;
    }
    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }
    public String getSuccessMsg() {
        return successMsg;
    }
    public void setSuccessMsg(String successMsg) {
        this.successMsg = successMsg;
    }
    public String getErrorCode() {
        return errorCode;
    }
    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }
}

+ 62 - 14
svr-lib-parent-pom/pom.xml

@ -80,6 +80,12 @@
        <version.joda-time>2.8.2</version.joda-time>
        <version.solr>5.5.1</version.solr>
        <version.fastdfs>1.25</version.fastdfs>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <asciidoctor.maven.plugin.version>1.5.5</asciidoctor.maven.plugin.version>
        <asciidoctorj.version>1.5.5</asciidoctorj.version>
        <maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
    </properties>
    <!--dependencyManagement作用子配置不写版本默认继承父配置-->
    <dependencyManagement>
@ -447,6 +453,62 @@
    </dependencyManagement>
    <build>
        <plugins>
            <!--编译插件 start-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
                <version>3.1</version>
            </plugin>
            <!--编译插件 end-->
            <plugin>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctor-maven-plugin</artifactId>
                <version>${asciidoctor.maven.plugin.version}</version>
                <configuration>
                    <sourceDirectory>build</sourceDirectory>
                    <outputDirectory>build/asciidoc/${project.version}</outputDirectory>
                    <headerFooter>true</headerFooter>
                    <doctype>book</doctype>
                    <sourceHighlighter>coderay</sourceHighlighter>
                    <attributes>
                        <toc>left</toc>
                        <toclevels>3</toclevels>
                        <sectnums>true</sectnums>
                        <revnumber>${project.version}</revnumber>
                        <revdate>${maven.build.timestamp}</revdate>
                        <organization>厦门健康之路</organization>
                        <sourcedir>${project.build.sourceDirectory}</sourcedir>
                    </attributes>
                </configuration>
                <executions>
                    <execution>
                        <id>output-html</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>process-asciidoc</goal>
                        </goals>
                        <configuration>
                            <backend>html5</backend>
                        </configuration>
                    </execution>
                    <execution>
                        <id>output-docbook</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>process-asciidoc</goal>
                        </goals>
                        <configuration>
                            <backend>docbook</backend>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <!--打成war包插件 还需要
@ -475,19 +537,5 @@
                <!--springboot插件 en-->
            </plugins>
        </pluginManagement>
        <plugins>
            <!--编译插件 start-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
                <version>3.1</version>
            </plugin>
            <!--编译插件 end-->
        </plugins>
    </build>
</project>

+ 5 - 5
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceOrderController.java

@ -23,14 +23,14 @@ import java.util.List;
 */
@RestController
@RequestMapping(IotRequestMapping.api_iot_common)
@Api(value = "设备订单管理相关操作", description = "设备订单管理相关操作")
@Api(tags = "设备订单管理相关操作", description = "设备订单管理相关操作")
public class IotDeviceOrderController extends EnvelopRestController{
    @Autowired
    private IotDeviceOrderService iotDeviceOrderService;
    @PostMapping(value = IotRequestMapping.DeviceOrder.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建设备订单", notes = "创建设备订单")
    public Envelop create(@ApiParam(name = "json_data", value = "", defaultValue = "")
    public Envelop<IotDeviceOrderDO> create(@ApiParam(name = "json_data", value = "", defaultValue = "")
                          @RequestBody String jsonData) {
        try {
            IotDeviceOrderDO iotDeviceOrder = toEntity(jsonData, IotDeviceOrderDO.class);
@ -42,7 +42,7 @@ public class IotDeviceOrderController extends EnvelopRestController{
    @GetMapping(value = IotRequestMapping.DeviceOrder.api_getById)
    @ApiOperation(value = "根据code查找设备订单", notes = "根据code查找设备订单")
    public Envelop findByCode(@ApiParam(name = "id", value = "id")
    public Envelop<IotDeviceOrderDO>  findByCode(@ApiParam(name = "id", value = "id")
                              @RequestParam(value = "id", required = true) String id
    ) {
        try {
@ -54,7 +54,7 @@ public class IotDeviceOrderController extends EnvelopRestController{
    @RequestMapping(value = IotRequestMapping.DeviceOrder.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取设备订单")
    public Envelop queryPage(
    public Envelop<IotDeviceOrderDO>  queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段(id,supplierName,type,contactsName,contactsMobile)", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件(supplierName?中 g1;contactsName?中 g1)")
@ -82,7 +82,7 @@ public class IotDeviceOrderController extends EnvelopRestController{
    @GetMapping(value = IotRequestMapping.DeviceOrder.api_getList)
    @ApiOperation(value = "获取设备订单列表(不分页)")
    public Envelop getList(
    public Envelop<IotDeviceOrderDO>  getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段(id,supplierName,type,contactsName,contactsMobile)", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")

+ 27 - 6
web-gateway/src/main/java/com/yihu/jw/config/SwaggerConfig.java

@ -1,8 +1,5 @@
package com.yihu.jw.config;
import com.yihu.jw.commnon.base.base.BaseContants;
import com.yihu.jw.commnon.base.wx.WechatContants;
import com.yihu.jw.commnon.wlyy.AgreementContants;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@ -13,9 +10,6 @@ import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import static com.google.common.base.Predicates.or;
import static springfox.documentation.builders.PathSelectors.regex;
@Configuration
@EnableSwagger2
@ComponentScan("com.yihu.jw.controller.**")
@ -23,6 +17,7 @@ public class SwaggerConfig {
    public static final String base_API = "base";
    public static final String wlyy_API = "wlyy";
    public static final String login_API = "login";
    public static final String iot_API = "iot";
    @Bean
@ -104,4 +99,30 @@ public class SwaggerConfig {
        return apiInfo;
    }
    @Bean
    public Docket iotAPI() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName(iot_API)
                .useDefaultResponseMessages(false)
                .apiInfo(iotApiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.yihu.jw.controller.iot"))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo iotApiInfo() {
        ApiInfo apiInfo = new ApiInfo("基卫2.0API",
                "基卫2.0API,提供物联网相关服务。",
                "1.0",
                "No terms of service",
                "wenfujian@jkzl.com",
                "The Apache License, Version 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0.html"
        );
        return apiInfo;
    }
}