Sfoglia il codice sorgente

健康小屋-首次提交

huangzhiyong 6 anni fa
parent
commit
fd4aa62053

+ 14 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/health/house/HealthyHouseMapping.java

@ -0,0 +1,14 @@
package com.yihu.jw.rm.health.house;
/**
 * Created by Trick on 2018/2/7.
 */
public class HealthyHouseMapping {
    public static final String api_healthyHouse_common = "svr-healthy-house";
    public static final String api_success ="succes";
    public static class HealthyHouse{
    }
}

+ 25 - 0
svr/svr-healthy-house/.gitignore

@ -0,0 +1,25 @@
/target/
!.mvn/wrapper/maven-wrapper.jar
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/build/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

+ 97 - 0
svr/svr-healthy-house/pom.xml

@ -0,0 +1,97 @@
<?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">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>com.yihu.jw</groupId>
		<artifactId>wlyy-parent-pom</artifactId>
		<version>2.0.0</version>
		<relativePath>../../wlyy-parent-pom/pom.xml</relativePath>
	</parent>
	<groupId>com.yihu.jw</groupId>
	<artifactId>healthy-house</artifactId>
	<version>${parent.version}</version>
	<packaging>jar</packaging>
	<name>healthy-house</name>
	<description>healthy-house for jw2.0</description>
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>1.8</java.version>
		<spring-cloud.version>Finchley.SR1</spring-cloud.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-jdbc</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-aop</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-logging</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-eureka</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-config</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.data</groupId>
			<artifactId>spring-data-jpa</artifactId>
		</dependency>
		<dependency>
			<groupId>com.yihu</groupId>
			<artifactId>swagger-starter</artifactId>
		</dependency>
		<dependency>
			<groupId>com.yihu</groupId>
			<artifactId>mysql-starter</artifactId>
		</dependency>
		<dependency>
			<groupId>com.yihu.jw</groupId>
			<artifactId>common-request-mapping</artifactId>
		</dependency>
		<dependency>
			<groupId>com.yihu.jw</groupId>
			<artifactId>common-entity</artifactId>
		</dependency>
	</dependencies>
</project>

+ 1 - 0
svr/svr-healthy-house/readme.MD

@ -0,0 +1 @@
svr-healthy-house i健康城市健康-健康小屋

+ 17 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/HealthyHouseApplication.java

@ -0,0 +1,17 @@
package com.yihu.jw.healthyhouse;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.oauth2.OAuth2AutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@SpringBootApplication(exclude = OAuth2AutoConfiguration.class)
@ComponentScan(basePackages = {"com"})
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
public class HealthyHouseApplication {
	public static void main(String[] args) {
		SpringApplication.run(HealthyHouseApplication.class, args);
	}
}

+ 49 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/config/SwaggerConfig.java

@ -0,0 +1,49 @@
//package com.yihu.jw.healthyhouse.config;
//
//import com.yihu.jw.rm.health.house.HealthyHouseMapping;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.ComponentScan;
//import org.springframework.context.annotation.Configuration;
//import springfox.documentation.service.ApiInfo;
//import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spring.web.plugins.Docket;
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
//
//import static springfox.documentation.builders.PathSelectors.regex;
//
//@Configuration
//@EnableSwagger2
//@ComponentScan("com.yihu.jw.**")
//public class SwaggerConfig {
//    public static final String house_API = "house";
//
//    @Bean
//    public Docket wlyyAPI() {
//        return new Docket(DocumentationType.SWAGGER_2)
//                .groupName(house_API)
//                .useDefaultResponseMessages(false)
//                .forCodeGeneration(false)
//                .pathMapping("/")
//                .select()
//                .paths(or(
//                        regex("/" + HealthyHouseMapping.api_healthyHouse_common + "/.*")
//                ))
//                .build()
//                .apiInfo(wlyyApiInfo());
//    }
//
//    private ApiInfo wlyyApiInfo() {
//        ApiInfo wlyyInfo = 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 wlyyInfo;
//    }
//
//
//}

+ 29 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/config/jpa/HibernateProperties.java

@ -0,0 +1,29 @@
package com.yihu.jw.healthyhouse.config.jpa;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;
import java.util.Properties;
/**
 * Created by chenweida on 2017/4/6.
 */
@Component
@RefreshScope
public class HibernateProperties {
    @Value("${hibernate.dialect}")
    private String dialect;
    @Value("${hibernate.show_sql}")
    private String show_sql;
    @Value("${hibernate.ejb.naming_strategy}")
    private String naming_strategy;
    public  Properties hibProperties() {
        Properties properties = new Properties();
        properties.put("hibernate.dialect",dialect);
        properties.put("hibernate.show_sql", show_sql);
        properties.put("hibernate.ejb.naming_strategy", naming_strategy);
        return properties;
    }
}

+ 58 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/config/jpa/WlyyHouseJpa.java

@ -0,0 +1,58 @@
package com.yihu.jw.healthyhouse.config.jpa;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import java.util.Properties;
/**
 * Created by chenweida on 2017/4/6.
 */
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
        entityManagerFactoryRef = "wlyyHouseEntityManagerFactory",
        transactionManagerRef = "wlyyHouseTransactionManager",
        basePackages = {"com.yihu.jw.healthyhouse.dao"})   //设置Repository所在位置
public class WlyyHouseJpa {
    @Autowired
    private HibernateProperties hibernateProperties;
    @Bean(name = "wlyyHouseEntityManagerFactory")
    @Primary
    public LocalContainerEntityManagerFactoryBean entityManagerFactoryPrimary(DataSource dataSource) {
        LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
        emfb.setDataSource(dataSource);
        emfb.setPackagesToScan("com.yihu.jw.healthyhouse.entity");
        emfb.setPersistenceUnitName("archives");
        JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        emfb.setJpaVendorAdapter(vendorAdapter);
        Properties properties = hibernateProperties.hibProperties();
        properties.put("hibernate.ejb.naming_strategy","org.hibernate.cfg.ImprovedNamingStrategy");
        emfb.setJpaProperties(hibernateProperties.hibProperties());
        return emfb;
    }
    @Bean(name = "wlyyHouseTransactionManager")
    @Primary
    JpaTransactionManager transactionManagerSecondary(
            @Qualifier("wlyyHouseEntityManagerFactory") EntityManagerFactory builder) {
        return new JpaTransactionManager(builder);
    }
}

+ 88 - 0
svr/svr-healthy-house/src/main/resources/application.yml

@ -0,0 +1,88 @@
##如果有配置服务的话,远程服务器和本地服务器配置不一致的情况下,优先远程的为主  git上 svr-base ->  git application ->本地 appliction ->本地 bootstarp
server:
  port: 10081
spring:
  application:
    name:  svr-healthy-house
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    max-active: 50
    max-idle: 50 #最大空闲连接
    min-idle: 10 #最小空闲连接
    validation-query-timeout: 20
    log-validation-errors: true
    validation-interval: 60000 #避免过度验证,保证验证不超过这个频率——以毫秒为单位。如果一个连接应该被验证,但上次验证未达到指定间隔,将不再次验证。
    validation-query: SELECT 1 #SQL 查询, 用来验证从连接池取出的连接, 在将连接返回给调用者之前。 如果指定, 则查询必须是一个SQL SELECT 并且必须返回至少一行记录
    test-on-borrow: true #指明是否在从池中取出连接前进行检验, 如果检验失败, 则从池中去除连接并尝试取出另一个。注意: 设置为true 后如果要生效,validationQuery 参数必须设置为非空字符串
    test-on-return: true #指明是否在归还到池中前进行检验 注意: 设置为true 后如果要生效validationQuery 参数必须设置为非空字符串
    idle-timeout: 30000
    connection-test-query: SELECT 1
    num-tests-per-eviction-run: 50 #在每次空闲连接回收器线程(如果有)运行时检查的连接数量,最好和maxActive
    test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
    min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
    time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
  data:
    elasticsearch: #ElasticsearchProperties
      cluster-name: jkzl #默认即为elasticsearch  集群名
      cluster-nodes: 172.19.103.68:9300 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
      local: false #是否本地连接
      properties: # Additional properties used to configure the client.
        enable: true
  # JEST (Elasticsearch HTTP client) (JestProperties)
  elasticsearch:
    jest:
      uris: http://172.19.103.68:9200
#      uris: http://172.19.103.68:9200
      connection-timeout: 60000 # Connection timeout in milliseconds.
      multi-threaded: true # Enable connection requests from multiple execution threads.
#      username: # Login user.
#      password: # Login password.
#      proxy.port:  # Proxy port the HTTP client should use.
#      proxy.host:  # Proxy host the HTTP client should use.
#hibernate 配置
hibernate:
  dialect: org.hibernate.dialect.MySQL5Dialect
  show_sql: true
  ejb:
    naming_strategy: org.hibernate.cfg.ImprovedNamingStrategy
fast-dfs:
  tracker-server: 172.19.103.54:22122 #服务器地址
  connect-timeout: 2 #链接超时时间
  network-timeout: 30
  charset: ISO8859-1 #编码
  http:
    tracker-http-port: 80
    anti-steal-token: no
    secret-key: FastDFS1234567890
  pool: #连接池大小
    init-size: 5
    max-size: 20
    wait-time: 500
---
spring:
  profiles: dev
  datasource:
    url: jdbc:mysql://172.19.103.77:3306/wlyy_archives?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: root
    password: 123456
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
---
spring:
  profiles: jwtest
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
---
spring:
  profiles: jwprod
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/

+ 14 - 0
svr/svr-healthy-house/src/main/resources/banner.txt

@ -0,0 +1,14 @@
 /$$                           /$$   /$$     /$$                         /$$
| $$                          | $$  | $$    | $$                        | $$
| $$$$$$$   /$$$$$$   /$$$$$$ | $$ /$$$$$$  | $$$$$$$  /$$   /$$        | $$$$$$$   /$$$$$$  /$$   /$$  /$$$$$$$  /$$$$$$
| $$__  $$ /$$__  $$ |____  $$| $$|_  $$_/  | $$__  $$| $$  | $$ /$$$$$$| $$__  $$ /$$__  $$| $$  | $$ /$$_____/ /$$__  $$
| $$  \ $$| $$$$$$$$  /$$$$$$$| $$  | $$    | $$  \ $$| $$  | $$|______/| $$  \ $$| $$  \ $$| $$  | $$|  $$$$$$ | $$$$$$$$
| $$  | $$| $$_____/ /$$__  $$| $$  | $$ /$$| $$  | $$| $$  | $$        | $$  | $$| $$  | $$| $$  | $$ \____  $$| $$_____/
| $$  | $$|  $$$$$$$|  $$$$$$$| $$  |  $$$$/| $$  | $$|  $$$$$$$        | $$  | $$|  $$$$$$/|  $$$$$$/ /$$$$$$$/|  $$$$$$$
|__/  |__/ \_______/ \_______/|__/   \___/  |__/  |__/ \____  $$        |__/  |__/ \______/  \______/ |_______/  \_______/
                                                       /$$  | $$
                                                      |  $$$$$$/
                                                       \______/
**************************spring-boot.version: ${spring-boot.version}*****************************

+ 45 - 0
svr/svr-healthy-house/src/main/resources/bootstrap.yml

@ -0,0 +1,45 @@
spring:
  #从发现服务里面取配置服务的信息
  cloud:
    config:
      failFast: true #启动快速失败 即链接不到配置服务就启动失败
      username: jw
      password: jkzl
      discovery:
        enabled: true #使用发现服务
        service-id: svr-configurations #配置服务的名字
---
spring:
  profiles: dev
##发现服务的地址
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@172.19.103.33:8761/eureka/
---
spring:
  profiles: jwtest
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@172.19.103.33:8761/eureka/
---
spring:
  profiles: jwprod
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@127.0.0.1:8761/eureka/

+ 16 - 0
svr/svr-healthy-house/src/test/java/com/yihu/jw/healthyhouse/HealthyHouseApplicationTests.java

@ -0,0 +1,16 @@
package com.yihu.jw.healthyhouse;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class HealthyHouseApplicationTests {
	@Test
	public void contextLoads() {
	}
}