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
d4944841
Commit
d4944841
authored
Apr 21, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增货主接口:删除发货地址
parent
b2273787
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
96 additions
and
2 deletions
+96
-2
DeliveryAddressController.java
...dule/goodsowner/controller/DeliveryAddressController.java
+17
-0
DeleteAddressForm.java
...ht/customer/module/goodsowner/form/DeleteAddressForm.java
+29
-0
DeliveryAddressForm.java
.../customer/module/goodsowner/form/DeliveryAddressForm.java
+1
-2
DeliveryAddressService.java
...mer/module/goodsowner/service/DeliveryAddressService.java
+10
-0
DeliveryAddressServiceImpl.java
...e/goodsowner/service/impl/DeliveryAddressServiceImpl.java
+9
-0
DeliveryAddressControllerTest.java
.../goodsowner/controller/DeliveryAddressControllerTest.java
+30
-0
No files found.
src/main/java/com/esv/freight/customer/module/goodsowner/controller/DeliveryAddressController.java
View file @
d4944841
...
...
@@ -3,9 +3,11 @@ 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.ValidatorInsert
;
import
com.esv.freight.customer.common.validator.groups.ValidatorUpdate
;
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
;
import
com.esv.freight.customer.module.goodsowner.service.DeliveryAddressService
;
import
com.esv.freight.customer.module.goodsowner.service.ReceiveAddressService
;
...
...
@@ -74,4 +76,19 @@ public class DeliveryAddressController {
deliveryAddressService
.
editAddress
(
form
);
return
EResponse
.
ok
();
}
/**
* description 删除发货地址
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/21 19:27
**/
@PostMapping
(
"/delete"
)
public
EResponse
delete
(
@RequestBody
@Validated
(
ValidatorDelete
.
class
)
DeleteAddressForm
form
)
throws
EException
{
int
count
=
deliveryAddressService
.
deleteAddress
(
form
);
JSONObject
data
=
new
JSONObject
();
data
.
put
(
"count"
,
count
);
return
EResponse
.
ok
(
data
);
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/form/DeleteAddressForm.java
0 → 100644
View file @
d4944841
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
form
;
import
com.esv.freight.customer.common.validator.groups.ValidatorDelete
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
javax.validation.constraints.NotBlank
;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.form.DeleteAddressForm
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/17 16:11
* @version:1.0
*/
@Data
public
class
DeleteAddressForm
{
@NotBlank
(
message
=
"参数id不能为空"
,
groups
=
{
ValidatorDelete
.
class
})
private
String
id
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/form/DeliveryAddressForm.java
View file @
d4944841
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
form
;
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
;
...
...
@@ -25,7 +24,7 @@ import javax.validation.constraints.Pattern;
@Data
public
class
DeliveryAddressForm
{
@NotNull
(
message
=
"参数id不能为空"
,
groups
=
{
ValidatorUpdate
.
class
,
ValidatorDetail
.
class
,
ValidatorDelete
.
class
})
@NotNull
(
message
=
"参数id不能为空"
,
groups
=
{
ValidatorUpdate
.
class
,
ValidatorDetail
.
class
})
private
Long
id
;
@NotNull
(
message
=
"参数ownerId不能为空"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorUpdate
.
class
})
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/service/DeliveryAddressService.java
View file @
d4944841
...
...
@@ -2,6 +2,7 @@ package com.esv.freight.customer.module.goodsowner.service;
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
java.util.List
;
...
...
@@ -33,6 +34,15 @@ public interface DeliveryAddressService extends IService<DeliveryAddressEntity>
**/
int
editAddress
(
DeliveryAddressForm
form
);
/**
* description 删除发货地址
* param [form]
* return int
* author Administrator
* createTime 2020/04/21 19:23
**/
int
deleteAddress
(
DeleteAddressForm
form
);
/**
* description 通过地址名称查询地址记录
* param [ownerId, addressName]
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/service/impl/DeliveryAddressServiceImpl.java
View file @
d4944841
...
...
@@ -10,12 +10,14 @@ import com.esv.freight.customer.feign.FeignBaseService;
import
com.esv.freight.customer.module.goodsowner.dao.DeliveryAddressDao
;
import
com.esv.freight.customer.module.goodsowner.entity.AuditHistoryEntity
;
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
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Arrays
;
import
java.util.List
;
...
...
@@ -89,6 +91,13 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
return
flag
;
}
@Override
public
int
deleteAddress
(
DeleteAddressForm
form
)
{
String
[]
ids
=
form
.
getId
().
split
(
","
);
int
count
=
this
.
baseMapper
.
deleteBatchIds
(
Arrays
.
asList
(
ids
));
return
count
;
}
@Override
public
List
<
DeliveryAddressEntity
>
getAddressByName
(
Long
ownerId
,
String
addressName
)
{
QueryWrapper
<
DeliveryAddressEntity
>
queryWrapper
=
new
QueryWrapper
<>();
...
...
src/test/java/com/esv/freight/customer/module/goodsowner/controller/DeliveryAddressControllerTest.java
View file @
d4944841
...
...
@@ -3,6 +3,7 @@ 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.DeleteAddressForm
;
import
com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Assert
;
...
...
@@ -268,4 +269,33 @@ public class DeliveryAddressControllerTest extends BaseTestController {
Assert
.
assertEquals
(
1002
,
result
.
getIntValue
(
"code"
));
}
/**
* 删除发货地址
**/
@Test
@Rollback
public
void
c1_delete_success_test
()
throws
Exception
{
String
url
=
"/goodsowner/delivery/address/delete"
;
// 构造数据
DeleteAddressForm
form
=
new
DeleteAddressForm
();
form
.
setId
(
"1,2,3,4,5"
);
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
(
"count"
));
}
}
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