Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
5a6b7adc
Commit
5a6b7adc
authored
Aug 23, 2023
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
es索引配置
parent
c46648bd
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
12 deletions
+38
-12
ch-core/src/main/java/com/wwdz/ch/core/config/ElasticSearchConfig.java
...ain/java/com/wwdz/ch/core/config/ElasticSearchConfig.java
+3
-3
ch-core/src/main/resources/application-dev.yml
ch-core/src/main/resources/application-dev.yml
+3
-2
ch-core/src/main/resources/application-prod.yml
ch-core/src/main/resources/application-prod.yml
+2
-2
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/CoinRequestDto.java
.../main/java/com/wwdz/ch/db/dto/request/CoinRequestDto.java
+1
-0
ch-dao/src/main/java/com/wwdz/ch/db/es/ItemEsDao.java
ch-dao/src/main/java/com/wwdz/ch/db/es/ItemEsDao.java
+22
-2
ch-dao/src/main/java/com/wwdz/ch/db/impl/ItemDaoImpl.java
ch-dao/src/main/java/com/wwdz/ch/db/impl/ItemDaoImpl.java
+5
-1
ch-wx-api/src/main/resources/application.yml
ch-wx-api/src/main/resources/application.yml
+2
-2
No files found.
ch-core/src/main/java/com/wwdz/ch/core/config/ElasticSearchConfig.java
View file @
5a6b7adc
...
@@ -40,13 +40,13 @@ public class ElasticSearchConfig {
...
@@ -40,13 +40,13 @@ public class ElasticSearchConfig {
/**
/**
* 多个ip用逗号隔开
* 多个ip用逗号隔开
*/
*/
@Value
(
"${spring.elasticsearch.
j
est.uris}"
)
@Value
(
"${spring.elasticsearch.
r
est.uris}"
)
private
String
elasticsearchUris
;
private
String
elasticsearchUris
;
@Value
(
"${spring.elasticsearch.
j
est.username}"
)
@Value
(
"${spring.elasticsearch.
r
est.username}"
)
private
String
username
;
private
String
username
;
@Value
(
"${spring.elasticsearch.
j
est.password}"
)
@Value
(
"${spring.elasticsearch.
r
est.password}"
)
private
String
password
;
private
String
password
;
private
final
static
String
crtName
=
"za-test.crt"
;
private
final
static
String
crtName
=
"za-test.crt"
;
...
...
ch-core/src/main/resources/application-dev.yml
View file @
5a6b7adc
...
@@ -161,10 +161,11 @@ spring:
...
@@ -161,10 +161,11 @@ spring:
database
:
0
database
:
0
elasticsearch
:
elasticsearch
:
j
est
:
r
est
:
uris
:
172.16.122.190:9200
uris
:
172.16.122.190:9200
username
:
elastic
username
:
elastic
password
:
changeme
password
:
changeme
index
:
quanku_dev
jackson
:
jackson
:
date-format
:
yyyy-MM-dd HH:mm:ss
date-format
:
yyyy-MM-dd HH:mm:ss
...
...
ch-core/src/main/resources/application-prod.yml
View file @
5a6b7adc
...
@@ -165,11 +165,11 @@ spring:
...
@@ -165,11 +165,11 @@ spring:
database
:
0
database
:
0
elasticsearch
:
elasticsearch
:
j
est
:
r
est
:
uris
:
172.16.122.190:9200
uris
:
172.16.122.190:9200
username
:
elastic
username
:
elastic
password
:
changeme
password
:
changeme
index
:
quanku_new
server
:
server
:
servlet
:
servlet
:
session
:
session
:
...
...
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/CoinRequestDto.java
View file @
5a6b7adc
...
@@ -93,4 +93,5 @@ public class CoinRequestDto extends BaseRequestDto implements Entity {
...
@@ -93,4 +93,5 @@ public class CoinRequestDto extends BaseRequestDto implements Entity {
* 用于同步数据到es
* 用于同步数据到es
*/
*/
private
Date
startUpdateTime
;
private
Date
startUpdateTime
;
}
}
ch-dao/src/main/java/com/wwdz/ch/db/es/ItemEsDao.java
View file @
5a6b7adc
...
@@ -15,6 +15,7 @@ import com.xxdxxs.utils.DateUtils;
...
@@ -15,6 +15,7 @@ import com.xxdxxs.utils.DateUtils;
import
com.xxdxxs.utils.StringUtils
;
import
com.xxdxxs.utils.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -28,7 +29,8 @@ public class ItemEsDao {
...
@@ -28,7 +29,8 @@ public class ItemEsDao {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ItemEsDao
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ItemEsDao
.
class
);
private
final
static
String
INDEX
=
"quanku_new"
;
@Value
(
"${spring.elasticsearch.rest.index}"
)
private
String
INDEX
;
//商品来源是中国,所对应的编码
//商品来源是中国,所对应的编码
private
final
static
List
<
String
>
CHINESE_SOURCE_LIST
=
Arrays
.
asList
(
"1"
,
"2"
,
"3"
,
"7"
,
"11"
,
"1000"
);
private
final
static
List
<
String
>
CHINESE_SOURCE_LIST
=
Arrays
.
asList
(
"1"
,
"2"
,
"3"
,
"7"
,
"11"
,
"1000"
);
...
@@ -160,6 +162,23 @@ public class ItemEsDao {
...
@@ -160,6 +162,23 @@ public class ItemEsDao {
}
}
public
Boolean
isExised
(
Long
id
)
{
try
{
CountRequest
.
Builder
builder
=
new
CountRequest
.
Builder
();
builder
.
index
(
INDEX
);
Query
termQuery
=
TermQuery
.
of
(
t
->
t
.
field
(
"id"
).
value
(
id
)).
_toQuery
();
builder
.
query
(
termQuery
);
CountRequest
countRequest
=
builder
.
build
();
CountResponse
countResponse
=
elasticsearchClient
.
count
(
countRequest
);
long
num
=
countResponse
.
count
();
return
num
>
0
;
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询es是否存在id为 {} 的数据出错"
,
id
);
}
return
null
;
}
public
void
update
(
Item
item
)
{
public
void
update
(
Item
item
)
{
String
id
=
String
.
valueOf
(
item
.
getId
());
String
id
=
String
.
valueOf
(
item
.
getId
());
try
{
try
{
...
@@ -167,6 +186,7 @@ public class ItemEsDao {
...
@@ -167,6 +186,7 @@ public class ItemEsDao {
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"images"
,
item
.
getImages
());
map
.
put
(
"images"
,
item
.
getImages
());
UpdateResponse
<
Item
>
updateResponse
=
elasticsearchClient
.
update
(
e
->
e
.
index
(
INDEX
).
id
(
id
).
doc
(
map
),
Item
.
class
);
UpdateResponse
<
Item
>
updateResponse
=
elasticsearchClient
.
update
(
e
->
e
.
index
(
INDEX
).
id
(
id
).
doc
(
map
),
Item
.
class
);
logger
.
info
(
"updateResponse = {}"
,
updateResponse
);
logger
.
info
(
"ES修改数据成功, id:{}, 修改内容: {} "
,
id
,
map
);
logger
.
info
(
"ES修改数据成功, id:{}, 修改内容: {} "
,
id
,
map
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"修改es数据出错 id: {}"
,
id
,
e
);
logger
.
error
(
"修改es数据出错 id: {}"
,
id
,
e
);
...
@@ -189,7 +209,7 @@ public class ItemEsDao {
...
@@ -189,7 +209,7 @@ public class ItemEsDao {
List
<
Hit
<
ItemOfEs
>>
hitList
=
searchResponse
.
hits
().
hits
();
List
<
Hit
<
ItemOfEs
>>
hitList
=
searchResponse
.
hits
().
hits
();
if
(!
CollectionUtils
.
isEmpty
(
hitList
))
{
if
(!
CollectionUtils
.
isEmpty
(
hitList
))
{
Date
time
=
hitList
.
get
(
0
).
source
().
getUpdateTime
();
Date
time
=
hitList
.
get
(
0
).
source
().
getUpdateTime
();
logger
.
info
(
">>>>>>>>>>>> 查询出的最大更新时间: {}"
,
DateUtils
.
toString
(
time
));
logger
.
info
(
">>>>>>>>>>>>
es
查询出的最大更新时间: {}"
,
DateUtils
.
toString
(
time
));
return
time
;
return
time
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
ch-dao/src/main/java/com/wwdz/ch/db/impl/ItemDaoImpl.java
View file @
5a6b7adc
...
@@ -65,7 +65,11 @@ public class ItemDaoImpl implements ItemDao {
...
@@ -65,7 +65,11 @@ public class ItemDaoImpl implements ItemDao {
public
List
<
Item
>
findListByPage
(
CoinRequestDto
coinRequestDto
)
{
public
List
<
Item
>
findListByPage
(
CoinRequestDto
coinRequestDto
)
{
ItemExample
example
=
new
ItemExample
();
ItemExample
example
=
new
ItemExample
();
ItemExample
.
Criteria
criteria
=
example
.
createCriteria
();
ItemExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(
StringUtils
.
hasLength
(
coinRequestDto
.
getSortColumn
()))
{
example
.
setOrderByClause
(
coinRequestDto
.
getSortColumn
()
+
" asc"
);
}
else
{
example
.
setOrderByClause
(
"create_time asc"
);
example
.
setOrderByClause
(
"create_time asc"
);
}
JdbcHelper
.
ifPresent
(
coinRequestDto
.
getStartUpdateTime
(),
criteria:
:
andUpdateTimeGreaterThan
);
JdbcHelper
.
ifPresent
(
coinRequestDto
.
getStartUpdateTime
(),
criteria:
:
andUpdateTimeGreaterThan
);
PageHelper
.
startPage
(
coinRequestDto
.
getPage
(),
coinRequestDto
.
getLimit
());
PageHelper
.
startPage
(
coinRequestDto
.
getPage
(),
coinRequestDto
.
getLimit
());
return
itemMapper
.
selectByExampleWithBLOBs
(
example
);
return
itemMapper
.
selectByExampleWithBLOBs
(
example
);
...
...
ch-wx-api/src/main/resources/application.yml
View file @
5a6b7adc
...
@@ -5,8 +5,8 @@ spring:
...
@@ -5,8 +5,8 @@ spring:
encoding
:
UTF-8
encoding
:
UTF-8
servlet
:
servlet
:
multipart
:
multipart
:
max-file-size
:
50M
b
max-file-size
:
50M
B
max-request-size
:
80Mb
max-request-size
:
50MB
location
:
/tmp
location
:
/tmp
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment