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
b73c4f2e
Commit
b73c4f2e
authored
Aug 17, 2023
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
type->kind
parent
95513f3e
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
238 additions
and
74 deletions
+238
-74
ch-admin-api/src/main/java/com/wwdz/ch/admin/job/SynCoinJob.java
...n-api/src/main/java/com/wwdz/ch/admin/job/SynCoinJob.java
+37
-2
ch-admin-api/src/test/java/com/wwdz/ch/admin/impl/ElasticsearchUtilTest.java
...st/java/com/wwdz/ch/admin/impl/ElasticsearchUtilTest.java
+24
-0
ch-admin-api/src/test/java/com/wwdz/ch/admin/impl/SynCoinJobTest.java
.../src/test/java/com/wwdz/ch/admin/impl/SynCoinJobTest.java
+22
-0
ch-core/src/main/java/com/wwdz/ch/core/consts/ItemKindEnum.java
...e/src/main/java/com/wwdz/ch/core/consts/ItemKindEnum.java
+5
-5
ch-core/src/main/java/com/wwdz/ch/core/util/ElasticsearchUtil.java
...rc/main/java/com/wwdz/ch/core/util/ElasticsearchUtil.java
+3
-0
ch-dao/src/main/java/com/wwdz/ch/db/dao/ItemDao.java
ch-dao/src/main/java/com/wwdz/ch/db/dao/ItemDao.java
+4
-0
ch-dao/src/main/java/com/wwdz/ch/db/domain/Item.java
ch-dao/src/main/java/com/wwdz/ch/db/domain/Item.java
+6
-6
ch-dao/src/main/java/com/wwdz/ch/db/domain/ItemExample.java
ch-dao/src/main/java/com/wwdz/ch/db/domain/ItemExample.java
+36
-36
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/CoinRequestDto.java
.../main/java/com/wwdz/ch/db/dto/request/CoinRequestDto.java
+1
-1
ch-dao/src/main/java/com/wwdz/ch/db/es/ItemEsDao.java
ch-dao/src/main/java/com/wwdz/ch/db/es/ItemEsDao.java
+66
-3
ch-dao/src/main/java/com/wwdz/ch/db/impl/ItemDaoImpl.java
ch-dao/src/main/java/com/wwdz/ch/db/impl/ItemDaoImpl.java
+15
-1
ch-dao/src/main/java/com/wwdz/ch/db/mapper/ItemMapper.java
ch-dao/src/main/java/com/wwdz/ch/db/mapper/ItemMapper.java
+0
-1
ch-dao/src/main/resources/com/wwdz/ch/db/mapper/ItemMapper.xml
...o/src/main/resources/com/wwdz/ch/db/mapper/ItemMapper.xml
+19
-19
No files found.
ch-admin-api/src/main/java/com/wwdz/ch/admin/job/SynCoinJob.java
View file @
b73c4f2e
...
...
@@ -5,11 +5,13 @@ import com.wwdz.ch.core.consts.CommConsts;
import
com.wwdz.ch.core.consts.CommonEnum
;
import
com.wwdz.ch.core.consts.MediaTypeEnum
;
import
com.wwdz.ch.core.storage.QiniuStorage
;
import
com.wwdz.ch.db.bean.ItemOfEs
;
import
com.wwdz.ch.db.dao.CoinsDao
;
import
com.wwdz.ch.db.dao.ItemDao
;
import
com.wwdz.ch.db.domain.Coins
;
import
com.wwdz.ch.db.domain.Item
;
import
com.wwdz.ch.db.dto.request.CoinRequestDto
;
import
com.wwdz.ch.db.es.ItemEsDao
;
import
com.xxdxxs.utils.CommonUtils
;
import
com.xxdxxs.utils.StringUtils
;
import
org.slf4j.Logger
;
...
...
@@ -28,6 +30,8 @@ import java.net.URL;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.stream.IntStream
;
@Component
...
...
@@ -44,6 +48,8 @@ public class SynCoinJob {
@Autowired
QiniuStorage
qiniuStorage
;
@Autowired
ItemEsDao
itemEsDao
;
public
void
execute
()
{
...
...
@@ -52,7 +58,7 @@ public class SynCoinJob {
CoinRequestDto
coinRequestDto
=
new
CoinRequestDto
();
coinRequestDto
.
setPage
(
1
);
coinRequestDto
.
setLimit
(
100
);
PageInfo
<
Item
>
pageInfo
=
itemDao
.
find
ByPage
(
coinRequestDto
);
PageInfo
<
Item
>
pageInfo
=
itemDao
.
find
PageExcludeFilter
(
coinRequestDto
);
int
totalPageNum
=
pageInfo
.
getPages
();
logger
.
info
(
"total page : {}, total : {}"
,
totalPageNum
,
pageInfo
.
getTotal
());
IntStream
.
rangeClosed
(
1
,
totalPageNum
).
parallel
().
forEach
(
i
->
{
...
...
@@ -102,7 +108,7 @@ public class SynCoinJob {
CoinRequestDto
coinRequestDto
=
new
CoinRequestDto
();
coinRequestDto
.
setPage
(
1
);
coinRequestDto
.
setLimit
(
100
);
PageInfo
<
Item
>
pageInfo
=
itemDao
.
find
ByPage
(
coinRequestDto
);
PageInfo
<
Item
>
pageInfo
=
itemDao
.
find
PageExcludeFilter
(
coinRequestDto
);
int
totalPageNum
=
pageInfo
.
getPages
();
logger
.
info
(
"total page : {}, total : {}"
,
totalPageNum
,
pageInfo
.
getTotal
());
IntStream
.
rangeClosed
(
1
,
totalPageNum
).
parallel
().
forEach
(
i
->
{
...
...
@@ -168,4 +174,33 @@ public class SynCoinJob {
return
null
;
}
public
void
synItemToEs
()
{
try
{
CoinRequestDto
coinRequestDto
=
new
CoinRequestDto
();
coinRequestDto
.
setPage
(
1
);
coinRequestDto
.
setLimit
(
100
);
PageInfo
<
Item
>
pageInfo
=
itemDao
.
findPageExcludeFilter
(
coinRequestDto
);
int
totalPageNum
=
pageInfo
.
getPages
();
logger
.
info
(
"total page : {}, total : {}"
,
totalPageNum
,
pageInfo
.
getTotal
());
IntStream
.
rangeClosed
(
1
,
totalPageNum
).
parallel
().
forEach
(
i
->
{
logger
.
info
(
">>>>>>>>>>>>>>>>> 当前同步数据的页码: {} 更新开始 <<<<<<<<<<<<<<<<<"
,
i
);
CoinRequestDto
dto
=
new
CoinRequestDto
();
dto
.
setPage
(
i
);
dto
.
setLimit
(
100
);
List
<
Item
>
itemList
=
itemDao
.
findListByPage
(
dto
);
itemEsDao
.
create
(
itemList
);
logger
.
info
(
">>>>>>>>>>>>>>>>> 页码 = {}, 同步es 成功 ! <<<<<<<<<<<<<<<<<"
,
i
);
try
{
Thread
.
sleep
(
100
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
});
logger
.
info
(
">>>>>>>>>>>>>>>>>数据同步es 完成 SUCCESS!!!!! <<<<<<<<<<<<<<<<<"
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"同步数据到es error {}"
,
e
);
}
}
}
ch-admin-api/src/test/java/com/wwdz/ch/admin/impl/ElasticsearchUtilTest.java
View file @
b73c4f2e
package
com.wwdz.ch.admin.impl
;
import
com.wwdz.ch.admin.job.SynCoinJob
;
import
com.wwdz.ch.core.entity.EsSearchParam
;
import
com.wwdz.ch.core.util.ElasticsearchUtil
;
import
com.wwdz.ch.db.bean.EsPageInfo
;
import
com.wwdz.ch.db.bean.ItemOfEs
;
import
com.wwdz.ch.db.dto.request.EsSearchRequestDto
;
import
com.wwdz.ch.db.es.ItemEsDao
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
...
...
@@ -16,13 +23,30 @@ import java.util.List;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
public
class
ElasticsearchUtilTest
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ElasticsearchUtilTest
.
class
);
@Autowired
ElasticsearchUtil
elasticsearchUtil
;
@Autowired
ItemEsDao
itemEsDao
;
@Test
public
void
findDocument
()
{
EsSearchParam
esSearchParam
=
EsSearchParam
.
of
(
"清代"
);
esSearchParam
.
setContent
(
"清代"
);
List
list
=
elasticsearchUtil
.
findDocument
(
esSearchParam
);
}
@Test
public
void
find
()
{
EsSearchRequestDto
esSearchRequestDto
=
new
EsSearchRequestDto
();
esSearchRequestDto
.
setContent
(
"清代"
);
esSearchRequestDto
.
setPage
(
1
);
esSearchRequestDto
.
setSize
(
20
);
EsPageInfo
esPageInfo
=
itemEsDao
.
findList
(
esSearchRequestDto
);
logger
.
info
(
"esPageInfo = {}"
,
esPageInfo
);
}
}
\ No newline at end of file
ch-admin-api/src/test/java/com/wwdz/ch/admin/impl/SynCoinJobTest.java
View file @
b73c4f2e
package
com.wwdz.ch.admin.impl
;
import
com.wwdz.ch.admin.job.SynCoinJob
;
import
com.wwdz.ch.db.es.ItemEsDao
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -15,8 +16,29 @@ public class SynCoinJobTest {
@Autowired
SynCoinJob
synCoinJob
;
@Autowired
ItemEsDao
itemEsDao
;
@Test
public
void
execute
()
{
synCoinJob
.
execute
();
}
@Test
public
void
updateImage
()
throws
Exception
{
synCoinJob
.
updateImageUrlOfsSize
();
}
@Test
public
void
createIndex
()
throws
Exception
{
itemEsDao
.
createIndex
();
}
@Test
public
void
synToEs
()
throws
Exception
{
synCoinJob
.
synItemToEs
();
}
}
\ No newline at end of file
ch-core/src/main/java/com/wwdz/ch/core/consts/Item
Type
Enum.java
→
ch-core/src/main/java/com/wwdz/ch/core/consts/Item
Kind
Enum.java
View file @
b73c4f2e
...
...
@@ -3,7 +3,7 @@ package com.wwdz.ch.core.consts;
/**
* 商品种类
*/
public
enum
Item
Type
Enum
{
public
enum
Item
Kind
Enum
{
COIN
(
1
,
"钱币"
),
NEPHRITE
(
2
,
"和田玉"
),
...
...
@@ -12,15 +12,15 @@ public enum ItemTypeEnum {
private
int
code
;
private
String
des
;
Item
Type
Enum
(
int
code
,
String
des
)
{
Item
Kind
Enum
(
int
code
,
String
des
)
{
this
.
code
=
code
;
this
.
des
=
des
;
}
public
static
String
getNameByCode
(
int
code
)
{
for
(
Item
TypeEnum
itemTypeEnum
:
ItemType
Enum
.
values
())
{
if
(
code
==
item
Type
Enum
.
getCode
())
{
return
item
Type
Enum
.
getDes
();
for
(
Item
KindEnum
itemKindEnum
:
ItemKind
Enum
.
values
())
{
if
(
code
==
item
Kind
Enum
.
getCode
())
{
return
item
Kind
Enum
.
getDes
();
}
}
return
null
;
...
...
ch-core/src/main/java/com/wwdz/ch/core/util/ElasticsearchUtil.java
View file @
b73c4f2e
...
...
@@ -73,4 +73,7 @@ public class ElasticsearchUtil {
}
return
Collections
.
emptyList
();
}
}
ch-dao/src/main/java/com/wwdz/ch/db/dao/ItemDao.java
View file @
b73c4f2e
...
...
@@ -17,6 +17,8 @@ public interface ItemDao {
PageInfo
<
Item
>
findByPage
(
CoinRequestDto
coinRequestDto
);
PageInfo
<
Item
>
findPageExcludeFilter
(
CoinRequestDto
coinRequestDto
);
Item
findDetails
(
Long
id
);
boolean
setCoin
(
Item
item
);
...
...
@@ -35,6 +37,8 @@ public interface ItemDao {
int
update
(
Item
item
);
PageInfo
<
Item
>
findByRandomPage
(
CoinRequestDto
coinRequestDto
);
/**
* 获取分类下的商品
...
...
ch-dao/src/main/java/com/wwdz/ch/db/domain/Item.java
View file @
b73c4f2e
...
...
@@ -10,7 +10,7 @@ import lombok.Data;
/**
* @author shiyu
* @date 2023/08/1
6
* @date 2023/08/1
7
*/
@Data
public
class
Item
implements
Entity
{
...
...
@@ -104,7 +104,7 @@ public class Item implements Entity {
/**
* 商品种类1钱币
*/
private
Integer
type
;
private
Integer
kind
;
/**
* 商品额外信息
...
...
@@ -157,7 +157,7 @@ public class Item implements Entity {
sb
.
append
(
", isSetted="
).
append
(
isSetted
);
sb
.
append
(
", originalSourceUrl="
).
append
(
originalSourceUrl
);
sb
.
append
(
", source="
).
append
(
source
);
sb
.
append
(
",
type="
).
append
(
type
);
sb
.
append
(
",
kind="
).
append
(
kind
);
sb
.
append
(
", extra="
).
append
(
extra
);
sb
.
append
(
", images="
).
append
(
images
);
sb
.
append
(
", videos="
).
append
(
videos
);
...
...
@@ -198,7 +198,7 @@ public class Item implements Entity {
&&
(
this
.
getIsSetted
()
==
null
?
other
.
getIsSetted
()
==
null
:
this
.
getIsSetted
().
equals
(
other
.
getIsSetted
()))
&&
(
this
.
getOriginalSourceUrl
()
==
null
?
other
.
getOriginalSourceUrl
()
==
null
:
this
.
getOriginalSourceUrl
().
equals
(
other
.
getOriginalSourceUrl
()))
&&
(
this
.
getSource
()
==
null
?
other
.
getSource
()
==
null
:
this
.
getSource
().
equals
(
other
.
getSource
()))
&&
(
this
.
get
Type
()
==
null
?
other
.
getType
()
==
null
:
this
.
getType
().
equals
(
other
.
getType
()))
&&
(
this
.
get
Kind
()
==
null
?
other
.
getKind
()
==
null
:
this
.
getKind
().
equals
(
other
.
getKind
()))
&&
(
this
.
getExtra
()
==
null
?
other
.
getExtra
()
==
null
:
this
.
getExtra
().
equals
(
other
.
getExtra
()))
&&
(
this
.
getImages
()
==
null
?
other
.
getImages
()
==
null
:
this
.
getImages
().
equals
(
other
.
getImages
()))
&&
(
this
.
getVideos
()
==
null
?
other
.
getVideos
()
==
null
:
this
.
getVideos
().
equals
(
other
.
getVideos
()))
...
...
@@ -228,7 +228,7 @@ public class Item implements Entity {
result
=
prime
*
result
+
((
getIsSetted
()
==
null
)
?
0
:
getIsSetted
().
hashCode
());
result
=
prime
*
result
+
((
getOriginalSourceUrl
()
==
null
)
?
0
:
getOriginalSourceUrl
().
hashCode
());
result
=
prime
*
result
+
((
getSource
()
==
null
)
?
0
:
getSource
().
hashCode
());
result
=
prime
*
result
+
((
get
Type
()
==
null
)
?
0
:
getType
().
hashCode
());
result
=
prime
*
result
+
((
get
Kind
()
==
null
)
?
0
:
getKind
().
hashCode
());
result
=
prime
*
result
+
((
getExtra
()
==
null
)
?
0
:
getExtra
().
hashCode
());
result
=
prime
*
result
+
((
getImages
()
==
null
)
?
0
:
getImages
().
hashCode
());
result
=
prime
*
result
+
((
getVideos
()
==
null
)
?
0
:
getVideos
().
hashCode
());
...
...
@@ -263,7 +263,7 @@ public class Item implements Entity {
isSetted
(
"is_setted"
,
"isSetted"
,
"INTEGER"
,
false
),
originalSourceUrl
(
"original_source_url"
,
"originalSourceUrl"
,
"VARCHAR"
,
false
),
source
(
"source"
,
"source"
,
"INTEGER"
,
true
),
type
(
"type"
,
"type"
,
"INTEGER"
,
tru
e
),
kind
(
"kind"
,
"kind"
,
"INTEGER"
,
fals
e
),
extra
(
"extra"
,
"extra"
,
"LONGVARCHAR"
,
false
),
images
(
"images"
,
"images"
,
"LONGVARCHAR"
,
false
),
videos
(
"videos"
,
"videos"
,
"LONGVARCHAR"
,
false
),
...
...
ch-dao/src/main/java/com/wwdz/ch/db/domain/ItemExample.java
View file @
b73c4f2e
...
...
@@ -2584,18 +2584,18 @@ public class ItemExample {
return
(
Criteria
)
this
;
}
public
Criteria
and
Type
IsNull
()
{
addCriterion
(
"
`type`
is null"
);
public
Criteria
and
Kind
IsNull
()
{
addCriterion
(
"
kind
is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
and
Type
IsNotNull
()
{
addCriterion
(
"
`type`
is not null"
);
public
Criteria
and
Kind
IsNotNull
()
{
addCriterion
(
"
kind
is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
and
Type
EqualTo
(
Integer
value
)
{
addCriterion
(
"
`type` ="
,
value
,
"type
"
);
public
Criteria
and
Kind
EqualTo
(
Integer
value
)
{
addCriterion
(
"
kind ="
,
value
,
"kind
"
);
return
(
Criteria
)
this
;
}
...
...
@@ -2606,13 +2606,13 @@ public class ItemExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
and
Type
EqualToColumn
(
Item
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"
`type`
= "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
public
Criteria
and
Kind
EqualToColumn
(
Item
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"
kind
= "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
and
Type
NotEqualTo
(
Integer
value
)
{
addCriterion
(
"
`type` <>"
,
value
,
"type
"
);
public
Criteria
and
Kind
NotEqualTo
(
Integer
value
)
{
addCriterion
(
"
kind <>"
,
value
,
"kind
"
);
return
(
Criteria
)
this
;
}
...
...
@@ -2623,13 +2623,13 @@ public class ItemExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
and
Type
NotEqualToColumn
(
Item
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"
`type`
<> "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
public
Criteria
and
Kind
NotEqualToColumn
(
Item
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"
kind
<> "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
and
Type
GreaterThan
(
Integer
value
)
{
addCriterion
(
"
`type` >"
,
value
,
"type
"
);
public
Criteria
and
Kind
GreaterThan
(
Integer
value
)
{
addCriterion
(
"
kind >"
,
value
,
"kind
"
);
return
(
Criteria
)
this
;
}
...
...
@@ -2640,13 +2640,13 @@ public class ItemExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
and
Type
GreaterThanColumn
(
Item
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"
`type`
> "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
public
Criteria
and
Kind
GreaterThanColumn
(
Item
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"
kind
> "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
and
Type
GreaterThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"
`type` >="
,
value
,
"type
"
);
public
Criteria
and
Kind
GreaterThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"
kind >="
,
value
,
"kind
"
);
return
(
Criteria
)
this
;
}
...
...
@@ -2657,13 +2657,13 @@ public class ItemExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
and
Type
GreaterThanOrEqualToColumn
(
Item
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"
`type`
>= "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
public
Criteria
and
Kind
GreaterThanOrEqualToColumn
(
Item
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"
kind
>= "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
and
Type
LessThan
(
Integer
value
)
{
addCriterion
(
"
`type` <"
,
value
,
"type
"
);
public
Criteria
and
Kind
LessThan
(
Integer
value
)
{
addCriterion
(
"
kind <"
,
value
,
"kind
"
);
return
(
Criteria
)
this
;
}
...
...
@@ -2674,13 +2674,13 @@ public class ItemExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
and
Type
LessThanColumn
(
Item
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"
`type`
< "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
public
Criteria
and
Kind
LessThanColumn
(
Item
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"
kind
< "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
and
Type
LessThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"
`type` <="
,
value
,
"type
"
);
public
Criteria
and
Kind
LessThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"
kind <="
,
value
,
"kind
"
);
return
(
Criteria
)
this
;
}
...
...
@@ -2691,28 +2691,28 @@ public class ItemExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
and
Type
LessThanOrEqualToColumn
(
Item
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"
`type`
<= "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
public
Criteria
and
Kind
LessThanOrEqualToColumn
(
Item
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"
kind
<= "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
and
Type
In
(
List
<
Integer
>
values
)
{
addCriterion
(
"
`type` in"
,
values
,
"type
"
);
public
Criteria
and
Kind
In
(
List
<
Integer
>
values
)
{
addCriterion
(
"
kind in"
,
values
,
"kind
"
);
return
(
Criteria
)
this
;
}
public
Criteria
and
Type
NotIn
(
List
<
Integer
>
values
)
{
addCriterion
(
"
`type` not in"
,
values
,
"type
"
);
public
Criteria
and
Kind
NotIn
(
List
<
Integer
>
values
)
{
addCriterion
(
"
kind not in"
,
values
,
"kind
"
);
return
(
Criteria
)
this
;
}
public
Criteria
and
Type
Between
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"
`type` between"
,
value1
,
value2
,
"type
"
);
public
Criteria
and
Kind
Between
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"
kind between"
,
value1
,
value2
,
"kind
"
);
return
(
Criteria
)
this
;
}
public
Criteria
and
Type
NotBetween
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"
`type` not between"
,
value1
,
value2
,
"type
"
);
public
Criteria
and
Kind
NotBetween
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"
kind not between"
,
value1
,
value2
,
"kind
"
);
return
(
Criteria
)
this
;
}
}
...
...
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/CoinRequestDto.java
View file @
b73c4f2e
...
...
@@ -81,7 +81,7 @@ public class CoinRequestDto extends BaseRequestDto implements Entity {
/**
* 商品种类1钱币
*/
private
Integer
type
;
private
Integer
kind
;
/**
* 商品视频, 分号分隔
...
...
ch-dao/src/main/java/com/wwdz/ch/db/es/ItemEsDao.java
View file @
b73c4f2e
...
...
@@ -4,16 +4,21 @@ import co.elastic.clients.elasticsearch.ElasticsearchClient;
import
co.elastic.clients.elasticsearch._types.SortOrder
;
import
co.elastic.clients.elasticsearch._types.query_dsl.MatchQuery
;
import
co.elastic.clients.elasticsearch._types.query_dsl.Query
;
import
co.elastic.clients.elasticsearch.core.SearchRequest
;
import
co.elastic.clients.elasticsearch.core.SearchResponse
;
import
co.elastic.clients.elasticsearch.core.*
;
import
co.elastic.clients.elasticsearch.core.bulk.BulkOperation
;
import
co.elastic.clients.elasticsearch.core.bulk.CreateOperation
;
import
co.elastic.clients.elasticsearch.core.search.Hit
;
import
co.elastic.clients.elasticsearch.indices.CreateIndexResponse
;
import
co.elastic.clients.elasticsearch.indices.DeleteIndexResponse
;
import
com.wwdz.ch.db.bean.EsPageInfo
;
import
com.wwdz.ch.db.bean.ItemOfEs
;
import
com.wwdz.ch.db.domain.Item
;
import
com.wwdz.ch.db.dto.request.EsSearchRequestDto
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Repository
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -22,11 +27,40 @@ public class ItemEsDao {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ItemEsDao
.
class
);
private
final
static
String
INDEX
=
"quanku_
new
"
;
private
final
static
String
INDEX
=
"quanku_
temp
"
;
@Resource
(
name
=
"clientByPasswd"
)
ElasticsearchClient
elasticsearchClient
;
public
void
createIndex
()
{
boolean
flag
=
false
;
try
{
flag
=
elasticsearchClient
.
exists
(
req
->
req
.
index
(
INDEX
)).
value
();
if
(
flag
){
logger
.
info
(
"索引 {} 已经存在!"
,
INDEX
);
}
else
{
CreateResponse
createResponse
=
elasticsearchClient
.
create
(
req
->
req
.
index
(
INDEX
));
logger
.
info
(
"创建索引的响应结果:{}"
,
createResponse
);
}
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
public
void
deleteIndex
()
{
boolean
flag
=
false
;
try
{
flag
=
elasticsearchClient
.
exists
(
req
->
req
.
index
(
INDEX
)).
value
();
if
(
flag
){
DeleteResponse
deleteResponse
=
elasticsearchClient
.
delete
(
req
->
req
.
index
(
INDEX
));
logger
.
info
(
"索引 {} 删除结果 :{} "
,
INDEX
,
deleteResponse
);
}
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
public
EsPageInfo
findList
(
EsSearchRequestDto
esSearchRequestDto
)
{
EsPageInfo
esPageInfo
=
null
;
...
...
@@ -65,4 +99,33 @@ public class ItemEsDao {
return
esPageInfo
;
}
public
void
create
(
List
<
Item
>
itemList
)
{
// 批量添加数据
List
<
BulkOperation
>
opts
=
new
ArrayList
<>();
for
(
Item
item
:
itemList
)
{
CreateOperation
<
Item
>
optObj
=
new
CreateOperation
.
Builder
<
Item
>()
.
index
(
INDEX
)
.
id
(
String
.
valueOf
(
item
.
getId
()))
.
document
(
item
)
.
build
();
BulkOperation
opt
=
new
BulkOperation
.
Builder
()
.
create
(
optObj
)
.
build
();
opts
.
add
(
opt
);
}
BulkRequest
bulkRequest
=
new
BulkRequest
.
Builder
()
.
operations
(
opts
)
.
build
();
try
{
BulkResponse
bulk
=
elasticsearchClient
.
bulk
(
bulkRequest
);
logger
.
info
(
"ES批量新增数据 : {}, 数量:{}"
,
bulk
);
}
catch
(
IOException
e
)
{
logger
.
info
(
"ES批量新增数据 error"
,
e
);
}
}
}
ch-dao/src/main/java/com/wwdz/ch/db/impl/ItemDaoImpl.java
View file @
b73c4f2e
...
...
@@ -17,6 +17,7 @@ import org.springframework.util.StringUtils;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.IntStream
;
@Repository
public
class
ItemDaoImpl
implements
ItemDao
{
...
...
@@ -84,6 +85,15 @@ public class ItemDaoImpl implements ItemDao {
}
@Override
public
PageInfo
<
Item
>
findPageExcludeFilter
(
CoinRequestDto
coinRequestDto
)
{
ItemExample
example
=
new
ItemExample
();
PageHelper
.
startPage
(
coinRequestDto
.
getPage
(),
coinRequestDto
.
getLimit
());
List
<
Item
>
list
=
itemMapper
.
selectByExampleWithBLOBs
(
example
);
return
new
PageInfo
<>(
list
);
}
@Override
public
Item
findDetails
(
Long
id
)
{
ItemExample
example
=
new
ItemExample
();
...
...
@@ -168,7 +178,11 @@ public class ItemDaoImpl implements ItemDao {
return
itemMapper
.
updateByPrimaryKeySelective
(
item
);
}
@Override
public
PageInfo
<
Item
>
findByRandomPage
(
CoinRequestDto
coinRequestDto
)
{
IntStream
.
range
(
0
,
767372
).
parallel
().
boxed
().
findAny
().
get
();
return
null
;
}
//-------------------------初始代码--------------------------//
...
...
ch-dao/src/main/java/com/wwdz/ch/db/mapper/ItemMapper.java
View file @
b73c4f2e
...
...
@@ -68,7 +68,6 @@ public interface ItemMapper {
*/
Item
selectByPrimaryKeySelective
(
@Param
(
"id"
)
Long
id
,
@Param
(
"selective"
)
Item
.
Column
...
selective
);
Item
selectByPrimaryKey
(
Long
id
);
int
updateByExampleSelective
(
@Param
(
"record"
)
Item
record
,
@Param
(
"example"
)
ItemExample
example
);
...
...
ch-dao/src/main/resources/com/wwdz/ch/db/mapper/ItemMapper.xml
View file @
b73c4f2e
...
...
@@ -20,7 +20,7 @@
<result
column=
"is_setted"
jdbcType=
"INTEGER"
property=
"isSetted"
/>
<result
column=
"original_source_url"
jdbcType=
"VARCHAR"
property=
"originalSourceUrl"
/>
<result
column=
"source"
jdbcType=
"INTEGER"
property=
"source"
/>
<result
column=
"
type"
jdbcType=
"INTEGER"
property=
"type
"
/>
<result
column=
"
kind"
jdbcType=
"INTEGER"
property=
"kind
"
/>
</resultMap>
<resultMap
extends=
"BaseResultMap"
id=
"ResultMapWithBLOBs"
type=
"com.wwdz.ch.db.domain.Item"
>
<result
column=
"extra"
jdbcType=
"LONGVARCHAR"
property=
"extra"
/>
...
...
@@ -92,7 +92,7 @@
<sql
id=
"Base_Column_List"
>
id, `name`, cid, is_on_sale, is_std, sort, share_image, top_image, price, create_time,
source_type, update_time, is_deleted, bid_time, remark, is_setted, original_source_url,
`source`,
`type`
`source`,
kind
</sql>
<sql
id=
"Blob_Column_List"
>
extra, images, videos, detail, original_extra
...
...
@@ -149,7 +149,7 @@
<otherwise>
id, `name`, cid, is_on_sale, is_std, sort, share_image, top_image, price, create_time,
source_type, update_time, is_deleted, bid_time, remark, is_setted, original_source_url,
`source`,
`type`
, extra, images, videos, detail, original_extra
`source`,
kind
, extra, images, videos, detail, original_extra
</otherwise>
</choose>
from item
...
...
@@ -184,7 +184,7 @@
<otherwise>
id, `name`, cid, is_on_sale, is_std, sort, share_image, top_image, price, create_time,
source_type, update_time, is_deleted, bid_time, remark, is_setted, original_source_url,
`source`,
`type`
, extra, images, videos, detail, original_extra
`source`,
kind
, extra, images, videos, detail, original_extra
</otherwise>
</choose>
from item
...
...
@@ -209,7 +209,7 @@
top_image, price, create_time,
source_type, update_time, is_deleted,
bid_time, remark, is_setted,
original_source_url, `source`,
`type`
,
original_source_url, `source`,
kind
,
extra, images, videos,
detail, original_extra)
values (#{name,jdbcType=VARCHAR}, #{cid,jdbcType=INTEGER}, #{isOnSale,jdbcType=BIT},
...
...
@@ -217,7 +217,7 @@
#{topImage,jdbcType=VARCHAR}, #{price,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP},
#{sourceType,jdbcType=INTEGER}, #{updateTime,jdbcType=TIMESTAMP}, #{isDeleted,jdbcType=BIT},
#{bidTime,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{isSetted,jdbcType=INTEGER},
#{originalSourceUrl,jdbcType=VARCHAR}, #{source,jdbcType=INTEGER}, #{
type
,jdbcType=INTEGER},
#{originalSourceUrl,jdbcType=VARCHAR}, #{source,jdbcType=INTEGER}, #{
kind
,jdbcType=INTEGER},
#{extra,jdbcType=LONGVARCHAR}, #{images,jdbcType=LONGVARCHAR}, #{videos,jdbcType=LONGVARCHAR},
#{detail,jdbcType=LONGVARCHAR}, #{originalExtra,jdbcType=LONGVARCHAR})
</insert>
...
...
@@ -278,8 +278,8 @@
<if
test=
"source != null"
>
`source`,
</if>
<if
test=
"
type
!= null"
>
`type`
,
<if
test=
"
kind
!= null"
>
kind
,
</if>
<if
test=
"extra != null"
>
extra,
...
...
@@ -349,8 +349,8 @@
<if
test=
"source != null"
>
#{source,jdbcType=INTEGER},
</if>
<if
test=
"
type
!= null"
>
#{
type
,jdbcType=INTEGER},
<if
test=
"
kind
!= null"
>
#{
kind
,jdbcType=INTEGER},
</if>
<if
test=
"extra != null"
>
#{extra,jdbcType=LONGVARCHAR},
...
...
@@ -432,8 +432,8 @@
<if
test=
"record.source != null"
>
`source` = #{record.source,jdbcType=INTEGER},
</if>
<if
test=
"record.
type
!= null"
>
`type` = #{record.type
,jdbcType=INTEGER},
<if
test=
"record.
kind
!= null"
>
kind = #{record.kind
,jdbcType=INTEGER},
</if>
<if
test=
"record.extra != null"
>
extra = #{record.extra,jdbcType=LONGVARCHAR},
...
...
@@ -475,7 +475,7 @@
is_setted = #{record.isSetted,jdbcType=INTEGER},
original_source_url = #{record.originalSourceUrl,jdbcType=VARCHAR},
`source` = #{record.source,jdbcType=INTEGER},
`type` = #{record.type
,jdbcType=INTEGER},
kind = #{record.kind
,jdbcType=INTEGER},
extra = #{record.extra,jdbcType=LONGVARCHAR},
images = #{record.images,jdbcType=LONGVARCHAR},
videos = #{record.videos,jdbcType=LONGVARCHAR},
...
...
@@ -505,7 +505,7 @@
is_setted = #{record.isSetted,jdbcType=INTEGER},
original_source_url = #{record.originalSourceUrl,jdbcType=VARCHAR},
`source` = #{record.source,jdbcType=INTEGER},
`type` = #{record.type
,jdbcType=INTEGER}
kind = #{record.kind
,jdbcType=INTEGER}
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
...
...
@@ -564,8 +564,8 @@
<if
test=
"source != null"
>
`source` = #{source,jdbcType=INTEGER},
</if>
<if
test=
"
type
!= null"
>
`type` = #{type
,jdbcType=INTEGER},
<if
test=
"
kind
!= null"
>
kind = #{kind
,jdbcType=INTEGER},
</if>
<if
test=
"extra != null"
>
extra = #{extra,jdbcType=LONGVARCHAR},
...
...
@@ -604,7 +604,7 @@
is_setted = #{isSetted,jdbcType=INTEGER},
original_source_url = #{originalSourceUrl,jdbcType=VARCHAR},
`source` = #{source,jdbcType=INTEGER},
`type` = #{type
,jdbcType=INTEGER},
kind = #{kind
,jdbcType=INTEGER},
extra = #{extra,jdbcType=LONGVARCHAR},
images = #{images,jdbcType=LONGVARCHAR},
videos = #{videos,jdbcType=LONGVARCHAR},
...
...
@@ -631,7 +631,7 @@
is_setted = #{isSetted,jdbcType=INTEGER},
original_source_url = #{originalSourceUrl,jdbcType=VARCHAR},
`source` = #{source,jdbcType=INTEGER},
`type` = #{type
,jdbcType=INTEGER}
kind = #{kind
,jdbcType=INTEGER}
where id = #{id,jdbcType=BIGINT}
</update>
<select
id=
"selectOneByExample"
parameterType=
"com.wwdz.ch.db.domain.ItemExample"
resultMap=
"BaseResultMap"
>
...
...
@@ -689,7 +689,7 @@
<otherwise>
id, `name`, cid, is_on_sale, is_std, sort, share_image, top_image, price, create_time,
source_type, update_time, is_deleted, bid_time, remark, is_setted, original_source_url,
`source`,
`type`
, extra, images, videos, detail, original_extra
`source`,
kind
, extra, images, videos, detail, original_extra
</otherwise>
</choose>
from item
...
...
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