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
bb8adb0e
Commit
bb8adb0e
authored
Apr 23, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增货主接口:获取货主和地址信息
parent
461d436f
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
632 additions
and
2 deletions
+632
-2
ErrorMessageComponent.java
...ight/customer/common/component/ErrorMessageComponent.java
+8
-0
AccountAndAddressController.java
...le/goodsowner/controller/AccountAndAddressController.java
+49
-0
AccountAndAddressForm.java
...ustomer/module/goodsowner/form/AccountAndAddressForm.java
+35
-0
AccountAndAddressService.java
...r/module/goodsowner/service/AccountAndAddressService.java
+26
-0
AccountAndAddressServiceIpml.java
...goodsowner/service/impl/AccountAndAddressServiceIpml.java
+103
-0
AccountAndAddressVO.java
...le/goodsowner/vo/account4address/AccountAndAddressVO.java
+37
-0
AccountVO.java
...tomer/module/goodsowner/vo/account4address/AccountVO.java
+36
-0
DeliveryAddressVO.java
...dule/goodsowner/vo/account4address/DeliveryAddressVO.java
+56
-0
ReceiveAddressVO.java
...odule/goodsowner/vo/account4address/ReceiveAddressVO.java
+56
-0
application-dev.yml
src/main/resources/application-dev.yml
+6
-1
application-test.yml
src/main/resources/application-test.yml
+62
-1
AccountAndAddressControllerTest.java
...oodsowner/controller/AccountAndAddressControllerTest.java
+158
-0
No files found.
src/main/java/com/esv/freight/customer/common/component/ErrorMessageComponent.java
View file @
bb8adb0e
...
@@ -101,4 +101,12 @@ public class ErrorMessageComponent {
...
@@ -101,4 +101,12 @@ public class ErrorMessageComponent {
@Value
(
"${error-message.goodsowner.regularly-route.detail.1001}"
)
@Value
(
"${error-message.goodsowner.regularly-route.detail.1001}"
)
private
String
goodsOwnerRegularlyRouteDetail1001
;
private
String
goodsOwnerRegularlyRouteDetail1001
;
@Value
(
"${error-message.goodsowner.ext.account-address.1001}"
)
private
String
goodsOwnerExtAccountAddress1001
;
@Value
(
"${error-message.goodsowner.ext.account-address.1002}"
)
private
String
goodsOwnerExtAccountAddress1002
;
@Value
(
"${error-message.goodsowner.ext.account-address.1003}"
)
private
String
goodsOwnerExtAccountAddress1003
;
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/controller/AccountAndAddressController.java
0 → 100644
View file @
bb8adb0e
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
controller
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.response.EResponse
;
import
com.esv.freight.customer.common.validator.groups.ValidatorDetail
;
import
com.esv.freight.customer.module.goodsowner.form.AccountAndAddressForm
;
import
com.esv.freight.customer.module.goodsowner.service.AccountAndAddressService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @description: 货主和地址Controller
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.controller.AccountAndAddressController
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/23 10:14
* @version:1.0
*/
@Slf4j
@RestController
@RequestMapping
(
"/goodsowner/ext"
)
@Validated
public
class
AccountAndAddressController
{
private
AccountAndAddressService
accountAndAddressService
;
@Autowired
public
AccountAndAddressController
(
AccountAndAddressService
accountAndAddressService
)
{
this
.
accountAndAddressService
=
accountAndAddressService
;
}
/**
* description 获取货主和地址信息
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/23 10:26
**/
@PostMapping
(
"/getOwnerAndAddressInfo"
)
public
EResponse
getOwnerAndAddressInfo
(
@RequestBody
@Validated
(
ValidatorDetail
.
class
)
AccountAndAddressForm
form
)
throws
EException
{
return
EResponse
.
ok
(
accountAndAddressService
.
getOwnerAndAddressInfo
(
form
));
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/form/AccountAndAddressForm.java
0 → 100644
View file @
bb8adb0e
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
form
;
import
com.esv.freight.customer.common.validator.groups.ValidatorDetail
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
javax.validation.constraints.NotNull
;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.form.AccountAndAddressForm
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/17 16:11
* @version:1.0
*/
@Data
public
class
AccountAndAddressForm
{
@NotNull
(
message
=
"参数ownerId不能为空"
,
groups
=
{
ValidatorDetail
.
class
})
private
Long
ownerId
;
@NotNull
(
message
=
"参数deliveryAddressId不能为空"
,
groups
=
{
ValidatorDetail
.
class
})
private
Long
deliveryAddressId
;
@NotNull
(
message
=
"参数receiveAddressId不能为空"
,
groups
=
{
ValidatorDetail
.
class
})
private
Long
receiveAddressId
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/service/AccountAndAddressService.java
0 → 100644
View file @
bb8adb0e
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
service
;
import
com.esv.freight.customer.module.goodsowner.form.AccountAndAddressForm
;
import
com.esv.freight.customer.module.goodsowner.vo.account4address.AccountAndAddressVO
;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.service.AccountAndAddressService
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/23 10:16
* @version:1.0
*/
public
interface
AccountAndAddressService
{
/**
* description 获取货主和地址信息
* param [form]
* return com.esv.freight.customer.module.goodsowner.vo.account4address.AccountAndAddressVO
* author Administrator
* createTime 2020/04/23 10:17
**/
AccountAndAddressVO
getOwnerAndAddressInfo
(
AccountAndAddressForm
form
);
}
src/main/java/com/esv/freight/customer/module/goodsowner/service/impl/AccountAndAddressServiceIpml.java
0 → 100644
View file @
bb8adb0e
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.esv.freight.customer.common.component.ErrorMessageComponent
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants
;
import
com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto
;
import
com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity
;
import
com.esv.freight.customer.module.goodsowner.entity.ReceiveAddressEntity
;
import
com.esv.freight.customer.module.goodsowner.form.AccountAndAddressForm
;
import
com.esv.freight.customer.module.goodsowner.form.AccountForm
;
import
com.esv.freight.customer.module.goodsowner.service.AccountAndAddressService
;
import
com.esv.freight.customer.module.goodsowner.service.AccountService
;
import
com.esv.freight.customer.module.goodsowner.service.DeliveryAddressService
;
import
com.esv.freight.customer.module.goodsowner.service.ReceiveAddressService
;
import
com.esv.freight.customer.module.goodsowner.vo.account4address.AccountAndAddressVO
;
import
com.esv.freight.customer.module.goodsowner.vo.account4address.AccountVO
;
import
com.esv.freight.customer.module.goodsowner.vo.account4address.DeliveryAddressVO
;
import
com.esv.freight.customer.module.goodsowner.vo.account4address.ReceiveAddressVO
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.service.impl.AccountAndAddressServiceIpml
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/23 10:17
* @version:1.0
*/
@Service
(
"accountAndAddressService"
)
public
class
AccountAndAddressServiceIpml
implements
AccountAndAddressService
{
private
ErrorMessageComponent
errorMessageComponent
;
private
AccountService
accountService
;
private
DeliveryAddressService
deliveryAddressService
;
private
ReceiveAddressService
receiveAddressService
;
@Autowired
public
AccountAndAddressServiceIpml
(
ErrorMessageComponent
errorMessageComponent
,
AccountService
accountService
,
DeliveryAddressService
deliveryAddressService
,
ReceiveAddressService
receiveAddressService
)
{
this
.
errorMessageComponent
=
errorMessageComponent
;
this
.
accountService
=
accountService
;
this
.
deliveryAddressService
=
deliveryAddressService
;
this
.
receiveAddressService
=
receiveAddressService
;
}
@Override
public
AccountAndAddressVO
getOwnerAndAddressInfo
(
AccountAndAddressForm
form
)
{
// 1.校验货主ID是否有效
AccountForm
accountForm
=
new
AccountForm
();
accountForm
.
setId
(
form
.
getOwnerId
());
AccountInfoDto
accountInfoDto
=
this
.
accountService
.
getAccountInfo
(
accountForm
);
if
(
null
==
accountInfoDto
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getGoodsOwnerExtAccountAddress1001
());
}
AccountVO
accountVO
=
new
AccountVO
();
accountVO
.
setOwnerId
(
form
.
getOwnerId
());
if
(
GoodsOwnerConstants
.
OWNER_TYPE_PERSONAL
.
equals
(
accountInfoDto
.
getOwnerType
()))
{
accountVO
.
setOwnerName
(
accountInfoDto
.
getContactor
());
}
else
{
accountVO
.
setOwnerName
(
accountInfoDto
.
getOwnerFullName
());
}
// 2.校验发货地址ID是否有效
DeliveryAddressEntity
deliveryAddressEntity
=
this
.
deliveryAddressService
.
getBaseMapper
().
selectOne
(
new
QueryWrapper
<
DeliveryAddressEntity
>().
lambda
()
.
eq
(
DeliveryAddressEntity:
:
getOwnerId
,
form
.
getOwnerId
())
.
eq
(
DeliveryAddressEntity:
:
getId
,
form
.
getDeliveryAddressId
())
);
if
(
null
==
deliveryAddressEntity
)
{
throw
new
EException
(
1002
,
errorMessageComponent
.
getGoodsOwnerExtAccountAddress1002
());
}
DeliveryAddressVO
deliveryAddressVO
=
new
DeliveryAddressVO
();
BeanUtils
.
copyProperties
(
deliveryAddressEntity
,
deliveryAddressVO
);
deliveryAddressVO
.
setAddressId
(
deliveryAddressEntity
.
getId
());
// 3.校验收货地址ID是否有效
ReceiveAddressEntity
receiveAddressEntity
=
this
.
receiveAddressService
.
getBaseMapper
().
selectOne
(
new
QueryWrapper
<
ReceiveAddressEntity
>().
lambda
()
.
eq
(
ReceiveAddressEntity:
:
getOwnerId
,
form
.
getOwnerId
())
.
eq
(
ReceiveAddressEntity:
:
getId
,
form
.
getReceiveAddressId
())
);
if
(
null
==
receiveAddressEntity
)
{
throw
new
EException
(
1003
,
errorMessageComponent
.
getGoodsOwnerExtAccountAddress1003
());
}
ReceiveAddressVO
receiveAddressVO
=
new
ReceiveAddressVO
();
BeanUtils
.
copyProperties
(
receiveAddressEntity
,
receiveAddressVO
);
receiveAddressVO
.
setAddressId
(
receiveAddressEntity
.
getId
());
// 4.返回
AccountAndAddressVO
accountAndAddressVO
=
new
AccountAndAddressVO
();
accountAndAddressVO
.
setOwnerInfo
(
accountVO
);
accountAndAddressVO
.
setDeliveryAddressInfo
(
deliveryAddressVO
);
accountAndAddressVO
.
setReceiveAddressInfo
(
receiveAddressVO
);
return
accountAndAddressVO
;
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/vo/account4address/AccountAndAddressVO.java
0 → 100644
View file @
bb8adb0e
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
vo
.
account4address
;
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.account4address.AccountAndAddressVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/23 10:11
* @version:1.0
*/
@Data
public
class
AccountAndAddressVO
{
/**
* 货主信息
*/
private
AccountVO
ownerInfo
;
/**
* 发货地址信息
*/
private
DeliveryAddressVO
deliveryAddressInfo
;
/**
* 收货地址信息
*/
private
ReceiveAddressVO
receiveAddressInfo
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/vo/account4address/AccountVO.java
0 → 100644
View file @
bb8adb0e
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
vo
.
account4address
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
java.io.Serializable
;
/**
* 货主信息表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-17 13:54:57
*/
@Data
public
class
AccountVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
7983069531280340728L
;
/**
*
*/
private
Long
ownerId
;
/**
* 货主姓名
*/
private
String
ownerName
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/vo/account4address/DeliveryAddressVO.java
0 → 100644
View file @
bb8adb0e
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
vo
.
account4address
;
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.account4address.DeliveryAddressVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/21 19:39
* @version:1.0
*/
@Data
public
class
DeliveryAddressVO
{
/**
*
*/
private
Long
addressId
;
/**
* 地址名称
*/
private
String
addressName
;
/**
* 省份代码
*/
private
String
provinceCode
;
/**
* 市代码
*/
private
String
cityCode
;
/**
* 区县代码
*/
private
String
districtCode
;
/**
* 详细地址
*/
private
String
detailAddress
;
/**
* 发货人
*/
private
String
deliverer
;
/**
* 发货人电话
*/
private
String
delivererPhone
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/vo/account4address/ReceiveAddressVO.java
0 → 100644
View file @
bb8adb0e
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
vo
.
account4address
;
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.account4address.ReceiveAddressVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/21 19:39
* @version:1.0
*/
@Data
public
class
ReceiveAddressVO
{
/**
*
*/
private
Long
addressId
;
/**
* 地址名称
*/
private
String
addressName
;
/**
* 省份代码
*/
private
String
provinceCode
;
/**
* 市代码
*/
private
String
cityCode
;
/**
* 区县代码
*/
private
String
districtCode
;
/**
* 详细地址
*/
private
String
detailAddress
;
/**
* 收货人
*/
private
String
receiver
;
/**
* 收货人电话
*/
private
String
receiverPhone
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
}
}
src/main/resources/application-dev.yml
View file @
bb8adb0e
...
@@ -100,4 +100,9 @@ error-message:
...
@@ -100,4 +100,9 @@ error-message:
1004
:
无效的发货地址ID
1004
:
无效的发货地址ID
1005
:
无效的收货地址ID
1005
:
无效的收货地址ID
detail
:
detail
:
1001
:
无效的常跑线路ID
1001
:
无效的常跑线路ID
\ No newline at end of file
ext
:
account-address
:
1001
:
无效的货主ID
1002
:
无效的发货地址ID
1003
:
无效的收货地址ID
\ No newline at end of file
src/main/resources/application-test.yml
View file @
bb8adb0e
...
@@ -44,4 +44,65 @@ mybatis-plus:
...
@@ -44,4 +44,65 @@ mybatis-plus:
ribbon
:
ribbon
:
eager-load
:
eager-load
:
enabled
:
true
enabled
:
true
clients
:
freight-base-service
clients
:
freight-base-service
\ No newline at end of file
error-message
:
goodsowner
:
account
:
add
:
1001
:
帐号已存在
edit
:
1001
:
无效的帐号ID
block
:
1001
:
无效的帐号ID
1002
:
帐号已停用
unblock
:
1001
:
无效的帐号ID
1002
:
帐号已启用
audit
:
1001
:
无效的帐号ID
1002
:
帐号已审核通过
audit-history
:
1001
:
无效的帐号ID
detail
:
1001
:
无效的帐号ID
1002
:
无效的手机号
password-check
:
1001
:
无效的手机号
1002
:
密码错误
register
:
1001
:
帐号已存在
delivery-address
:
add
:
1001
:
重复的地址名称
edit
:
1001
:
无效的地址ID
1002
:
重复的地址名称
detail
:
1001
:
无效的地址ID
receive-address
:
add
:
1001
:
重复的地址名称
edit
:
1001
:
无效的地址ID
1002
:
重复的地址名称
detail
:
1001
:
无效的地址ID
regularly-route
:
add
:
1001
:
重复的常跑线路名称
1002
:
无效的货主ID
1003
:
无效的发货地址ID
1004
:
无效的收货地址ID
edit
:
1001
:
无效的常跑线路ID
1002
:
重复的常跑线路名称
1003
:
无效的货主ID
1004
:
无效的发货地址ID
1005
:
无效的收货地址ID
detail
:
1001
:
无效的常跑线路ID
ext
:
account-address
:
1001
:
无效的货主ID
1002
:
无效的发货地址ID
1003
:
无效的收货地址ID
\ No newline at end of file
src/test/java/com/esv/freight/customer/module/goodsowner/controller/AccountAndAddressControllerTest.java
0 → 100644
View file @
bb8adb0e
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.esv.freight.customer.BaseTestController
;
import
com.esv.freight.customer.common.response.ECode
;
import
com.esv.freight.customer.module.goodsowner.form.AccountAndAddressForm
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Assert
;
import
org.junit.FixMethodOrder
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.MethodSorters
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.web.servlet.MvcResult
;
import
org.springframework.test.web.servlet.request.MockMvcRequestBuilders
;
import
org.springframework.test.web.servlet.result.MockMvcResultHandlers
;
import
org.springframework.test.web.servlet.result.MockMvcResultMatchers
;
import
org.springframework.transaction.annotation.Transactional
;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.controller.AccountAndAddressControllerTest
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/23 10:49
* @version:1.0
*/
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
@Slf4j
@FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
@Transactional
@Rollback
(
false
)
public
class
AccountAndAddressControllerTest
extends
BaseTestController
{
/**
* 获取货主和地址信息
**/
@Test
public
void
a1_getOwnerAndAddressInfo_success_test
()
throws
Exception
{
String
url
=
"/goodsowner//ext/getOwnerAndAddressInfo"
;
// 构造数据
AccountAndAddressForm
form
=
new
AccountAndAddressForm
();
form
.
setOwnerId
(
1L
);
form
.
setDeliveryAddressId
(
7L
);
form
.
setReceiveAddressId
(
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
.
assertTrue
(
result
.
getJSONObject
(
"data"
).
containsKey
(
"ownerInfo"
));
Assert
.
assertTrue
(
result
.
getJSONObject
(
"data"
).
containsKey
(
"deliveryAddressInfo"
));
Assert
.
assertTrue
(
result
.
getJSONObject
(
"data"
).
containsKey
(
"receiveAddressInfo"
));
}
/**
* 获取货主和地址信息:无效的货主ID
**/
@Test
public
void
a1_getOwnerAndAddressInfo_wrong_owner_id_failure_test
()
throws
Exception
{
String
url
=
"/goodsowner//ext/getOwnerAndAddressInfo"
;
// 构造数据
AccountAndAddressForm
form
=
new
AccountAndAddressForm
();
form
.
setOwnerId
(
99999L
);
form
.
setDeliveryAddressId
(
7L
);
form
.
setReceiveAddressId
(
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
(
1001
,
result
.
getIntValue
(
"code"
));
}
/**
* 获取货主和地址信息:无效的发货地址ID
**/
@Test
public
void
a2_getOwnerAndAddressInfo_wrong_delivery_id_failure_test
()
throws
Exception
{
String
url
=
"/goodsowner//ext/getOwnerAndAddressInfo"
;
// 构造数据
AccountAndAddressForm
form
=
new
AccountAndAddressForm
();
form
.
setOwnerId
(
1L
);
form
.
setDeliveryAddressId
(
99999L
);
form
.
setReceiveAddressId
(
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
(
1002
,
result
.
getIntValue
(
"code"
));
}
/**
* 获取货主和地址信息:无效的收货地址ID
**/
@Test
public
void
a3_getOwnerAndAddressInfo_wrong_receive_id_failure_test
()
throws
Exception
{
String
url
=
"/goodsowner//ext/getOwnerAndAddressInfo"
;
// 构造数据
AccountAndAddressForm
form
=
new
AccountAndAddressForm
();
form
.
setOwnerId
(
1L
);
form
.
setDeliveryAddressId
(
7L
);
form
.
setReceiveAddressId
(
99999L
);
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
(
1003
,
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