Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
customer-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SuperHive
back-end
customer-service
Commits
d6f4008e
Commit
d6f4008e
authored
Apr 22, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增货主接口:分页查询发货地址列表
parent
d3c04e69
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
329 additions
and
11 deletions
+329
-11
DeliveryAddressController.java
...dule/goodsowner/controller/DeliveryAddressController.java
+13
-4
DeliveryAddressDao.java
...ht/customer/module/goodsowner/dao/DeliveryAddressDao.java
+12
-0
ReceiveAddressDao.java
...ght/customer/module/goodsowner/dao/ReceiveAddressDao.java
+2
-0
AccountInfoDto.java
...reight/customer/module/goodsowner/dto/AccountInfoDto.java
+0
-2
DeliveryAddressDto.java
...ht/customer/module/goodsowner/dto/DeliveryAddressDto.java
+102
-0
DeliveryAddressForm.java
.../customer/module/goodsowner/form/DeliveryAddressForm.java
+20
-2
DeliveryAddressService.java
...mer/module/goodsowner/service/DeliveryAddressService.java
+12
-0
DeliveryAddressServiceImpl.java
...e/goodsowner/service/impl/DeliveryAddressServiceImpl.java
+42
-3
DeliveryAddressListVO.java
.../customer/module/goodsowner/vo/DeliveryAddressListVO.java
+76
-0
DeliveryAddressDao.xml
src/main/resources/mapper/goodsowner/DeliveryAddressDao.xml
+20
-0
ReceiveAddressDao.xml
src/main/resources/mapper/goodsowner/ReceiveAddressDao.xml
+1
-0
DeliveryAddressControllerTest.java
.../goodsowner/controller/DeliveryAddressControllerTest.java
+29
-0
No files found.
src/main/java/com/esv/freight/customer/module/goodsowner/controller/DeliveryAddressController.java
View file @
d6f4008e
...
...
@@ -3,10 +3,7 @@ package com.esv.freight.customer.module.goodsowner.controller;
import
com.alibaba.fastjson.JSONObject
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.response.EResponse
;
import
com.esv.freight.customer.common.validator.groups.ValidatorDelete
;
import
com.esv.freight.customer.common.validator.groups.ValidatorDetail
;
import
com.esv.freight.customer.common.validator.groups.ValidatorInsert
;
import
com.esv.freight.customer.common.validator.groups.ValidatorUpdate
;
import
com.esv.freight.customer.common.validator.groups.*
;
import
com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants
;
import
com.esv.freight.customer.module.goodsowner.form.DeleteAddressForm
;
import
com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm
;
...
...
@@ -117,4 +114,16 @@ public class DeliveryAddressController {
data
.
put
(
"count"
,
count
);
return
EResponse
.
ok
(
data
);
}
/**
* description 分页查询发货地址列表
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/22 9:28
**/
@PostMapping
(
"/list"
)
public
EResponse
list
(
@RequestBody
@Validated
(
ValidatorList
.
class
)
DeliveryAddressForm
form
)
throws
EException
{
return
EResponse
.
ok
(
deliveryAddressService
.
selectAddressList
(
form
));
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/dao/DeliveryAddressDao.java
View file @
d6f4008e
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.Map
;
/**
* 货主发货地址表
*
...
...
@@ -13,5 +16,14 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public
interface
DeliveryAddressDao
extends
BaseMapper
<
DeliveryAddressEntity
>
{
/**
* description 分页查询地址列表
* param [page, queryObj]
* return com.baomidou.mybatisplus.core.metadata.IPage
* author Administrator
* createTime 2020/04/22 9:20
**/
IPage
selectAddressList
(
IPage
page
,
Map
<
String
,
Object
>
queryObj
);
}
src/main/java/com/esv/freight/customer/module/goodsowner/dao/ReceiveAddressDao.java
View file @
d6f4008e
...
...
@@ -13,5 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public
interface
ReceiveAddressDao
extends
BaseMapper
<
ReceiveAddressEntity
>
{
}
src/main/java/com/esv/freight/customer/module/goodsowner/dto/AccountInfoDto.java
View file @
d6f4008e
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
dto
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.Data
;
import
java.util.Date
;
...
...
@@ -20,7 +19,6 @@ public class AccountInfoDto {
/**
*
*/
@TableId
private
Long
id
;
/**
* 租户ID
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/dto/DeliveryAddressDto.java
0 → 100644
View file @
d6f4008e
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
dto
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.util.Date
;
/**
* 货主发货地址表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-21 15:27:27
*/
@Data
public
class
DeliveryAddressDto
{
/**
*
*/
private
Long
id
;
/**
* 货主类型:1-个人、2-企业
*/
private
String
ownerType
;
/**
* 客户名称
*/
private
String
ownerFullName
;
/**
* (个人或企业)联系人
*/
private
String
contactor
;
/**
* 地址编码
*/
private
String
addressNumber
;
/**
* 地址名称
*/
private
String
addressName
;
/**
* 省份代码
*/
private
String
provinceCode
;
/**
* 市代码
*/
private
String
cityCode
;
/**
* 区县代码
*/
private
String
districtCode
;
/**
* 详细地址
*/
private
String
detailAddress
;
/**
* 发货人
*/
private
String
deliverer
;
/**
* 发货人电话
*/
private
String
delivererPhone
;
/**
* 发货人座机
*/
private
String
delivererTelephone
;
/**
* 经度
*/
private
BigDecimal
lon
;
/**
* 纬度
*/
private
BigDecimal
lat
;
/**
* 是否默认发货地址:0-非默认,1-默认
*/
private
Boolean
defaultAddress
;
/**
* 0-未删除,1-已删除
*/
private
Boolean
deleted
;
/**
* 创建者
*/
private
String
createUser
;
/**
* 修改者
*/
private
String
updateUser
;
/**
* 创建时间
*/
private
Date
createTime
;
/**
* 修改时间
*/
private
Date
updateTime
;
}
src/main/java/com/esv/freight/customer/module/goodsowner/form/DeliveryAddressForm.java
View file @
d6f4008e
...
...
@@ -2,12 +2,14 @@ package com.esv.freight.customer.module.goodsowner.form;
import
com.esv.freight.customer.common.validator.groups.ValidatorDetail
;
import
com.esv.freight.customer.common.validator.groups.ValidatorInsert
;
import
com.esv.freight.customer.common.validator.groups.ValidatorList
;
import
com.esv.freight.customer.common.validator.groups.ValidatorUpdate
;
import
com.esv.freight.customer.module.goodsowner.validator.groups.AddressBrief
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
org.hibernate.validator.constraints.Length
;
import
org.hibernate.validator.constraints.Range
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
...
...
@@ -35,11 +37,11 @@ public class DeliveryAddressForm {
@NotBlank
(
message
=
"参数addressName不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
String
addressName
;
@Length
(
min
=
6
,
max
=
6
,
message
=
"参数provinceCode长度不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorUpdate
.
class
})
@Length
(
min
=
6
,
max
=
6
,
message
=
"参数provinceCode长度不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorUpdate
.
class
,
ValidatorList
.
class
})
@NotBlank
(
message
=
"参数provinceCode不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
String
provinceCode
;
@Length
(
min
=
6
,
max
=
6
,
message
=
"参数cityCode长度不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorUpdate
.
class
})
@Length
(
min
=
6
,
max
=
6
,
message
=
"参数cityCode长度不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorUpdate
.
class
,
ValidatorList
.
class
})
@NotBlank
(
message
=
"参数cityCode不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
String
cityCode
;
...
...
@@ -71,6 +73,22 @@ public class DeliveryAddressForm {
@Pattern
(
regexp
=
"[01]"
,
message
=
"参数addressCopy不合法"
,
groups
=
{
ValidatorInsert
.
class
})
private
String
addressCopy
;
@Length
(
max
=
50
,
message
=
"参数keywords长度不合法"
,
groups
=
{
ValidatorList
.
class
})
private
String
keywords
;
/**
* 页码
**/
@Range
(
min
=
1
,
max
=
65535
,
message
=
"无效的pageNum"
,
groups
=
{
ValidatorList
.
class
})
@NotNull
(
message
=
"参数pageNum不能为空"
,
groups
=
{
ValidatorList
.
class
})
private
Integer
pageNum
;
/**
* 每页记录条数
**/
@Range
(
min
=
1
,
max
=
100
,
message
=
"pageSize"
,
groups
=
{
ValidatorList
.
class
})
@NotNull
(
message
=
"参数pageSize不能为空"
,
groups
=
{
ValidatorList
.
class
})
private
Integer
pageSize
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/service/DeliveryAddressService.java
View file @
d6f4008e
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.esv.freight.customer.common.vo.PageResultVO
;
import
com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity
;
import
com.esv.freight.customer.module.goodsowner.form.DeleteAddressForm
;
import
com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm
;
import
com.esv.freight.customer.module.goodsowner.vo.DeliveryAddressBriefVO
;
import
com.esv.freight.customer.module.goodsowner.vo.DeliveryAddressListVO
;
import
com.esv.freight.customer.module.goodsowner.vo.DeliveryAddressVO
;
import
java.util.List
;
import
java.util.Map
;
/**
* 货主发货地址表
...
...
@@ -72,5 +75,14 @@ public interface DeliveryAddressService extends IService<DeliveryAddressEntity>
**/
List
<
DeliveryAddressEntity
>
getAddressByName
(
Long
ownerId
,
String
addressName
);
/**
* description 分页查询地址列表
* param [form]
* return com.esv.freight.customer.common.vo.PageResultVO
* author Administrator
* createTime 2020/04/22 9:21
**/
PageResultVO
selectAddressList
(
DeliveryAddressForm
form
);
}
src/main/java/com/esv/freight/customer/module/goodsowner/service/impl/DeliveryAddressServiceImpl.java
View file @
d6f4008e
...
...
@@ -2,17 +2,24 @@ package com.esv.freight.customer.module.goodsowner.service.impl;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.esv.freight.customer.common.component.ErrorMessageComponent
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.util.FeignUtils
;
import
com.esv.freight.customer.common.vo.PageResultVO
;
import
com.esv.freight.customer.feign.FeignBaseService
;
import
com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants
;
import
com.esv.freight.customer.module.goodsowner.dao.DeliveryAddressDao
;
import
com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto
;
import
com.esv.freight.customer.module.goodsowner.dto.DeliveryAddressDto
;
import
com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity
;
import
com.esv.freight.customer.module.goodsowner.form.DeleteAddressForm
;
import
com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm
;
import
com.esv.freight.customer.module.goodsowner.service.DeliveryAddressService
;
import
com.esv.freight.customer.module.goodsowner.vo.DeliveryAddressBriefVO
;
import
com.esv.freight.customer.module.goodsowner.vo.DeliveryAddressListVO
;
import
com.esv.freight.customer.module.goodsowner.vo.DeliveryAddressVO
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -20,9 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.*
;
@Service
(
"deliveryAddressService"
)
...
...
@@ -154,4 +159,38 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
queryWrapper
.
eq
(
"address_name"
,
addressName
);
return
this
.
getBaseMapper
().
selectList
(
queryWrapper
);
}
@Override
public
PageResultVO
selectAddressList
(
DeliveryAddressForm
form
)
{
// 分页查询
Map
<
String
,
Object
>
queryObj
=
new
HashMap
<>(
3
);
if
(
StringUtils
.
isNotBlank
(
form
.
getKeywords
()))
{
queryObj
.
put
(
"keywords"
,
form
.
getKeywords
());
}
if
(
StringUtils
.
isNotBlank
(
form
.
getProvinceCode
()))
{
queryObj
.
put
(
"provinceCode"
,
form
.
getProvinceCode
());
}
if
(
StringUtils
.
isNotBlank
(
form
.
getCityCode
()))
{
queryObj
.
put
(
"cityCode"
,
form
.
getCityCode
());
}
IPage
<
DeliveryAddressDto
>
page
=
new
Page
<>(
form
.
getPageNum
(),
form
.
getPageSize
());
this
.
baseMapper
.
selectAddressList
(
page
,
queryObj
);
// 数据转换
List
<
DeliveryAddressDto
>
addressDtoList
=
page
.
getRecords
();
List
<
DeliveryAddressListVO
>
addressListVOList
=
new
ArrayList
<>();
addressDtoList
.
forEach
(
entity
->
{
DeliveryAddressListVO
vo
=
new
DeliveryAddressListVO
();
BeanUtils
.
copyProperties
(
entity
,
vo
);
vo
.
setCreateTime
(
entity
.
getCreateTime
().
getTime
());
if
(
GoodsOwnerConstants
.
OWNER_TYPE_PERSONAL
.
equals
(
entity
.
getOwnerType
()))
{
vo
.
setGoodsOwnerName
(
entity
.
getContactor
());
}
else
{
vo
.
setGoodsOwnerName
(
entity
.
getOwnerFullName
());
}
addressListVOList
.
add
(
vo
);
});
return
new
PageResultVO
(
page
,
addressListVOList
);
}
}
\ No newline at end of file
src/main/java/com/esv/freight/customer/module/goodsowner/vo/DeliveryAddressListVO.java
0 → 100644
View file @
d6f4008e
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
vo
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.vo.DeliveryAddressListVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/21 19:39
* @version:1.0
*/
@Data
public
class
DeliveryAddressListVO
{
/**
*
*/
private
Long
id
;
/**
* 地址编码
*/
private
String
goodsOwnerName
;
/**
* 地址编码
*/
private
String
addressNumber
;
/**
* 地址名称
*/
private
String
addressName
;
/**
* 省份代码
*/
private
String
provinceCode
;
/**
* 市代码
*/
private
String
cityCode
;
/**
* 区县代码
*/
private
String
districtCode
;
/**
* 详细地址
*/
private
String
detailAddress
;
/**
* 发货人
*/
private
String
deliverer
;
/**
* 发货人电话
*/
private
String
delivererPhone
;
/**
* 发货人座机
*/
private
String
delivererTelephone
;
/**
*
*/
private
String
createUser
;
/**
*
*/
private
Long
createTime
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
}
}
src/main/resources/mapper/goodsowner/DeliveryAddressDao.xml
View file @
d6f4008e
...
...
@@ -28,5 +28,25 @@
<result
property=
"updateTime"
column=
"update_time"
/>
</resultMap>
<!-- 分页查询地址列表 -->
<select
id=
"selectAddressList"
parameterType=
"java.util.Map"
resultType=
"com.esv.freight.customer.module.goodsowner.dto.DeliveryAddressDto"
>
select a.*, b.owner_type, b.owner_full_name, b.contactor
from goods_owner_delivery_address a, goods_owner_info b
where a.owner_id = b.account_id
<if
test=
"queryObj.provinceCode != null"
>
and b.province_code = #{queryObj.provinceCode}
</if>
<if
test=
"queryObj.cityCode != null"
>
and b.city_code = #{queryObj.cityCode}
</if>
<if
test=
"queryObj.keywords != null"
>
and (a.address_name like CONCAT('%',#{queryObj.keywords},'%')
or b.owner_full_name like CONCAT('%',#{queryObj.keywords},'%')
or b.owner_brief_name like CONCAT('%',#{queryObj.keywords},'%')
or b.contactor like CONCAT('%',#{queryObj.keywords},'%'))
</if>
ORDER BY a.update_time DESC
</select>
</mapper>
\ No newline at end of file
src/main/resources/mapper/goodsowner/ReceiveAddressDao.xml
View file @
d6f4008e
...
...
@@ -29,4 +29,5 @@
</resultMap>
</mapper>
\ No newline at end of file
src/test/java/com/esv/freight/customer/module/goodsowner/controller/DeliveryAddressControllerTest.java
View file @
d6f4008e
...
...
@@ -384,4 +384,33 @@ public class DeliveryAddressControllerTest extends BaseTestController {
Assert
.
assertFalse
(
result
.
getJSONArray
(
"data"
).
isEmpty
());
}
/**
* 分页查询发货地址列表
**/
@Test
public
void
f1_list_success_test
()
throws
Exception
{
String
url
=
"/goodsowner/delivery/address/list"
;
// 构造数据
DeliveryAddressForm
form
=
new
DeliveryAddressForm
();
form
.
setPageNum
(
1
);
form
.
setPageSize
(
10
);
JSONObject
reqJson
=
JSONObject
.
parseObject
(
form
.
toString
());
MvcResult
mvcResult
=
this
.
getMockMvc
().
perform
(
MockMvcRequestBuilders
.
post
(
url
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
.
headers
(
this
.
getDefaultHttpHeaders
())
.
content
(
reqJson
.
toJSONString
()))
.
andDo
(
MockMvcResultHandlers
.
print
())
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
())
.
andReturn
();
String
responseStr
=
mvcResult
.
getResponse
().
getContentAsString
();
log
.
info
(
responseStr
);
JSONObject
result
=
JSONObject
.
parseObject
(
responseStr
);
Assert
.
assertEquals
(
ECode
.
SUCCESS
.
code
(),
result
.
getIntValue
(
"code"
));
Assert
.
assertTrue
(
result
.
getJSONObject
(
"data"
).
containsKey
(
"records"
));
}
}
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