From 4175b8dc99f19a1d44e3450026679a929c09ff0d Mon Sep 17 00:00:00 2001 From: wangchao Date: Thu, 16 Apr 2020 15:25:31 +0800 Subject: [PATCH] =?UTF-8?q?dev=5Fgovgrid=E5=88=86=E6=94=AF=E6=96=B0?= =?UTF-8?q?=E5=BB=BAgov=5Fgird=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-gateway/pom.xml | 6 + epmet-module/gov-grid/gov-grid-client/pom.xml | 15 ++ .../gov-grid/gov-grid-server/Dockerfile | 11 + .../gov-grid-server/docker-compose.yml | 15 ++ epmet-module/gov-grid/gov-grid-server/pom.xml | 191 ++++++++++++++++++ .../java/com/epmet/GovGridApplication.java | 23 +++ .../com/epmet/config/ModuleConfigImpl.java | 26 +++ .../java/com/epmet/config/SwaggerConfig.java | 68 +++++++ .../com/epmet/exception/ModuleErrorCode.java | 16 ++ .../src/main/resources/bootstrap.yml | 119 +++++++++++ .../src/main/resources/logback-spring.xml | 159 +++++++++++++++ epmet-module/gov-grid/pom.xml | 20 ++ epmet-module/pom.xml | 1 + 13 files changed, 670 insertions(+) create mode 100644 epmet-module/gov-grid/gov-grid-client/pom.xml create mode 100644 epmet-module/gov-grid/gov-grid-server/Dockerfile create mode 100644 epmet-module/gov-grid/gov-grid-server/docker-compose.yml create mode 100644 epmet-module/gov-grid/gov-grid-server/pom.xml create mode 100644 epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/GovGridApplication.java create mode 100644 epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/config/ModuleConfigImpl.java create mode 100644 epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/config/SwaggerConfig.java create mode 100644 epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/exception/ModuleErrorCode.java create mode 100644 epmet-module/gov-grid/gov-grid-server/src/main/resources/bootstrap.yml create mode 100644 epmet-module/gov-grid/gov-grid-server/src/main/resources/logback-spring.xml create mode 100644 epmet-module/gov-grid/pom.xml diff --git a/epmet-gateway/pom.xml b/epmet-gateway/pom.xml index dbdf2ef12c..63d72d19ad 100644 --- a/epmet-gateway/pom.xml +++ b/epmet-gateway/pom.xml @@ -151,6 +151,8 @@ http://127.0.0.1:8095 http://127.0.0.1:8096 + + http://127.0.0.1:8097 @@ -207,6 +209,8 @@ lb://resi-group-server lb://resi-partymember-server + + lb://gov-grid-server @@ -263,6 +267,8 @@ lb://resi-group-server lb://resi-partymember-server + + lb://gov-grid-server diff --git a/epmet-module/gov-grid/gov-grid-client/pom.xml b/epmet-module/gov-grid/gov-grid-client/pom.xml new file mode 100644 index 0000000000..1628c20535 --- /dev/null +++ b/epmet-module/gov-grid/gov-grid-client/pom.xml @@ -0,0 +1,15 @@ + + + + gov-grid + com.epmet + 2.0.0 + + 4.0.0 + + gov-grid-client + + + \ No newline at end of file diff --git a/epmet-module/gov-grid/gov-grid-server/Dockerfile b/epmet-module/gov-grid/gov-grid-server/Dockerfile new file mode 100644 index 0000000000..05e0085107 --- /dev/null +++ b/epmet-module/gov-grid/gov-grid-server/Dockerfile @@ -0,0 +1,11 @@ +FROM java:8 + +RUN export LANG="zh_CN.UTF-8" +RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +RUN echo 'Asia/Shanghai' > /etc/timezone + +COPY ./target/*.jar ./app.jar + +EXPOSE 8092 + +ENTRYPOINT ["java","-Xms32m","-Xmx200m","-jar","./app.jar"] \ No newline at end of file diff --git a/epmet-module/gov-grid/gov-grid-server/docker-compose.yml b/epmet-module/gov-grid/gov-grid-server/docker-compose.yml new file mode 100644 index 0000000000..5c796174a7 --- /dev/null +++ b/epmet-module/gov-grid/gov-grid-server/docker-compose.yml @@ -0,0 +1,15 @@ +version: "3.7" +services: + gov-org-server: + container_name: gov-grid-server-dev + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-dev/gov-grid-server:0.3.0 + ports: + - "8097:8097" + network_mode: host # 使用现有网络 + volumes: + - "/opt/epmet-cloud-logs/dev:/logs" + deploy: + resources: + limits: + cpus: '0.1' + memory: 250M \ No newline at end of file diff --git a/epmet-module/gov-grid/gov-grid-server/pom.xml b/epmet-module/gov-grid/gov-grid-server/pom.xml new file mode 100644 index 0000000000..02e8b83550 --- /dev/null +++ b/epmet-module/gov-grid/gov-grid-server/pom.xml @@ -0,0 +1,191 @@ + + + 4.0.0 + 0.3.0 + + com.epmet + gov-grid + 2.0.0 + + gov-grid-server + jar + + + + com.epmet + gov-grid-client + 2.0.0 + + + com.epmet + epmet-commons-mybatis + 2.0.0 + + + com.epmet + epmet-commons-dynamic-datasource + 2.0.0 + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework + spring-context-support + + + org.springframework.boot + spring-boot-starter-actuator + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + io.github.openfeign + feign-httpclient + 10.3.0 + + + + + com.epmet + gov-org-client + 2.0.0 + + + com.epmet + resi-partymember-client + 2.0.0 + compile + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + ${project.basedir}/src/main/java + + + true + ${basedir}/src/main/resources + + + + + + + dev-local + + true + + + 8097 + dev + + + + + + epmet + elink@833066 + + 0 + 127.0.0.1 + 6379 + 123456 + + false + 122.152.200.70:8848 + fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b + + + false + + + + + dev + + + 8097 + dev + + + + + + epmet + elink@833066 + + 0 + r-m5eoz5b6tkx09y6bpz.redis.rds.aliyuncs.com + 6379 + EpmEtrEdIs!q@w + + true + 192.168.10.150:8848 + 67e3c350-533e-4d7c-9f8f-faf1b4aa82ae + + + false + + + + + test + + + 8097 + test + + + + + + epmet + elink@833066 + + 0 + 10.10.10.248 + 6379 + 123456 + + true + 122.152.200.70:8848 + fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b + + + false + + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/GovGridApplication.java b/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/GovGridApplication.java new file mode 100644 index 0000000000..ac047e4a68 --- /dev/null +++ b/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/GovGridApplication.java @@ -0,0 +1,23 @@ +package com.epmet; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; + +/** + * + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@SpringBootApplication +@EnableDiscoveryClient +@EnableFeignClients +public class GovGridApplication { + + public static void main(String[] args) { + SpringApplication.run(GovGridApplication.class, args); + } + +} diff --git a/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/config/ModuleConfigImpl.java b/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/config/ModuleConfigImpl.java new file mode 100644 index 0000000000..e15538fdaa --- /dev/null +++ b/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/config/ModuleConfigImpl.java @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.config; + +import com.epmet.commons.tools.config.ModuleConfig; +import org.springframework.stereotype.Service; + +/** + * 模块配置信息 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Service +public class ModuleConfigImpl implements ModuleConfig { + @Override + public String getName() { + return "govgrid"; + } +} diff --git a/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/config/SwaggerConfig.java b/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/config/SwaggerConfig.java new file mode 100644 index 0000000000..e4ceef42ee --- /dev/null +++ b/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/config/SwaggerConfig.java @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.config; + +import com.epmet.commons.tools.constant.Constant; +import io.swagger.annotations.ApiOperation; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.ApiKey; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import java.util.List; + +import static com.google.common.collect.Lists.newArrayList; + +/** + * Swagger配置 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Configuration +@EnableSwagger2 +public class SwaggerConfig { + + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .select() + //加了ApiOperation注解的类,才生成接口文档 + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + //包下的类,才生成接口文档 + //.apis(RequestHandlerSelectors.basePackage("io.renren.controller")) + .paths(PathSelectors.any()) + .build() + .directModelSubstitute(java.util.Date.class, String.class) + .securitySchemes(security()); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("人人开源") + .description("系统模块开发文档") + .termsOfServiceUrl("https://www.renren.io/community") + .version("1.4.0") + .build(); + } + + private List security() { + return newArrayList( + new ApiKey(Constant.TOKEN_HEADER, Constant.TOKEN_HEADER, "header") + ); + } + +} diff --git a/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/exception/ModuleErrorCode.java b/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/exception/ModuleErrorCode.java new file mode 100644 index 0000000000..f7aba2c2c7 --- /dev/null +++ b/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/exception/ModuleErrorCode.java @@ -0,0 +1,16 @@ +package com.epmet.exception; + +import com.epmet.commons.tools.exception.ErrorCode; + +/** + * 模块错误编码,由9位数字组成,前6位为模块编码,后3位为业务编码 + *

+ * 如:100001001(100001代表模块,001代表业务代码) + *

+ * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public interface ModuleErrorCode extends ErrorCode { + +} diff --git a/epmet-module/gov-grid/gov-grid-server/src/main/resources/bootstrap.yml b/epmet-module/gov-grid/gov-grid-server/src/main/resources/bootstrap.yml new file mode 100644 index 0000000000..711bab33d1 --- /dev/null +++ b/epmet-module/gov-grid/gov-grid-server/src/main/resources/bootstrap.yml @@ -0,0 +1,119 @@ +server: + port: @server.port@ + servlet: + context-path: /gov/grid + +spring: + main: + allow-bean-definition-overriding: true + application: + name: gov-grid-server + #环境 dev|test|prod + profiles: + active: dev + messages: + encoding: UTF-8 + basename: i18n/messages_common + jackson: + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + redis: + database: @spring.redis.index@ + host: @spring.redis.host@ + port: @spring.redis.port@ + password: @spring.redis.password@ + timeout: 30s + datasource: + druid: + #MySQL + driver-class-name: com.mysql.cj.jdbc.Driver + url: @spring.datasource.druid.url@ + username: @spring.datasource.druid.username@ + password: @spring.datasource.druid.password@ + initial-size: 10 + max-active: 100 + min-idle: 10 + max-wait: 60000 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 300000 + #Oracle需要打开注释 + #validation-query: SELECT 1 FROM DUAL + test-while-idle: true + test-on-borrow: false + test-on-return: false + filter: + stat: + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: false + wall: + config: + multi-statement-allow: true + cloud: + nacos: + discovery: + server-addr: @nacos.server-addr@ + #nacos的命名空间ID,默认是public + namespace: @nacos.discovery.namespace@ + #不把自己注册到注册中心的地址 + register-enabled: @nacos.register-enabled@ + ip: @nacos.ip@ + config: + enabled: @nacos.config-enabled@ + server-addr: @nacos.server-addr@ + namespace: @nacos.config.namespace@ + group: @nacos.config.group@ + file-extension: yaml +management: + endpoints: + web: + exposure: + include: "*" + endpoint: + health: + show-details: ALWAYS + +mybatis-plus: + mapper-locations: classpath:/mapper/**/*.xml + #实体扫描,多个package用逗号或者分号分隔 + typeAliasesPackage: com.epmet.entity + global-config: + #数据库相关配置 + db-config: + #主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; + id-type: ID_WORKER + #字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断" + field-strategy: NOT_NULL + #驼峰下划线转换 + column-underline: true + banner: false + #原生配置 + configuration: + map-underscore-to-camel-case: true + cache-enabled: false + call-setters-on-nulls: true + jdbc-type-for-null: 'null' + +feign: + hystrix: + enabled: true + client: + config: + default: + loggerLevel: BASIC + httpclient: + enabled: true + +hystrix: + command: + default: + execution: + isolation: + thread: + timeoutInMilliseconds: 60000 #缺省为1000 + +ribbon: + ReadTimeout: 300000 + ConnectTimeout: 300000 diff --git a/epmet-module/gov-grid/gov-grid-server/src/main/resources/logback-spring.xml b/epmet-module/gov-grid/gov-grid-server/src/main/resources/logback-spring.xml new file mode 100644 index 0000000000..1c80278558 --- /dev/null +++ b/epmet-module/gov-grid/gov-grid-server/src/main/resources/logback-spring.xml @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + debug + + + ${CONSOLE_LOG_PATTERN} + + UTF-8 + + + + + + + + ${log.path}/debug.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/debug-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + debug + ACCEPT + DENY + + + + + + + ${log.path}/info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/info-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + info + ACCEPT + DENY + + + + + + + ${log.path}/warn.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/warn-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + warn + ACCEPT + DENY + + + + + + + ${log.path}/error.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/error-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epmet-module/gov-grid/pom.xml b/epmet-module/gov-grid/pom.xml new file mode 100644 index 0000000000..5c0bc36a59 --- /dev/null +++ b/epmet-module/gov-grid/pom.xml @@ -0,0 +1,20 @@ + + + + epmet-module + com.epmet + 2.0.0 + + 4.0.0 + + gov-grid + pom + + gov-grid-client + gov-grid-server + + + + \ No newline at end of file diff --git a/epmet-module/pom.xml b/epmet-module/pom.xml index f48d428c3e..81243917bf 100644 --- a/epmet-module/pom.xml +++ b/epmet-module/pom.xml @@ -27,6 +27,7 @@ resi-mine resi-group resi-partymember + gov-grid