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
b1ef2de4
Commit
b1ef2de4
authored
Apr 22, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增货主接口:新增发货、收货地址时,增加复制功能
parent
80e5931c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
77 additions
and
10 deletions
+77
-10
DeliveryAddressController.java
...dule/goodsowner/controller/DeliveryAddressController.java
+17
-4
ReceiveAddressController.java
...odule/goodsowner/controller/ReceiveAddressController.java
+17
-4
DeliveryAddressServiceImpl.java
...e/goodsowner/service/impl/DeliveryAddressServiceImpl.java
+1
-0
ReceiveAddressServiceImpl.java
...le/goodsowner/service/impl/ReceiveAddressServiceImpl.java
+1
-0
DeliveryAddressControllerTest.java
.../goodsowner/controller/DeliveryAddressControllerTest.java
+41
-2
No files found.
src/main/java/com/esv/freight/customer/module/goodsowner/controller/DeliveryAddressController.java
View file @
b1ef2de4
...
@@ -7,10 +7,12 @@ import com.esv.freight.customer.common.validator.groups.*;
...
@@ -7,10 +7,12 @@ import com.esv.freight.customer.common.validator.groups.*;
import
com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants
;
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.DeleteAddressForm
;
import
com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm
;
import
com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm
;
import
com.esv.freight.customer.module.goodsowner.form.ReceiveAddressForm
;
import
com.esv.freight.customer.module.goodsowner.service.DeliveryAddressService
;
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.ReceiveAddressService
;
import
com.esv.freight.customer.module.goodsowner.validator.groups.AddressBrief
;
import
com.esv.freight.customer.module.goodsowner.validator.groups.AddressBrief
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
@@ -52,14 +54,25 @@ public class DeliveryAddressController {
...
@@ -52,14 +54,25 @@ public class DeliveryAddressController {
**/
**/
@PostMapping
(
"/add"
)
@PostMapping
(
"/add"
)
public
EResponse
add
(
@RequestBody
@Validated
(
ValidatorInsert
.
class
)
DeliveryAddressForm
form
)
throws
EException
{
public
EResponse
add
(
@RequestBody
@Validated
(
ValidatorInsert
.
class
)
DeliveryAddressForm
form
)
throws
EException
{
Long
id
=
deliveryAddressService
.
addAddress
(
form
);
JSONObject
data
=
new
JSONObject
();
data
.
put
(
"id"
,
id
);
// 判断是否复制地址
// 判断是否复制地址
if
(
GoodsOwnerConstants
.
ADDRESS_COPY_YES
.
equals
(
form
.
getAddressCopy
()))
{
if
(
GoodsOwnerConstants
.
ADDRESS_COPY_YES
.
equals
(
form
.
getAddressCopy
()))
{
ReceiveAddressForm
receiveAddressForm
=
new
ReceiveAddressForm
();
BeanUtils
.
copyProperties
(
form
,
receiveAddressForm
);
receiveAddressForm
.
setReceiver
(
form
.
getDeliverer
());
receiveAddressForm
.
setReceiverPhone
(
form
.
getDelivererPhone
());
receiveAddressForm
.
setReceiverTelephone
(
form
.
getDelivererTelephone
());
try
{
receiveAddressService
.
addAddress
(
receiveAddressForm
);
}
catch
(
Exception
e
)
{
log
.
error
(
"复制为收货地址时发生错误"
);
log
.
error
(
e
.
getMessage
(),
e
);
}
}
}
Long
id
=
deliveryAddressService
.
addAddress
(
form
);
JSONObject
data
=
new
JSONObject
();
data
.
put
(
"id"
,
id
);
return
EResponse
.
ok
(
data
);
return
EResponse
.
ok
(
data
);
}
}
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/controller/ReceiveAddressController.java
View file @
b1ef2de4
...
@@ -6,11 +6,13 @@ import com.esv.freight.customer.common.response.EResponse;
...
@@ -6,11 +6,13 @@ import com.esv.freight.customer.common.response.EResponse;
import
com.esv.freight.customer.common.validator.groups.*
;
import
com.esv.freight.customer.common.validator.groups.*
;
import
com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants
;
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.DeleteAddressForm
;
import
com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm
;
import
com.esv.freight.customer.module.goodsowner.form.ReceiveAddressForm
;
import
com.esv.freight.customer.module.goodsowner.form.ReceiveAddressForm
;
import
com.esv.freight.customer.module.goodsowner.service.DeliveryAddressService
;
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.ReceiveAddressService
;
import
com.esv.freight.customer.module.goodsowner.validator.groups.AddressBrief
;
import
com.esv.freight.customer.module.goodsowner.validator.groups.AddressBrief
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
@@ -52,14 +54,25 @@ public class ReceiveAddressController {
...
@@ -52,14 +54,25 @@ public class ReceiveAddressController {
**/
**/
@PostMapping
(
"/add"
)
@PostMapping
(
"/add"
)
public
EResponse
add
(
@RequestBody
@Validated
(
ValidatorInsert
.
class
)
ReceiveAddressForm
form
)
throws
EException
{
public
EResponse
add
(
@RequestBody
@Validated
(
ValidatorInsert
.
class
)
ReceiveAddressForm
form
)
throws
EException
{
Long
id
=
receiveAddressService
.
addAddress
(
form
);
JSONObject
data
=
new
JSONObject
();
data
.
put
(
"id"
,
id
);
// 判断是否复制地址
// 判断是否复制地址
if
(
GoodsOwnerConstants
.
ADDRESS_COPY_YES
.
equals
(
form
.
getAddressCopy
()))
{
if
(
GoodsOwnerConstants
.
ADDRESS_COPY_YES
.
equals
(
form
.
getAddressCopy
()))
{
DeliveryAddressForm
deliveryAddressForm
=
new
DeliveryAddressForm
();
BeanUtils
.
copyProperties
(
form
,
deliveryAddressForm
);
deliveryAddressForm
.
setDeliverer
(
form
.
getReceiver
());
deliveryAddressForm
.
setDeliverer
(
form
.
getReceiverPhone
());
deliveryAddressForm
.
setDeliverer
(
form
.
getReceiverTelephone
());
try
{
deliveryAddressService
.
addAddress
(
deliveryAddressForm
);
}
catch
(
Exception
e
)
{
log
.
error
(
"复制为发货地址时发生错误"
);
log
.
error
(
e
.
getMessage
(),
e
);
}
}
}
Long
id
=
receiveAddressService
.
addAddress
(
form
);
JSONObject
data
=
new
JSONObject
();
data
.
put
(
"id"
,
id
);
return
EResponse
.
ok
(
data
);
return
EResponse
.
ok
(
data
);
}
}
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/service/impl/DeliveryAddressServiceImpl.java
View file @
b1ef2de4
...
@@ -60,6 +60,7 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
...
@@ -60,6 +60,7 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
batchIdResJson
=
FeignUtils
.
getFeignResultData
(
feignBaseService
.
getBatchId
(
batchIdReqJson
));
batchIdResJson
=
FeignUtils
.
getFeignResultData
(
feignBaseService
.
getBatchId
(
batchIdReqJson
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"调用[基础服务]生成发货地址编号失败"
);
log
.
error
(
"调用[基础服务]生成发货地址编号失败"
);
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
EException
(
"生成发货地址编号时发生错误"
);
throw
new
EException
(
"生成发货地址编号时发生错误"
);
}
}
String
addressNumber
=
batchIdResJson
.
getString
(
"batchId"
);
String
addressNumber
=
batchIdResJson
.
getString
(
"batchId"
);
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/service/impl/ReceiveAddressServiceImpl.java
View file @
b1ef2de4
...
@@ -60,6 +60,7 @@ public class ReceiveAddressServiceImpl extends ServiceImpl<ReceiveAddressDao, Re
...
@@ -60,6 +60,7 @@ public class ReceiveAddressServiceImpl extends ServiceImpl<ReceiveAddressDao, Re
batchIdResJson
=
FeignUtils
.
getFeignResultData
(
feignBaseService
.
getBatchId
(
batchIdReqJson
));
batchIdResJson
=
FeignUtils
.
getFeignResultData
(
feignBaseService
.
getBatchId
(
batchIdReqJson
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"调用[基础服务]生成收货地址编号失败"
);
log
.
error
(
"调用[基础服务]生成收货地址编号失败"
);
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
EException
(
"生成收货地址编号时发生错误"
);
throw
new
EException
(
"生成收货地址编号时发生错误"
);
}
}
String
addressNumber
=
batchIdResJson
.
getString
(
"batchId"
);
String
addressNumber
=
batchIdResJson
.
getString
(
"batchId"
);
...
...
src/test/java/com/esv/freight/customer/module/goodsowner/controller/DeliveryAddressControllerTest.java
View file @
b1ef2de4
...
@@ -76,12 +76,51 @@ public class DeliveryAddressControllerTest extends BaseTestController {
...
@@ -76,12 +76,51 @@ public class DeliveryAddressControllerTest extends BaseTestController {
Assert
.
assertTrue
(
result
.
getJSONObject
(
"data"
).
containsKey
(
"id"
));
Assert
.
assertTrue
(
result
.
getJSONObject
(
"data"
).
containsKey
(
"id"
));
}
}
/**
* 新增发货地址:同时复制为收货地址
**/
@Test
public
void
a2_add_with_copy_success_test
()
throws
Exception
{
String
url
=
"/goodsowner/delivery/address/add"
;
// 构造数据
DeliveryAddressForm
form
=
new
DeliveryAddressForm
();
form
.
setOwnerId
(
1L
);
form
.
setAddressName
(
"沈阳故宫博物院"
);
form
.
setProvinceCode
(
"210000"
);
form
.
setCityCode
(
"210100"
);
form
.
setDistrictCode
(
"210103"
);
form
.
setDetailAddress
(
"沈阳路171号"
);
form
.
setDeliverer
(
"黄皇"
);
form
.
setDelivererPhone
(
"13912340001"
);
form
.
setDelivererTelephone
(
"(024)24850576"
);
form
.
setLon
(
"123.464052"
);
form
.
setLat
(
"41.800415"
);
form
.
setAddressCopy
(
"1"
);
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
@Test
@Rollback
@Rollback
public
void
a
2
_add_repeat_addressName_failure_test
()
throws
Exception
{
public
void
a
3
_add_repeat_addressName_failure_test
()
throws
Exception
{
String
url
=
"/goodsowner/delivery/address/add"
;
String
url
=
"/goodsowner/delivery/address/add"
;
// 构造数据
// 构造数据
...
@@ -119,7 +158,7 @@ public class DeliveryAddressControllerTest extends BaseTestController {
...
@@ -119,7 +158,7 @@ public class DeliveryAddressControllerTest extends BaseTestController {
**/
**/
@Test
@Test
@Rollback
@Rollback
public
void
a
3
_add_wrong_param_failure_test
()
throws
Exception
{
public
void
a
4
_add_wrong_param_failure_test
()
throws
Exception
{
String
url
=
"/goodsowner/delivery/address/add"
;
String
url
=
"/goodsowner/delivery/address/add"
;
// 构造数据
// 构造数据
...
...
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