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
303d8f91
Commit
303d8f91
authored
Jul 19, 2023
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
es config
parent
421dc45b
Changes
22
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
1307 additions
and
721 deletions
+1307
-721
ch-admin-api/src/main/java/com/wwdz/ch/admin/controller/SetCoinController.java
.../java/com/wwdz/ch/admin/controller/SetCoinController.java
+53
-0
ch-admin-api/src/main/java/com/wwdz/ch/admin/entity/vo/CoinVo.java
...api/src/main/java/com/wwdz/ch/admin/entity/vo/CoinVo.java
+92
-0
ch-admin-api/src/main/java/com/wwdz/ch/admin/impl/CoinServiceImpl.java
...src/main/java/com/wwdz/ch/admin/impl/CoinServiceImpl.java
+33
-0
ch-admin-api/src/main/java/com/wwdz/ch/admin/service/AdminGoodsService.java
...ain/java/com/wwdz/ch/admin/service/AdminGoodsService.java
+4
-7
ch-admin-api/src/main/java/com/wwdz/ch/admin/service/CoinService.java
.../src/main/java/com/wwdz/ch/admin/service/CoinService.java
+16
-0
ch-core/pom.xml
ch-core/pom.xml
+1
-1
ch-core/src/main/java/com/wwdz/ch/core/config/ElasticsearchConfig.java
...ain/java/com/wwdz/ch/core/config/ElasticsearchConfig.java
+68
-0
ch-core/src/main/java/com/wwdz/ch/core/consts/ResultCode.java
...ore/src/main/java/com/wwdz/ch/core/consts/ResultCode.java
+78
-0
ch-core/src/main/java/com/wwdz/ch/core/entity/EsSearchParam.java
.../src/main/java/com/wwdz/ch/core/entity/EsSearchParam.java
+44
-0
ch-core/src/main/java/com/wwdz/ch/core/type/Result.java
ch-core/src/main/java/com/wwdz/ch/core/type/Result.java
+115
-0
ch-core/src/main/java/com/wwdz/ch/core/type/SimpleResult.java
...ore/src/main/java/com/wwdz/ch/core/type/SimpleResult.java
+2
-0
ch-core/src/main/java/com/wwdz/ch/core/util/ElasticsearchUtil.java
...rc/main/java/com/wwdz/ch/core/util/ElasticsearchUtil.java
+59
-0
ch-core/src/main/resources/application-dev.yml
ch-core/src/main/resources/application-dev.yml
+1
-1
ch-dao/pom.xml
ch-dao/pom.xml
+12
-0
ch-dao/src/main/java/com/wwdz/ch/db/bean/CoinOfEs.java
ch-dao/src/main/java/com/wwdz/ch/db/bean/CoinOfEs.java
+28
-0
ch-dao/src/main/java/com/wwdz/ch/db/dao/ItemMapper.java
ch-dao/src/main/java/com/wwdz/ch/db/dao/ItemMapper.java
+1
-88
ch-dao/src/main/java/com/wwdz/ch/db/domain/Item.java
ch-dao/src/main/java/com/wwdz/ch/db/domain/Item.java
+120
-382
ch-dao/src/main/java/com/wwdz/ch/db/domain/ItemExample.java
ch-dao/src/main/java/com/wwdz/ch/db/domain/ItemExample.java
+437
-123
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/BaseRequestDto.java
.../main/java/com/wwdz/ch/db/dto/request/BaseRequestDto.java
+17
-0
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/CoinRequestDto.java
.../main/java/com/wwdz/ch/db/dto/request/CoinRequestDto.java
+43
-0
ch-dao/src/main/java/com/wwdz/ch/db/service/ItemService.java
ch-dao/src/main/java/com/wwdz/ch/db/service/ItemService.java
+6
-4
ch-dao/src/main/resources/com/wwdz/ch/db/dao/ItemMapper.xml
ch-dao/src/main/resources/com/wwdz/ch/db/dao/ItemMapper.xml
+77
-115
No files found.
ch-admin-api/src/main/java/com/wwdz/ch/admin/controller/SetCoinController.java
0 → 100644
View file @
303d8f91
package
com.wwdz.ch.admin.controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.wwdz.ch.admin.annotation.RequiresPermissionsDesc
;
import
com.wwdz.ch.admin.entity.vo.CategoryVo
;
import
com.wwdz.ch.admin.entity.vo.CoinVo
;
import
com.wwdz.ch.admin.service.CoinService
;
import
com.wwdz.ch.admin.util.AuthSupport
;
import
com.wwdz.ch.core.type.ListResult
;
import
com.wwdz.ch.core.type.SimpleResult
;
import
com.wwdz.ch.db.domain.Category
;
import
com.wwdz.ch.db.dto.request.CoinRequestDto
;
import
com.xxdxxs.utils.JsonUtils
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
/**
* 钱币设置
*/
@RestController
@RequestMapping
(
"/admin/setCoin"
)
public
class
SetCoinController
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SetCoinController
.
class
);
@Autowired
private
CoinService
coinService
;
@RequiresPermissions
(
"admin:setCoin:findDetail"
)
@RequiresPermissionsDesc
(
menu
=
{
"钱币列表"
,
"钱币明细"
},
button
=
"查询"
)
@PostMapping
(
"/findDetail"
)
public
SimpleResult
<
CoinVo
>
findDetail
(
@RequestBody
CoinRequestDto
coinRequestDto
)
{
logger
.
info
(
"【请求开始】操作人:["
+
AuthSupport
.
userName
()+
"] 钱币列表->钱币明细->查询,请求参数:parma:{}"
,
coinRequestDto
);
CoinVo
coinVo
=
coinService
.
findDetails
(
coinRequestDto
);
logger
.
info
(
"【请求结束】钱币列表->钱币明细->查询:total:{}"
,
JsonUtils
.
from
(
coinVo
));
return
new
SimpleResult
<>(
coinVo
);
}
@RequiresPermissions
(
"admin:setCoin:update"
)
@RequiresPermissionsDesc
(
menu
=
{
"钱币列表"
,
"钱币设置"
},
button
=
"更新"
)
@PostMapping
(
"/update"
)
public
Object
update
(
@RequestBody
CoinRequestDto
coinRequestDto
)
{
logger
.
info
(
"【请求开始】操作人:["
+
AuthSupport
.
userName
()+
"] 钱币列表->钱币设置->更新,请求参数:parma:{}"
,
coinRequestDto
);
coinService
.
setCoin
(
coinRequestDto
);
logger
.
info
(
"【请求结束】钱币列表->钱币明细->更新"
);
return
new
SimpleResult
<>(
true
);
}
}
ch-admin-api/src/main/java/com/wwdz/ch/admin/entity/vo/CoinVo.java
0 → 100644
View file @
303d8f91
package
com.wwdz.ch.admin.entity.vo
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
import
java.util.Date
;
@Data
public
class
CoinVo
implements
Entity
{
private
Long
id
;
/**
* 钱币名称
*/
private
String
name
;
/**
* 钱币所属类目ID
*/
private
Integer
cid
;
/**
* 是否上架
*/
private
Boolean
isOnSale
;
/**
* 是否标准件
*/
private
Boolean
isStd
;
/**
* 排序
*/
private
Integer
sort
;
/**
* 商品分享朋友圈图片
*/
private
String
shareImage
;
/**
* 价格, 要除以100
*/
private
Long
price
;
/**
* 创建时间
*/
private
Date
created
;
/**
* 来源类型(1系统2用户上传)
*/
private
Boolean
sourceType
;
/**
* 更新时间
*/
private
Date
updated
;
/**
* 逻辑删除
*/
private
Boolean
isDeleted
;
/**
* 成交时间
*/
private
String
bidTime
;
/**
* 备注说明
*/
private
String
remark
;
/**
* 钱币额外信息
*/
private
String
extra
;
/**
* 商品图片,分号分隔
*/
private
String
images
;
/**
* 商品详细介绍,是富文本格式
*/
private
String
detail
;
}
ch-admin-api/src/main/java/com/wwdz/ch/admin/impl/CoinServiceImpl.java
0 → 100644
View file @
303d8f91
package
com.wwdz.ch.admin.impl
;
import
com.wwdz.ch.admin.entity.vo.CoinVo
;
import
com.wwdz.ch.admin.service.CoinService
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.db.dto.request.CoinRequestDto
;
import
com.wwdz.ch.db.service.ItemService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Service
public
class
CoinServiceImpl
implements
CoinService
{
@Autowired
ItemService
itemService
;
@Override
public
List
<
CoinVo
>
findList
(
CoinRequestDto
coinRequestDto
)
{
return
null
;
}
@Override
public
CoinVo
findDetails
(
CoinRequestDto
coinRequestDto
)
{
return
null
;
}
@Override
public
Result
setCoin
(
CoinRequestDto
coinRequestDto
)
{
return
null
;
}
}
ch-admin-api/src/main/java/com/wwdz/ch/admin/service/AdminGoodsService.java
View file @
303d8f91
package
com.wwdz.ch.admin.service
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
com.wwdz.ch.admin.entity.vo.ItemVo
;
...
...
@@ -120,10 +117,10 @@ public class AdminGoodsService {
if
(
error
!=
null
)
{
return
error
;
}
Date
now
=
new
Date
();
// 商品基本信息表Dts_goods
item
.
setCreated
(
LocalDateTime
.
now
()
);
item
.
setUpdated
(
LocalDateTime
.
now
()
);
item
.
setCreated
(
now
);
item
.
setUpdated
(
now
);
item
.
setIsDeleted
(
false
);
itemService
.
add
(
item
);
...
...
ch-admin-api/src/main/java/com/wwdz/ch/admin/service/CoinService.java
0 → 100644
View file @
303d8f91
package
com.wwdz.ch.admin.service
;
import
com.wwdz.ch.admin.entity.vo.CoinVo
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.db.dto.request.CoinRequestDto
;
import
java.util.List
;
public
interface
CoinService
{
List
<
CoinVo
>
findList
(
CoinRequestDto
coinRequestDto
);
CoinVo
findDetails
(
CoinRequestDto
coinRequestDto
);
Result
setCoin
(
CoinRequestDto
coinRequestDto
);
}
ch-core/pom.xml
View file @
303d8f91
...
...
@@ -127,7 +127,7 @@
<dependency>
<groupId>
co.elastic.clients
</groupId>
<artifactId>
elasticsearch-java
</artifactId>
<version>
8.
1
.2
</version>
<version>
8.
8
.2
</version>
</dependency>
</dependencies>
...
...
ch-core/src/main/java/com/wwdz/ch/core/config/ElasticsearchConfig.java
0 → 100644
View file @
303d8f91
package
com.wwdz.ch.core.config
;
import
co.elastic.clients.elasticsearch.ElasticsearchAsyncClient
;
import
co.elastic.clients.elasticsearch.ElasticsearchClient
;
import
co.elastic.clients.json.jackson.JacksonJsonpMapper
;
import
co.elastic.clients.transport.rest_client.RestClientTransport
;
import
org.apache.http.HttpHost
;
import
org.elasticsearch.client.RestClient
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.StringUtils
;
@Component
public
class
ElasticsearchConfig
{
/**
* 多个ip用逗号隔开
*/
@Value
(
"${spring.elasticsearch.jest.uris}"
)
private
String
elasticsearchUris
;
/**
* 同步方式
* @return
*/
@Bean
public
ElasticsearchClient
elasticsearchClient
()
{
HttpHost
[]
httpHosts
=
toHttpHost
();
RestClient
restClient
=
RestClient
.
builder
(
httpHosts
).
build
();
RestClientTransport
transport
=
new
RestClientTransport
(
restClient
,
new
JacksonJsonpMapper
());
return
new
ElasticsearchClient
(
transport
);
}
/**
* 异步方式
* @return
*/
@Bean
public
ElasticsearchAsyncClient
elasticsearchAsyncClient
()
{
HttpHost
[]
httpHosts
=
toHttpHost
();
RestClient
restClient
=
RestClient
.
builder
(
httpHosts
).
build
();
RestClientTransport
transport
=
new
RestClientTransport
(
restClient
,
new
JacksonJsonpMapper
());
return
new
ElasticsearchAsyncClient
(
transport
);
}
/**
* 解析配置的字符串hosts,转为HttpHost对象数组
*
* @return
*/
private
HttpHost
[]
toHttpHost
()
{
if
(!
StringUtils
.
hasLength
(
elasticsearchUris
))
{
throw
new
RuntimeException
(
"invalid elasticsearch configuration. elasticsearch.hosts不能为空!"
);
}
// 多个IP逗号隔开
String
[]
hostArray
=
elasticsearchUris
.
split
(
","
);
HttpHost
[]
httpHosts
=
new
HttpHost
[
hostArray
.
length
];
HttpHost
httpHost
;
for
(
int
i
=
0
;
i
<
hostArray
.
length
;
i
++)
{
String
[]
strings
=
hostArray
[
i
].
split
(
":"
);
httpHost
=
new
HttpHost
(
strings
[
0
],
Integer
.
parseInt
(
strings
[
1
]),
"http"
);
httpHosts
[
i
]
=
httpHost
;
}
return
httpHosts
;
}
}
ch-core/src/main/java/com/wwdz/ch/core/consts/ResultCode.java
0 → 100644
View file @
303d8f91
package
com.wwdz.ch.core.consts
;
/**
* 返回结果码枚举
*/
public
enum
ResultCode
{
SUCCESS
(
1000
,
"成功"
),
FAILED
(
4000
,
"操作失败"
),
UNKNOWN_USER
(
4001
,
"请先登录"
),
INVALID_FILE
(
4002
,
"文件类型不正确"
),
LOGIN_FAILED
(
4003
,
"登录失败"
),
INTERCEPTED
(
4004
,
"该订单已被拦截"
),
WAIT_STAGE_RETURN
(
4005
,
"该订单状态待驿站取回不能进行当前操作"
),
NOT_PLAYER
(
4030
,
"没有此用户"
),
RPC_EXCEPTION
(
5001
,
"RPC接口调用异常"
),
INTERAL_ERROR
(
5005
,
"内部错误"
),
UPLOAD_IMAGE_ERRROR
(
5006
,
"传图错误"
),
INVALID_DATA
(
5007
,
"数据不合法"
),
UPLOAD_IMAGE_EXITS_ERRROR
(
55555
,
"图片没有上传成功"
),
PARAM_ERROR
(
5011
,
"参数错误"
),
TOO_MANY_REQUEST
(
5011
,
"请求频繁,请稍后试"
),
ILLEGAL_REQUEST
(
5012
,
"非法请求"
),
PARSE_ERROR
(
5013
,
"数据解析异常"
),
DUPLICATE_SUBMIT
(
5014
,
"重复提交"
),
SQL_EXECPTION
(
5015
,
"sql执行异常"
),
DEL_DATA_FAILED
(
5016
,
"删除数据失败"
),
UPDATE_DATA_FAILED
(
5019
,
"更新数据失败"
),
SENTINEL_WAIT
(
5017
,
"页面访问太火爆了,请稍后重试!"
),
GET_LOCK_FAILED
(
5018
,
"获取分布式锁失败"
),
CHECK_FAIL
(
6005
,
"验证失败"
),
AUCTION_INFO_ERROR
(
8111
,
"加载失败,请重试"
),
AUCTION_ITEM_LIMIT
(
8601
,
"访问过于频繁,请稍后再试"
),
NO_RECEIVE_ADDRESS
(
8701
,
"请联系客服完善退货地址"
),
//2023-05-05新增
VERIFY_CODE_IS_EXIST
(
21006
,
"验证码{0}秒内不重复发送"
),
VERIFY_CODE_IS_INVAILD
(
21007
,
"验证码过期"
),
VERIFY_CODE_IS_ERROR
(
21008
,
"验证码错误"
),
/**
* 用户名或密码错误
*/
LOGIN_ERROR
(
21009
,
"用户名或密码错误"
),
/**
* 当前用户无权限访问
*/
ACCESS_DENIED
(
21010
,
"当前用户无权限访问"
),
/**
* 账号不存在
*/
LOGIN_ACCOUNT_ERROR
(
21011
,
"账号不存在"
),
/**
* 账号未启用
*/
LOGIN_ACCOUNT_UNENABLED
(
21012
,
"用户已被禁用"
),
;
int
code
;
String
message
;
ResultCode
(
int
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
public
int
getCode
()
{
return
code
;
}
public
String
getMessage
()
{
return
message
;
}
}
ch-core/src/main/java/com/wwdz/ch/core/entity/EsSearchParam.java
0 → 100644
View file @
303d8f91
package
com.wwdz.ch.core.entity
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
import
java.util.Map
;
@Data
public
class
EsSearchParam
implements
Entity
{
private
Map
<
String
,
String
>
paramMap
;
private
String
content
;
private
String
sortField
;
private
Boolean
isDesc
=
true
;
private
int
page
=
1
;
private
int
size
=
20
;
public
EsSearchParam
(
Map
<
String
,
String
>
paramMap
,
String
content
,
String
sortField
,
Boolean
isDesc
,
int
page
,
int
size
)
{
this
.
paramMap
=
paramMap
;
this
.
content
=
content
;
this
.
sortField
=
sortField
;
this
.
isDesc
=
isDesc
;
this
.
page
=
page
;
this
.
size
=
size
;
}
public
EsSearchParam
(
String
content
,
String
sortField
,
Boolean
isDesc
,
int
page
,
int
size
)
{
this
.
content
=
content
;
this
.
sortField
=
sortField
;
this
.
isDesc
=
isDesc
;
this
.
page
=
page
;
this
.
size
=
size
;
}
public
EsSearchParam
(
String
content
,
int
page
,
int
size
)
{
this
.
content
=
content
;
this
.
page
=
page
;
this
.
size
=
size
;
}
public
EsSearchParam
of
(
String
content
,
int
page
,
int
size
)
{
return
new
EsSearchParam
(
content
,
page
,
size
);
}
}
ch-core/src/main/java/com/wwdz/ch/core/type/Result.java
0 → 100644
View file @
303d8f91
package
com.wwdz.ch.core.type
;
import
com.wwdz.ch.core.consts.ResultCode
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
@Data
public
class
Result
<
T
>
implements
Entity
{
private
Integer
errno
;
private
Boolean
success
;
private
String
errmsg
;
private
T
data
;
public
Result
(
Integer
errno
,
String
msg
,
T
body
)
{
this
.
errno
=
errno
;
this
.
errmsg
=
msg
;
this
.
data
=
body
;
}
public
Result
(
Integer
errno
,
String
msg
)
{
this
.
errno
=
errno
;
this
.
errmsg
=
msg
;
}
public
Result
(
Boolean
successful
,
T
body
)
{
this
.
success
=
successful
;
this
.
data
=
body
;
}
public
Result
(
Integer
errno
,
Boolean
successful
,
String
msg
)
{
this
.
errno
=
errno
;
this
.
success
=
successful
;
this
.
errmsg
=
msg
;
}
public
Result
(
Integer
errno
,
Boolean
successful
,
String
msg
,
T
body
)
{
this
.
errno
=
errno
;
this
.
success
=
successful
;
this
.
errmsg
=
msg
;
this
.
data
=
body
;
}
public
Result
(
Integer
errno
,
Boolean
successful
,
T
body
)
{
this
.
errno
=
errno
;
this
.
success
=
successful
;
this
.
data
=
body
;
}
public
Result
(
Boolean
successful
)
{
this
.
success
=
successful
;
}
public
static
<
T
>
Result
<
T
>
success
()
{
return
new
Result
<>(
ResultCode
.
SUCCESS
.
getCode
(),
true
,
ResultCode
.
SUCCESS
.
getMessage
());
}
public
static
<
T
>
Result
<
T
>
success
(
T
body
)
{
return
new
Result
<>(
ResultCode
.
SUCCESS
.
getCode
(),
true
,
body
);
}
public
static
<
T
>
Result
<
T
>
failed
()
{
return
new
Result
<>(
false
);
}
public
static
<
T
>
Result
<
T
>
failed
(
Integer
code
,
String
msg
)
{
return
new
Result
<>(
code
,
false
,
msg
,
null
);
}
public
static
<
T
>
Result
<
T
>
failed
(
ResultCode
resultCode
)
{
return
new
Result
<>(
resultCode
.
getCode
(),
false
,
resultCode
.
getMessage
(),
null
);
}
public
static
<
T
>
Result
<
T
>
failed
(
String
errormsg
)
{
return
failed
(
ResultCode
.
FAILED
.
getCode
(),
errormsg
);
}
public
Integer
getErrno
()
{
return
errno
;
}
public
void
setErrno
(
Integer
errno
)
{
this
.
errno
=
errno
;
}
public
Boolean
getSuccess
()
{
return
success
;
}
public
void
setSuccess
(
Boolean
success
)
{
this
.
success
=
success
;
}
public
String
getErrmsg
()
{
return
errmsg
;
}
public
void
setErrmsg
(
String
errmsg
)
{
this
.
errmsg
=
errmsg
;
}
public
void
setData
(
T
data
)
{
this
.
data
=
data
;
}
public
T
getData
()
{
return
data
;
}
}
ch-core/src/main/java/com/wwdz/ch/core/type/SimpleResult.java
View file @
303d8f91
...
...
@@ -15,6 +15,8 @@ public class SimpleResult<T> extends BaseResult{
this
.
msg
=
msg
;
}
public
T
getData
()
{
return
data
;
}
...
...
ch-core/src/main/java/com/wwdz/ch/core/util/ElasticsearchUtil.java
0 → 100644
View file @
303d8f91
package
com.wwdz.ch.core.util
;
import
co.elastic.clients.elasticsearch.ElasticsearchClient
;
import
co.elastic.clients.elasticsearch._types.SortOrder
;
import
co.elastic.clients.elasticsearch.core.GetRequest
;
import
co.elastic.clients.elasticsearch.core.GetResponse
;
import
co.elastic.clients.elasticsearch.core.SearchRequest
;
import
co.elastic.clients.elasticsearch.core.SearchResponse
;
import
co.elastic.clients.util.ObjectBuilder
;
import
com.wwdz.ch.core.entity.EsSearchParam
;
import
com.wwdz.ch.db.bean.CoinOfEs
;
import
com.xxdxxs.entity.Entity
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.function.Function
;
@Component
public
class
ElasticsearchUtil
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ElasticsearchUtil
.
class
);
private
final
static
String
INDEX
=
"quanku"
;
@Autowired
ElasticsearchClient
elasticsearchClient
;
public
List
<?
extends
Entity
>
findDocument
(
EsSearchParam
esSearchParam
)
{
try
{
int
page
=
esSearchParam
.
getPage
();
int
size
=
esSearchParam
.
getSize
();
int
from
=
(
page
-
1
)
*
size
;
SearchRequest
.
Builder
builder
=
new
SearchRequest
.
Builder
();
builder
.
index
(
INDEX
);
builder
.
from
(
from
);
builder
.
size
(
size
);
builder
.
sort
(
f
->
f
.
field
(
o
->
o
.
field
(
"coin_id"
)
.
order
(
SortOrder
.
Desc
)));
SearchRequest
searchRequest
=
SearchRequest
.
of
((
Function
<
SearchRequest
.
Builder
,
ObjectBuilder
<
SearchRequest
>>)
builder
);
SearchResponse
<
CoinOfEs
>
searchResponse
=
elasticsearchClient
.
search
(
searchRequest
,
CoinOfEs
.
class
);
GetResponse
<
CoinOfEs
>
response
=
elasticsearchClient
.
get
(
s
->
s
.
index
(
"quanku"
)
.
id
(
"e051445c-ae8c-47ef-ab18-97b34025d49a"
),
CoinOfEs
.
class
);
logger
.
info
(
"getResponse:{}"
,
response
.
source
());
if
(
response
.
found
())
{
CoinOfEs
coinOfEs
=
response
.
source
();
assert
coinOfEs
!=
null
;
logger
.
info
(
"coin name= {} "
,
coinOfEs
.
getName
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
Collections
.
emptyList
();
}
}
ch-core/src/main/resources/application-dev.yml
View file @
303d8f91
...
...
@@ -155,4 +155,4 @@ spring:
elasticsearch
:
jest
:
uris
:
172.16.122.190:9200
\ No newline at end of file
uris
:
172.16.122.190:9200
ch-dao/pom.xml
View file @
303d8f91
...
...
@@ -93,6 +93,18 @@
<version>
1.6.1
</version>
</dependency>
<dependency>
<groupId>
com.github.xxdxxs
</groupId>
<artifactId>
xxdxxs
</artifactId>
<version>
1.0.2-RELEASE
</version>
<exclusions>
<exclusion>
<artifactId>
druid
</artifactId>
<groupId>
com.alibaba
</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
com.itfsw
</groupId>
<artifactId>
mybatis-generator-plugin
</artifactId>
...
...
ch-dao/src/main/java/com/wwdz/ch/db/bean/CoinOfEs.java
0 → 100644
View file @
303d8f91
package
com.wwdz.ch.db.bean
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
@Data
public
class
CoinOfEs
implements
Entity
{
/**
* 钱币id
*/
private
String
coin_id
;
/**
* 钱币名称
*/
private
String
name
;
/**
* 置顶图片
*/
private
String
top_image_path
;
/**
* 价格
*/
private
String
price
;
}
ch-dao/src/main/java/com/wwdz/ch/db/dao/ItemMapper.java
View file @
303d8f91
...
...
@@ -2,51 +2,18 @@ package com.wwdz.ch.db.dao;
import
com.wwdz.ch.db.domain.Item
;
import
com.wwdz.ch.db.domain.ItemExample
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
@Mapper
public
interface
ItemMapper
{
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item
*
* @mbg.generated
*/
long
countByExample
(
ItemExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item
*
* @mbg.generated
*/
int
deleteByExample
(
ItemExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item
*
* @mbg.generated
*/
int
deleteByPrimaryKey
(
Long
id
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item
*
* @mbg.generated
*/
int
insert
(
Item
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item
*
* @mbg.generated
*/
int
insertSelective
(
Item
record
);
/**
...
...
@@ -85,20 +52,8 @@ public interface ItemMapper {
*/
List
<
Item
>
selectByExampleSelective
(
@Param
(
"example"
)
ItemExample
example
,
@Param
(
"selective"
)
Item
.
Column
...
selective
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item
*
* @mbg.generated
*/
List
<
Item
>
selectByExampleWithBLOBs
(
ItemExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item
*
* @mbg.generated
*/
List
<
Item
>
selectByExample
(
ItemExample
example
);
/**
...
...
@@ -110,60 +65,18 @@ public interface ItemMapper {
*/
Item
selectByPrimaryKeySelective
(
@Param
(
"id"
)
Long
id
,
@Param
(
"selective"
)
Item
.
Column
...
selective
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item
*
* @mbg.generated
*/
Item
selectByPrimaryKey
(
Long
id
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item
*
* @mbg.generated
*/
int
updateByExampleSelective
(
@Param
(
"record"
)
Item
record
,
@Param
(
"example"
)
ItemExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item
*
* @mbg.generated
*/
int
updateByExampleWithBLOBs
(
@Param
(
"record"
)
Item
record
,
@Param
(
"example"
)
ItemExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item
*
* @mbg.generated
*/
int
updateByExample
(
@Param
(
"record"
)
Item
record
,
@Param
(
"example"
)
ItemExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item
*
* @mbg.generated
*/
int
updateByPrimaryKeySelective
(
Item
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item
*
* @mbg.generated
*/
int
updateByPrimaryKeyWithBLOBs
(
Item
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item
*
* @mbg.generated
*/
int
updateByPrimaryKey
(
Item
record
);
/**
...
...
ch-dao/src/main/java/com/wwdz/ch/db/domain/Item.java
View file @
303d8f91
This diff is collapsed.
Click to expand it.
ch-dao/src/main/java/com/wwdz/ch/db/domain/ItemExample.java
View file @
303d8f91
This diff is collapsed.
Click to expand it.
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/BaseRequestDto.java
0 → 100644
View file @
303d8f91
package
com.wwdz.ch.db.dto.request
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
@Data
public
class
BaseRequestDto
implements
Entity
{
public
Integer
page
=
1
;
public
Integer
size
=
20
;
private
String
sortColumn
;
private
String
order
;
}
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/CoinRequestDto.java
0 → 100644
View file @
303d8f91
package
com.wwdz.ch.db.dto.request
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
@Data
public
class
CoinRequestDto
extends
BaseRequestDto
implements
Entity
{
private
String
name
;
/**
* 钱币所属分类
*/
private
String
cid
;
/**
* 直径
*/
private
String
diameter
;
/**
* 厚度
*/
private
String
thickness
;
/**
* 质量(重量)
*/
private
String
weight
;
/**
* 是否标准件
* 0否;1是
*/
private
Integer
isStd
;
/**
* 图片
*/
private
String
imgBaseStr
;
private
String
remark
;
}
ch-dao/src/main/java/com/wwdz/ch/db/service/ItemService.java
View file @
303d8f91
...
...
@@ -9,6 +9,7 @@ import org.springframework.util.StringUtils;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.Date
;
import
java.util.List
;
@Service
...
...
@@ -117,17 +118,18 @@ public class ItemService {
}
public
int
updateById
(
Item
item
)
{
item
.
setUpdated
(
LocalDateTime
.
now
());
item
.
setUpdated
(
new
Date
());
return
itemMapper
.
updateByPrimaryKeySelective
(
item
);
}
public
void
deleteById
(
Long
id
)
{
itemMapper
.
logicalDeleteByPrimaryKey
(
id
);
//
itemMapper.logicalDeleteByPrimaryKey(id);
}
public
void
add
(
Item
item
)
{
item
.
setCreated
(
LocalDateTime
.
now
());
item
.
setUpdated
(
LocalDateTime
.
now
());
Date
now
=
new
Date
();
item
.
setCreated
(
now
);
item
.
setUpdated
(
now
);
itemMapper
.
insertSelective
(
item
);
}
...
...
ch-dao/src/main/resources/com/wwdz/ch/db/dao/ItemMapper.xml
View file @
303d8f91
This diff is collapsed.
Click to expand it.
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