Parcourir la Source

增加ES用户认证功能

wangdong6 3 ans auparavant
Parent
commit
85813f73bf

+ 2 - 1
pom.xml

@ -106,6 +106,7 @@
106 106
                <artifactId>spring-boot-maven-plugin</artifactId>
107 107
            </plugin>
108 108
            <!-- 配置文件转移到conf目录 -->
109
            <!-- 配置文件转移到conf目录 -->
109 110
            <plugin>
110 111
                <groupId>org.apache.maven.plugins</groupId>
111 112
                <artifactId>maven-resources-plugin</artifactId>
@ -120,7 +121,7 @@
120 121
                            <encoding>UTF-8</encoding>
121 122
                            <!-- 表示把配置文件拷到和jar包同一个路径下 -->
122 123
                            <outputDirectory>
123
                                ${project.build.directory}/config
124
                                ${project.build.directory}/conf
124 125
                            </outputDirectory>
125 126
                            <resources>
126 127
                                <resource>

+ 2 - 2
src/main/assembly/package.xml

@ -30,8 +30,8 @@
30 30
31 31
    <!-- 把项目的配置文件,打包进zip文件的config目录 -->
32 32
    <fileSet>
33
<!--      <directory>/src/main/resources/environment/${env}</directory>-->
34
      <directory>/src/main/resources</directory>
33
      <directory>/src/main/resources/environment/${env}</directory>
34
<!--      <directory>/src/main/resources</directory>-->
35 35
      <outputDirectory>/config</outputDirectory>
36 36
      <includes>
37 37
        <include>**/*.properties</include>

+ 16 - 3
src/main/java/com/ai/bss/es/esmanage/service/impl/EsServiceImpl.java

@ -12,13 +12,16 @@ import com.alibaba.fastjson.JSONArray;
12 12
import com.alibaba.fastjson.JSONObject;
13 13
import com.alibaba.fastjson.TypeReference;
14 14
import lombok.extern.slf4j.Slf4j;
15
import org.elasticsearch.index.query.QueryBuilders;
16 15
import org.elasticsearch.index.query.TermsQueryBuilder;
16
import org.springframework.beans.factory.annotation.Autowired;
17 17
import org.springframework.beans.factory.annotation.Value;
18 18
import org.springframework.stereotype.Service;
19 19
import org.springframework.util.StringUtils;
20 20
21
import java.util.*;
21
import java.util.ArrayList;
22
import java.util.HashMap;
23
import java.util.Iterator;
24
import java.util.Map;
22 25
23 26
24 27
@Slf4j
@ -28,15 +31,22 @@ public class EsServiceImpl implements EsService {
28 31
29 32
    @Value("${es.server:10.19.29.37:10020}")
30 33
    String esServer ;
34
    @Value("${es.server.username}")
35
    String userName ;
36
    @Value("${es.server.password}")
37
    String password ;
31 38
39
//    @Autowired
40
//    ElasticEntityRepository elasticEntityRepository;
32 41
33 42
    ElasticEntityRepository elasticEntityRepository = null;
34 43
35 44
    private ElasticEntityRepository getElasticEntityRepository(){
36 45
        if(elasticEntityRepository==null){
46
//            elasticEntityRepository = new ElasticEntityRepositoryImpl(esServer,userName,password);
37 47
            elasticEntityRepository = new ElasticEntityRepositoryImpl();
38 48
            log.debug("esServer:"+esServer);
39
            elasticEntityRepository.initServer(esServer);
49
            elasticEntityRepository.initServer(esServer,userName,password);
40 50
        }
41 51
        return elasticEntityRepository;
42 52
    }
@ -116,6 +126,9 @@ public class EsServiceImpl implements EsService {
116 126
        timeInfo.setStartTime(requestEntity.getStartTime());
117 127
        timeInfo.setEndTime(requestEntity.getEndTime());
118 128
        timeInfo.setFieldName(requestEntity.getTimeFieldName());
129
130
        log.debug("es-server: " + esServer);
131
119 132
        ElasticPage elasticPage = getElasticEntityRepository().findEntity(requestEntity.getTableName(), fieldMap, timeInfo, pageInfo,sortMap);
120 133
121 134
        return ResponseResult.sucess(elasticPage.getTotalSize(),elasticPage.getResults());

+ 6 - 2
src/main/resources/application.properties

@ -2,5 +2,9 @@ server.port=8111
2 2
spring.application.name=elastic
3 3
4 4
5
es.server=10.19.29.37:10020
6
es.server.port=10021
5
#es.server=10.19.90.34:9200
6
es.server=10.19.14.26:9200
7
es.server.port=9200
8
9
es.server.username=
10
es.server.password=

+ 6 - 2
src/main/resources/environment/dev/application.properties

@ -2,5 +2,9 @@ server.port=8111
2 2
spring.application.name=elastic
3 3
4 4
5
es.server=8.130.50.1:10021
6
es.server.port=10021
5
#es.server=10.19.90.34:9200
6
es.server=10.19.14.26:9200
7
es.server.port=9200
8
9
es.server.username=elastic
10
es.server.password=Trustlink999

+ 2 - 2
src/main/resources/environment/product/application.properties

@ -2,5 +2,5 @@ server.port=8111
2 2
spring.application.name=elastic
3 3
4 4
5
es.server=8.130.50.1:10021
6
es.server.port=10021
5
es.server=10.19.14.26:9200
6
es.server.port=9200