Commit 57b89a9921ee20e77c59a99cac22ea91a8f74b67
Exists in
master
Merge remote-tracking branch 'origin/master'
Showing
56 changed files
with
1817 additions
and
767 deletions
Show diff stats
cloud/.gitignore
cloud/autho/pom.xml
@@ -19,11 +19,11 @@ | @@ -19,11 +19,11 @@ | ||
19 | <artifactId>common</artifactId> | 19 | <artifactId>common</artifactId> |
20 | <version>1.0.0</version> | 20 | <version>1.0.0</version> |
21 | </dependency> | 21 | </dependency> |
22 | - <dependency> | ||
23 | - <groupId>org.springframework.boot</groupId> | ||
24 | - <artifactId>spring-boot-starter-test</artifactId> | ||
25 | - <scope>test</scope> | ||
26 | - </dependency> | 22 | +<!-- <dependency>--> |
23 | +<!-- <groupId>org.springframework.boot</groupId>--> | ||
24 | +<!-- <artifactId>spring-boot-starter-test</artifactId>--> | ||
25 | +<!-- <scope>test</scope>--> | ||
26 | +<!-- </dependency>--> | ||
27 | <dependency> | 27 | <dependency> |
28 | <groupId>org.springframework.cloud</groupId> | 28 | <groupId>org.springframework.cloud</groupId> |
29 | <artifactId>spring-cloud-starter-feign</artifactId> | 29 | <artifactId>spring-cloud-starter-feign</artifactId> |
@@ -69,7 +69,7 @@ | @@ -69,7 +69,7 @@ | ||
69 | 69 | ||
70 | <build> | 70 | <build> |
71 | <!--打包文件名--> | 71 | <!--打包文件名--> |
72 | - <finalName>autho</finalName> | 72 | + <finalName>quartz_server</finalName> |
73 | <!--打包方式--> | 73 | <!--打包方式--> |
74 | <plugins> | 74 | <plugins> |
75 | <!-- 设置编译版本 --> | 75 | <!-- 设置编译版本 --> |
@@ -91,7 +91,7 @@ | @@ -91,7 +91,7 @@ | ||
91 | <configuration> | 91 | <configuration> |
92 | <archive> | 92 | <archive> |
93 | <manifest> | 93 | <manifest> |
94 | - <mainClass>com.sincere.autho.AuthoApplication</mainClass> | 94 | + <mainClass>com.sincere.userSearch.UserApplication</mainClass> |
95 | <addClasspath>true</addClasspath> | 95 | <addClasspath>true</addClasspath> |
96 | <classpathPrefix>lib/</classpathPrefix> | 96 | <classpathPrefix>lib/</classpathPrefix> |
97 | </manifest> | 97 | </manifest> |
@@ -0,0 +1,24 @@ | @@ -0,0 +1,24 @@ | ||
1 | +#端口 | ||
2 | +server: | ||
3 | + port: 8761 | ||
4 | +# address: sincere.myjxt.com | ||
5 | + | ||
6 | +#服务名称 | ||
7 | +spring: | ||
8 | + application: | ||
9 | + name: eureka-server1 | ||
10 | + main: | ||
11 | + allow-bean-definition-overriding: true | ||
12 | + | ||
13 | + | ||
14 | +management: | ||
15 | + endpoints: | ||
16 | + web: | ||
17 | + exposure: | ||
18 | + include: "*" | ||
19 | + endpoint: | ||
20 | + health: | ||
21 | + show-details: always | ||
22 | + | ||
23 | + | ||
24 | + | ||
0 | \ No newline at end of file | 25 | \ No newline at end of file |
cloud/autho/src/test/java/com/sincere/autho/AuthoApplicationTests.java
@@ -1,16 +0,0 @@ | @@ -1,16 +0,0 @@ | ||
1 | -package com.sincere.autho; | ||
2 | - | ||
3 | -import org.junit.Test; | ||
4 | -import org.junit.runner.RunWith; | ||
5 | -import org.springframework.boot.test.context.SpringBootTest; | ||
6 | -import org.springframework.test.context.junit4.SpringRunner; | ||
7 | - | ||
8 | -@RunWith(SpringRunner.class) | ||
9 | -@SpringBootTest | ||
10 | -public class AuthoApplicationTests { | ||
11 | - | ||
12 | - @Test | ||
13 | - public void contextLoads() { | ||
14 | - } | ||
15 | - | ||
16 | -} |
cloud/common/pom.xml
@@ -99,7 +99,7 @@ | @@ -99,7 +99,7 @@ | ||
99 | </dependency> | 99 | </dependency> |
100 | </dependencies> | 100 | </dependencies> |
101 | 101 | ||
102 | - <build> | 102 | + <!-- <build> |
103 | <plugins> | 103 | <plugins> |
104 | <plugin> | 104 | <plugin> |
105 | <groupId>org.springframework.boot</groupId> | 105 | <groupId>org.springframework.boot</groupId> |
@@ -109,6 +109,6 @@ | @@ -109,6 +109,6 @@ | ||
109 | </configuration> | 109 | </configuration> |
110 | </plugin> | 110 | </plugin> |
111 | </plugins> | 111 | </plugins> |
112 | - </build> | 112 | + </build>--> |
113 | 113 | ||
114 | </project> | 114 | </project> |
cloud/common/src/main/java/com/sincere/common/util/BaiduApiUtiols.java
@@ -1,84 +0,0 @@ | @@ -1,84 +0,0 @@ | ||
1 | -package com.sincere.common.util; | ||
2 | - | ||
3 | -import org.springframework.http.HttpEntity; | ||
4 | -import org.springframework.http.HttpHeaders; | ||
5 | -import org.springframework.http.MediaType; | ||
6 | -import org.springframework.http.ResponseEntity; | ||
7 | -import org.springframework.util.LinkedMultiValueMap; | ||
8 | -import org.springframework.util.MultiValueMap; | ||
9 | -import org.springframework.web.client.RestTemplate; | ||
10 | - | ||
11 | -public class BaiduApiUtiols { | ||
12 | - | ||
13 | - public static BaiduApiUtiols baiduApiUtiols; | ||
14 | - | ||
15 | - public static BaiduApiUtiols getInstance() { | ||
16 | - | ||
17 | - if (null == baiduApiUtiols) { | ||
18 | - synchronized (BaiduApiUtiols.class) { | ||
19 | - baiduApiUtiols = new BaiduApiUtiols(); | ||
20 | - } | ||
21 | - } | ||
22 | - return baiduApiUtiols; | ||
23 | - } | ||
24 | - | ||
25 | - | ||
26 | - /** | ||
27 | - * @param imgPath 图片路径 | ||
28 | - * @param group_id 学校id | ||
29 | - * @param user_id 用户id | ||
30 | - * @param user_info 用户名字 | ||
31 | - * @return | ||
32 | - */ | ||
33 | - public String registerFace(String imgPath, String group_id, String user_id, String user_info) { | ||
34 | - | ||
35 | - String registUrl = "https://aip.baidubce.com/rest/2.0/face/v3/faceset/user/add?access_token=" + AuthService.getFaceAuthToken(); | ||
36 | - long time = System.currentTimeMillis(); | ||
37 | - System.out.println("starttime:"+time); | ||
38 | - RestTemplate restTemplate = new RestTemplate(); | ||
39 | - MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>(); | ||
40 | - multiValueMap.add("image", Base64Util.imageencode(imgPath)); | ||
41 | - multiValueMap.add("image_type", "BASE64"); | ||
42 | - multiValueMap.add("group_id", group_id); | ||
43 | - multiValueMap.add("user_id", user_id); | ||
44 | - multiValueMap.add("user_info", user_info); | ||
45 | -// multiValueMap.add("quality_control", "NORMAL"); | ||
46 | - System.out.println("multiValueMap:" + multiValueMap.toString()); | ||
47 | - HttpHeaders headers = new HttpHeaders(); | ||
48 | - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); | ||
49 | - HttpEntity<MultiValueMap> requestEntity = new HttpEntity<MultiValueMap>(multiValueMap, | ||
50 | - headers); | ||
51 | - System.out.println("midddle:"+(System.currentTimeMillis()-time)); | ||
52 | - time = System.currentTimeMillis(); | ||
53 | - ResponseEntity<String> result = restTemplate.postForEntity(registUrl, requestEntity, String.class); | ||
54 | - System.out.println("end:"+(System.currentTimeMillis()-time)); | ||
55 | - System.out.println("result:" + result.getBody()); | ||
56 | - return result.getBody(); | ||
57 | - | ||
58 | - } | ||
59 | - | ||
60 | - public String searchFace(String imgPath,String group_id, String user_id){ | ||
61 | - String searchFace = "https://aip.baidubce.com/rest/2.0/face/v3/search?access_token="+AuthService.getFaceAuthToken(); | ||
62 | - long time = System.currentTimeMillis(); | ||
63 | - RestTemplate restTemplate = new RestTemplate(); | ||
64 | - MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>(); | ||
65 | - multiValueMap.add("image", Base64Util.imageencode(imgPath)); | ||
66 | - multiValueMap.add("image_type", "BASE64"); | ||
67 | - multiValueMap.add("group_id_list", group_id);//从指定的group中进行查找 用逗号分隔,上限10个 | ||
68 | - multiValueMap.add("user_id", user_id);//当需要对特定用户进行比对时,指定user_id进行比对。即人脸认证功能。 | ||
69 | -// multiValueMap.add("quality_control", "NORMAL"); | ||
70 | - System.out.println("multiValueMap:" + multiValueMap.toString()); | ||
71 | - HttpHeaders headers = new HttpHeaders(); | ||
72 | - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); | ||
73 | - HttpEntity<MultiValueMap> requestEntity = new HttpEntity<MultiValueMap>(multiValueMap, | ||
74 | - headers); | ||
75 | - System.out.println("midddle:"+(System.currentTimeMillis()-time)); | ||
76 | - time = System.currentTimeMillis(); | ||
77 | - ResponseEntity<String> result = restTemplate.postForEntity(searchFace, requestEntity, String.class); | ||
78 | - System.out.println("end:"+(System.currentTimeMillis()-time)); | ||
79 | - System.out.println("result:" + result.getBody()); | ||
80 | - return result.getBody(); | ||
81 | - | ||
82 | - } | ||
83 | - | ||
84 | -} |
cloud/common/src/main/java/com/sincere/common/util/HttpClientUtils.java
@@ -40,17 +40,17 @@ public class HttpClientUtils { | @@ -40,17 +40,17 @@ public class HttpClientUtils { | ||
40 | requestConfig = RequestConfig.custom().setSocketTimeout(5000).setConnectTimeout(5000).build(); | 40 | requestConfig = RequestConfig.custom().setSocketTimeout(5000).setConnectTimeout(5000).build(); |
41 | } | 41 | } |
42 | 42 | ||
43 | - public static void main(String[] args){ | ||
44 | -// String url = "http://http://zhktest.114school.com.cn/szkjapi/toyxy/addTeacherOrg" ; | ||
45 | -// String json = "{\"name\": \"子部门\",\"groupname\": \"父部门\",\"schoolid\": \"16\",\"token\": \"05719991\"}" ; | ||
46 | -// JSONObject jsonObject = HttpClientUtils.httpPostJson(url,json); | 43 | +// public static void main(String[] args){ |
44 | +//// String url = "http://http://zhktest.114school.com.cn/szkjapi/toyxy/addTeacherOrg" ; | ||
45 | +//// String json = "{\"name\": \"子部门\",\"groupname\": \"父部门\",\"schoolid\": \"16\",\"token\": \"05719991\"}" ; | ||
46 | +//// JSONObject jsonObject = HttpClientUtils.httpPostJson(url,json); | ||
47 | +//// System.out.println(jsonObject.toJSONString()); | ||
48 | +// | ||
49 | +// String url = "http://campus.myjxt.com/api/Room/GetListPageRoom" ; | ||
50 | +// String json = "PageIndex=1&roomId=6583&pageSize=9999" ; | ||
51 | +// JSONObject jsonObject = HttpClientUtils.httpPost(url,json); | ||
47 | // System.out.println(jsonObject.toJSONString()); | 52 | // System.out.println(jsonObject.toJSONString()); |
48 | - | ||
49 | - String url = "http://campus.myjxt.com/api/Room/GetListPageRoom" ; | ||
50 | - String json = "PageIndex=1&roomId=6583&pageSize=9999" ; | ||
51 | - JSONObject jsonObject = HttpClientUtils.httpPost(url,json); | ||
52 | - System.out.println(jsonObject.toJSONString()); | ||
53 | - } | 53 | +// } |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * post请求传输json参数 | 56 | * post请求传输json参数 |
@@ -0,0 +1,66 @@ | @@ -0,0 +1,66 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
5 | + <parent> | ||
6 | + <artifactId>cloud</artifactId> | ||
7 | + <groupId>com.sincere</groupId> | ||
8 | + <version>1.0.0</version> | ||
9 | + </parent> | ||
10 | + <modelVersion>4.0.0</modelVersion> | ||
11 | + | ||
12 | + <artifactId>fIle-center</artifactId> | ||
13 | + | ||
14 | + <description>文件中心</description> | ||
15 | + | ||
16 | + <properties> | ||
17 | + <swagger-version>2.9.2</swagger-version> | ||
18 | + </properties> | ||
19 | + | ||
20 | + | ||
21 | + <dependencies> | ||
22 | + | ||
23 | + <dependency> | ||
24 | + <groupId>io.springfox</groupId> | ||
25 | + <artifactId>springfox-swagger-ui</artifactId> | ||
26 | + <version>${swagger-version}</version> | ||
27 | + </dependency> | ||
28 | + <dependency> | ||
29 | + <groupId>io.springfox</groupId> | ||
30 | + <artifactId>springfox-swagger2</artifactId> | ||
31 | + <version>${swagger-version}</version> | ||
32 | + </dependency> | ||
33 | + | ||
34 | + <!-- WEB守护进程启动springboot --> | ||
35 | + <dependency> | ||
36 | + <groupId>org.springframework.boot</groupId> | ||
37 | + <artifactId>spring-boot-starter-web</artifactId> | ||
38 | + </dependency> | ||
39 | + | ||
40 | + <dependency> | ||
41 | + <groupId>com.aliyun.oss</groupId> | ||
42 | + <artifactId>aliyun-sdk-oss</artifactId> | ||
43 | + <version>2.8.3</version> | ||
44 | + </dependency> | ||
45 | + | ||
46 | + </dependencies> | ||
47 | + <!-- 形成带第三方jar包的可执行jar包,jar包目录结构如下 application.properties lib META-INF mybatis | ||
48 | + org --> | ||
49 | + <build> | ||
50 | + <plugins> | ||
51 | + <plugin> | ||
52 | + <groupId>org.springframework.boot</groupId> | ||
53 | + <artifactId>spring-boot-maven-plugin</artifactId> | ||
54 | + <executions> | ||
55 | + <execution> | ||
56 | + <goals> | ||
57 | + <goal>repackage</goal> | ||
58 | + </goals> | ||
59 | + </execution> | ||
60 | + </executions> | ||
61 | + </plugin> | ||
62 | + | ||
63 | + </plugins> | ||
64 | + <finalName>file-center</finalName> | ||
65 | + </build> | ||
66 | +</project> | ||
0 | \ No newline at end of file | 67 | \ No newline at end of file |
cloud/fIle-center/src/main/java/com/sincere/file/FileApplication.java
0 → 100644
@@ -0,0 +1,15 @@ | @@ -0,0 +1,15 @@ | ||
1 | +package com.sincere.file; | ||
2 | + | ||
3 | +import org.springframework.boot.SpringApplication; | ||
4 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
5 | +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; | ||
6 | +import org.springframework.cloud.netflix.eureka.EnableEurekaClient; | ||
7 | + | ||
8 | +@EnableDiscoveryClient | ||
9 | +@SpringBootApplication | ||
10 | +public class FileApplication { | ||
11 | + | ||
12 | + public static void main(String[] args) { | ||
13 | + SpringApplication.run(FileApplication.class,args); | ||
14 | + } | ||
15 | +} |
cloud/fIle-center/src/main/java/com/sincere/file/config/AliyunOSSConfig.java
0 → 100644
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
1 | +package com.sincere.file.config; | ||
2 | + | ||
3 | +import com.aliyun.oss.OSSClient; | ||
4 | +import org.springframework.beans.factory.annotation.Value; | ||
5 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
6 | +import org.springframework.context.annotation.Bean; | ||
7 | +import org.springframework.context.annotation.Configuration; | ||
8 | + | ||
9 | + | ||
10 | +/** | ||
11 | + * @author 作者 owen E-mail: 624191343@qq.com | ||
12 | + * @version 创建时间:2018年1月31日 下午9:11:36 类说明 白名单 | ||
13 | + * 阿里云配置 | ||
14 | + */ | ||
15 | +@Configuration | ||
16 | +public class AliyunOSSConfig { | ||
17 | + | ||
18 | + @Value("${aliyun.oss.endpoint:xxxxx}") | ||
19 | + private String endpoint; | ||
20 | + @Value("${aliyun.oss.access-key:xxxxx}") | ||
21 | + private String accessKeyId; | ||
22 | + @Value("${aliyun.oss.accessKeySecret:xxxxx}") | ||
23 | + private String accessKeySecret; | ||
24 | + | ||
25 | + /** | ||
26 | + * 阿里云文件存储client | ||
27 | + * 只有配置了aliyun.oss.access-key才可以使用 | ||
28 | + */ | ||
29 | + @Bean | ||
30 | + @ConditionalOnProperty(name = "aliyun.oss.access-key", matchIfMissing = true) | ||
31 | + public OSSClient ossClient() { | ||
32 | + OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret); | ||
33 | + return ossClient; | ||
34 | + } | ||
35 | + | ||
36 | +} |
cloud/fIle-center/src/main/java/com/sincere/file/config/SwaggerConfig.java
0 → 100644
@@ -0,0 +1,89 @@ | @@ -0,0 +1,89 @@ | ||
1 | +package com.sincere.file.config; | ||
2 | + | ||
3 | +import org.springframework.context.MessageSource; | ||
4 | +import org.springframework.context.annotation.Bean; | ||
5 | +import org.springframework.context.annotation.Configuration; | ||
6 | +import org.springframework.context.support.ResourceBundleMessageSource; | ||
7 | +import org.springframework.stereotype.Component; | ||
8 | +import org.springframework.web.servlet.ViewResolver; | ||
9 | +import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; | ||
10 | +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | ||
11 | +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
12 | +import org.springframework.web.servlet.view.InternalResourceViewResolver; | ||
13 | +import org.springframework.web.servlet.view.JstlView; | ||
14 | +import springfox.documentation.builders.ApiInfoBuilder; | ||
15 | +import springfox.documentation.builders.ParameterBuilder; | ||
16 | +import springfox.documentation.builders.PathSelectors; | ||
17 | +import springfox.documentation.builders.RequestHandlerSelectors; | ||
18 | +import springfox.documentation.schema.ModelRef; | ||
19 | +import springfox.documentation.service.ApiInfo; | ||
20 | +import springfox.documentation.service.Parameter; | ||
21 | +import springfox.documentation.spi.DocumentationType; | ||
22 | +import springfox.documentation.spring.web.plugins.Docket; | ||
23 | +import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
24 | + | ||
25 | +import java.util.ArrayList; | ||
26 | +import java.util.List; | ||
27 | + | ||
28 | +@Component | ||
29 | +@Configuration | ||
30 | +@EnableSwagger2 | ||
31 | +public class SwaggerConfig implements WebMvcConfigurer { | ||
32 | + | ||
33 | + @Bean | ||
34 | + public Docket createRestApi() { | ||
35 | + | ||
36 | + | ||
37 | + ParameterBuilder tokenPar = new ParameterBuilder(); | ||
38 | + List<Parameter> pars = new ArrayList<>(); | ||
39 | + tokenPar.name("ossPath").description("OSS存储路径,例如: YikeData"). | ||
40 | + modelRef(new ModelRef("string")). | ||
41 | + parameterType("header").required(false).build(); | ||
42 | + | ||
43 | + pars.add(tokenPar.build()); | ||
44 | + | ||
45 | + return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select() | ||
46 | + .apis(RequestHandlerSelectors.basePackage("com.sincere.file.control")) | ||
47 | +// .apis(RequestHandlerSelectors.any()) | ||
48 | +// .paths( input ->PathSelectors.regex("/file/*").apply(input) || PathSelectors.regex("/fileinfo.*").apply(input) | ||
49 | +// ) | ||
50 | + .paths(PathSelectors.any()) | ||
51 | + .build().globalOperationParameters(pars); | ||
52 | + } | ||
53 | + | ||
54 | + private ApiInfo apiInfo() { | ||
55 | + return new ApiInfoBuilder().title("文件中心api").description("文件中心api").version("1.0").build(); | ||
56 | + } | ||
57 | + | ||
58 | + @Bean | ||
59 | + public ViewResolver viewResolver() { | ||
60 | + InternalResourceViewResolver resolver = new InternalResourceViewResolver(); | ||
61 | + resolver.setViewClass(JstlView.class); | ||
62 | + resolver.setPrefix("/"); | ||
63 | + resolver.setSuffix(".html"); | ||
64 | + return resolver; | ||
65 | + | ||
66 | + } | ||
67 | + | ||
68 | + @Bean | ||
69 | + public MessageSource messageSource() { | ||
70 | + ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); | ||
71 | + messageSource.setBasename("messages"); | ||
72 | + return messageSource; | ||
73 | + } | ||
74 | + | ||
75 | + @Override | ||
76 | + public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||
77 | +// super.addResourceHandlers(registry); | ||
78 | + registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); | ||
79 | + registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); | ||
80 | + } | ||
81 | + | ||
82 | + @Override | ||
83 | + public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { | ||
84 | + configurer.enable(); | ||
85 | + } | ||
86 | + | ||
87 | + | ||
88 | + | ||
89 | +} | ||
0 | \ No newline at end of file | 90 | \ No newline at end of file |
cloud/fIle-center/src/main/java/com/sincere/file/control/FileControl.java
0 → 100644
@@ -0,0 +1,42 @@ | @@ -0,0 +1,42 @@ | ||
1 | +package com.sincere.file.control; | ||
2 | + | ||
3 | +import com.sincere.file.model.FileInfo; | ||
4 | +import com.sincere.file.service.FileService; | ||
5 | +import com.sincere.file.utils.FileUtil; | ||
6 | +import io.swagger.annotations.Api; | ||
7 | +import io.swagger.annotations.ApiOperation; | ||
8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
9 | +import org.springframework.web.bind.annotation.*; | ||
10 | +import org.springframework.web.multipart.MultipartFile; | ||
11 | + | ||
12 | +import javax.servlet.http.HttpServletRequest; | ||
13 | + | ||
14 | +@RestController | ||
15 | +@Api(tags = "文件管理") | ||
16 | +@RequestMapping(value = "file/*") | ||
17 | +public class FileControl { | ||
18 | + | ||
19 | + @Autowired | ||
20 | + FileService fileService; | ||
21 | + | ||
22 | + @PostMapping("fileUpload") | ||
23 | + @ApiOperation("上传文件") | ||
24 | + public String fileUpload(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws Exception { | ||
25 | + | ||
26 | + String ossPath = request.getHeader("ossPath");//oss的二级目录 | ||
27 | + | ||
28 | + FileInfo fileInfo = fileService.upload(file, ossPath); | ||
29 | + | ||
30 | + return fileInfo.getUrl(); | ||
31 | + | ||
32 | + } | ||
33 | + | ||
34 | + | ||
35 | + @DeleteMapping("deleteFile/{fileName}") | ||
36 | + @ApiOperation("删除文件") | ||
37 | + public boolean deleteFile(@PathVariable String fileName,HttpServletRequest request){ | ||
38 | + String ossPath = request.getHeader("ossPath");//oss的二级目录 | ||
39 | + fileService.delete(fileName,ossPath); | ||
40 | + return true; | ||
41 | + } | ||
42 | +} |
cloud/fIle-center/src/main/java/com/sincere/file/model/FileInfo.java
0 → 100644
@@ -0,0 +1,39 @@ | @@ -0,0 +1,39 @@ | ||
1 | +package com.sincere.file.model; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | + | ||
5 | +import java.io.Serializable; | ||
6 | +import java.util.Date; | ||
7 | + | ||
8 | +/** | ||
9 | + * @author 作者 owen E-mail: 624191343@qq.com | ||
10 | + * @version 创建时间:2017年11月12日 上午22:57:51 | ||
11 | + * file实体类 | ||
12 | +*/ | ||
13 | +@Data | ||
14 | +public class FileInfo implements Serializable { | ||
15 | + | ||
16 | + private static final long serialVersionUID = -1438078028040922174L; | ||
17 | +// md5字段 | ||
18 | + private String id; | ||
19 | +// 原始文件名 | ||
20 | + private String name; | ||
21 | +// 是否图片 | ||
22 | + private Boolean isImg; | ||
23 | +// 上传文件类型 | ||
24 | + private String contentType; | ||
25 | +// 文件大小 | ||
26 | + private long size; | ||
27 | +// 冗余字段 | ||
28 | + private String path; | ||
29 | +// oss访问路径 oss需要设置公共读 | ||
30 | + private String url; | ||
31 | +// FileType字段 | ||
32 | + private String source; | ||
33 | + private Date createTime; | ||
34 | + /** | ||
35 | + * 目录磁盘地址 | ||
36 | + */ | ||
37 | +// @TableField(exist = false) | ||
38 | +// private String pathDir; | ||
39 | +} |
cloud/fIle-center/src/main/java/com/sincere/file/service/FileService.java
0 → 100644
@@ -0,0 +1,24 @@ | @@ -0,0 +1,24 @@ | ||
1 | +package com.sincere.file.service; | ||
2 | + | ||
3 | +import com.sincere.file.model.FileInfo; | ||
4 | +import org.springframework.web.multipart.MultipartFile; | ||
5 | + | ||
6 | +import java.util.Map; | ||
7 | + | ||
8 | +/** | ||
9 | + * @author 作者 owen E-mail: 624191343@qq.com | ||
10 | + * @version 创建时间:2017年11月12日 上午22:57:51 | ||
11 | + * 文件service 目前仅支持阿里云oss,七牛云 | ||
12 | +*/ | ||
13 | +public interface FileService { | ||
14 | + | ||
15 | + FileInfo upload(MultipartFile file,String filePath) throws Exception; | ||
16 | + | ||
17 | + void delete(String fileName,String filePath); | ||
18 | + | ||
19 | + FileInfo getById(String id); | ||
20 | + | ||
21 | +// PageResult<FileInfo> findList(Map<String, Object> params); | ||
22 | + | ||
23 | + void unZip(String filePath, String descDir) throws RuntimeException ; | ||
24 | +} |
cloud/fIle-center/src/main/java/com/sincere/file/service/impl/AbstractFileService.java
0 → 100644
@@ -0,0 +1,88 @@ | @@ -0,0 +1,88 @@ | ||
1 | +package com.sincere.file.service.impl; | ||
2 | + | ||
3 | +import com.sincere.file.model.FileInfo; | ||
4 | +import com.sincere.file.service.FileService; | ||
5 | +import com.sincere.file.utils.FileUtil; | ||
6 | +import lombok.extern.slf4j.Slf4j; | ||
7 | +import org.springframework.web.multipart.MultipartFile; | ||
8 | + | ||
9 | +import java.util.concurrent.ExecutorService; | ||
10 | +import java.util.concurrent.Executors; | ||
11 | + | ||
12 | +/** | ||
13 | + * @author 作者 owen E-mail: 624191343@qq.com | ||
14 | + * @version 创建时间:2017年11月12日 上午22:57:51 | ||
15 | + * AbstractFileService 抽取类 | ||
16 | + * 根据filetype 实例化具体oss对象 | ||
17 | +*/ | ||
18 | +@Slf4j | ||
19 | +public abstract class AbstractFileService implements FileService { | ||
20 | + | ||
21 | +// protected abstract FileDao getFileDao(); | ||
22 | + protected static ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); | ||
23 | + @Override | ||
24 | + public FileInfo upload(MultipartFile file,String filePath) throws Exception { | ||
25 | + FileInfo fileInfo = FileUtil.getFileInfo(file); | ||
26 | +// FileInfo oldFileInfo = getFileDao().getById(fileInfo.getId()); | ||
27 | +// if (oldFileInfo != null) { | ||
28 | +// return oldFileInfo; | ||
29 | +// } | ||
30 | +// | ||
31 | +// if (!fileInfo.getName().contains(".")) { | ||
32 | +// throw new IllegalArgumentException("缺少后缀名"); | ||
33 | +// } | ||
34 | + | ||
35 | + uploadFile(file, fileInfo,filePath); | ||
36 | + | ||
37 | +// fileInfo.setSource(fileType().name());// 设置文件来源 | ||
38 | +// getFileDao().save(fileInfo);// 将文件信息保存到数据库 | ||
39 | +// // 本地保存文件 | ||
40 | +// FileUtil.saveFile(file,fileInfo.getPath()); | ||
41 | +// log.info("上传文件:{}", fileInfo); | ||
42 | + | ||
43 | + return fileInfo; | ||
44 | + } | ||
45 | + | ||
46 | + /** | ||
47 | + * 上传文件 | ||
48 | + * | ||
49 | + * @param file | ||
50 | + * @param fileInfo | ||
51 | + */ | ||
52 | + protected abstract void uploadFile(MultipartFile file, FileInfo fileInfo,String filePath) throws Exception; | ||
53 | + | ||
54 | + @Override | ||
55 | + public void delete(String fileName,String filePath) { | ||
56 | + deleteFile(fileName,filePath); | ||
57 | +// getFileDao().delete(fileInfo.getId()); | ||
58 | + log.info("删除文件:{}", fileName); | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * 删除文件资源 | ||
63 | + * | ||
64 | +// * @param fileInfo | ||
65 | + * @return | ||
66 | + */ | ||
67 | + protected abstract boolean deleteFile(String fileName,String filePath); | ||
68 | + | ||
69 | + @Override | ||
70 | + public FileInfo getById(String id){ | ||
71 | +// return getFileDao().getById(id); | ||
72 | + return null; | ||
73 | + } | ||
74 | + | ||
75 | +// public PageResult<FileInfo> findList(Map<String, Object> params){ | ||
76 | +// //设置分页信息,分别是当前页数和每页显示的总记录数【记住:必须在mapper接口中的方法执行之前设置该分页信息】 | ||
77 | +// PageHelper.startPage(MapUtils.getInteger(params, "page"),MapUtils.getInteger(params, "limit"),true); | ||
78 | +// | ||
79 | +// List<FileInfo> list = getFileDao().findList(params); | ||
80 | +// PageInfo<FileInfo> pageInfo = new PageInfo<>(list); | ||
81 | +// return PageResult.<FileInfo>builder().data(pageInfo.getList()).code(0).count(pageInfo.getTotal()).build(); | ||
82 | +// } | ||
83 | + | ||
84 | + @Override | ||
85 | + public void unZip(String filePath, String descDir) throws RuntimeException { | ||
86 | + | ||
87 | + } | ||
88 | +} |
cloud/fIle-center/src/main/java/com/sincere/file/service/impl/AliyunOssServiceImpl.java
0 → 100644
@@ -0,0 +1,51 @@ | @@ -0,0 +1,51 @@ | ||
1 | +package com.sincere.file.service.impl; | ||
2 | + | ||
3 | +import com.aliyun.oss.OSSClient; | ||
4 | +import com.sincere.file.model.FileInfo; | ||
5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
6 | +import org.springframework.beans.factory.annotation.Value; | ||
7 | +import org.springframework.stereotype.Service; | ||
8 | +import org.springframework.web.multipart.MultipartFile; | ||
9 | + | ||
10 | +/** | ||
11 | + * @author 作者 owen E-mail: 624191343@qq.com | ||
12 | + * @version 创建时间:2017年11月12日 上午22:57:51 | ||
13 | +* 阿里云oss存储文件 | ||
14 | +*/ | ||
15 | +@Service("aliyunOssServiceImpl") | ||
16 | +public class AliyunOssServiceImpl extends AbstractFileService { | ||
17 | + | ||
18 | +// @Autowired | ||
19 | +// private FileDao fileDao; | ||
20 | + | ||
21 | +// @Override | ||
22 | +// protected FileDao getFileDao() { | ||
23 | +// return fileDao; | ||
24 | +// } | ||
25 | + | ||
26 | +// @Override | ||
27 | +// protected FileType fileType() { | ||
28 | +// return FileType.ALIYUN; | ||
29 | +// } | ||
30 | + | ||
31 | + @Autowired | ||
32 | + private OSSClient ossClient; | ||
33 | + | ||
34 | + @Value("${aliyun.oss.bucketName:xxxxx}") | ||
35 | + private String bucketName; | ||
36 | + @Value("${aliyun.oss.domain:xxxxx}") | ||
37 | + private String domain; | ||
38 | + | ||
39 | + @Override | ||
40 | + protected void uploadFile(MultipartFile file, FileInfo fileInfo,String filePath) throws Exception { | ||
41 | + ossClient.putObject(bucketName, filePath+"/"+fileInfo.getName(), file.getInputStream()); | ||
42 | + fileInfo.setUrl(domain + "/" + fileInfo.getName()); | ||
43 | + } | ||
44 | + | ||
45 | + @Override | ||
46 | + protected boolean deleteFile(String fileName,String filePath) { | ||
47 | + ossClient.deleteObject(bucketName,filePath+"/"+ fileName); | ||
48 | + return true; | ||
49 | + } | ||
50 | + | ||
51 | +} |
cloud/fIle-center/src/main/java/com/sincere/file/utils/FileUtil.java
0 → 100644
@@ -0,0 +1,88 @@ | @@ -0,0 +1,88 @@ | ||
1 | +package com.sincere.file.utils; | ||
2 | + | ||
3 | +import com.sincere.file.model.FileInfo; | ||
4 | +import lombok.extern.slf4j.Slf4j; | ||
5 | +import org.apache.commons.codec.digest.DigestUtils; | ||
6 | +import org.springframework.web.multipart.MultipartFile; | ||
7 | + | ||
8 | +import java.io.File; | ||
9 | +import java.io.IOException; | ||
10 | +import java.io.InputStream; | ||
11 | +import java.util.Date; | ||
12 | + | ||
13 | +/** | ||
14 | + * @author 作者 owen E-mail: 624191343@qq.com | ||
15 | + * @version 创建时间:2017年11月12日 上午22:57:51 | ||
16 | + * 文件工具类 | ||
17 | +*/ | ||
18 | +@Slf4j | ||
19 | +public class FileUtil { | ||
20 | + | ||
21 | + public static FileInfo getFileInfo(MultipartFile file) throws Exception { | ||
22 | + String md5 = fileMd5(file.getInputStream()); | ||
23 | + | ||
24 | + FileInfo fileInfo = new FileInfo(); | ||
25 | + fileInfo.setId(md5);// 将文件的md5设置为文件表的id | ||
26 | + fileInfo.setName(file.getOriginalFilename()); | ||
27 | + fileInfo.setContentType(file.getContentType()); | ||
28 | + fileInfo.setIsImg(fileInfo.getContentType().startsWith("image/")); | ||
29 | + fileInfo.setSize(file.getSize()); | ||
30 | + fileInfo.setCreateTime(new Date()); | ||
31 | + | ||
32 | + return fileInfo; | ||
33 | + } | ||
34 | + | ||
35 | + /** | ||
36 | + * 文件的md5 | ||
37 | + * | ||
38 | + * @param inputStream | ||
39 | + * @return | ||
40 | + */ | ||
41 | + public static String fileMd5(InputStream inputStream) { | ||
42 | + try { | ||
43 | + return DigestUtils.md5Hex(inputStream); | ||
44 | + } catch (IOException e) { | ||
45 | + log.error("FileUtil->fileMd5:{}" ,e.getMessage()); | ||
46 | + } | ||
47 | + | ||
48 | + return null; | ||
49 | + } | ||
50 | + | ||
51 | + public static String saveFile(MultipartFile file, String path) { | ||
52 | + try { | ||
53 | + File targetFile = new File(path); | ||
54 | + if (targetFile.exists()) { | ||
55 | + return path; | ||
56 | + } | ||
57 | + | ||
58 | + if (!targetFile.getParentFile().exists()) { | ||
59 | + targetFile.getParentFile().mkdirs(); | ||
60 | + } | ||
61 | + file.transferTo(targetFile); | ||
62 | + | ||
63 | + return path; | ||
64 | + } catch (Exception e) { | ||
65 | + log.error("FileUtil->saveFile:{}" ,e.getMessage()); | ||
66 | + } | ||
67 | + | ||
68 | + return null; | ||
69 | + } | ||
70 | + | ||
71 | + public static boolean deleteFile(String pathname) { | ||
72 | + File file = new File(pathname); | ||
73 | + if (file.exists()) { | ||
74 | + boolean flag = file.delete(); | ||
75 | + | ||
76 | + if (flag) { | ||
77 | + File[] files = file.getParentFile().listFiles(); | ||
78 | + if (files == null || files.length == 0) { | ||
79 | + file.getParentFile().delete(); | ||
80 | + } | ||
81 | + } | ||
82 | + | ||
83 | + return flag; | ||
84 | + } | ||
85 | + | ||
86 | + return false; | ||
87 | + } | ||
88 | +} |
@@ -0,0 +1,181 @@ | @@ -0,0 +1,181 @@ | ||
1 | +#阿里云文件上传 | ||
2 | +aliyun: | ||
3 | + oss: | ||
4 | + access-key: QiuM3PwHTnVotcGy | ||
5 | + accessKeySecret: Yqs7RlaC1MioZu2YYJ6u0TdeO13VFC | ||
6 | + endpoint: http://oss-cn-hangzhou.aliyuncs.com | ||
7 | + bucketName: szyundisk | ||
8 | + domain: https://szyundisk.oss-cn-hangzhou.aliyuncs.com | ||
9 | +##七牛文件上传 | ||
10 | +#qiniu: | ||
11 | +# oss: | ||
12 | +# access-key: owGiAWGn6DpU5zlrfLP4K9iQusahmspTW6PxRABW | ||
13 | +# accessKeySecret: 5CBWKFd1pP-OSiusd1Bvhokp-ih4i3bs2QA2r-U2 | ||
14 | +# endpoint: http://q4c5xw7eb.bkt.clouddn.com | ||
15 | +# bucketName: ocpowenwangwen | ||
16 | +## 本地文件上传 | ||
17 | +#file: | ||
18 | +# oss: | ||
19 | +# domain: http://127.0.0.1:9200/api-file | ||
20 | +# path: d:/uploadshp | ||
21 | +# prefix: /statics | ||
22 | + | ||
23 | +#fastDFS配置 | ||
24 | +#fdfs: | ||
25 | +# oss : | ||
26 | +# ##nginx需要安装fastdfs插件 | ||
27 | +# domain: http://192.168.235.173/ | ||
28 | +# soTimeout: 1500 | ||
29 | +# connectTimeout: 600 | ||
30 | +# pool: | ||
31 | +# jmx-enabled: false | ||
32 | +# trackerList: 192.168.235.173:22122 | ||
33 | + | ||
34 | + | ||
35 | +#spring: | ||
36 | +# datasource: | ||
37 | +# dynamic: | ||
38 | +# enable: true | ||
39 | +# druid: | ||
40 | +# # JDBC 配置(驱动类自动从url的mysql识别,数据源类型自动识别) | ||
41 | +# core: | ||
42 | +# url: jdbc:mysql://localhost:3306/file_center?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false | ||
43 | +# username: root | ||
44 | +# password: 123456 | ||
45 | +# driver-class-name: com.mysql.cj.jdbc.Driver | ||
46 | +# log: | ||
47 | +# url: jdbc:mysql://localhost:3306/log_center?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false | ||
48 | +# username: root | ||
49 | +# password: 123456 | ||
50 | +# driver-class-name: com.mysql.cj.jdbc.Driver | ||
51 | +# #连接池配置(通常来说,只需要修改initialSize、minIdle、maxActive | ||
52 | +# initial-size: 1 | ||
53 | +# max-active: 20 | ||
54 | +# min-idle: 1 | ||
55 | +# # 配置获取连接等待超时的时间 | ||
56 | +# max-wait: 60000 | ||
57 | +# #打开PSCache,并且指定每个连接上PSCache的大小 | ||
58 | +# pool-prepared-statements: true | ||
59 | +# max-pool-prepared-statement-per-connection-size: 20 | ||
60 | +# validation-query: SELECT 'x' | ||
61 | +# test-on-borrow: false | ||
62 | +# test-on-return: false | ||
63 | +# test-while-idle: true | ||
64 | +# #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 | ||
65 | +# time-between-eviction-runs-millis: 60000 | ||
66 | +# #配置一个连接在池中最小生存的时间,单位是毫秒 | ||
67 | +# min-evictable-idle-time-millis: 300000 | ||
68 | +# filters: stat,wall | ||
69 | +# # WebStatFilter配置,说明请参考Druid Wiki,配置_配置WebStatFilter | ||
70 | +# #是否启用StatFilter默认值true | ||
71 | +# web-stat-filter.enabled: true | ||
72 | +# web-stat-filter.url-pattern: /* | ||
73 | +# web-stat-filter.exclusions: "*.js , *.gif ,*.jpg ,*.png ,*.css ,*.ico , /druid/*" | ||
74 | +# web-stat-filter.session-stat-max-count: 1000 | ||
75 | +# web-stat-filter.profile-enable: true | ||
76 | +# # StatViewServlet配置 | ||
77 | +# #展示Druid的统计信息,StatViewServlet的用途包括:1.提供监控信息展示的html页面2.提供监控信息的JSON API | ||
78 | +# #是否启用StatViewServlet默认值true | ||
79 | +# stat-view-servlet.enabled: true | ||
80 | +# #根据配置中的url-pattern来访问内置监控页面,如果是上面的配置,内置监控页面的首页是/druid/index.html例如: | ||
81 | +# #http://110.76.43.235:9000/druid/index.html | ||
82 | +# #http://110.76.43.235:8080/mini-web/druid/index.html | ||
83 | +# stat-view-servlet.url-pattern: /druid/* | ||
84 | +# #允许清空统计数据 | ||
85 | +# stat-view-servlet.reset-enable: true | ||
86 | +# stat-view-servlet.login-username: admin | ||
87 | +# stat-view-servlet.login-password: admin | ||
88 | +# #StatViewSerlvet展示出来的监控信息比较敏感,是系统运行的内部情况,如果你需要做访问控制,可以配置allow和deny这两个参数 | ||
89 | +# #deny优先于allow,如果在deny列表中,就算在allow列表中,也会被拒绝。如果allow没有配置或者为空,则允许所有访问 | ||
90 | +# #配置的格式 | ||
91 | +# #<IP> | ||
92 | +# #或者<IP>/<SUB_NET_MASK_size>其中128.242.127.1/24 | ||
93 | +# #24表示,前面24位是子网掩码,比对的时候,前面24位相同就匹配,不支持IPV6。 | ||
94 | +# #stat-view-servlet.allow= | ||
95 | +# #stat-view-servlet.deny=128.242.127.1/24,128.242.128.1 | ||
96 | +# # Spring监控配置,说明请参考Druid Github Wiki,配置_Druid和Spring关联监控配置 | ||
97 | +# #aop-patterns= # Spring监控AOP切入点,如x.y.z.service.*,配置多个英文逗号分隔 | ||
98 | +#################### mysq end ########################## | ||
99 | +## zipkin: | ||
100 | +## base-url: http://127.0.0.1:11008 | ||
101 | +# redis: | ||
102 | +#################### redis 单机版 start ########################## | ||
103 | +# host: 127.0.0.1 | ||
104 | +# port: 6379 | ||
105 | +# timeout: 6000 | ||
106 | +# database: 1 | ||
107 | +# lettuce: | ||
108 | +# pool: | ||
109 | +# max-active: 10 # 连接池最大连接数(使用负值表示没有限制),如果赋值为-1,则表示不限制;如果pool已经分配了maxActive个jedis实例,则此时pool的状态为exhausted(耗尽) | ||
110 | +# max-idle: 8 # 连接池中的最大空闲连接 ,默认值也是8 | ||
111 | +# max-wait: 100 # # 等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时。如果超过等待时间,则直接抛出JedisConnectionException | ||
112 | +# min-idle: 2 # 连接池中的最小空闲连接 ,默认值也是0 | ||
113 | +# shutdown-timeout: 100ms | ||
114 | +#################### redis 单机版 end ########################## | ||
115 | +## cluster: | ||
116 | +## nodes: 130.75.131.237:7000,130.75.131.238:7000,130.75.131.239:7000,130.75.131.237:7001,130.75.131.238:7001,130.75.131.239:7001 | ||
117 | +## #130.75.131.237:7000,130.75.131.238:7000,130.75.131.239:7000,130.75.131.237:7001,130.75.131.238:7001,130.75.131.239:7001 | ||
118 | +## #192.168.3.157:7000,192.168.3.158:7000,192.168.3.159:7000,192.168.3.157:7001,192.168.3.158:7001,192.168.3.159:7001 | ||
119 | +## timeout: 1000 # 连接超时时间(毫秒) | ||
120 | +## lettuce: | ||
121 | +## pool: | ||
122 | +## max-active: 10 # 连接池最大连接数(使用负值表示没有限制),如果赋值为-1,则表示不限制;如果pool已经分配了maxActive个jedis实例,则此时pool的状态为exhausted(耗尽) | ||
123 | +## max-idle: 8 # 连接池中的最大空闲连接 ,默认值也是8 | ||
124 | +## max-wait: 100 # # 等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时。如果超过等待时间,则直接抛出JedisConnectionException | ||
125 | +## min-idle: 2 # 连接池中的最小空闲连接 ,默认值也是0 | ||
126 | +## shutdown-timeout: 100ms | ||
127 | +# | ||
128 | +##mybatis: | ||
129 | +#mybatis-plus: | ||
130 | +# configuration: | ||
131 | +# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl | ||
132 | +# config-location: classpath:mybatis.cfg.xml | ||
133 | +# mapper-locations: classpath*:com/open/**/dao/*.xml | ||
134 | +# | ||
135 | +# | ||
136 | +#security: | ||
137 | +# oauth2: | ||
138 | +# ignored: /files-anon/** , /doc.html ,/upload.html , /uploads.html ,/js/** ,/document.html | ||
139 | +# token: | ||
140 | +# store: | ||
141 | +# type: redis | ||
142 | + | ||
143 | + | ||
144 | +#设置最大超时时间 | ||
145 | +ribbon: | ||
146 | + httpclient: | ||
147 | + enabled: false | ||
148 | + okhttp: | ||
149 | + enabled: true | ||
150 | + ReadTimeout: 90000 | ||
151 | + ConnectTimeout: 90000 | ||
152 | + OkToRetryOnAllOperations: true | ||
153 | + MaxAutoRetries: 1 | ||
154 | + MaxAutoRetriesNextServer: 1 | ||
155 | + | ||
156 | + | ||
157 | +#设置最大容错超时时间 | ||
158 | +#hystrix: | ||
159 | +# command: | ||
160 | +# default: | ||
161 | +# execution: | ||
162 | +# timeout: | ||
163 | +# enabled: true | ||
164 | +# isolation: | ||
165 | +# thread: | ||
166 | +# timeoutInMilliseconds: 90000 | ||
167 | + | ||
168 | + | ||
169 | + | ||
170 | +#logging: | ||
171 | +# level: | ||
172 | +# com.open.capacity: INFO | ||
173 | +# org.hibernate: INFO | ||
174 | +# org.hibernate.type.descriptor.sql.BasicBinder: TRACE | ||
175 | +# org.hibernate.type.descriptor.sql.BasicExtractor: TRACE | ||
176 | +# com.neusoft: DEBUG | ||
177 | +# com.netflix: DEBUG #用于心跳检测输出的日志 | ||
178 | + | ||
179 | + | ||
180 | + | ||
181 | + | ||
0 | \ No newline at end of file | 182 | \ No newline at end of file |
@@ -0,0 +1,43 @@ | @@ -0,0 +1,43 @@ | ||
1 | +#端口 | ||
2 | +server: | ||
3 | + port: 5000 #固定端口 | ||
4 | +# port: ${randomServerPort.value[5000,5005]} #随机端口 | ||
5 | + | ||
6 | +#服务名称 | ||
7 | +spring: | ||
8 | + application: | ||
9 | + name: file-center | ||
10 | + servlet: | ||
11 | + multipart: | ||
12 | + max-request-size: 400MB | ||
13 | + max-file-size: 400MB | ||
14 | + | ||
15 | +management: | ||
16 | + endpoints: | ||
17 | + web: | ||
18 | + exposure: | ||
19 | + include: "*" | ||
20 | + endpoint: | ||
21 | + health: | ||
22 | + show-details: always | ||
23 | + | ||
24 | +#eureka client配置 | ||
25 | +eureka: | ||
26 | + client: | ||
27 | + serviceUrl: | ||
28 | +# defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/ | ||
29 | + defaultZone: http://121.40.109.21:8761/eureka/,http://121.40.109.21:8762/eureka/ | ||
30 | + #http://134.224.249.33:1111/eureka/ 正式库 | ||
31 | + #http://134.224.249.33:1111/eureka/ 测试库 | ||
32 | + #http://127.0.0.1:8761/eureka,http://127.0.0.1:8762/eureka | ||
33 | + registry-fetch-interval-seconds: 5 | ||
34 | + instance-info-replication-interval-seconds: 10 | ||
35 | + instance: | ||
36 | + prefer-ip-address: true | ||
37 | + instance-id: ${spring.application.name} | ||
38 | +# instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${server.port}} #固定端口 | ||
39 | +# instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${randomServerPort.value[5000,5005]}} #随机端口 | ||
40 | + lease-renewal-interval-in-seconds: 10 #每隔几秒告诉eureka服务器我还存活,用于心跳检测 | ||
41 | + lease-expiration-duration-in-seconds: 10 #如果心跳检测一直没有发送,10秒后会从eureka服务器中将此服务剔除 | ||
42 | + status-page-url: http://${spring.cloud.client.ip-address}:${server.port}/doc.html # ${server.port}为该服务的端口号 | ||
43 | +# status-page-url: http://${spring.cloud.client.ip-address}:${randomServerPort.value[5000,5005]}/document.html # ${server.port}为该服务的端口号 | ||
0 | \ No newline at end of file | 44 | \ No newline at end of file |
cloud/getaway/pom.xml
@@ -46,20 +46,21 @@ | @@ -46,20 +46,21 @@ | ||
46 | </dependency> | 46 | </dependency> |
47 | </dependencies> | 47 | </dependencies> |
48 | 48 | ||
49 | -<!-- <build>--> | ||
50 | -<!-- <plugins>--> | ||
51 | -<!-- <plugin>--> | ||
52 | -<!-- <groupId>org.springframework.boot</groupId>--> | ||
53 | -<!-- <artifactId>spring-boot-maven-plugin</artifactId>--> | ||
54 | -<!-- <executions>--> | ||
55 | -<!-- <execution>--> | ||
56 | -<!-- <goals>--> | ||
57 | -<!-- <goal>repackage</goal>--> | ||
58 | -<!-- </goals>--> | ||
59 | -<!-- </execution>--> | ||
60 | -<!-- </executions>--> | ||
61 | -<!-- </plugin>--> | ||
62 | -<!-- </plugins>--> | ||
63 | -<!-- </build>--> | 49 | + <build> |
50 | + <plugins> | ||
51 | + <plugin> | ||
52 | + <groupId>org.springframework.boot</groupId> | ||
53 | + <artifactId>spring-boot-maven-plugin</artifactId> | ||
54 | + <executions> | ||
55 | + <execution> | ||
56 | + <goals> | ||
57 | + <goal>repackage</goal> | ||
58 | + </goals> | ||
59 | + </execution> | ||
60 | + </executions> | ||
61 | + </plugin> | ||
62 | + </plugins> | ||
63 | + <finalName>${project.artifactId}</finalName> | ||
64 | + </build> | ||
64 | 65 | ||
65 | </project> | 66 | </project> |
cloud/getaway/src/main/java/com/sincere/getaway/GetawayApplication.java
@@ -10,6 +10,7 @@ import org.springframework.cloud.client.SpringCloudApplication; | @@ -10,6 +10,7 @@ import org.springframework.cloud.client.SpringCloudApplication; | ||
10 | @SpringCloudApplication | 10 | @SpringCloudApplication |
11 | public class GetawayApplication { | 11 | public class GetawayApplication { |
12 | 12 | ||
13 | + | ||
13 | public static void main(String[] args) { | 14 | public static void main(String[] args) { |
14 | SpringApplication.run(GetawayApplication.class, args); | 15 | SpringApplication.run(GetawayApplication.class, args); |
15 | } | 16 | } |
cloud/getaway/src/main/java/com/sincere/getaway/client/config/PermitUrlProperties.java
@@ -16,7 +16,7 @@ public class PermitUrlProperties { | @@ -16,7 +16,7 @@ public class PermitUrlProperties { | ||
16 | */ | 16 | */ |
17 | private static final String[] ENDPOINTS = { | 17 | private static final String[] ENDPOINTS = { |
18 | 18 | ||
19 | - "/v2/api-docs/**", "/swagger-ui.html", "/swagger-resources/**", "/webjars/**" , // api-gateway webflux swagger | 19 | + "/v2/api-docs/**", "/swagger-ui.html","/swagger/index.html", "/swagger-resources/**", "/webjars/**" , // api-gateway webflux swagger |
20 | "/**/v2/api-docs/**", "/**/swagger-ui.html", "/**/swagger-resources/**", "/**/webjars/**" //业务中心swagger | 20 | "/**/v2/api-docs/**", "/**/swagger-ui.html", "/**/swagger-resources/**", "/**/webjars/**" //业务中心swagger |
21 | }; | 21 | }; |
22 | 22 |
cloud/getaway/src/main/java/com/sincere/getaway/client/config/SwaggerProvider.java
@@ -2,6 +2,7 @@ package com.sincere.getaway.client.config; | @@ -2,6 +2,7 @@ package com.sincere.getaway.client.config; | ||
2 | 2 | ||
3 | import lombok.AllArgsConstructor; | 3 | import lombok.AllArgsConstructor; |
4 | import org.springframework.cloud.gateway.config.GatewayProperties; | 4 | import org.springframework.cloud.gateway.config.GatewayProperties; |
5 | +import org.springframework.cloud.gateway.route.RouteDefinition; | ||
5 | import org.springframework.cloud.gateway.route.RouteLocator; | 6 | import org.springframework.cloud.gateway.route.RouteLocator; |
6 | import org.springframework.cloud.gateway.support.NameUtils; | 7 | import org.springframework.cloud.gateway.support.NameUtils; |
7 | import org.springframework.context.annotation.Primary; | 8 | import org.springframework.context.annotation.Primary; |
@@ -33,15 +34,19 @@ public class SwaggerProvider implements SwaggerResourcesProvider { | @@ -33,15 +34,19 @@ public class SwaggerProvider implements SwaggerResourcesProvider { | ||
33 | .filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName())) | 34 | .filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName())) |
34 | .forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(), | 35 | .forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(), |
35 | predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0") | 36 | predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0") |
36 | - .replace("/**", API_URI))))); | 37 | + .replace("/**", API_URI),routeDefinition)))); |
37 | return resources; | 38 | return resources; |
38 | } | 39 | } |
39 | 40 | ||
40 | - private SwaggerResource swaggerResource(String name, String location) { | 41 | + private SwaggerResource swaggerResource(String name, String location, RouteDefinition routeDefinition) { |
41 | SwaggerResource swaggerResource = new SwaggerResource(); | 42 | SwaggerResource swaggerResource = new SwaggerResource(); |
42 | swaggerResource.setName(name); | 43 | swaggerResource.setName(name); |
43 | swaggerResource.setLocation(location); | 44 | swaggerResource.setLocation(location); |
44 | swaggerResource.setSwaggerVersion("2.0"); | 45 | swaggerResource.setSwaggerVersion("2.0"); |
46 | +// swaggerResource.setUrl(routeDefinition.getUri().toString()); | ||
47 | + System.out.println("location:-------------------------------------------"+location); | ||
48 | + System.out.println("host-----------------------------------------------"+routeDefinition.getUri().toString()); | ||
49 | + System.out.println("name:-------------------------------------------"+routeDefinition.toString()); | ||
45 | return swaggerResource; | 50 | return swaggerResource; |
46 | } | 51 | } |
47 | } | 52 | } |
cloud/getaway/src/main/resources/application.yml
@@ -21,10 +21,18 @@ spring: | @@ -21,10 +21,18 @@ spring: | ||
21 | - Path=/usersearch/** | 21 | - Path=/usersearch/** |
22 | filters: | 22 | filters: |
23 | - StripPrefix=1 | 23 | - StripPrefix=1 |
24 | - - id: haikangserver | ||
25 | - uri: lb://haikangserver | 24 | + - id: SmartCampusWebApi |
25 | + uri: http://120.26.116.253:9022 | ||
26 | +# uri: lb://SmartCampusWebApi | ||
26 | predicates: | 27 | predicates: |
27 | - - Path=/haikangserver/** | 28 | + - Path=/SmartCampusWebApi/** |
29 | + filters: | ||
30 | + - StripPrefix=1 | ||
31 | + - id: file-center | ||
32 | +# uri: lb://file-center | ||
33 | + uri: http://121.40.30.78:5000 | ||
34 | + predicates: | ||
35 | + - Path=/file-center/** | ||
28 | filters: | 36 | filters: |
29 | - StripPrefix=1 | 37 | - StripPrefix=1 |
30 | - id: authserver | 38 | - id: authserver |
@@ -33,5 +41,25 @@ spring: | @@ -33,5 +41,25 @@ spring: | ||
33 | - Path=/authserver/** | 41 | - Path=/authserver/** |
34 | filters: | 42 | filters: |
35 | - StripPrefix=1 | 43 | - StripPrefix=1 |
44 | +# discovery: | ||
45 | +# locator: | ||
46 | +# lowerCaseServiceId: true | ||
47 | +# enabled: true | ||
48 | + | ||
49 | + | ||
50 | + | ||
51 | +#设置最大超时时间 | ||
52 | +ribbon: | ||
53 | + httpclient: | ||
54 | + enabled: false | ||
55 | + okhttp: | ||
56 | + enabled: true | ||
57 | + ReadTimeout: 90000 | ||
58 | + ConnectTimeout: 90000 | ||
59 | + OkToRetryOnAllOperations: true | ||
60 | + MaxAutoRetries: 1 | ||
61 | + MaxAutoRetriesNextServer: 1 | ||
62 | + | ||
63 | + | ||
36 | url: | 64 | url: |
37 | - ignored: /authserver/** | ||
38 | \ No newline at end of file | 65 | \ No newline at end of file |
66 | + ignored: /SmartCampusWebApi/**,/authserver/** | ||
39 | \ No newline at end of file | 67 | \ No newline at end of file |
cloud/getaway/src/main/resources/bootstrap.yml
cloud/geteway/.gitignore
@@ -1,31 +0,0 @@ | @@ -1,31 +0,0 @@ | ||
1 | -HELP.md | ||
2 | -target/ | ||
3 | -!.mvn/wrapper/maven-wrapper.jar | ||
4 | -!**/src/main/** | ||
5 | -!**/src/test/** | ||
6 | - | ||
7 | -### STS ### | ||
8 | -.apt_generated | ||
9 | -.classpath | ||
10 | -.factorypath | ||
11 | -.project | ||
12 | -.settings | ||
13 | -.springBeans | ||
14 | -.sts4-cache | ||
15 | - | ||
16 | -### IntelliJ IDEA ### | ||
17 | -.idea | ||
18 | -*.iws | ||
19 | -*.iml | ||
20 | -*.ipr | ||
21 | - | ||
22 | -### NetBeans ### | ||
23 | -/nbproject/private/ | ||
24 | -/nbbuild/ | ||
25 | -/dist/ | ||
26 | -/nbdist/ | ||
27 | -/.nb-gradle/ | ||
28 | -build/ | ||
29 | - | ||
30 | -### VS Code ### | ||
31 | -.vscode/ |
cloud/geteway/.mvn/wrapper/MavenWrapperDownloader.java
@@ -1,114 +0,0 @@ | @@ -1,114 +0,0 @@ | ||
1 | -/* | ||
2 | -Licensed to the Apache Software Foundation (ASF) under one | ||
3 | -or more contributor license agreements. See the NOTICE file | ||
4 | -distributed with this work for additional information | ||
5 | -regarding copyright ownership. The ASF licenses this file | ||
6 | -to you under the Apache License, Version 2.0 (the | ||
7 | -"License"); you may not use this file except in compliance | ||
8 | -with the License. You may obtain a copy of the License at | ||
9 | - | ||
10 | - https://www.apache.org/licenses/LICENSE-2.0 | ||
11 | - | ||
12 | -Unless required by applicable law or agreed to in writing, | ||
13 | -software distributed under the License is distributed on an | ||
14 | -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
15 | -KIND, either express or implied. See the License for the | ||
16 | -specific language governing permissions and limitations | ||
17 | -under the License. | ||
18 | -*/ | ||
19 | - | ||
20 | -import java.io.File; | ||
21 | -import java.io.FileInputStream; | ||
22 | -import java.io.FileOutputStream; | ||
23 | -import java.io.IOException; | ||
24 | -import java.net.URL; | ||
25 | -import java.nio.channels.Channels; | ||
26 | -import java.nio.channels.ReadableByteChannel; | ||
27 | -import java.util.Properties; | ||
28 | - | ||
29 | -public class MavenWrapperDownloader { | ||
30 | - | ||
31 | - /** | ||
32 | - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. | ||
33 | - */ | ||
34 | - private static final String DEFAULT_DOWNLOAD_URL = | ||
35 | - "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; | ||
36 | - | ||
37 | - /** | ||
38 | - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to | ||
39 | - * use instead of the default one. | ||
40 | - */ | ||
41 | - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = | ||
42 | - ".mvn/wrapper/maven-wrapper.properties"; | ||
43 | - | ||
44 | - /** | ||
45 | - * Path where the maven-wrapper.jar will be saved to. | ||
46 | - */ | ||
47 | - private static final String MAVEN_WRAPPER_JAR_PATH = | ||
48 | - ".mvn/wrapper/maven-wrapper.jar"; | ||
49 | - | ||
50 | - /** | ||
51 | - * Name of the property which should be used to override the default download url for the wrapper. | ||
52 | - */ | ||
53 | - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; | ||
54 | - | ||
55 | - public static void main(String args[]) { | ||
56 | - System.out.println("- Downloader started"); | ||
57 | - File baseDirectory = new File(args[0]); | ||
58 | - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); | ||
59 | - | ||
60 | - // If the maven-wrapper.properties exists, read it and check if it contains a custom | ||
61 | - // wrapperUrl parameter. | ||
62 | - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); | ||
63 | - String url = DEFAULT_DOWNLOAD_URL; | ||
64 | - if (mavenWrapperPropertyFile.exists()) { | ||
65 | - FileInputStream mavenWrapperPropertyFileInputStream = null; | ||
66 | - try { | ||
67 | - mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); | ||
68 | - Properties mavenWrapperProperties = new Properties(); | ||
69 | - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); | ||
70 | - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); | ||
71 | - } catch (IOException e) { | ||
72 | - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); | ||
73 | - } finally { | ||
74 | - try { | ||
75 | - if (mavenWrapperPropertyFileInputStream != null) { | ||
76 | - mavenWrapperPropertyFileInputStream.close(); | ||
77 | - } | ||
78 | - } catch (IOException e) { | ||
79 | - // Ignore ... | ||
80 | - } | ||
81 | - } | ||
82 | - } | ||
83 | - System.out.println("- Downloading from: : " + url); | ||
84 | - | ||
85 | - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); | ||
86 | - if (!outputFile.getParentFile().exists()) { | ||
87 | - if (!outputFile.getParentFile().mkdirs()) { | ||
88 | - System.out.println( | ||
89 | - "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); | ||
90 | - } | ||
91 | - } | ||
92 | - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); | ||
93 | - try { | ||
94 | - downloadFileFromURL(url, outputFile); | ||
95 | - System.out.println("Done"); | ||
96 | - System.exit(0); | ||
97 | - } catch (Throwable e) { | ||
98 | - System.out.println("- Error downloading"); | ||
99 | - e.printStackTrace(); | ||
100 | - System.exit(1); | ||
101 | - } | ||
102 | - } | ||
103 | - | ||
104 | - private static void downloadFileFromURL(String urlString, File destination) throws Exception { | ||
105 | - URL website = new URL(urlString); | ||
106 | - ReadableByteChannel rbc; | ||
107 | - rbc = Channels.newChannel(website.openStream()); | ||
108 | - FileOutputStream fos = new FileOutputStream(destination); | ||
109 | - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); | ||
110 | - fos.close(); | ||
111 | - rbc.close(); | ||
112 | - } | ||
113 | - | ||
114 | -} |
cloud/geteway/.mvn/wrapper/maven-wrapper.jar
No preview for this file type
cloud/geteway/.mvn/wrapper/maven-wrapper.properties
@@ -1 +0,0 @@ | @@ -1 +0,0 @@ | ||
1 | -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip |
cloud/geteway/mvnw
@@ -1,286 +0,0 @@ | @@ -1,286 +0,0 @@ | ||
1 | -#!/bin/sh | ||
2 | -# ---------------------------------------------------------------------------- | ||
3 | -# Licensed to the Apache Software Foundation (ASF) under one | ||
4 | -# or more contributor license agreements. See the NOTICE file | ||
5 | -# distributed with this work for additional information | ||
6 | -# regarding copyright ownership. The ASF licenses this file | ||
7 | -# to you under the Apache License, Version 2.0 (the | ||
8 | -# "License"); you may not use this file except in compliance | ||
9 | -# with the License. You may obtain a copy of the License at | ||
10 | -# | ||
11 | -# https://www.apache.org/licenses/LICENSE-2.0 | ||
12 | -# | ||
13 | -# Unless required by applicable law or agreed to in writing, | ||
14 | -# software distributed under the License is distributed on an | ||
15 | -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
16 | -# KIND, either express or implied. See the License for the | ||
17 | -# specific language governing permissions and limitations | ||
18 | -# under the License. | ||
19 | -# ---------------------------------------------------------------------------- | ||
20 | - | ||
21 | -# ---------------------------------------------------------------------------- | ||
22 | -# Maven2 Start Up Batch script | ||
23 | -# | ||
24 | -# Required ENV vars: | ||
25 | -# ------------------ | ||
26 | -# JAVA_HOME - location of a JDK home dir | ||
27 | -# | ||
28 | -# Optional ENV vars | ||
29 | -# ----------------- | ||
30 | -# M2_HOME - location of maven2's installed home dir | ||
31 | -# MAVEN_OPTS - parameters passed to the Java VM when running Maven | ||
32 | -# e.g. to debug Maven itself, use | ||
33 | -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 | ||
34 | -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files | ||
35 | -# ---------------------------------------------------------------------------- | ||
36 | - | ||
37 | -if [ -z "$MAVEN_SKIP_RC" ] ; then | ||
38 | - | ||
39 | - if [ -f /etc/mavenrc ] ; then | ||
40 | - . /etc/mavenrc | ||
41 | - fi | ||
42 | - | ||
43 | - if [ -f "$HOME/.mavenrc" ] ; then | ||
44 | - . "$HOME/.mavenrc" | ||
45 | - fi | ||
46 | - | ||
47 | -fi | ||
48 | - | ||
49 | -# OS specific support. $var _must_ be set to either true or false. | ||
50 | -cygwin=false; | ||
51 | -darwin=false; | ||
52 | -mingw=false | ||
53 | -case "`uname`" in | ||
54 | - CYGWIN*) cygwin=true ;; | ||
55 | - MINGW*) mingw=true;; | ||
56 | - Darwin*) darwin=true | ||
57 | - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home | ||
58 | - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html | ||
59 | - if [ -z "$JAVA_HOME" ]; then | ||
60 | - if [ -x "/usr/libexec/java_home" ]; then | ||
61 | - export JAVA_HOME="`/usr/libexec/java_home`" | ||
62 | - else | ||
63 | - export JAVA_HOME="/Library/Java/Home" | ||
64 | - fi | ||
65 | - fi | ||
66 | - ;; | ||
67 | -esac | ||
68 | - | ||
69 | -if [ -z "$JAVA_HOME" ] ; then | ||
70 | - if [ -r /etc/gentoo-release ] ; then | ||
71 | - JAVA_HOME=`java-config --jre-home` | ||
72 | - fi | ||
73 | -fi | ||
74 | - | ||
75 | -if [ -z "$M2_HOME" ] ; then | ||
76 | - ## resolve links - $0 may be a link to maven's home | ||
77 | - PRG="$0" | ||
78 | - | ||
79 | - # need this for relative symlinks | ||
80 | - while [ -h "$PRG" ] ; do | ||
81 | - ls=`ls -ld "$PRG"` | ||
82 | - link=`expr "$ls" : '.*-> \(.*\)$'` | ||
83 | - if expr "$link" : '/.*' > /dev/null; then | ||
84 | - PRG="$link" | ||
85 | - else | ||
86 | - PRG="`dirname "$PRG"`/$link" | ||
87 | - fi | ||
88 | - done | ||
89 | - | ||
90 | - saveddir=`pwd` | ||
91 | - | ||
92 | - M2_HOME=`dirname "$PRG"`/.. | ||
93 | - | ||
94 | - # make it fully qualified | ||
95 | - M2_HOME=`cd "$M2_HOME" && pwd` | ||
96 | - | ||
97 | - cd "$saveddir" | ||
98 | - # echo Using m2 at $M2_HOME | ||
99 | -fi | ||
100 | - | ||
101 | -# For Cygwin, ensure paths are in UNIX format before anything is touched | ||
102 | -if $cygwin ; then | ||
103 | - [ -n "$M2_HOME" ] && | ||
104 | - M2_HOME=`cygpath --unix "$M2_HOME"` | ||
105 | - [ -n "$JAVA_HOME" ] && | ||
106 | - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` | ||
107 | - [ -n "$CLASSPATH" ] && | ||
108 | - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` | ||
109 | -fi | ||
110 | - | ||
111 | -# For Mingw, ensure paths are in UNIX format before anything is touched | ||
112 | -if $mingw ; then | ||
113 | - [ -n "$M2_HOME" ] && | ||
114 | - M2_HOME="`(cd "$M2_HOME"; pwd)`" | ||
115 | - [ -n "$JAVA_HOME" ] && | ||
116 | - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" | ||
117 | - # TODO classpath? | ||
118 | -fi | ||
119 | - | ||
120 | -if [ -z "$JAVA_HOME" ]; then | ||
121 | - javaExecutable="`which javac`" | ||
122 | - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then | ||
123 | - # readlink(1) is not available as standard on Solaris 10. | ||
124 | - readLink=`which readlink` | ||
125 | - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then | ||
126 | - if $darwin ; then | ||
127 | - javaHome="`dirname \"$javaExecutable\"`" | ||
128 | - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" | ||
129 | - else | ||
130 | - javaExecutable="`readlink -f \"$javaExecutable\"`" | ||
131 | - fi | ||
132 | - javaHome="`dirname \"$javaExecutable\"`" | ||
133 | - javaHome=`expr "$javaHome" : '\(.*\)/bin'` | ||
134 | - JAVA_HOME="$javaHome" | ||
135 | - export JAVA_HOME | ||
136 | - fi | ||
137 | - fi | ||
138 | -fi | ||
139 | - | ||
140 | -if [ -z "$JAVACMD" ] ; then | ||
141 | - if [ -n "$JAVA_HOME" ] ; then | ||
142 | - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | ||
143 | - # IBM's JDK on AIX uses strange locations for the executables | ||
144 | - JAVACMD="$JAVA_HOME/jre/sh/java" | ||
145 | - else | ||
146 | - JAVACMD="$JAVA_HOME/bin/java" | ||
147 | - fi | ||
148 | - else | ||
149 | - JAVACMD="`which java`" | ||
150 | - fi | ||
151 | -fi | ||
152 | - | ||
153 | -if [ ! -x "$JAVACMD" ] ; then | ||
154 | - echo "Error: JAVA_HOME is not defined correctly." >&2 | ||
155 | - echo " We cannot execute $JAVACMD" >&2 | ||
156 | - exit 1 | ||
157 | -fi | ||
158 | - | ||
159 | -if [ -z "$JAVA_HOME" ] ; then | ||
160 | - echo "Warning: JAVA_HOME environment variable is not set." | ||
161 | -fi | ||
162 | - | ||
163 | -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher | ||
164 | - | ||
165 | -# traverses directory structure from process work directory to filesystem root | ||
166 | -# first directory with .mvn subdirectory is considered project base directory | ||
167 | -find_maven_basedir() { | ||
168 | - | ||
169 | - if [ -z "$1" ] | ||
170 | - then | ||
171 | - echo "Path not specified to find_maven_basedir" | ||
172 | - return 1 | ||
173 | - fi | ||
174 | - | ||
175 | - basedir="$1" | ||
176 | - wdir="$1" | ||
177 | - while [ "$wdir" != '/' ] ; do | ||
178 | - if [ -d "$wdir"/.mvn ] ; then | ||
179 | - basedir=$wdir | ||
180 | - break | ||
181 | - fi | ||
182 | - # workaround for JBEAP-8937 (on Solaris 10/Sparc) | ||
183 | - if [ -d "${wdir}" ]; then | ||
184 | - wdir=`cd "$wdir/.."; pwd` | ||
185 | - fi | ||
186 | - # end of workaround | ||
187 | - done | ||
188 | - echo "${basedir}" | ||
189 | -} | ||
190 | - | ||
191 | -# concatenates all lines of a file | ||
192 | -concat_lines() { | ||
193 | - if [ -f "$1" ]; then | ||
194 | - echo "$(tr -s '\n' ' ' < "$1")" | ||
195 | - fi | ||
196 | -} | ||
197 | - | ||
198 | -BASE_DIR=`find_maven_basedir "$(pwd)"` | ||
199 | -if [ -z "$BASE_DIR" ]; then | ||
200 | - exit 1; | ||
201 | -fi | ||
202 | - | ||
203 | -########################################################################################## | ||
204 | -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central | ||
205 | -# This allows using the maven wrapper in projects that prohibit checking in binary data. | ||
206 | -########################################################################################## | ||
207 | -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then | ||
208 | - if [ "$MVNW_VERBOSE" = true ]; then | ||
209 | - echo "Found .mvn/wrapper/maven-wrapper.jar" | ||
210 | - fi | ||
211 | -else | ||
212 | - if [ "$MVNW_VERBOSE" = true ]; then | ||
213 | - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." | ||
214 | - fi | ||
215 | - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" | ||
216 | - while IFS="=" read key value; do | ||
217 | - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; | ||
218 | - esac | ||
219 | - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" | ||
220 | - if [ "$MVNW_VERBOSE" = true ]; then | ||
221 | - echo "Downloading from: $jarUrl" | ||
222 | - fi | ||
223 | - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" | ||
224 | - | ||
225 | - if command -v wget > /dev/null; then | ||
226 | - if [ "$MVNW_VERBOSE" = true ]; then | ||
227 | - echo "Found wget ... using wget" | ||
228 | - fi | ||
229 | - wget "$jarUrl" -O "$wrapperJarPath" | ||
230 | - elif command -v curl > /dev/null; then | ||
231 | - if [ "$MVNW_VERBOSE" = true ]; then | ||
232 | - echo "Found curl ... using curl" | ||
233 | - fi | ||
234 | - curl -o "$wrapperJarPath" "$jarUrl" | ||
235 | - else | ||
236 | - if [ "$MVNW_VERBOSE" = true ]; then | ||
237 | - echo "Falling back to using Java to download" | ||
238 | - fi | ||
239 | - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" | ||
240 | - if [ -e "$javaClass" ]; then | ||
241 | - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then | ||
242 | - if [ "$MVNW_VERBOSE" = true ]; then | ||
243 | - echo " - Compiling MavenWrapperDownloader.java ..." | ||
244 | - fi | ||
245 | - # Compiling the Java class | ||
246 | - ("$JAVA_HOME/bin/javac" "$javaClass") | ||
247 | - fi | ||
248 | - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then | ||
249 | - # Running the downloader | ||
250 | - if [ "$MVNW_VERBOSE" = true ]; then | ||
251 | - echo " - Running MavenWrapperDownloader.java ..." | ||
252 | - fi | ||
253 | - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") | ||
254 | - fi | ||
255 | - fi | ||
256 | - fi | ||
257 | -fi | ||
258 | -########################################################################################## | ||
259 | -# End of extension | ||
260 | -########################################################################################## | ||
261 | - | ||
262 | -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} | ||
263 | -if [ "$MVNW_VERBOSE" = true ]; then | ||
264 | - echo $MAVEN_PROJECTBASEDIR | ||
265 | -fi | ||
266 | -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" | ||
267 | - | ||
268 | -# For Cygwin, switch paths to Windows format before running java | ||
269 | -if $cygwin; then | ||
270 | - [ -n "$M2_HOME" ] && | ||
271 | - M2_HOME=`cygpath --path --windows "$M2_HOME"` | ||
272 | - [ -n "$JAVA_HOME" ] && | ||
273 | - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` | ||
274 | - [ -n "$CLASSPATH" ] && | ||
275 | - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` | ||
276 | - [ -n "$MAVEN_PROJECTBASEDIR" ] && | ||
277 | - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` | ||
278 | -fi | ||
279 | - | ||
280 | -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain | ||
281 | - | ||
282 | -exec "$JAVACMD" \ | ||
283 | - $MAVEN_OPTS \ | ||
284 | - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ | ||
285 | - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ | ||
286 | - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" |
cloud/geteway/mvnw.cmd
@@ -1,161 +0,0 @@ | @@ -1,161 +0,0 @@ | ||
1 | -@REM ---------------------------------------------------------------------------- | ||
2 | -@REM Licensed to the Apache Software Foundation (ASF) under one | ||
3 | -@REM or more contributor license agreements. See the NOTICE file | ||
4 | -@REM distributed with this work for additional information | ||
5 | -@REM regarding copyright ownership. The ASF licenses this file | ||
6 | -@REM to you under the Apache License, Version 2.0 (the | ||
7 | -@REM "License"); you may not use this file except in compliance | ||
8 | -@REM with the License. You may obtain a copy of the License at | ||
9 | -@REM | ||
10 | -@REM https://www.apache.org/licenses/LICENSE-2.0 | ||
11 | -@REM | ||
12 | -@REM Unless required by applicable law or agreed to in writing, | ||
13 | -@REM software distributed under the License is distributed on an | ||
14 | -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
15 | -@REM KIND, either express or implied. See the License for the | ||
16 | -@REM specific language governing permissions and limitations | ||
17 | -@REM under the License. | ||
18 | -@REM ---------------------------------------------------------------------------- | ||
19 | - | ||
20 | -@REM ---------------------------------------------------------------------------- | ||
21 | -@REM Maven2 Start Up Batch script | ||
22 | -@REM | ||
23 | -@REM Required ENV vars: | ||
24 | -@REM JAVA_HOME - location of a JDK home dir | ||
25 | -@REM | ||
26 | -@REM Optional ENV vars | ||
27 | -@REM M2_HOME - location of maven2's installed home dir | ||
28 | -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands | ||
29 | -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending | ||
30 | -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven | ||
31 | -@REM e.g. to debug Maven itself, use | ||
32 | -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 | ||
33 | -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files | ||
34 | -@REM ---------------------------------------------------------------------------- | ||
35 | - | ||
36 | -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' | ||
37 | -@echo off | ||
38 | -@REM set title of command window | ||
39 | -title %0 | ||
40 | -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' | ||
41 | -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% | ||
42 | - | ||
43 | -@REM set %HOME% to equivalent of $HOME | ||
44 | -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") | ||
45 | - | ||
46 | -@REM Execute a user defined script before this one | ||
47 | -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre | ||
48 | -@REM check for pre script, once with legacy .bat ending and once with .cmd ending | ||
49 | -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" | ||
50 | -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" | ||
51 | -:skipRcPre | ||
52 | - | ||
53 | -@setlocal | ||
54 | - | ||
55 | -set ERROR_CODE=0 | ||
56 | - | ||
57 | -@REM To isolate internal variables from possible post scripts, we use another setlocal | ||
58 | -@setlocal | ||
59 | - | ||
60 | -@REM ==== START VALIDATION ==== | ||
61 | -if not "%JAVA_HOME%" == "" goto OkJHome | ||
62 | - | ||
63 | -echo. | ||
64 | -echo Error: JAVA_HOME not found in your environment. >&2 | ||
65 | -echo Please set the JAVA_HOME variable in your environment to match the >&2 | ||
66 | -echo location of your Java installation. >&2 | ||
67 | -echo. | ||
68 | -goto error | ||
69 | - | ||
70 | -:OkJHome | ||
71 | -if exist "%JAVA_HOME%\bin\java.exe" goto init | ||
72 | - | ||
73 | -echo. | ||
74 | -echo Error: JAVA_HOME is set to an invalid directory. >&2 | ||
75 | -echo JAVA_HOME = "%JAVA_HOME%" >&2 | ||
76 | -echo Please set the JAVA_HOME variable in your environment to match the >&2 | ||
77 | -echo location of your Java installation. >&2 | ||
78 | -echo. | ||
79 | -goto error | ||
80 | - | ||
81 | -@REM ==== END VALIDATION ==== | ||
82 | - | ||
83 | -:init | ||
84 | - | ||
85 | -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". | ||
86 | -@REM Fallback to current working directory if not found. | ||
87 | - | ||
88 | -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% | ||
89 | -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir | ||
90 | - | ||
91 | -set EXEC_DIR=%CD% | ||
92 | -set WDIR=%EXEC_DIR% | ||
93 | -:findBaseDir | ||
94 | -IF EXIST "%WDIR%"\.mvn goto baseDirFound | ||
95 | -cd .. | ||
96 | -IF "%WDIR%"=="%CD%" goto baseDirNotFound | ||
97 | -set WDIR=%CD% | ||
98 | -goto findBaseDir | ||
99 | - | ||
100 | -:baseDirFound | ||
101 | -set MAVEN_PROJECTBASEDIR=%WDIR% | ||
102 | -cd "%EXEC_DIR%" | ||
103 | -goto endDetectBaseDir | ||
104 | - | ||
105 | -:baseDirNotFound | ||
106 | -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% | ||
107 | -cd "%EXEC_DIR%" | ||
108 | - | ||
109 | -:endDetectBaseDir | ||
110 | - | ||
111 | -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig | ||
112 | - | ||
113 | -@setlocal EnableExtensions EnableDelayedExpansion | ||
114 | -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a | ||
115 | -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% | ||
116 | - | ||
117 | -:endReadAdditionalConfig | ||
118 | - | ||
119 | -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" | ||
120 | -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" | ||
121 | -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain | ||
122 | - | ||
123 | -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" | ||
124 | -FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( | ||
125 | - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B | ||
126 | -) | ||
127 | - | ||
128 | -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central | ||
129 | -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. | ||
130 | -if exist %WRAPPER_JAR% ( | ||
131 | - echo Found %WRAPPER_JAR% | ||
132 | -) else ( | ||
133 | - echo Couldn't find %WRAPPER_JAR%, downloading it ... | ||
134 | - echo Downloading from: %DOWNLOAD_URL% | ||
135 | - powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" | ||
136 | - echo Finished downloading %WRAPPER_JAR% | ||
137 | -) | ||
138 | -@REM End of extension | ||
139 | - | ||
140 | -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* | ||
141 | -if ERRORLEVEL 1 goto error | ||
142 | -goto end | ||
143 | - | ||
144 | -:error | ||
145 | -set ERROR_CODE=1 | ||
146 | - | ||
147 | -:end | ||
148 | -@endlocal & set ERROR_CODE=%ERROR_CODE% | ||
149 | - | ||
150 | -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost | ||
151 | -@REM check for post script, once with legacy .bat ending and once with .cmd ending | ||
152 | -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" | ||
153 | -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" | ||
154 | -:skipRcPost | ||
155 | - | ||
156 | -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' | ||
157 | -if "%MAVEN_BATCH_PAUSE%" == "on" pause | ||
158 | - | ||
159 | -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% | ||
160 | - | ||
161 | -exit /B %ERROR_CODE% |
cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserControl.java
1 | package com.sincere.haikangface.control; | 1 | package com.sincere.haikangface.control; |
2 | 2 | ||
3 | -import com.netflix.ribbon.proxy.annotation.Http; | ||
4 | import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; | 3 | import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; |
5 | -import com.sincere.common.util.BaiduApiUtiols; | 4 | +import com.sincere.haikangface.utils.BaiduApiUtiols; |
6 | import com.sincere.haikangface.CMSServer; | 5 | import com.sincere.haikangface.CMSServer; |
7 | import com.sincere.haikangface.async.SendUserAsync; | 6 | import com.sincere.haikangface.async.SendUserAsync; |
8 | import com.sincere.haikangface.bean.StudentBean; | 7 | import com.sincere.haikangface.bean.StudentBean; |
@@ -23,10 +22,8 @@ import org.springframework.web.bind.annotation.RequestMethod; | @@ -23,10 +22,8 @@ import org.springframework.web.bind.annotation.RequestMethod; | ||
23 | import org.springframework.web.bind.annotation.RequestParam; | 22 | import org.springframework.web.bind.annotation.RequestParam; |
24 | import org.springframework.web.bind.annotation.RestController; | 23 | import org.springframework.web.bind.annotation.RestController; |
25 | import org.springframework.web.multipart.MultipartFile; | 24 | import org.springframework.web.multipart.MultipartFile; |
26 | -import sun.rmi.runtime.Log; | ||
27 | 25 | ||
28 | import java.io.*; | 26 | import java.io.*; |
29 | -import java.math.BigInteger; | ||
30 | import java.text.SimpleDateFormat; | 27 | import java.text.SimpleDateFormat; |
31 | import java.util.Calendar; | 28 | import java.util.Calendar; |
32 | import java.util.Date; | 29 | import java.util.Date; |
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/BaiduApiUtiols.java
0 → 100644
@@ -0,0 +1,86 @@ | @@ -0,0 +1,86 @@ | ||
1 | +package com.sincere.haikangface.utils; | ||
2 | + | ||
3 | +import com.sincere.common.util.AuthService; | ||
4 | +import com.sincere.common.util.Base64Util; | ||
5 | +import org.springframework.http.HttpEntity; | ||
6 | +import org.springframework.http.HttpHeaders; | ||
7 | +import org.springframework.http.MediaType; | ||
8 | +import org.springframework.http.ResponseEntity; | ||
9 | +import org.springframework.util.LinkedMultiValueMap; | ||
10 | +import org.springframework.util.MultiValueMap; | ||
11 | +import org.springframework.web.client.RestTemplate; | ||
12 | + | ||
13 | +public class BaiduApiUtiols { | ||
14 | + | ||
15 | + public static BaiduApiUtiols baiduApiUtiols; | ||
16 | + | ||
17 | + public static BaiduApiUtiols getInstance() { | ||
18 | + | ||
19 | + if (null == baiduApiUtiols) { | ||
20 | + synchronized (BaiduApiUtiols.class) { | ||
21 | + baiduApiUtiols = new BaiduApiUtiols(); | ||
22 | + } | ||
23 | + } | ||
24 | + return baiduApiUtiols; | ||
25 | + } | ||
26 | + | ||
27 | + | ||
28 | + /** | ||
29 | + * @param imgPath 图片路径 | ||
30 | + * @param group_id 学校id | ||
31 | + * @param user_id 用户id | ||
32 | + * @param user_info 用户名字 | ||
33 | + * @return | ||
34 | + */ | ||
35 | + public String registerFace(String imgPath, String group_id, String user_id, String user_info) { | ||
36 | + | ||
37 | + String registUrl = "https://aip.baidubce.com/rest/2.0/face/v3/faceset/user/add?access_token=" + AuthService.getFaceAuthToken(); | ||
38 | + long time = System.currentTimeMillis(); | ||
39 | + System.out.println("starttime:"+time); | ||
40 | + RestTemplate restTemplate = new RestTemplate(); | ||
41 | + MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>(); | ||
42 | + multiValueMap.add("image", Base64Util.imageencode(imgPath)); | ||
43 | + multiValueMap.add("image_type", "BASE64"); | ||
44 | + multiValueMap.add("group_id", group_id); | ||
45 | + multiValueMap.add("user_id", user_id); | ||
46 | + multiValueMap.add("user_info", user_info); | ||
47 | +// multiValueMap.add("quality_control", "NORMAL"); | ||
48 | + System.out.println("multiValueMap:" + multiValueMap.toString()); | ||
49 | + HttpHeaders headers = new HttpHeaders(); | ||
50 | + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); | ||
51 | + HttpEntity<MultiValueMap> requestEntity = new HttpEntity<MultiValueMap>(multiValueMap, | ||
52 | + headers); | ||
53 | + System.out.println("midddle:"+(System.currentTimeMillis()-time)); | ||
54 | + time = System.currentTimeMillis(); | ||
55 | + ResponseEntity<String> result = restTemplate.postForEntity(registUrl, requestEntity, String.class); | ||
56 | + System.out.println("end:"+(System.currentTimeMillis()-time)); | ||
57 | + System.out.println("result:" + result.getBody()); | ||
58 | + return result.getBody(); | ||
59 | + | ||
60 | + } | ||
61 | + | ||
62 | + public String searchFace(String imgPath,String group_id, String user_id){ | ||
63 | + String searchFace = "https://aip.baidubce.com/rest/2.0/face/v3/search?access_token="+AuthService.getFaceAuthToken(); | ||
64 | + long time = System.currentTimeMillis(); | ||
65 | + RestTemplate restTemplate = new RestTemplate(); | ||
66 | + MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>(); | ||
67 | + multiValueMap.add("image", Base64Util.imageencode(imgPath)); | ||
68 | + multiValueMap.add("image_type", "BASE64"); | ||
69 | + multiValueMap.add("group_id_list", group_id);//从指定的group中进行查找 用逗号分隔,上限10个 | ||
70 | + multiValueMap.add("user_id", user_id);//当需要对特定用户进行比对时,指定user_id进行比对。即人脸认证功能。 | ||
71 | +// multiValueMap.add("quality_control", "NORMAL"); | ||
72 | + System.out.println("multiValueMap:" + multiValueMap.toString()); | ||
73 | + HttpHeaders headers = new HttpHeaders(); | ||
74 | + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); | ||
75 | + HttpEntity<MultiValueMap> requestEntity = new HttpEntity<MultiValueMap>(multiValueMap, | ||
76 | + headers); | ||
77 | + System.out.println("midddle:"+(System.currentTimeMillis()-time)); | ||
78 | + time = System.currentTimeMillis(); | ||
79 | + ResponseEntity<String> result = restTemplate.postForEntity(searchFace, requestEntity, String.class); | ||
80 | + System.out.println("end:"+(System.currentTimeMillis()-time)); | ||
81 | + System.out.println("result:" + result.getBody()); | ||
82 | + return result.getBody(); | ||
83 | + | ||
84 | + } | ||
85 | + | ||
86 | +} |
cloud/pom.xml
@@ -27,7 +27,7 @@ | @@ -27,7 +27,7 @@ | ||
27 | <modules> | 27 | <modules> |
28 | <module>server1</module> | 28 | <module>server1</module> |
29 | <module>server2</module> | 29 | <module>server2</module> |
30 | -<!-- <module>autho</module>--> | 30 | + <module>autho</module> |
31 | <module>common</module> | 31 | <module>common</module> |
32 | <module>getaway</module> | 32 | <module>getaway</module> |
33 | <module>haikang</module> | 33 | <module>haikang</module> |
@@ -41,8 +41,9 @@ | @@ -41,8 +41,9 @@ | ||
41 | <!-- <module>weigeng</module>--> | 41 | <!-- <module>weigeng</module>--> |
42 | <!-- <module>independence</module>--> | 42 | <!-- <module>independence</module>--> |
43 | <!-- <module>quartz</module>--> | 43 | <!-- <module>quartz</module>--> |
44 | - <!-- <module>zkAttendance</module>--> | 44 | +<!-- <module>zkAttendance</module>--> |
45 | <module>user_search</module> | 45 | <module>user_search</module> |
46 | + <module>fIle-center</module> | ||
46 | </modules> | 47 | </modules> |
47 | 48 | ||
48 | <dependencies> | 49 | <dependencies> |
@@ -79,7 +80,12 @@ | @@ -79,7 +80,12 @@ | ||
79 | <artifactId>commons-io</artifactId> | 80 | <artifactId>commons-io</artifactId> |
80 | <version>2.6</version> | 81 | <version>2.6</version> |
81 | </dependency> | 82 | </dependency> |
82 | - | 83 | + <dependency> |
84 | + <groupId>org.springframework.boot</groupId> | ||
85 | + <artifactId>spring-boot-starter-test</artifactId> | ||
86 | + <scope>test</scope> | ||
87 | + <version>2.0.2.RELEASE</version> | ||
88 | + </dependency> | ||
83 | </dependencies> | 89 | </dependencies> |
84 | 90 | ||
85 | <dependencyManagement> | 91 | <dependencyManagement> |
@@ -107,4 +113,96 @@ | @@ -107,4 +113,96 @@ | ||
107 | </dependency> | 113 | </dependency> |
108 | </dependencies> | 114 | </dependencies> |
109 | </dependencyManagement> | 115 | </dependencyManagement> |
116 | + <build> | ||
117 | + <pluginManagement> | ||
118 | + <plugins> | ||
119 | + <plugin> | ||
120 | + <groupId>org.springframework.boot</groupId> | ||
121 | + <artifactId>spring-boot-maven-plugin</artifactId> | ||
122 | + </plugin> | ||
123 | + <plugin> | ||
124 | + <artifactId>maven-compiler-plugin</artifactId> | ||
125 | + <configuration> | ||
126 | + <target>${java.version}</target> | ||
127 | + <source>${java.version}</source> | ||
128 | + <encoding>UTF-8</encoding> | ||
129 | + </configuration> | ||
130 | + </plugin> | ||
131 | + <plugin> | ||
132 | + <groupId>org.apache.maven.plugins</groupId> | ||
133 | + <artifactId>maven-jar-plugin</artifactId> | ||
134 | + <configuration> | ||
135 | + <archive> | ||
136 | + <addMavenDescriptor>false</addMavenDescriptor> | ||
137 | + </archive> | ||
138 | + </configuration> | ||
139 | + </plugin> | ||
140 | + </plugins> | ||
141 | + </pluginManagement> | ||
142 | + <resources> | ||
143 | + <resource> | ||
144 | + <directory>src/main/resources</directory> | ||
145 | + <includes> | ||
146 | + <include>**/*.properties</include> | ||
147 | + <include>**/*.yml</include> | ||
148 | + <include>**/*.xml</include> | ||
149 | + <include>**/*.tld</include> | ||
150 | + <include>**/*.p12</include> | ||
151 | + <include>**/*.conf</include> | ||
152 | + <include>**/*.txt</include> | ||
153 | + <include>**/*.wsdl</include> | ||
154 | + <include>**/*.xsd</include> | ||
155 | + <include>**/*.ftl</include> | ||
156 | + <include>**/*.lua</include> | ||
157 | + <include>**/*.json</include> | ||
158 | + <include>processes/*</include> | ||
159 | + <include>**/spring.factories</include> | ||
160 | + </includes> | ||
161 | + <filtering>false</filtering> | ||
162 | + </resource> | ||
163 | + <resource> | ||
164 | + <directory>src/main/java</directory> | ||
165 | + <includes> | ||
166 | + <include>**/*.properties</include> | ||
167 | + <include>**/*.xml</include> | ||
168 | + <include>**/*.tld</include> | ||
169 | + </includes> | ||
170 | + <filtering>false</filtering> | ||
171 | + </resource> | ||
172 | + <resource> | ||
173 | + <directory>src/main/view</directory> | ||
174 | + <includes> | ||
175 | + <include>**/*.*</include> | ||
176 | + </includes> | ||
177 | + <filtering>false</filtering> | ||
178 | + </resource> | ||
179 | + | ||
180 | + <resource> | ||
181 | + <directory>src/main/proto</directory> | ||
182 | + <includes> | ||
183 | + <include>**/*.proto</include> | ||
184 | + </includes> | ||
185 | + <filtering>false</filtering> | ||
186 | + </resource> | ||
187 | + </resources> | ||
188 | + </build> | ||
189 | + | ||
190 | + <!-- 形成带第三方jar包的可执行jar包,jar包目录结构如下 application.properties lib META-INF mybatis | ||
191 | + org --> | ||
192 | + <!-- <build> | ||
193 | + <plugins> | ||
194 | + <plugin> | ||
195 | + <groupId>org.springframework.boot</groupId> | ||
196 | + <artifactId>spring-boot-maven-plugin</artifactId> | ||
197 | + <!–<executions> | ||
198 | + <execution> | ||
199 | + <goals> | ||
200 | + <goal>repackage</goal> | ||
201 | + </goals> | ||
202 | + </execution> | ||
203 | + </executions>–> | ||
204 | + </plugin> | ||
205 | + </plugins> | ||
206 | + <finalName>${project.artifactId}</finalName> | ||
207 | + </build>--> | ||
110 | </project> | 208 | </project> |
cloud/server1/pom.xml
@@ -28,6 +28,7 @@ | @@ -28,6 +28,7 @@ | ||
28 | <artifactId>spring-boot-maven-plugin</artifactId> | 28 | <artifactId>spring-boot-maven-plugin</artifactId> |
29 | </plugin> | 29 | </plugin> |
30 | </plugins> | 30 | </plugins> |
31 | + <finalName>${project.artifactId}</finalName> | ||
31 | </build> | 32 | </build> |
32 | 33 | ||
33 | </project> | 34 | </project> |
cloud/server1/src/main/java/com/sincere/server1/listener/EurekaInstanceCanceledListener.java
0 → 100644
@@ -0,0 +1,59 @@ | @@ -0,0 +1,59 @@ | ||
1 | +package com.sincere.server1.listener; | ||
2 | + | ||
3 | + | ||
4 | +import com.netflix.discovery.shared.Applications; | ||
5 | +import com.netflix.eureka.EurekaServerContextHolder; | ||
6 | +import com.netflix.eureka.registry.PeerAwareInstanceRegistry; | ||
7 | +import lombok.extern.slf4j.Slf4j; | ||
8 | +import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceCanceledEvent; | ||
9 | +import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRegisteredEvent; | ||
10 | +import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRenewedEvent; | ||
11 | +import org.springframework.cloud.netflix.eureka.server.event.EurekaRegistryAvailableEvent; | ||
12 | +import org.springframework.context.ApplicationEvent; | ||
13 | +import org.springframework.context.ApplicationListener; | ||
14 | +import org.springframework.context.annotation.Configuration; | ||
15 | + | ||
16 | +/** | ||
17 | + * 用于监听eureka服务停机通知 | ||
18 | + * Created by ace on 2017/7/8. | ||
19 | + */ | ||
20 | +@Slf4j | ||
21 | +@Configuration | ||
22 | +public class EurekaInstanceCanceledListener implements ApplicationListener { | ||
23 | + @Override | ||
24 | + public void onApplicationEvent(ApplicationEvent applicationEvent) { | ||
25 | + // 服务挂掉事件 | ||
26 | + if (applicationEvent instanceof EurekaInstanceCanceledEvent) { | ||
27 | + EurekaInstanceCanceledEvent event = (EurekaInstanceCanceledEvent) applicationEvent; | ||
28 | + // 获取当前Eureka实例中的节点信息 | ||
29 | + PeerAwareInstanceRegistry registry = EurekaServerContextHolder.getInstance().getServerContext().getRegistry(); | ||
30 | + Applications applications = registry.getApplications(); | ||
31 | + // 遍历获取已注册节点中与当前失效节点ID一致的节点信息 | ||
32 | + applications.getRegisteredApplications().forEach((registeredApplication) -> { | ||
33 | + registeredApplication.getInstances().forEach((instance) -> { | ||
34 | + if (instance.getInstanceId().equals(event.getServerId())) { | ||
35 | + log.debug("服务:" + instance.getAppName() + " 挂啦。。。"); | ||
36 | + // // TODO: 2017/9/3 扩展消息提醒 邮件、手机短信、微信等 | ||
37 | + } | ||
38 | + }); | ||
39 | + }); | ||
40 | + | ||
41 | + | ||
42 | + } | ||
43 | + if (applicationEvent instanceof EurekaInstanceRegisteredEvent) { | ||
44 | + EurekaInstanceRegisteredEvent event = (EurekaInstanceRegisteredEvent) applicationEvent; | ||
45 | + log.debug("服务:" + event.getInstanceInfo().getAppName() + " 注册成功啦。。。"); | ||
46 | + } | ||
47 | + if (applicationEvent instanceof EurekaInstanceRenewedEvent) { | ||
48 | + EurekaInstanceRenewedEvent event = (EurekaInstanceRenewedEvent) applicationEvent; | ||
49 | + log.debug("心跳检测服务:" + event.getInstanceInfo().getAppName() + "。。"); | ||
50 | + } | ||
51 | + if (applicationEvent instanceof EurekaRegistryAvailableEvent) { | ||
52 | + log.debug("服务 Aualiable。。"); | ||
53 | + } | ||
54 | + | ||
55 | + } | ||
56 | + | ||
57 | + | ||
58 | +} | ||
59 | + |
cloud/server1/src/main/resources/application.yaml
1 | -server: | ||
2 | - port: 8761 | ||
3 | - | ||
4 | -spring: | ||
5 | - application: | ||
6 | - name: eureka-server1 | ||
7 | - profiles: | ||
8 | - active: dev | ||
9 | - | ||
10 | eureka: | 1 | eureka: |
11 | instance: | 2 | instance: |
12 | - preferIpAddress: true | ||
13 | # 注册周期心跳 默认30s 这里改成5s 建议生成环境使用默认值30 | 3 | # 注册周期心跳 默认30s 这里改成5s 建议生成环境使用默认值30 |
14 | lease-renewal-interval-in-seconds: 10 | 4 | lease-renewal-interval-in-seconds: 10 |
15 | lease-expiration-duration-in-seconds: 60 | 5 | lease-expiration-duration-in-seconds: 60 |
16 | - | ||
17 | hostname: localhost | 6 | hostname: localhost |
7 | + prefer-ip-address: true | ||
18 | server: | 8 | server: |
19 | #是否开启保护模式 | 9 | #是否开启保护模式 |
20 | - enable-self-preservation: true | ||
21 | - eviction-interval-timer-in-ms: 4000 | 10 | + enable-self-preservation: false #关闭服务器自我保护,客户端心跳检测15分钟内错误达到80%服务会保护,导致别人还认为是好用的服务 |
11 | + eviction-interval-timer-in-ms: 4000 #清理间隔(单位毫秒,默认是60*1000)5秒将客户端剔除的服务在服务注册列表中剔除# | ||
22 | #当进入保护模式的情况下,注册中心不会注销服务,以兼容分区故障 | 12 | #当进入保护模式的情况下,注册中心不会注销服务,以兼容分区故障 |
23 | - renewal-percent-threshold: 0.5 | 13 | + renewal-percent-threshold: 0.5 # 指定每分钟需要收到的续约次数的阈值,默认值就是:0.85 |
14 | + response-cache-update-interval-ms: 3000 #eureka server刷新readCacheMap的时间,注意,client读取的是readCacheMap,这个时间决定了多久会把readWriteCacheMap的缓存更新到readCacheMap上 #eureka server刷新readCacheMap的时间,注意,client读取的是readCacheMap,这个时间决定了多久会把readWriteCacheMap的缓存更新到readCacheMap上默认30s | ||
15 | + response-cache-auto-expiration-in-seconds: 180 #eureka server缓存readWriteCacheMap失效时间,这个只有在这个时间过去后缓存才会失效,失效前不会更新,过期后从registry重新读取注册服务信息,registry是一个ConcurrentHashMap。 | ||
24 | client: | 16 | client: |
25 | #是否注册eureka,高可用的清况下使用 | 17 | #是否注册eureka,高可用的清况下使用 |
26 | - register-with-eureka: true | 18 | + register-with-eureka: true #false:不作为一个客户端注册到注册中心,是否将自身的实例信息注册到eureka服务器 |
27 | #是否启用获取服务注册信息 | 19 | #是否启用获取服务注册信息 |
28 | - fetch-registry: true | 20 | + fetch-registry: false #为true时,可以启动,但报异常:Cannot execute request on any known server ,是否从eureka服务端获取注册信息,消费者需要配置true |
21 | + instance-info-replication-interval-seconds: 10 | ||
22 | + registry-fetch-interval-seconds: 30 #从eureka服务端获取注册信息的间隔时间 | ||
29 | service-url: | 23 | service-url: |
30 | - defaultZone: http://localhost:8762/eureka/ | ||
31 | \ No newline at end of file | 24 | \ No newline at end of file |
25 | + defaultZone: http://localhost:8762/eureka/ | ||
26 | + | ||
27 | +ribbon: | ||
28 | + ServerListRefreshInterval: 1000 #刷新服务列表源的间隔时间 |
@@ -0,0 +1,24 @@ | @@ -0,0 +1,24 @@ | ||
1 | +#端口 | ||
2 | +server: | ||
3 | + port: 8761 | ||
4 | +# address: sincere.myjxt.com | ||
5 | + | ||
6 | +#服务名称 | ||
7 | +spring: | ||
8 | + application: | ||
9 | + name: eureka-server1 | ||
10 | + main: | ||
11 | + allow-bean-definition-overriding: true | ||
12 | + | ||
13 | + | ||
14 | +management: | ||
15 | + endpoints: | ||
16 | + web: | ||
17 | + exposure: | ||
18 | + include: "*" | ||
19 | + endpoint: | ||
20 | + health: | ||
21 | + show-details: always | ||
22 | + | ||
23 | + | ||
24 | + | ||
0 | \ No newline at end of file | 25 | \ No newline at end of file |
@@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
1 | +<#import "/spring.ftl" as spring /> | ||
2 | +<nav class="navbar navbar-default" role="navigation" > | ||
3 | + <div class="container"> | ||
4 | + <div class="navbar-header"> | ||
5 | + <a class="navbar-brand" href="<@spring.url dashboardPath/>"><span></span></a> | ||
6 | + <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> | ||
7 | + <span class="sr-only">切换导航</span> | ||
8 | + <span class="icon-bar"></span> | ||
9 | + <span class="icon-bar"></span> | ||
10 | + <span class="icon-bar"></span> | ||
11 | + </button> | ||
12 | + </div> | ||
13 | + <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> | ||
14 | + <ul class="nav navbar-nav navbar-right"> | ||
15 | + <li> | ||
16 | + <a href="<@spring.url dashboardPath/>">主页</a> | ||
17 | + </li> | ||
18 | + <li> | ||
19 | + <a href="<@spring.url dashboardPath/>/lastn">最近启动的1000个服务</a> | ||
20 | + </li> | ||
21 | + </ul> | ||
22 | + </div> | ||
23 | + </div> | ||
24 | +</nav> | ||
25 | + | ||
26 | + |
@@ -0,0 +1,71 @@ | @@ -0,0 +1,71 @@ | ||
1 | +<#import "/spring.ftl" as spring /> | ||
2 | +<!doctype html> | ||
3 | +<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> | ||
4 | +<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> | ||
5 | +<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> | ||
6 | +<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> | ||
7 | + <head> | ||
8 | + <base href="<@spring.url basePath/>"> | ||
9 | + <title>注册中心-事件</title> | ||
10 | + <link rel="stylesheet" type="text/css" href="eureka/css/wro.css"> | ||
11 | + </head> | ||
12 | + <body id="three"> | ||
13 | + | ||
14 | + <!--[if lt IE 7]> | ||
15 | + <p>您使用的是旧版本的浏览器。请升级您的浏览器以改善您的体验。</p> | ||
16 | + <![endif]--> | ||
17 | + | ||
18 | + <#include "header.ftl"> | ||
19 | + | ||
20 | + <div class="container-fluid xd-container"> | ||
21 | + <#include "navbar.ftl"> | ||
22 | + | ||
23 | + <div id="xd-jobs" class="tab-pane active col-md-12"> | ||
24 | + <ul class="nav nav-tabs" role="tablist" id="myTab"> | ||
25 | + <li class="active"><a data-toggle="tab" href="#cancelled">最后1000个取消的租约</a></li> | ||
26 | + <li><a data-toggle="tab" href="#registered">最近1000份新注册租约</a></li> | ||
27 | + </ul> | ||
28 | + <div class="tab-content"> | ||
29 | + <div class="tab-pane" id="cancelled"> | ||
30 | + <table id='lastNCanceled' class="table table-striped table-hover"> | ||
31 | + <thead> | ||
32 | + <tr><th>租约</th><th>时间戳</th></tr> | ||
33 | + </thead> | ||
34 | + <tbody> | ||
35 | + <#if lastNCanceled?has_content> | ||
36 | + <#list lastNCanceled as entry> | ||
37 | + <tr><td>${entry.date?datetime}</td><td>${entry.id}</td></tr> | ||
38 | + </#list> | ||
39 | + <#else> | ||
40 | + <tr><td colspan="2">没有可用的资源</td></tr> | ||
41 | + </#if> | ||
42 | + <tbody> | ||
43 | + </table> | ||
44 | + </div> | ||
45 | + <div class="tab-pane" id="registered"> | ||
46 | + <table id='lastNRegistered' class="table table-striped table-hover"> | ||
47 | + <thead> | ||
48 | + <tr><th>租约</th><th>时间戳</th></tr> | ||
49 | + </thead> | ||
50 | + <tbody> | ||
51 | + <#if lastNRegistered?has_content> | ||
52 | + <#list lastNRegistered as entry> | ||
53 | + <tr><td>${entry.date?datetime}</td><td>${entry.id}</td></tr> | ||
54 | + </#list> | ||
55 | + <#else> | ||
56 | + <tr><td colspan="2">没有可用的资源</td></tr> | ||
57 | + </#if> | ||
58 | + </tbody> | ||
59 | + </table> | ||
60 | + </div> | ||
61 | + </div> | ||
62 | + </div> | ||
63 | + </div> | ||
64 | + <script type="text/javascript" src="eureka/js/wro.js" ></script> | ||
65 | + <script type="text/javascript"> | ||
66 | + $(function () { | ||
67 | + $('#myTab a:last').tab('show') | ||
68 | + }) | ||
69 | + </script> | ||
70 | + </body> | ||
71 | +</html> |
@@ -0,0 +1,71 @@ | @@ -0,0 +1,71 @@ | ||
1 | +<h1>系统状态</h1> | ||
2 | +<div class="row"> | ||
3 | + <div class="col-md-6"> | ||
4 | + <table id='instances' class="table table-condensed table-striped table-hover"> | ||
5 | + <#if amazonInfo??> | ||
6 | + <tr> | ||
7 | + <td>服务注册和发现</td> | ||
8 | + <td>AMI: ${amiId!}</td> | ||
9 | + </tr> | ||
10 | + <tr> | ||
11 | + <td>空间</td> | ||
12 | + <td>${availabilityZone!}</td> | ||
13 | + </tr> | ||
14 | + <tr> | ||
15 | + <td>示例Id</td> | ||
16 | + <td>${instanceId!}</td> | ||
17 | + </tr> | ||
18 | + </#if> | ||
19 | + <tr> | ||
20 | + <td>环境</td> | ||
21 | + <td>${environment!}</td> | ||
22 | + </tr> | ||
23 | + <tr> | ||
24 | + <td>数据中心</td> | ||
25 | + <td>${datacenter!}</td> | ||
26 | + </tr> | ||
27 | + </table> | ||
28 | + </div> | ||
29 | + <div class="col-md-6"> | ||
30 | + <table id='instances' class="table table-condensed table-striped table-hover"> | ||
31 | + <tr> | ||
32 | + <td>当前时间</td> | ||
33 | + <td>${currentTime}</td> | ||
34 | + </tr> | ||
35 | + <tr> | ||
36 | + <td>运行</td> | ||
37 | + <td>${upTime}</td> | ||
38 | + </tr> | ||
39 | + <tr> | ||
40 | + <td>启用租约到期时间</td> | ||
41 | + <td>${registry.leaseExpirationEnabled?c}</td> | ||
42 | + </tr> | ||
43 | + <tr> | ||
44 | + <td>续订阈值</td> | ||
45 | + <td>${registry.numOfRenewsPerMinThreshold}</td> | ||
46 | + </tr> | ||
47 | + <tr> | ||
48 | + <td>续订 (最后一分钟)</td> | ||
49 | + <td>${registry.numOfRenewsInLastMin}</td> | ||
50 | + </tr> | ||
51 | + </table> | ||
52 | + </div> | ||
53 | +</div> | ||
54 | + | ||
55 | +<#if isBelowRenewThresold> | ||
56 | + <#if !registry.selfPreservationModeEnabled> | ||
57 | + <h4 id="uptime"><font size="+1" color="red"><b>续订小于阈值。自保存模式已关闭。如果出现网络/其他问题, 这可能不会保护实例过期。</b></font></h4> | ||
58 | + <#else> | ||
59 | + <h4 id="uptime"><font size="+1" color="red"><b> 紧急!注册中心可能不正确地验证身份, 当他们没有的情况下。续订小于阈值, 因此实例不会过期, 只是为了安全起见。</b></font></h4> | ||
60 | + </#if> | ||
61 | +<#elseif !registry.selfPreservationModeEnabled> | ||
62 | + <h4 id="uptime"><font size="+1" color="red"><b>自保存模式已关闭。如果出现网络/其他问题, 这可能不会保护实例过期。</b></font></h4> | ||
63 | +</#if> | ||
64 | + | ||
65 | +<h1>服务副本</h1> | ||
66 | +<ul class="list-group"> | ||
67 | + <#list replicas as replica> | ||
68 | + <li class="list-group-item"><a href="${replica.value}">${replica.key}</a></li> | ||
69 | + </#list> | ||
70 | +</ul> | ||
71 | + |
@@ -0,0 +1,113 @@ | @@ -0,0 +1,113 @@ | ||
1 | +<#import "/spring.ftl" as spring /> | ||
2 | +<!doctype html> | ||
3 | +<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> | ||
4 | +<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> | ||
5 | +<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> | ||
6 | +<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> | ||
7 | + <head> | ||
8 | + <base href="<@spring.url basePath/>"> | ||
9 | + <meta charset="utf-8"> | ||
10 | + <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
11 | + <title>服务注册和发现</title> | ||
12 | + <meta name="description" content=""> | ||
13 | + <meta name="viewport" content="width=device-width"> | ||
14 | + | ||
15 | + <link rel="stylesheet" href="eureka/css/wro.css"> | ||
16 | + | ||
17 | + </head> | ||
18 | + | ||
19 | + <body id="one"> | ||
20 | + <#include "header.ftl"> | ||
21 | + <div class="container-fluid xd-container"> | ||
22 | + <#include "navbar.ftl"> | ||
23 | + <h1>当前注册的服务实例</h1> | ||
24 | + <table id='instances' class="table table-striped table-hover"> | ||
25 | + <thead style="background-color: #328eba"> | ||
26 | + <tr><th>应用</th><th>申请</th><th>可用性区域</th><th>状态</th></tr> | ||
27 | + </thead> | ||
28 | + <tbody> | ||
29 | + <#if apps?has_content> | ||
30 | + <#list apps as app> | ||
31 | + <tr> | ||
32 | + <td><b>${app.name}</b></td> | ||
33 | + <td> | ||
34 | + <#list app.amiCounts as amiCount> | ||
35 | + <b>${amiCount.key}</b> (${amiCount.value})<#if amiCount_has_next>,</#if> | ||
36 | + </#list> | ||
37 | + </td> | ||
38 | + <td> | ||
39 | + <#list app.zoneCounts as zoneCount> | ||
40 | + <b>${zoneCount.key}</b> (${zoneCount.value})<#if zoneCount_has_next>,</#if> | ||
41 | + </#list> | ||
42 | + </td> | ||
43 | + <td> | ||
44 | + <#list app.instanceInfos as instanceInfo> | ||
45 | + <#if instanceInfo.isNotUp> | ||
46 | + <font color=red size=+1><b> | ||
47 | + </#if> | ||
48 | + <b>${instanceInfo.status}</b> (${instanceInfo.instances?size}) - | ||
49 | + <#if instanceInfo.isNotUp> | ||
50 | + </b></font> | ||
51 | + </#if> | ||
52 | + <#list instanceInfo.instances as instance> | ||
53 | + <#if instance.isHref> | ||
54 | + <a href="${instance.url}" target="_blank">${instance.id}</a> | ||
55 | + <#else> | ||
56 | + ${instance.id} | ||
57 | + </#if><#if instance_has_next>,</#if> | ||
58 | + </#list> | ||
59 | + </#list> | ||
60 | + </td> | ||
61 | + </tr> | ||
62 | + </#list> | ||
63 | + <#else> | ||
64 | + <tr><td colspan="4">没有可用的实例</td></tr> | ||
65 | + </#if> | ||
66 | + | ||
67 | + </tbody> | ||
68 | + </table> | ||
69 | + | ||
70 | + <h1>一般信息</h1> | ||
71 | + | ||
72 | + <table id='generalInfo' class="table table-striped table-hover"> | ||
73 | + <thead> | ||
74 | + <tr><th>名称</th><th>值</th></tr> | ||
75 | + </thead> | ||
76 | + <tbody> | ||
77 | + <#list statusInfo.generalStats?keys as stat> | ||
78 | + <tr> | ||
79 | + <td>${stat}</td><td>${statusInfo.generalStats[stat]!""}</td> | ||
80 | + </tr> | ||
81 | + </#list> | ||
82 | + <#list statusInfo.applicationStats?keys as stat> | ||
83 | + <tr> | ||
84 | + <td>${stat}</td><td>${statusInfo.applicationStats[stat]!""}</td> | ||
85 | + </tr> | ||
86 | + </#list> | ||
87 | + </tbody> | ||
88 | + </table> | ||
89 | + | ||
90 | + <h1>示例信息</h1> | ||
91 | + | ||
92 | + <table id='instanceInfo' class="table table-striped table-hover"> | ||
93 | + <thead> | ||
94 | + <tr><th>名称</th><th>值</th></tr> | ||
95 | + <thead> | ||
96 | + <tbody> | ||
97 | + <#list instanceInfo?keys as key> | ||
98 | + <tr> | ||
99 | + <td>${key}</td><td>${instanceInfo[key]!""}</td> | ||
100 | + </tr> | ||
101 | + </#list> | ||
102 | + </tbody> | ||
103 | + </table> | ||
104 | + </div> | ||
105 | + <script type="text/javascript" src="eureka/js/wro.js" ></script> | ||
106 | + <script type="text/javascript"> | ||
107 | + $(document).ready(function() { | ||
108 | + $('table.stripeable tr:odd').addClass('odd'); | ||
109 | + $('table.stripeable tr:even').addClass('even'); | ||
110 | + }); | ||
111 | + </script> | ||
112 | + </body> | ||
113 | +</html> |
cloud/server2/pom.xml
cloud/server2/src/main/java/com/sincere/server2/listener/EurekaInstanceCanceledListener.java
0 → 100644
@@ -0,0 +1,59 @@ | @@ -0,0 +1,59 @@ | ||
1 | +package com.sincere.server2.listener; | ||
2 | + | ||
3 | + | ||
4 | +import com.netflix.discovery.shared.Applications; | ||
5 | +import com.netflix.eureka.EurekaServerContextHolder; | ||
6 | +import com.netflix.eureka.registry.PeerAwareInstanceRegistry; | ||
7 | +import lombok.extern.slf4j.Slf4j; | ||
8 | +import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceCanceledEvent; | ||
9 | +import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRegisteredEvent; | ||
10 | +import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRenewedEvent; | ||
11 | +import org.springframework.cloud.netflix.eureka.server.event.EurekaRegistryAvailableEvent; | ||
12 | +import org.springframework.context.ApplicationEvent; | ||
13 | +import org.springframework.context.ApplicationListener; | ||
14 | +import org.springframework.context.annotation.Configuration; | ||
15 | + | ||
16 | +/** | ||
17 | + * 用于监听eureka服务停机通知 | ||
18 | + * Created by ace on 2017/7/8. | ||
19 | + */ | ||
20 | +@Slf4j | ||
21 | +@Configuration | ||
22 | +public class EurekaInstanceCanceledListener implements ApplicationListener { | ||
23 | + @Override | ||
24 | + public void onApplicationEvent(ApplicationEvent applicationEvent) { | ||
25 | + // 服务挂掉事件 | ||
26 | + if (applicationEvent instanceof EurekaInstanceCanceledEvent) { | ||
27 | + EurekaInstanceCanceledEvent event = (EurekaInstanceCanceledEvent) applicationEvent; | ||
28 | + // 获取当前Eureka实例中的节点信息 | ||
29 | + PeerAwareInstanceRegistry registry = EurekaServerContextHolder.getInstance().getServerContext().getRegistry(); | ||
30 | + Applications applications = registry.getApplications(); | ||
31 | + // 遍历获取已注册节点中与当前失效节点ID一致的节点信息 | ||
32 | + applications.getRegisteredApplications().forEach((registeredApplication) -> { | ||
33 | + registeredApplication.getInstances().forEach((instance) -> { | ||
34 | + if (instance.getInstanceId().equals(event.getServerId())) { | ||
35 | + log.debug("服务:" + instance.getAppName() + " 挂啦。。。"); | ||
36 | + // // TODO: 2017/9/3 扩展消息提醒 邮件、手机短信、微信等 | ||
37 | + } | ||
38 | + }); | ||
39 | + }); | ||
40 | + | ||
41 | + | ||
42 | + } | ||
43 | + if (applicationEvent instanceof EurekaInstanceRegisteredEvent) { | ||
44 | + EurekaInstanceRegisteredEvent event = (EurekaInstanceRegisteredEvent) applicationEvent; | ||
45 | + log.debug("服务:" + event.getInstanceInfo().getAppName() + " 注册成功啦。。。"); | ||
46 | + } | ||
47 | + if (applicationEvent instanceof EurekaInstanceRenewedEvent) { | ||
48 | + EurekaInstanceRenewedEvent event = (EurekaInstanceRenewedEvent) applicationEvent; | ||
49 | + log.debug("心跳检测服务:" + event.getInstanceInfo().getAppName() + "。。"); | ||
50 | + } | ||
51 | + if (applicationEvent instanceof EurekaRegistryAvailableEvent) { | ||
52 | + log.debug("服务 Aualiable。。"); | ||
53 | + } | ||
54 | + | ||
55 | + } | ||
56 | + | ||
57 | + | ||
58 | +} | ||
59 | + |
cloud/server2/src/main/resources/application.yaml
@@ -9,22 +9,29 @@ spring: | @@ -9,22 +9,29 @@ spring: | ||
9 | 9 | ||
10 | eureka: | 10 | eureka: |
11 | instance: | 11 | instance: |
12 | - preferIpAddress: true | ||
13 | # 注册周期心跳 默认30s 这里改成5s 建议生成环境使用默认值30 | 12 | # 注册周期心跳 默认30s 这里改成5s 建议生成环境使用默认值30 |
14 | lease-renewal-interval-in-seconds: 10 | 13 | lease-renewal-interval-in-seconds: 10 |
15 | lease-expiration-duration-in-seconds: 60 | 14 | lease-expiration-duration-in-seconds: 60 |
16 | - | ||
17 | hostname: localhost | 15 | hostname: localhost |
16 | + prefer-ip-address: true | ||
18 | server: | 17 | server: |
19 | #是否开启保护模式 | 18 | #是否开启保护模式 |
20 | - enable-self-preservation: true | ||
21 | - eviction-interval-timer-in-ms: 4000 | 19 | + enable-self-preservation: false #关闭服务器自我保护,客户端心跳检测15分钟内错误达到80%服务会保护,导致别人还认为是好用的服务 |
20 | + eviction-interval-timer-in-ms: 4000 #清理间隔(单位毫秒,默认是60*1000)5秒将客户端剔除的服务在服务注册列表中剔除# | ||
22 | #当进入保护模式的情况下,注册中心不会注销服务,以兼容分区故障 | 21 | #当进入保护模式的情况下,注册中心不会注销服务,以兼容分区故障 |
23 | - renewal-percent-threshold: 0.5 | 22 | + renewal-percent-threshold: 0.5 # 指定每分钟需要收到的续约次数的阈值,默认值就是:0.85 |
23 | + response-cache-update-interval-ms: 3000 #eureka server刷新readCacheMap的时间,注意,client读取的是readCacheMap,这个时间决定了多久会把readWriteCacheMap的缓存更新到readCacheMap上 #eureka server刷新readCacheMap的时间,注意,client读取的是readCacheMap,这个时间决定了多久会把readWriteCacheMap的缓存更新到readCacheMap上默认30s | ||
24 | + response-cache-auto-expiration-in-seconds: 180 #eureka server缓存readWriteCacheMap失效时间,这个只有在这个时间过去后缓存才会失效,失效前不会更新,过期后从registry重新读取注册服务信息,registry是一个ConcurrentHashMap。 | ||
24 | client: | 25 | client: |
25 | #是否注册eureka,高可用的清况下使用 | 26 | #是否注册eureka,高可用的清况下使用 |
26 | - register-with-eureka: true | 27 | + register-with-eureka: true #false:不作为一个客户端注册到注册中心,是否将自身的实例信息注册到eureka服务器 |
27 | #是否启用获取服务注册信息 | 28 | #是否启用获取服务注册信息 |
28 | - fetch-registry: true | 29 | + fetch-registry: false #为true时,可以启动,但报异常:Cannot execute request on any known server ,是否从eureka服务端获取注册信息,消费者需要配置true |
30 | + instance-info-replication-interval-seconds: 10 | ||
31 | + registry-fetch-interval-seconds: 30 #从eureka服务端获取注册信息的间隔时间 | ||
29 | service-url: | 32 | service-url: |
30 | - defaultZone: http://localhost:8761/eureka/ | ||
31 | \ No newline at end of file | 33 | \ No newline at end of file |
34 | + defaultZone: http://localhost:8761/eureka/ | ||
35 | + | ||
36 | + | ||
37 | +ribbon: | ||
38 | + ServerListRefreshInterval: 1000 #刷新服务列表源的间隔时间 | ||
32 | \ No newline at end of file | 39 | \ No newline at end of file |
@@ -0,0 +1,24 @@ | @@ -0,0 +1,24 @@ | ||
1 | +#端口 | ||
2 | +server: | ||
3 | + port: 8762 | ||
4 | +# address: sincere.myjxt.com | ||
5 | + | ||
6 | +#服务名称 | ||
7 | +spring: | ||
8 | + application: | ||
9 | + name: eureka-server2 | ||
10 | + main: | ||
11 | + allow-bean-definition-overriding: true | ||
12 | + | ||
13 | + | ||
14 | +management: | ||
15 | + endpoints: | ||
16 | + web: | ||
17 | + exposure: | ||
18 | + include: "*" | ||
19 | + endpoint: | ||
20 | + health: | ||
21 | + show-details: always | ||
22 | + | ||
23 | + | ||
24 | + | ||
0 | \ No newline at end of file | 25 | \ No newline at end of file |
@@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
1 | +<#import "/spring.ftl" as spring /> | ||
2 | +<nav class="navbar navbar-default" role="navigation" > | ||
3 | + <div class="container"> | ||
4 | + <div class="navbar-header"> | ||
5 | + <a class="navbar-brand" href="<@spring.url dashboardPath/>"><span></span></a> | ||
6 | + <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> | ||
7 | + <span class="sr-only">切换导航</span> | ||
8 | + <span class="icon-bar"></span> | ||
9 | + <span class="icon-bar"></span> | ||
10 | + <span class="icon-bar"></span> | ||
11 | + </button> | ||
12 | + </div> | ||
13 | + <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> | ||
14 | + <ul class="nav navbar-nav navbar-right"> | ||
15 | + <li> | ||
16 | + <a href="<@spring.url dashboardPath/>">主页</a> | ||
17 | + </li> | ||
18 | + <li> | ||
19 | + <a href="<@spring.url dashboardPath/>/lastn">最近启动的1000个服务</a> | ||
20 | + </li> | ||
21 | + </ul> | ||
22 | + </div> | ||
23 | + </div> | ||
24 | +</nav> | ||
25 | + | ||
26 | + |
@@ -0,0 +1,71 @@ | @@ -0,0 +1,71 @@ | ||
1 | +<#import "/spring.ftl" as spring /> | ||
2 | +<!doctype html> | ||
3 | +<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> | ||
4 | +<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> | ||
5 | +<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> | ||
6 | +<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> | ||
7 | + <head> | ||
8 | + <base href="<@spring.url basePath/>"> | ||
9 | + <title>注册中心-事件</title> | ||
10 | + <link rel="stylesheet" type="text/css" href="eureka/css/wro.css"> | ||
11 | + </head> | ||
12 | + <body id="three"> | ||
13 | + | ||
14 | + <!--[if lt IE 7]> | ||
15 | + <p>您使用的是旧版本的浏览器。请升级您的浏览器以改善您的体验。</p> | ||
16 | + <![endif]--> | ||
17 | + | ||
18 | + <#include "header.ftl"> | ||
19 | + | ||
20 | + <div class="container-fluid xd-container"> | ||
21 | + <#include "navbar.ftl"> | ||
22 | + | ||
23 | + <div id="xd-jobs" class="tab-pane active col-md-12"> | ||
24 | + <ul class="nav nav-tabs" role="tablist" id="myTab"> | ||
25 | + <li class="active"><a data-toggle="tab" href="#cancelled">最后1000个取消的租约</a></li> | ||
26 | + <li><a data-toggle="tab" href="#registered">最近1000份新注册租约</a></li> | ||
27 | + </ul> | ||
28 | + <div class="tab-content"> | ||
29 | + <div class="tab-pane" id="cancelled"> | ||
30 | + <table id='lastNCanceled' class="table table-striped table-hover"> | ||
31 | + <thead> | ||
32 | + <tr><th>租约</th><th>时间戳</th></tr> | ||
33 | + </thead> | ||
34 | + <tbody> | ||
35 | + <#if lastNCanceled?has_content> | ||
36 | + <#list lastNCanceled as entry> | ||
37 | + <tr><td>${entry.date?datetime}</td><td>${entry.id}</td></tr> | ||
38 | + </#list> | ||
39 | + <#else> | ||
40 | + <tr><td colspan="2">没有可用的资源</td></tr> | ||
41 | + </#if> | ||
42 | + <tbody> | ||
43 | + </table> | ||
44 | + </div> | ||
45 | + <div class="tab-pane" id="registered"> | ||
46 | + <table id='lastNRegistered' class="table table-striped table-hover"> | ||
47 | + <thead> | ||
48 | + <tr><th>租约</th><th>时间戳</th></tr> | ||
49 | + </thead> | ||
50 | + <tbody> | ||
51 | + <#if lastNRegistered?has_content> | ||
52 | + <#list lastNRegistered as entry> | ||
53 | + <tr><td>${entry.date?datetime}</td><td>${entry.id}</td></tr> | ||
54 | + </#list> | ||
55 | + <#else> | ||
56 | + <tr><td colspan="2">没有可用的资源</td></tr> | ||
57 | + </#if> | ||
58 | + </tbody> | ||
59 | + </table> | ||
60 | + </div> | ||
61 | + </div> | ||
62 | + </div> | ||
63 | + </div> | ||
64 | + <script type="text/javascript" src="eureka/js/wro.js" ></script> | ||
65 | + <script type="text/javascript"> | ||
66 | + $(function () { | ||
67 | + $('#myTab a:last').tab('show') | ||
68 | + }) | ||
69 | + </script> | ||
70 | + </body> | ||
71 | +</html> |
@@ -0,0 +1,71 @@ | @@ -0,0 +1,71 @@ | ||
1 | +<h1>系统状态</h1> | ||
2 | +<div class="row"> | ||
3 | + <div class="col-md-6"> | ||
4 | + <table id='instances' class="table table-condensed table-striped table-hover"> | ||
5 | + <#if amazonInfo??> | ||
6 | + <tr> | ||
7 | + <td>服务注册和发现</td> | ||
8 | + <td>AMI: ${amiId!}</td> | ||
9 | + </tr> | ||
10 | + <tr> | ||
11 | + <td>空间</td> | ||
12 | + <td>${availabilityZone!}</td> | ||
13 | + </tr> | ||
14 | + <tr> | ||
15 | + <td>示例Id</td> | ||
16 | + <td>${instanceId!}</td> | ||
17 | + </tr> | ||
18 | + </#if> | ||
19 | + <tr> | ||
20 | + <td>环境</td> | ||
21 | + <td>${environment!}</td> | ||
22 | + </tr> | ||
23 | + <tr> | ||
24 | + <td>数据中心</td> | ||
25 | + <td>${datacenter!}</td> | ||
26 | + </tr> | ||
27 | + </table> | ||
28 | + </div> | ||
29 | + <div class="col-md-6"> | ||
30 | + <table id='instances' class="table table-condensed table-striped table-hover"> | ||
31 | + <tr> | ||
32 | + <td>当前时间</td> | ||
33 | + <td>${currentTime}</td> | ||
34 | + </tr> | ||
35 | + <tr> | ||
36 | + <td>运行</td> | ||
37 | + <td>${upTime}</td> | ||
38 | + </tr> | ||
39 | + <tr> | ||
40 | + <td>启用租约到期时间</td> | ||
41 | + <td>${registry.leaseExpirationEnabled?c}</td> | ||
42 | + </tr> | ||
43 | + <tr> | ||
44 | + <td>续订阈值</td> | ||
45 | + <td>${registry.numOfRenewsPerMinThreshold}</td> | ||
46 | + </tr> | ||
47 | + <tr> | ||
48 | + <td>续订 (最后一分钟)</td> | ||
49 | + <td>${registry.numOfRenewsInLastMin}</td> | ||
50 | + </tr> | ||
51 | + </table> | ||
52 | + </div> | ||
53 | +</div> | ||
54 | + | ||
55 | +<#if isBelowRenewThresold> | ||
56 | + <#if !registry.selfPreservationModeEnabled> | ||
57 | + <h4 id="uptime"><font size="+1" color="red"><b>续订小于阈值。自保存模式已关闭。如果出现网络/其他问题, 这可能不会保护实例过期。</b></font></h4> | ||
58 | + <#else> | ||
59 | + <h4 id="uptime"><font size="+1" color="red"><b> 紧急!注册中心可能不正确地验证身份, 当他们没有的情况下。续订小于阈值, 因此实例不会过期, 只是为了安全起见。</b></font></h4> | ||
60 | + </#if> | ||
61 | +<#elseif !registry.selfPreservationModeEnabled> | ||
62 | + <h4 id="uptime"><font size="+1" color="red"><b>自保存模式已关闭。如果出现网络/其他问题, 这可能不会保护实例过期。</b></font></h4> | ||
63 | +</#if> | ||
64 | + | ||
65 | +<h1>服务副本</h1> | ||
66 | +<ul class="list-group"> | ||
67 | + <#list replicas as replica> | ||
68 | + <li class="list-group-item"><a href="${replica.value}">${replica.key}</a></li> | ||
69 | + </#list> | ||
70 | +</ul> | ||
71 | + |
@@ -0,0 +1,113 @@ | @@ -0,0 +1,113 @@ | ||
1 | +<#import "/spring.ftl" as spring /> | ||
2 | +<!doctype html> | ||
3 | +<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> | ||
4 | +<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> | ||
5 | +<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> | ||
6 | +<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> | ||
7 | + <head> | ||
8 | + <base href="<@spring.url basePath/>"> | ||
9 | + <meta charset="utf-8"> | ||
10 | + <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
11 | + <title>服务注册和发现</title> | ||
12 | + <meta name="description" content=""> | ||
13 | + <meta name="viewport" content="width=device-width"> | ||
14 | + | ||
15 | + <link rel="stylesheet" href="eureka/css/wro.css"> | ||
16 | + | ||
17 | + </head> | ||
18 | + | ||
19 | + <body id="one"> | ||
20 | + <#include "header.ftl"> | ||
21 | + <div class="container-fluid xd-container"> | ||
22 | + <#include "navbar.ftl"> | ||
23 | + <h1>当前注册的服务实例</h1> | ||
24 | + <table id='instances' class="table table-striped table-hover"> | ||
25 | + <thead style="background-color: #328eba"> | ||
26 | + <tr><th>应用</th><th>申请</th><th>可用性区域</th><th>状态</th></tr> | ||
27 | + </thead> | ||
28 | + <tbody> | ||
29 | + <#if apps?has_content> | ||
30 | + <#list apps as app> | ||
31 | + <tr> | ||
32 | + <td><b>${app.name}</b></td> | ||
33 | + <td> | ||
34 | + <#list app.amiCounts as amiCount> | ||
35 | + <b>${amiCount.key}</b> (${amiCount.value})<#if amiCount_has_next>,</#if> | ||
36 | + </#list> | ||
37 | + </td> | ||
38 | + <td> | ||
39 | + <#list app.zoneCounts as zoneCount> | ||
40 | + <b>${zoneCount.key}</b> (${zoneCount.value})<#if zoneCount_has_next>,</#if> | ||
41 | + </#list> | ||
42 | + </td> | ||
43 | + <td> | ||
44 | + <#list app.instanceInfos as instanceInfo> | ||
45 | + <#if instanceInfo.isNotUp> | ||
46 | + <font color=red size=+1><b> | ||
47 | + </#if> | ||
48 | + <b>${instanceInfo.status}</b> (${instanceInfo.instances?size}) - | ||
49 | + <#if instanceInfo.isNotUp> | ||
50 | + </b></font> | ||
51 | + </#if> | ||
52 | + <#list instanceInfo.instances as instance> | ||
53 | + <#if instance.isHref> | ||
54 | + <a href="${instance.url}" target="_blank">${instance.id}</a> | ||
55 | + <#else> | ||
56 | + ${instance.id} | ||
57 | + </#if><#if instance_has_next>,</#if> | ||
58 | + </#list> | ||
59 | + </#list> | ||
60 | + </td> | ||
61 | + </tr> | ||
62 | + </#list> | ||
63 | + <#else> | ||
64 | + <tr><td colspan="4">没有可用的实例</td></tr> | ||
65 | + </#if> | ||
66 | + | ||
67 | + </tbody> | ||
68 | + </table> | ||
69 | + | ||
70 | + <h1>一般信息</h1> | ||
71 | + | ||
72 | + <table id='generalInfo' class="table table-striped table-hover"> | ||
73 | + <thead> | ||
74 | + <tr><th>名称</th><th>值</th></tr> | ||
75 | + </thead> | ||
76 | + <tbody> | ||
77 | + <#list statusInfo.generalStats?keys as stat> | ||
78 | + <tr> | ||
79 | + <td>${stat}</td><td>${statusInfo.generalStats[stat]!""}</td> | ||
80 | + </tr> | ||
81 | + </#list> | ||
82 | + <#list statusInfo.applicationStats?keys as stat> | ||
83 | + <tr> | ||
84 | + <td>${stat}</td><td>${statusInfo.applicationStats[stat]!""}</td> | ||
85 | + </tr> | ||
86 | + </#list> | ||
87 | + </tbody> | ||
88 | + </table> | ||
89 | + | ||
90 | + <h1>示例信息</h1> | ||
91 | + | ||
92 | + <table id='instanceInfo' class="table table-striped table-hover"> | ||
93 | + <thead> | ||
94 | + <tr><th>名称</th><th>值</th></tr> | ||
95 | + <thead> | ||
96 | + <tbody> | ||
97 | + <#list instanceInfo?keys as key> | ||
98 | + <tr> | ||
99 | + <td>${key}</td><td>${instanceInfo[key]!""}</td> | ||
100 | + </tr> | ||
101 | + </#list> | ||
102 | + </tbody> | ||
103 | + </table> | ||
104 | + </div> | ||
105 | + <script type="text/javascript" src="eureka/js/wro.js" ></script> | ||
106 | + <script type="text/javascript"> | ||
107 | + $(document).ready(function() { | ||
108 | + $('table.stripeable tr:odd').addClass('odd'); | ||
109 | + $('table.stripeable tr:even').addClass('even'); | ||
110 | + }); | ||
111 | + </script> | ||
112 | + </body> | ||
113 | +</html> |
cloud/user_search/pom.xml
cloud/zkAttendance/src/main/java/com/sincere/att/AttApplication.java
@@ -15,6 +15,9 @@ import org.springframework.cloud.openfeign.EnableFeignClients; | @@ -15,6 +15,9 @@ import org.springframework.cloud.openfeign.EnableFeignClients; | ||
15 | @SpringBootApplication | 15 | @SpringBootApplication |
16 | public class AttApplication { | 16 | public class AttApplication { |
17 | 17 | ||
18 | +// public static void main(String[] args) { | ||
19 | +// SpringApplication.run(AttApplication.class, args); | ||
20 | +// } | ||
18 | public static void main(String[] args) { | 21 | public static void main(String[] args) { |
19 | SpringApplication.run(AttApplication.class, args); | 22 | SpringApplication.run(AttApplication.class, args); |
20 | } | 23 | } |