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
865af84a
Commit
865af84a
authored
Apr 21, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增货主接口:查看发货地址详情
parent
d4944841
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
190 additions
and
1 deletion
+190
-1
ErrorMessageComponent.java
...ight/customer/common/component/ErrorMessageComponent.java
+3
-0
DeliveryAddressController.java
...dule/goodsowner/controller/DeliveryAddressController.java
+13
-0
DeliveryAddressService.java
...mer/module/goodsowner/service/DeliveryAddressService.java
+10
-0
DeliveryAddressServiceImpl.java
...e/goodsowner/service/impl/DeliveryAddressServiceImpl.java
+30
-0
DeliveryAddressVO.java
...ight/customer/module/goodsowner/vo/DeliveryAddressVO.java
+74
-0
application-dev.yml
src/main/resources/application-dev.yml
+3
-1
DeliveryAddressControllerTest.java
.../goodsowner/controller/DeliveryAddressControllerTest.java
+57
-0
No files found.
src/main/java/com/esv/freight/customer/common/component/ErrorMessageComponent.java
View file @
865af84a
...
...
@@ -64,4 +64,7 @@ public class ErrorMessageComponent {
@Value
(
"${error-message.goodsowner.delivery-address.edit.1002}"
)
private
String
goodsOwnerDeliveryAddressEdit1002
;
@Value
(
"${error-message.goodsowner.delivery-address.detail.1001}"
)
private
String
goodsOwnerDeliveryAddressDetail1001
;
}
src/main/java/com/esv/freight/customer/module/goodsowner/controller/DeliveryAddressController.java
View file @
865af84a
...
...
@@ -4,6 +4,7 @@ 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.module.goodsowner.GoodsOwnerConstants
;
...
...
@@ -77,6 +78,18 @@ public class DeliveryAddressController {
return
EResponse
.
ok
();
}
/**
* description 查看发货地址详情
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/21 19:55
**/
@PostMapping
(
"/detail"
)
public
EResponse
detail
(
@RequestBody
@Validated
(
ValidatorDetail
.
class
)
DeliveryAddressForm
form
)
throws
EException
{
return
EResponse
.
ok
(
deliveryAddressService
.
getAddressDetail
(
form
));
}
/**
* description 删除发货地址
* param [form]
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/service/DeliveryAddressService.java
View file @
865af84a
...
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
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.DeliveryAddressVO
;
import
java.util.List
;
...
...
@@ -43,6 +44,15 @@ public interface DeliveryAddressService extends IService<DeliveryAddressEntity>
**/
int
deleteAddress
(
DeleteAddressForm
form
);
/**
* description 查看发货地址详情
* param [form]
* return com.esv.freight.customer.module.goodsowner.vo.DeliveryAddressVO
* author Administrator
* createTime 2020/04/21 19:50
**/
DeliveryAddressVO
getAddressDetail
(
DeliveryAddressForm
form
);
/**
* description 通过地址名称查询地址记录
* param [ownerId, addressName]
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/service/impl/DeliveryAddressServiceImpl.java
View file @
865af84a
...
...
@@ -13,10 +13,13 @@ 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.DeliveryAddressVO
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.math.BigDecimal
;
import
java.util.Arrays
;
import
java.util.List
;
...
...
@@ -60,6 +63,12 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
DeliveryAddressEntity
addressEntity
=
new
DeliveryAddressEntity
();
BeanUtils
.
copyProperties
(
form
,
addressEntity
);
addressEntity
.
setAddressNumber
(
addressNumber
);
if
(
StringUtils
.
isNotBlank
(
form
.
getLon
()))
{
addressEntity
.
setLon
(
new
BigDecimal
(
form
.
getLon
()));
}
if
(
StringUtils
.
isNotBlank
(
form
.
getLat
()))
{
addressEntity
.
setLat
(
new
BigDecimal
(
form
.
getLat
()));
}
this
.
baseMapper
.
insert
(
addressEntity
);
return
addressEntity
.
getId
();
...
...
@@ -86,6 +95,12 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
// 3.更新地址
DeliveryAddressEntity
updateEntity
=
new
DeliveryAddressEntity
();
BeanUtils
.
copyProperties
(
form
,
updateEntity
);
if
(
StringUtils
.
isNotBlank
(
form
.
getLon
()))
{
updateEntity
.
setLon
(
new
BigDecimal
(
form
.
getLon
()));
}
if
(
StringUtils
.
isNotBlank
(
form
.
getLat
()))
{
updateEntity
.
setLat
(
new
BigDecimal
(
form
.
getLat
()));
}
int
flag
=
this
.
baseMapper
.
updateById
(
updateEntity
);
return
flag
;
...
...
@@ -98,6 +113,21 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
return
count
;
}
@Override
public
DeliveryAddressVO
getAddressDetail
(
DeliveryAddressForm
form
)
{
// 1.判断ID是否有效
DeliveryAddressEntity
entity
=
this
.
baseMapper
.
selectById
(
form
.
getId
());
if
(
null
==
entity
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getGoodsOwnerDeliveryAddressDetail1001
());
}
// 数据转换
DeliveryAddressVO
addressVO
=
new
DeliveryAddressVO
();
BeanUtils
.
copyProperties
(
entity
,
addressVO
);
return
addressVO
;
}
@Override
public
List
<
DeliveryAddressEntity
>
getAddressByName
(
Long
ownerId
,
String
addressName
)
{
QueryWrapper
<
DeliveryAddressEntity
>
queryWrapper
=
new
QueryWrapper
<>();
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/vo/DeliveryAddressVO.java
0 → 100644
View file @
865af84a
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
;
import
java.math.BigDecimal
;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.vo.DeliveryAddressVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/21 19:39
* @version:1.0
*/
@Data
public
class
DeliveryAddressVO
{
/**
*
*/
private
Long
id
;
/**
* 地址编码
*/
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
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
}
}
src/main/resources/application-dev.yml
View file @
865af84a
...
...
@@ -77,3 +77,5 @@ error-message:
edit
:
1001
:
无效的地址ID
1002
:
重复的地址名称
detail
:
1001
:
无效的地址ID
\ No newline at end of file
src/test/java/com/esv/freight/customer/module/goodsowner/controller/DeliveryAddressControllerTest.java
View file @
865af84a
...
...
@@ -298,4 +298,61 @@ public class DeliveryAddressControllerTest extends BaseTestController {
Assert
.
assertTrue
(
result
.
getJSONObject
(
"data"
).
containsKey
(
"count"
));
}
/**
* 查看发货地址详情
**/
@Test
@Rollback
public
void
d1_detail_success_test
()
throws
Exception
{
String
url
=
"/goodsowner/delivery/address/detail"
;
// 构造数据
DeliveryAddressForm
form
=
new
DeliveryAddressForm
();
form
.
setId
(
5L
);
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
.
assertFalse
(
result
.
getJSONObject
(
"data"
).
isEmpty
());
}
/**
* 查看发货地址详情:无效的ID
**/
@Test
@Rollback
public
void
d2_detail_wrong_id_failure_test
()
throws
Exception
{
String
url
=
"/goodsowner/delivery/address/detail"
;
// 构造数据
DeliveryAddressForm
form
=
new
DeliveryAddressForm
();
form
.
setId
(
9999L
);
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
(
1001
,
result
.
getIntValue
(
"code"
));
}
}
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