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
a6879bcf
Commit
a6879bcf
authored
Apr 21, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增货主接口:新增发货地址
parent
92552b60
Changes
23
Show whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
451 additions
and
26 deletions
+451
-26
ErrorMessageComponent.java
...ight/customer/common/component/ErrorMessageComponent.java
+3
-0
GoodsOwnerConstants.java
...eight/customer/module/goodsowner/GoodsOwnerConstants.java
+6
-0
DeliveryAddressController.java
...dule/goodsowner/controller/DeliveryAddressController.java
+63
-0
GoodsOwnerController.java
...er/module/goodsowner/controller/GoodsOwnerController.java
+1
-1
DeliveryAddressDao.java
...ht/customer/module/goodsowner/dao/DeliveryAddressDao.java
+2
-2
ReceiveAddressDao.java
...ght/customer/module/goodsowner/dao/ReceiveAddressDao.java
+2
-2
RegularlyRouteDao.java
...ght/customer/module/goodsowner/dao/RegularlyRouteDao.java
+2
-2
AccountEntity.java
...ight/customer/module/goodsowner/entity/AccountEntity.java
+1
-1
AuditHistoryEntity.java
...customer/module/goodsowner/entity/AuditHistoryEntity.java
+1
-1
DeliveryAddressEntity.java
...tomer/module/goodsowner/entity/DeliveryAddressEntity.java
+14
-4
InfoEntity.java
...freight/customer/module/goodsowner/entity/InfoEntity.java
+1
-1
ReceiveAddressEntity.java
...stomer/module/goodsowner/entity/ReceiveAddressEntity.java
+14
-4
RegularlyRouteEntity.java
...stomer/module/goodsowner/entity/RegularlyRouteEntity.java
+14
-4
DeliveryAddressForm.java
.../customer/module/goodsowner/form/DeliveryAddressForm.java
+78
-0
DeliveryAddressService.java
...mer/module/goodsowner/service/DeliveryAddressService.java
+22
-1
ReceiveAddressService.java
...omer/module/goodsowner/service/ReceiveAddressService.java
+1
-1
RegularlyRouteService.java
...omer/module/goodsowner/service/RegularlyRouteService.java
+1
-1
DeliveryAddressServiceImpl.java
...e/goodsowner/service/impl/DeliveryAddressServiceImpl.java
+61
-0
application-dev.yml
src/main/resources/application-dev.yml
+4
-1
DeliveryAddressDao.xml
src/main/resources/mapper/goodsowner/DeliveryAddressDao.xml
+2
-0
ReceiveAddressDao.xml
src/main/resources/mapper/goodsowner/ReceiveAddressDao.xml
+2
-0
RegularlyRouteDao.xml
src/main/resources/mapper/goodsowner/RegularlyRouteDao.xml
+2
-0
DeliveryAddressControllerTest.java
.../goodsowner/controller/DeliveryAddressControllerTest.java
+154
-0
No files found.
src/main/java/com/esv/freight/customer/common/component/ErrorMessageComponent.java
View file @
a6879bcf
...
...
@@ -56,4 +56,7 @@ public class ErrorMessageComponent {
@Value
(
"${error-message.goodsowner.account.register.1001}"
)
private
String
goodsOwnerAccountRegister1001
;
@Value
(
"${error-message.goodsowner.delivery-address.add.1001}"
)
private
String
goodsOwnerDeliveryAddressAdd1001
;
}
src/main/java/com/esv/freight/customer/module/goodsowner/GoodsOwnerConstants.java
View file @
a6879bcf
...
...
@@ -36,4 +36,10 @@ public class GoodsOwnerConstants {
public
static
final
String
OWNER_ACCOUNT_STATUS_UNBLOCK
=
"1"
;
public
static
final
String
OWNER_ACCOUNT_STATUS_BLOCK
=
"2"
;
/**
* 是否同为收货地址:0-不是、1-是
**/
public
static
final
String
ADDRESS_COPY_NO
=
"0"
;
public
static
final
String
ADDRESS_COPY_YES
=
"1"
;
}
src/main/java/com/esv/freight/customer/module/goodsowner/controller/DeliveryAddressController.java
0 → 100644
View file @
a6879bcf
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.GoodsOwnerConstants
;
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
;
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.DeliveryAddressController
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/21 15:40
* @version:1.0
*/
@Slf4j
@RestController
@RequestMapping
(
"/goodsowner/delivery/address"
)
@Validated
public
class
DeliveryAddressController
{
private
DeliveryAddressService
deliveryAddressService
;
private
ReceiveAddressService
receiveAddressService
;
@Autowired
public
DeliveryAddressController
(
DeliveryAddressService
deliveryAddressService
,
ReceiveAddressService
receiveAddressService
)
{
this
.
deliveryAddressService
=
deliveryAddressService
;
this
.
receiveAddressService
=
receiveAddressService
;
}
/**
* description 新增发货地址
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/21 16:56
**/
@PostMapping
(
"/add"
)
public
EResponse
add
(
@RequestBody
@Validated
(
ValidatorInsert
.
class
)
DeliveryAddressForm
form
)
throws
EException
{
// 判断是否复制地址
if
(
GoodsOwnerConstants
.
ADDRESS_COPY_YES
.
equals
(
form
.
getAddressCopy
()))
{
}
Long
id
=
deliveryAddressService
.
addAddress
(
form
);
JSONObject
data
=
new
JSONObject
();
data
.
put
(
"id"
,
id
);
return
EResponse
.
ok
(
data
);
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/controller/GoodsOwnerController.java
View file @
a6879bcf
...
...
@@ -37,7 +37,7 @@ import java.util.ArrayList;
import
java.util.List
;
/**
* @description:
* @description:
承运商帐号Controller
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.controller.GoodsOwnerController
* @author: 黄朝斌
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/dao/DeliveryAddressDao.java
View file @
a6879bcf
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
dao
;
import
com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity
;
import
org.apache.ibatis.annotations.Mapper
;
/**
...
...
@@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Mapper;
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-
17 13:54:5
7
* @date 2020-04-
21 15:27:2
7
*/
@Mapper
public
interface
DeliveryAddressDao
extends
BaseMapper
<
DeliveryAddressEntity
>
{
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/dao/ReceiveAddressDao.java
View file @
a6879bcf
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
dao
;
import
com.esv.freight.customer.module.goodsowner.entity.ReceiveAddressEntity
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.esv.freight.customer.module.goodsowner.entity.ReceiveAddressEntity
;
import
org.apache.ibatis.annotations.Mapper
;
/**
...
...
@@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Mapper;
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-
17 13:54:5
7
* @date 2020-04-
21 15:27:2
7
*/
@Mapper
public
interface
ReceiveAddressDao
extends
BaseMapper
<
ReceiveAddressEntity
>
{
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/dao/RegularlyRouteDao.java
View file @
a6879bcf
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
dao
;
import
com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity
;
import
org.apache.ibatis.annotations.Mapper
;
/**
...
...
@@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Mapper;
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-
17 13:54:5
7
* @date 2020-04-
21 15:27:2
7
*/
@Mapper
public
interface
RegularlyRouteDao
extends
BaseMapper
<
RegularlyRouteEntity
>
{
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/entity/AccountEntity.java
View file @
a6879bcf
...
...
@@ -19,8 +19,8 @@ import java.util.Date;
@Data
@TableName
(
"goods_owner_account"
)
public
class
AccountEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
5500989619988830120L
;
/**
*
*/
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/entity/AuditHistoryEntity.java
View file @
a6879bcf
...
...
@@ -17,8 +17,8 @@ import lombok.Data;
@Data
@TableName
(
"goods_owner_audit_history"
)
public
class
AuditHistoryEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
3070587675449333212L
;
/**
*
*/
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/entity/DeliveryAddressEntity.java
View file @
a6879bcf
...
...
@@ -12,18 +12,28 @@ import lombok.Data;
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-
17 13:54:5
7
* @date 2020-04-
21 15:27:2
7
*/
@Data
@TableName
(
"goods_owner_delivery_address"
)
public
class
DeliveryAddressEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
-
5505542548412849641L
;
/**
*
*/
@TableId
private
Long
id
;
/**
* 租户ID
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Long
tenantId
;
/**
* 部门ID
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Long
departmentId
;
/**
* 货主ID
*/
...
...
@@ -89,12 +99,12 @@ public class DeliveryAddressEntity implements Serializable {
/**
* 修改者
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
@TableField
(
fill
=
FieldFill
.
INSERT
_UPDATE
)
private
String
updateUser
;
/**
* 创建时间
*/
@TableField
(
fill
=
FieldFill
.
INSERT
_UPDATE
)
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
/**
* 修改时间
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/entity/InfoEntity.java
View file @
a6879bcf
...
...
@@ -17,8 +17,8 @@ import lombok.Data;
@Data
@TableName
(
"goods_owner_info"
)
public
class
InfoEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
6703178702529854078L
;
/**
*
*/
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/entity/ReceiveAddressEntity.java
View file @
a6879bcf
...
...
@@ -12,18 +12,28 @@ import lombok.Data;
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-
17 13:54:5
7
* @date 2020-04-
21 15:27:2
7
*/
@Data
@TableName
(
"goods_owner_receive_address"
)
public
class
ReceiveAddressEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
6330420883281393071L
;
/**
*
*/
@TableId
private
Long
id
;
/**
* 租户ID
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Long
tenantId
;
/**
* 部门ID
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Long
departmentId
;
/**
* 货主ID
*/
...
...
@@ -89,12 +99,12 @@ public class ReceiveAddressEntity implements Serializable {
/**
* 修改者
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
@TableField
(
fill
=
FieldFill
.
INSERT
_UPDATE
)
private
String
updateUser
;
/**
* 创建时间
*/
@TableField
(
fill
=
FieldFill
.
INSERT
_UPDATE
)
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
/**
* 修改时间
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/entity/RegularlyRouteEntity.java
View file @
a6879bcf
...
...
@@ -11,18 +11,28 @@ import lombok.Data;
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-
17 13:54:5
7
* @date 2020-04-
21 15:27:2
7
*/
@Data
@TableName
(
"goods_owner_regularly_route"
)
public
class
RegularlyRouteEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
5207299128296225089L
;
/**
*
*/
@TableId
private
Long
id
;
/**
* 租户ID
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Long
tenantId
;
/**
* 部门ID
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Long
departmentId
;
/**
* 货主ID
*/
...
...
@@ -56,12 +66,12 @@ public class RegularlyRouteEntity implements Serializable {
/**
* 修改者
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
@TableField
(
fill
=
FieldFill
.
INSERT
_UPDATE
)
private
String
updateUser
;
/**
* 创建时间
*/
@TableField
(
fill
=
FieldFill
.
INSERT
_UPDATE
)
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
/**
* 修改时间
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/form/DeliveryAddressForm.java
0 → 100644
View file @
a6879bcf
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
;
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
;
import
javax.validation.constraints.Pattern
;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/17 16:11
* @version:1.0
*/
@Data
public
class
DeliveryAddressForm
{
@NotNull
(
message
=
"参数id不能为空"
,
groups
=
{
ValidatorUpdate
.
class
,
ValidatorDetail
.
class
,
ValidatorDelete
.
class
})
private
Long
id
;
@NotNull
(
message
=
"参数ownerId不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
Long
ownerId
;
@Length
(
max
=
50
,
message
=
"参数addressName长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@NotBlank
(
message
=
"参数addressName不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
String
addressName
;
@Length
(
min
=
6
,
max
=
6
,
message
=
"参数provinceCode长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@NotBlank
(
message
=
"参数provinceCode不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
String
provinceCode
;
@Length
(
min
=
6
,
max
=
6
,
message
=
"参数cityCode长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@NotBlank
(
message
=
"参数cityCode不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
String
cityCode
;
@Length
(
min
=
6
,
max
=
6
,
message
=
"参数districtCode长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@NotBlank
(
message
=
"参数districtCode不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
String
districtCode
;
@Length
(
max
=
50
,
message
=
"参数detailAddress长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@NotBlank
(
message
=
"参数detailAddress不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
String
detailAddress
;
@Length
(
max
=
20
,
message
=
"参数deliverer长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@NotBlank
(
message
=
"参数deliverer不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
String
deliverer
;
@Length
(
min
=
11
,
max
=
11
,
message
=
"参数delivererPhone长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@NotBlank
(
message
=
"参数delivererPhone不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
String
delivererPhone
;
@Length
(
max
=
20
,
message
=
"参数delivererTelephone长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
private
String
delivererTelephone
;
@Length
(
max
=
10
,
message
=
"参数lon长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
private
String
lon
;
@Length
(
max
=
10
,
message
=
"参数lat长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
private
String
lat
;
@Pattern
(
regexp
=
"[01]"
,
message
=
"参数addressCopy不合法"
,
groups
=
{
ValidatorInsert
.
class
})
private
String
addressCopy
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/service/DeliveryAddressService.java
View file @
a6879bcf
...
...
@@ -2,15 +2,36 @@ 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.DeliveryAddressForm
;
import
java.util.List
;
/**
* 货主发货地址表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-
17 13:54:5
7
* @date 2020-04-
21 15:27:2
7
*/
public
interface
DeliveryAddressService
extends
IService
<
DeliveryAddressEntity
>
{
/**
* description 新增发货地址
* param [form]
* return java.lang.Long
* author Administrator
* createTime 2020/04/21 15:59
**/
Long
addAddress
(
DeliveryAddressForm
form
);
/**
* description 通过地址名称查询地址记录
* param [ownerId, addressName]
* return java.util.List<com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity>
* author Administrator
* createTime 2020/04/21 16:33
**/
List
<
DeliveryAddressEntity
>
getAddressByName
(
Long
ownerId
,
String
addressName
);
}
src/main/java/com/esv/freight/customer/module/goodsowner/service/ReceiveAddressService.java
View file @
a6879bcf
...
...
@@ -8,7 +8,7 @@ import com.esv.freight.customer.module.goodsowner.entity.ReceiveAddressEntity;
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-
17 13:54:5
7
* @date 2020-04-
21 15:27:2
7
*/
public
interface
ReceiveAddressService
extends
IService
<
ReceiveAddressEntity
>
{
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/service/RegularlyRouteService.java
View file @
a6879bcf
...
...
@@ -8,7 +8,7 @@ import com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity;
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-
17 13:54:5
7
* @date 2020-04-
21 15:27:2
7
*/
public
interface
RegularlyRouteService
extends
IService
<
RegularlyRouteEntity
>
{
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/service/impl/DeliveryAddressServiceImpl.java
View file @
a6879bcf
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.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.DeliveryAddressDao
;
import
com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity
;
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
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
@Service
(
"deliveryAddressService"
)
public
class
DeliveryAddressServiceImpl
extends
ServiceImpl
<
DeliveryAddressDao
,
DeliveryAddressEntity
>
implements
DeliveryAddressService
{
private
FeignBaseService
feignBaseService
;
private
ErrorMessageComponent
errorMessageComponent
;
@Autowired
public
DeliveryAddressServiceImpl
(
FeignBaseService
feignBaseService
,
ErrorMessageComponent
errorMessageComponent
)
{
this
.
feignBaseService
=
feignBaseService
;
this
.
errorMessageComponent
=
errorMessageComponent
;
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Long
addAddress
(
DeliveryAddressForm
form
)
{
// 1.判断地址是否重复
List
<
DeliveryAddressEntity
>
deliveryAddressEntityList
=
this
.
getAddressByName
(
form
.
getOwnerId
(),
form
.
getAddressName
());
if
(
0
<
deliveryAddressEntityList
.
size
())
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getGoodsOwnerDeliveryAddressAdd1001
());
}
// 2.获取地址编码
JSONObject
batchIdReqJson
=
new
JSONObject
();
batchIdReqJson
.
put
(
"prefix"
,
"FH"
);
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
addressNumber
=
batchIdResJson
.
getString
(
"batchId"
);
// 3.新增地址
DeliveryAddressEntity
addressEntity
=
new
DeliveryAddressEntity
();
BeanUtils
.
copyProperties
(
form
,
addressEntity
);
addressEntity
.
setAddressNumber
(
addressNumber
);
this
.
baseMapper
.
insert
(
addressEntity
);
return
addressEntity
.
getId
();
}
@Override
public
List
<
DeliveryAddressEntity
>
getAddressByName
(
Long
ownerId
,
String
addressName
)
{
QueryWrapper
<
DeliveryAddressEntity
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
eq
(
"owner_id"
,
ownerId
);
queryWrapper
.
eq
(
"address_name"
,
addressName
);
return
this
.
getBaseMapper
().
selectList
(
queryWrapper
);
}
}
\ No newline at end of file
src/main/resources/application-dev.yml
View file @
a6879bcf
...
...
@@ -71,3 +71,6 @@ error-message:
1002
:
密码错误
register
:
1001
:
帐号已存在
delivery-address
:
add
:
1001
:
重复的发货地址名称
\ No newline at end of file
src/main/resources/mapper/goodsowner/DeliveryAddressDao.xml
View file @
a6879bcf
...
...
@@ -6,6 +6,8 @@
<!-- 可根据自己的需求,是否要使用 -->
<resultMap
type=
"com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity"
id=
"deliveryAddressMap"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"tenantId"
column=
"tenant_id"
/>
<result
property=
"departmentId"
column=
"department_id"
/>
<result
property=
"ownerId"
column=
"owner_id"
/>
<result
property=
"addressNumber"
column=
"address_number"
/>
<result
property=
"addressName"
column=
"address_name"
/>
...
...
src/main/resources/mapper/goodsowner/ReceiveAddressDao.xml
View file @
a6879bcf
...
...
@@ -6,6 +6,8 @@
<!-- 可根据自己的需求,是否要使用 -->
<resultMap
type=
"com.esv.freight.customer.module.goodsowner.entity.ReceiveAddressEntity"
id=
"receiveAddressMap"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"tenantId"
column=
"tenant_id"
/>
<result
property=
"departmentId"
column=
"department_id"
/>
<result
property=
"ownerId"
column=
"owner_id"
/>
<result
property=
"addressNumber"
column=
"address_number"
/>
<result
property=
"addressName"
column=
"address_name"
/>
...
...
src/main/resources/mapper/goodsowner/RegularlyRouteDao.xml
View file @
a6879bcf
...
...
@@ -6,6 +6,8 @@
<!-- 可根据自己的需求,是否要使用 -->
<resultMap
type=
"com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity"
id=
"regularlyRouteMap"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"tenantId"
column=
"tenant_id"
/>
<result
property=
"departmentId"
column=
"department_id"
/>
<result
property=
"ownerId"
column=
"owner_id"
/>
<result
property=
"routeNumber"
column=
"route_number"
/>
<result
property=
"routeName"
column=
"route_name"
/>
...
...
src/test/java/com/esv/freight/customer/module/goodsowner/controller/DeliveryAddressControllerTest.java
0 → 100644
View file @
a6879bcf
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.DeliveryAddressForm
;
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
DeliveryAddressControllerTest
extends
BaseTestController
{
/**
* 新增发货地址
**/
@Test
public
void
a1_add_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
(
"朝阳街少帅府巷46号"
);
form
.
setDeliverer
(
"张作霖"
);
form
.
setDelivererPhone
(
"13912340001"
);
form
.
setDelivererTelephone
(
"(024)24850576"
);
form
.
setLon
(
"123.464052"
);
form
.
setLat
(
"41.800415"
);
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_repeat_addressName_failure_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
(
"朝阳街少帅府巷46号"
);
form
.
setDeliverer
(
"张作霖"
);
form
.
setDelivererPhone
(
"13912340001"
);
form
.
setDelivererTelephone
(
"(024)24850576"
);
form
.
setLon
(
"123.464052"
);
form
.
setLat
(
"41.800415"
);
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"
));
}
/**
* 新增发货地址:地址名称重复
**/
@Test
@Rollback
public
void
a3_add_wrong_param_failure_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("朝阳街少帅府巷46号");
form
.
setDeliverer
(
"张作霖"
);
form
.
setDelivererPhone
(
"13912340001"
);
form
.
setDelivererTelephone
(
"(024)24850576"
);
form
.
setLon
(
"123.464052"
);
form
.
setLat
(
"41.800415"
);
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
.
PARAM_ERROR
.
code
(),
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