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
a13d5e10
Commit
a13d5e10
authored
Apr 22, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增货主接口:新增常跑线路
parent
b1ef2de4
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
417 additions
and
2 deletions
+417
-2
ErrorMessageComponent.java
...ight/customer/common/component/ErrorMessageComponent.java
+9
-0
RegularlyRouteController.java
...odule/goodsowner/controller/RegularlyRouteController.java
+47
-0
RegularlyRouteForm.java
...t/customer/module/goodsowner/form/RegularlyRouteForm.java
+44
-0
RegularlyRouteService.java
...omer/module/goodsowner/service/RegularlyRouteService.java
+21
-0
DeliveryAddressServiceImpl.java
...e/goodsowner/service/impl/DeliveryAddressServiceImpl.java
+1
-0
ReceiveAddressServiceImpl.java
...le/goodsowner/service/impl/ReceiveAddressServiceImpl.java
+1
-0
RegularlyRouteServiceImpl.java
...le/goodsowner/service/impl/RegularlyRouteServiceImpl.java
+92
-1
application-dev.yml
src/main/resources/application-dev.yml
+7
-1
RegularlyRouteControllerTest.java
...e/goodsowner/controller/RegularlyRouteControllerTest.java
+195
-0
No files found.
src/main/java/com/esv/freight/customer/common/component/ErrorMessageComponent.java
View file @
a13d5e10
...
@@ -78,4 +78,13 @@ public class ErrorMessageComponent {
...
@@ -78,4 +78,13 @@ public class ErrorMessageComponent {
@Value
(
"${error-message.goodsowner.receive-address.detail.1001}"
)
@Value
(
"${error-message.goodsowner.receive-address.detail.1001}"
)
private
String
goodsOwnerReceiveAddressDetail1001
;
private
String
goodsOwnerReceiveAddressDetail1001
;
@Value
(
"${error-message.goodsowner.regularly-route.add.1001}"
)
private
String
goodsOwnerRegularlyRouteAdd1001
;
@Value
(
"${error-message.goodsowner.regularly-route.add.1002}"
)
private
String
goodsOwnerRegularlyRouteAdd1002
;
@Value
(
"${error-message.goodsowner.regularly-route.add.1003}"
)
private
String
goodsOwnerRegularlyRouteAdd1003
;
@Value
(
"${error-message.goodsowner.regularly-route.add.1004}"
)
private
String
goodsOwnerRegularlyRouteAdd1004
;
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/controller/RegularlyRouteController.java
0 → 100644
View file @
a13d5e10
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.ValidatorInsert
;
import
com.esv.freight.customer.module.goodsowner.form.RegularlyRouteForm
;
import
com.esv.freight.customer.module.goodsowner.service.RegularlyRouteService
;
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.RegularlyRouteController
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/22 13:20
* @version:1.0
*/
@Slf4j
@RestController
@RequestMapping
(
"/goodsowner/regularly/route"
)
@Validated
public
class
RegularlyRouteController
{
private
RegularlyRouteService
regularlyRouteService
;
@Autowired
public
RegularlyRouteController
(
RegularlyRouteService
regularlyRouteService
)
{
this
.
regularlyRouteService
=
regularlyRouteService
;
}
@PostMapping
(
"/add"
)
public
EResponse
add
(
@RequestBody
@Validated
(
ValidatorInsert
.
class
)
RegularlyRouteForm
form
)
throws
EException
{
Long
id
=
regularlyRouteService
.
add
(
form
);
JSONObject
data
=
new
JSONObject
();
data
.
put
(
"id"
,
id
);
return
EResponse
.
ok
(
data
);
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/form/RegularlyRouteForm.java
0 → 100644
View file @
a13d5e10
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
form
;
import
com.esv.freight.customer.common.validator.groups.ValidatorInsert
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
org.hibernate.validator.constraints.Length
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.form.RegularlyRouteForm
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/17 16:11
* @version:1.0
*/
@Data
public
class
RegularlyRouteForm
{
// @NotNull(message = "参数id不能为空")
private
Long
id
;
@Length
(
max
=
50
,
message
=
"参数routeName长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@NotBlank
(
message
=
"参数routeName不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
String
routeName
;
@NotNull
(
message
=
"参数ownerId不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
Long
ownerId
;
@NotNull
(
message
=
"参数deliveryId不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
Long
deliveryId
;
@NotNull
(
message
=
"参数receiveId不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
Long
receiveId
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/service/RegularlyRouteService.java
View file @
a13d5e10
...
@@ -2,6 +2,9 @@ package com.esv.freight.customer.module.goodsowner.service;
...
@@ -2,6 +2,9 @@ package com.esv.freight.customer.module.goodsowner.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity
;
import
com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity
;
import
com.esv.freight.customer.module.goodsowner.form.RegularlyRouteForm
;
import
java.util.List
;
/**
/**
* 货主常跑线路表
* 货主常跑线路表
...
@@ -12,5 +15,23 @@ import com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity;
...
@@ -12,5 +15,23 @@ import com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity;
*/
*/
public
interface
RegularlyRouteService
extends
IService
<
RegularlyRouteEntity
>
{
public
interface
RegularlyRouteService
extends
IService
<
RegularlyRouteEntity
>
{
/**
* description 根据线路名称查询货主线路列表
* param [form]
* return java.util.List<com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity>
* author Administrator
* createTime 2020/04/22 13:32
**/
List
<
RegularlyRouteEntity
>
getOwnerRouteByName
(
RegularlyRouteForm
form
);
/**
* description 新增常跑线路
* param [form]
* return java.lang.Long
* author Administrator
* createTime 2020/04/22 13:36
**/
Long
add
(
RegularlyRouteForm
form
);
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/service/impl/DeliveryAddressServiceImpl.java
View file @
a13d5e10
...
@@ -69,6 +69,7 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
...
@@ -69,6 +69,7 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
DeliveryAddressEntity
addressEntity
=
new
DeliveryAddressEntity
();
DeliveryAddressEntity
addressEntity
=
new
DeliveryAddressEntity
();
BeanUtils
.
copyProperties
(
form
,
addressEntity
);
BeanUtils
.
copyProperties
(
form
,
addressEntity
);
addressEntity
.
setAddressNumber
(
addressNumber
);
addressEntity
.
setAddressNumber
(
addressNumber
);
addressEntity
.
setId
(
null
);
if
(
StringUtils
.
isNotBlank
(
form
.
getLon
()))
{
if
(
StringUtils
.
isNotBlank
(
form
.
getLon
()))
{
addressEntity
.
setLon
(
new
BigDecimal
(
form
.
getLon
()));
addressEntity
.
setLon
(
new
BigDecimal
(
form
.
getLon
()));
}
}
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/service/impl/ReceiveAddressServiceImpl.java
View file @
a13d5e10
...
@@ -68,6 +68,7 @@ public class ReceiveAddressServiceImpl extends ServiceImpl<ReceiveAddressDao, Re
...
@@ -68,6 +68,7 @@ public class ReceiveAddressServiceImpl extends ServiceImpl<ReceiveAddressDao, Re
// 3.新增地址
// 3.新增地址
ReceiveAddressEntity
addressEntity
=
new
ReceiveAddressEntity
();
ReceiveAddressEntity
addressEntity
=
new
ReceiveAddressEntity
();
BeanUtils
.
copyProperties
(
form
,
addressEntity
);
BeanUtils
.
copyProperties
(
form
,
addressEntity
);
addressEntity
.
setId
(
null
);
addressEntity
.
setAddressNumber
(
addressNumber
);
addressEntity
.
setAddressNumber
(
addressNumber
);
if
(
StringUtils
.
isNotBlank
(
form
.
getLon
()))
{
if
(
StringUtils
.
isNotBlank
(
form
.
getLon
()))
{
addressEntity
.
setLon
(
new
BigDecimal
(
form
.
getLon
()));
addressEntity
.
setLon
(
new
BigDecimal
(
form
.
getLon
()));
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/service/impl/RegularlyRouteServiceImpl.java
View file @
a13d5e10
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
service
.
impl
;
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.extension.service.impl.ServiceImpl
;
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.feign.FeignBaseService
;
import
com.esv.freight.customer.module.goodsowner.dao.RegularlyRouteDao
;
import
com.esv.freight.customer.module.goodsowner.dao.RegularlyRouteDao
;
import
com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity
;
import
com.esv.freight.customer.module.goodsowner.entity.*
;
import
com.esv.freight.customer.module.goodsowner.form.RegularlyRouteForm
;
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.service.RegularlyRouteService
;
import
com.esv.freight.customer.module.goodsowner.service.RegularlyRouteService
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Service
(
"regularlyRouteService"
)
@Service
(
"regularlyRouteService"
)
public
class
RegularlyRouteServiceImpl
extends
ServiceImpl
<
RegularlyRouteDao
,
RegularlyRouteEntity
>
implements
RegularlyRouteService
{
public
class
RegularlyRouteServiceImpl
extends
ServiceImpl
<
RegularlyRouteDao
,
RegularlyRouteEntity
>
implements
RegularlyRouteService
{
private
ErrorMessageComponent
errorMessageComponent
;
private
FeignBaseService
feignBaseService
;
private
AccountService
accountService
;
private
DeliveryAddressService
deliveryAddressService
;
private
ReceiveAddressService
receiveAddressService
;
@Autowired
public
RegularlyRouteServiceImpl
(
ErrorMessageComponent
errorMessageComponent
,
FeignBaseService
feignBaseService
,
AccountService
accountService
,
DeliveryAddressService
deliveryAddressService
,
ReceiveAddressService
receiveAddressService
)
{
this
.
errorMessageComponent
=
errorMessageComponent
;
this
.
feignBaseService
=
feignBaseService
;
this
.
accountService
=
accountService
;
this
.
deliveryAddressService
=
deliveryAddressService
;
this
.
receiveAddressService
=
receiveAddressService
;
}
@Override
public
Long
add
(
RegularlyRouteForm
form
)
{
// 1.校验线路名称是否重复
List
<
RegularlyRouteEntity
>
routeEntityList
=
this
.
getOwnerRouteByName
(
form
);
if
(
0
<
routeEntityList
.
size
())
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getGoodsOwnerRegularlyRouteAdd1001
());
}
// 2.校验获取ID是否有效
AccountEntity
accountEntity
=
this
.
accountService
.
getById
(
form
.
getOwnerId
());
if
(
null
==
accountEntity
)
{
throw
new
EException
(
1002
,
errorMessageComponent
.
getGoodsOwnerRegularlyRouteAdd1002
());
}
// 3.校验发货地址ID是否有效
DeliveryAddressEntity
deliveryAddressEntity
=
this
.
deliveryAddressService
.
getById
(
form
.
getDeliveryId
());
if
(
null
==
deliveryAddressEntity
)
{
throw
new
EException
(
1003
,
errorMessageComponent
.
getGoodsOwnerRegularlyRouteAdd1003
());
}
// 4.校验收货地址ID是否有效
ReceiveAddressEntity
receiveAddressEntity
=
this
.
receiveAddressService
.
getById
(
form
.
getReceiveId
());
if
(
null
==
receiveAddressEntity
)
{
throw
new
EException
(
1004
,
errorMessageComponent
.
getGoodsOwnerRegularlyRouteAdd1004
());
}
// 5.获取路线编码
JSONObject
batchIdReqJson
=
new
JSONObject
();
batchIdReqJson
.
put
(
"prefix"
,
"LX"
);
batchIdReqJson
.
put
(
"formatter"
,
"yyyyMMdd"
);
batchIdReqJson
.
put
(
"length"
,
13
);
JSONObject
batchIdResJson
;
try
{
batchIdResJson
=
FeignUtils
.
getFeignResultData
(
feignBaseService
.
getBatchId
(
batchIdReqJson
));
}
catch
(
Exception
e
)
{
log
.
error
(
"调用[基础服务]生成路线编号失败"
);
throw
new
EException
(
"生成路线编号时发生错误"
);
}
String
routeNumber
=
batchIdResJson
.
getString
(
"batchId"
);
// 6.新增
RegularlyRouteEntity
routeEntity
=
new
RegularlyRouteEntity
();
BeanUtils
.
copyProperties
(
form
,
routeEntity
);
routeEntity
.
setId
(
null
);
routeEntity
.
setRouteNumber
(
routeNumber
);
this
.
baseMapper
.
insert
(
routeEntity
);
return
routeEntity
.
getId
();
}
@Override
public
List
<
RegularlyRouteEntity
>
getOwnerRouteByName
(
RegularlyRouteForm
form
)
{
QueryWrapper
<
RegularlyRouteEntity
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
eq
(
"owner_id"
,
form
.
getOwnerId
());
queryWrapper
.
eq
(
"route_name"
,
form
.
getRouteName
());
return
this
.
baseMapper
.
selectList
(
queryWrapper
);
}
}
}
\ No newline at end of file
src/main/resources/application-dev.yml
View file @
a13d5e10
...
@@ -87,3 +87,9 @@ error-message:
...
@@ -87,3 +87,9 @@ error-message:
1002
:
重复的地址名称
1002
:
重复的地址名称
detail
:
detail
:
1001
:
无效的地址ID
1001
:
无效的地址ID
regularly-route
:
add
:
1001
:
重复的常跑线路名称
1002
:
无效的货主ID
1003
:
无效的发货地址ID
1004
:
无效的收货地址ID
\ No newline at end of file
src/test/java/com/esv/freight/customer/module/goodsowner/controller/RegularlyRouteControllerTest.java
0 → 100644
View file @
a13d5e10
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.RegularlyRouteForm
;
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.DeliveryAddressControllerTest
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/21 16:57
* @version:1.0
*/
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
@Slf4j
@FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
@Transactional
@Rollback
(
false
)
public
class
RegularlyRouteControllerTest
extends
BaseTestController
{
/**
* 新增常跑线路
**/
@Test
public
void
a1_add_success_test
()
throws
Exception
{
String
url
=
"/goodsowner/regularly/route/add"
;
// 构造数据
RegularlyRouteForm
form
=
new
RegularlyRouteForm
();
form
.
setOwnerId
(
1L
);
form
.
setRouteName
(
"沈阳-大连线路"
);
form
.
setDeliveryId
(
7L
);
form
.
setReceiveId
(
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
(
"id"
));
}
/**
* 新增常跑线路:名称重复
**/
@Test
@Rollback
public
void
a2_add_failure_repeat_name_test
()
throws
Exception
{
String
url
=
"/goodsowner/regularly/route/add"
;
// 构造数据
RegularlyRouteForm
form
=
new
RegularlyRouteForm
();
form
.
setOwnerId
(
1L
);
form
.
setRouteName
(
"沈阳-大连线路"
);
form
.
setDeliveryId
(
7L
);
form
.
setReceiveId
(
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
@Rollback
public
void
a3_add_failure_repeat_name_test
()
throws
Exception
{
String
url
=
"/goodsowner/regularly/route/add"
;
// 构造数据
RegularlyRouteForm
form
=
new
RegularlyRouteForm
();
form
.
setOwnerId
(
99999L
);
form
.
setRouteName
(
"沈阳-大连线路111"
);
form
.
setDeliveryId
(
7L
);
form
.
setReceiveId
(
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
@Rollback
public
void
a4_add_failure_wrong_delivery_id_test
()
throws
Exception
{
String
url
=
"/goodsowner/regularly/route/add"
;
// 构造数据
RegularlyRouteForm
form
=
new
RegularlyRouteForm
();
form
.
setOwnerId
(
1L
);
form
.
setRouteName
(
"沈阳-大连线路111"
);
form
.
setDeliveryId
(
99999L
);
form
.
setReceiveId
(
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
(
1003
,
result
.
getIntValue
(
"code"
));
}
/**
* 新增常跑线路:无效的收货地址ID
**/
@Test
@Rollback
public
void
a5_add_failure_wrong_receive_id_test
()
throws
Exception
{
String
url
=
"/goodsowner/regularly/route/add"
;
// 构造数据
RegularlyRouteForm
form
=
new
RegularlyRouteForm
();
form
.
setOwnerId
(
1L
);
form
.
setRouteName
(
"沈阳-大连线路111"
);
form
.
setDeliveryId
(
7L
);
form
.
setReceiveId
(
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
(
1004
,
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