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
0a48f425
Commit
0a48f425
authored
Apr 29, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
承运商接口:注册司机
parent
d4857259
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
275 additions
and
4 deletions
+275
-4
ErrorMessageComponent.java
...ight/customer/common/component/ErrorMessageComponent.java
+7
-0
CarrierAccountService.java
...ustomer/module/carrier/service/CarrierAccountService.java
+9
-0
CarrierAccountServiceImpl.java
...odule/carrier/service/impl/CarrierAccountServiceImpl.java
+5
-0
DriverController.java
...t/customer/module/driver/controller/DriverController.java
+17
-0
DriverInfoForm.java
...v/freight/customer/module/driver/form/DriverInfoForm.java
+3
-2
DriverAccountService.java
.../customer/module/driver/service/DriverAccountService.java
+9
-0
DriverAccountServiceImpl.java
.../module/driver/service/impl/DriverAccountServiceImpl.java
+58
-1
ValidatorRegister.java
...mer/module/driver/validator/groups/ValidatorRegister.java
+15
-0
application-dev.yml
src/main/resources/application-dev.yml
+5
-1
DriverAccountAddTest.java
...stomer/module/driver/controller/DriverAccountAddTest.java
+54
-0
DriverAccountTest.java
.../customer/module/driver/controller/DriverAccountTest.java
+93
-0
No files found.
src/main/java/com/esv/freight/customer/common/component/ErrorMessageComponent.java
View file @
0a48f425
...
...
@@ -176,6 +176,8 @@ public class ErrorMessageComponent {
private
String
carrierDriverAdd1003
;
@Value
(
"${error-message.carrier.driver.add.1004}"
)
private
String
carrierDriverAdd1004
;
@Value
(
"${error-message.carrier.driver.add.1005}"
)
private
String
carrierDriverAdd1005
;
@Value
(
"${error-message.carrier.driver.edit.1001}"
)
private
String
carrierDriverEdit1001
;
...
...
@@ -203,4 +205,9 @@ public class ErrorMessageComponent {
private
String
carrierDriverUnblock1001
;
@Value
(
"${error-message.carrier.driver.unblock.1002}"
)
private
String
carrierDriverUnblock1002
;
@Value
(
"${error-message.carrier.driver.register.1001}"
)
private
String
carrierDriverRegister1001
;
@Value
(
"${error-message.carrier.driver.register.1002}"
)
private
String
carrierDriverRegister1002
;
}
src/main/java/com/esv/freight/customer/module/carrier/service/CarrierAccountService.java
View file @
0a48f425
...
...
@@ -73,5 +73,14 @@ public interface CarrierAccountService extends IService<CarrierAccountEntity> {
**/
PageResultVO
getCarrier4Page
(
CarrierQueryForm
queryObj
);
/**
* description 通过ID查询承运商帐号
* param [id]
* return com.esv.freight.customer.module.carrier.entity.CarrierAccountEntity
* author Administrator
* createTime 2020/04/29 10:52
**/
CarrierAccountEntity
getCarrierById
(
Long
id
);
}
src/main/java/com/esv/freight/customer/module/carrier/service/impl/CarrierAccountServiceImpl.java
View file @
0a48f425
...
...
@@ -219,4 +219,9 @@ public class CarrierAccountServiceImpl extends ServiceImpl<CarrierAccountDao, Ca
return
new
PageResultVO
(
page
,
targetRecordList
);
}
@Override
public
CarrierAccountEntity
getCarrierById
(
Long
id
)
{
return
this
.
baseMapper
.
selectById
(
id
);
}
}
\ No newline at end of file
src/main/java/com/esv/freight/customer/module/driver/controller/DriverController.java
View file @
0a48f425
...
...
@@ -16,6 +16,7 @@ import com.esv.freight.customer.module.driver.form.DriverAuditForm;
import
com.esv.freight.customer.module.driver.form.DriverInfoForm
;
import
com.esv.freight.customer.module.driver.form.DriverQueryForm
;
import
com.esv.freight.customer.module.driver.service.DriverAccountService
;
import
com.esv.freight.customer.module.driver.validator.groups.ValidatorRegister
;
import
com.esv.freight.customer.module.driver.vo.DriverDetailVO
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -171,4 +172,20 @@ public class DriverController {
return
EResponse
.
ok
();
}
/**
* description 注册司机
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/29 11:03
**/
@PostMapping
(
"/register"
)
public
EResponse
register
(
@RequestBody
@Validated
(
ValidatorRegister
.
class
)
DriverInfoForm
form
)
throws
EException
{
Long
id
=
driverAccountService
.
registerDriver
(
form
);
JSONObject
data
=
new
JSONObject
();
data
.
put
(
"id"
,
id
);
return
EResponse
.
ok
(
data
);
}
}
src/main/java/com/esv/freight/customer/module/driver/form/DriverInfoForm.java
View file @
0a48f425
...
...
@@ -2,6 +2,7 @@ package com.esv.freight.customer.module.driver.form;
import
com.esv.freight.customer.common.validator.groups.ValidatorInsert
;
import
com.esv.freight.customer.common.validator.groups.ValidatorUpdate
;
import
com.esv.freight.customer.module.driver.validator.groups.ValidatorRegister
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
...
...
@@ -31,12 +32,12 @@ public class DriverInfoForm {
/**
* 承运商帐号ID
*/
@NotNull
(
message
=
"参数carrierId不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
@NotNull
(
message
=
"参数carrierId不能为空"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorRegister
.
class
})
private
Long
carrierId
;
/**
* 登录帐号,司机手机号
*/
@Length
(
min
=
11
,
max
=
11
,
message
=
"参数account长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@Length
(
min
=
11
,
max
=
11
,
message
=
"参数account长度不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorRegister
.
class
})
@NotBlank
(
message
=
"参数account不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
private
String
account
;
/**
...
...
src/main/java/com/esv/freight/customer/module/driver/service/DriverAccountService.java
View file @
0a48f425
...
...
@@ -69,5 +69,14 @@ public interface DriverAccountService extends IService<DriverAccountEntity> {
**/
Integer
unblockDriver
(
Long
id
);
/**
* description 注册司机
* param [form]
* return java.lang.Long
* author Administrator
* createTime 2020/04/29 10:43
**/
Long
registerDriver
(
DriverInfoForm
form
);
}
src/main/java/com/esv/freight/customer/module/driver/service/impl/DriverAccountServiceImpl.java
View file @
0a48f425
...
...
@@ -7,6 +7,8 @@ import com.esv.freight.customer.common.component.ErrorMessageComponent;
import
com.esv.freight.customer.common.component.PasswordComponent
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.util.ReqUtils
;
import
com.esv.freight.customer.module.carrier.entity.CarrierAccountEntity
;
import
com.esv.freight.customer.module.carrier.service.CarrierAccountService
;
import
com.esv.freight.customer.module.driver.DriverConstants
;
import
com.esv.freight.customer.module.driver.dao.DriverAccountDao
;
import
com.esv.freight.customer.module.driver.dto.DriverDetailDto
;
...
...
@@ -36,13 +38,17 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv
private
DriverAuditHistoryService
driverAuditHistoryService
;
private
CarrierAccountService
carrierAccountService
;
@Autowired
public
DriverAccountServiceImpl
(
ErrorMessageComponent
errorMessageComponent
,
PasswordComponent
passwordComponent
,
DriverInfoService
driverInfoService
,
DriverAuditHistoryService
driverAuditHistoryService
)
{
DriverInfoService
driverInfoService
,
DriverAuditHistoryService
driverAuditHistoryService
,
CarrierAccountService
carrierAccountService
)
{
this
.
errorMessageComponent
=
errorMessageComponent
;
this
.
passwordComponent
=
passwordComponent
;
this
.
driverInfoService
=
driverInfoService
;
this
.
driverAuditHistoryService
=
driverAuditHistoryService
;
this
.
carrierAccountService
=
carrierAccountService
;
}
@Override
...
...
@@ -75,6 +81,11 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv
throw
new
EException
(
1004
,
errorMessageComponent
.
getCarrierDriverAdd1004
());
}
}
// 1.5:校验承运商帐号ID是否有效
CarrierAccountEntity
carrierAccountEntity
=
this
.
carrierAccountService
.
getCarrierById
(
form
.
getCarrierId
());
if
(
null
==
carrierAccountEntity
)
{
throw
new
EException
(
1005
,
errorMessageComponent
.
getCarrierDriverAdd1005
());
}
// 2:新增司机帐号
DriverAccountEntity
driverAccountEntity
=
new
DriverAccountEntity
();
...
...
@@ -229,4 +240,50 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv
driverAccountEntity
.
setAccountStatus
(
DriverConstants
.
ACCOUNT_STATUS_UNBLOCK
);
return
this
.
baseMapper
.
updateById
(
driverAccountEntity
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Long
registerDriver
(
DriverInfoForm
form
)
{
// 1:校验账号是否已存在
Integer
count
=
this
.
baseMapper
.
selectCount
(
new
QueryWrapper
<
DriverAccountEntity
>().
lambda
()
.
eq
(
DriverAccountEntity:
:
getAccount
,
form
.
getAccount
()));
if
(
0
<
count
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getCarrierDriverRegister1001
());
}
// 2:校验承运商帐号ID是否有效
CarrierAccountEntity
carrierAccountEntity
=
this
.
carrierAccountService
.
getCarrierById
(
form
.
getCarrierId
());
if
(
null
==
carrierAccountEntity
)
{
throw
new
EException
(
1002
,
errorMessageComponent
.
getCarrierDriverRegister1002
());
}
// 3:新增司机帐号
DriverAccountEntity
driverAccountEntity
=
new
DriverAccountEntity
();
driverAccountEntity
.
setAccount
(
form
.
getAccount
());
driverAccountEntity
.
setCarrierId
(
form
.
getCarrierId
());
driverAccountEntity
.
setSalt
(
passwordComponent
.
generateAccountPwdSalt
());
driverAccountEntity
.
setAccountStatus
(
DriverConstants
.
ACCOUNT_STATUS_BLOCK
);
driverAccountEntity
.
setSourceType
(
DriverConstants
.
ACCOUNT_SOURCE_TYPE_REGISTER
);
driverAccountEntity
.
setAuthenticateStatus
(
DriverConstants
.
ACCOUNT_AUTHENTICATE_STATUS_NO
);
driverAccountEntity
.
setAuditStatus
(
DriverConstants
.
ACCOUNT_AUDIT_STATUS_UNAUDITED
);
this
.
baseMapper
.
insert
(
driverAccountEntity
);
Long
driverId
=
driverAccountEntity
.
getId
();
// 4:新增司机信息
DriverInfoEntity
driverInfoEntity
=
new
DriverInfoEntity
();
driverInfoEntity
.
setDriverId
(
driverId
);
driverInfoEntity
.
setCarrierId
(
form
.
getCarrierId
());
this
.
driverInfoService
.
getBaseMapper
().
insert
(
driverInfoEntity
);
// 5:新增审核记录
DriverAuditHistoryEntity
driverAuditHistoryEntity
=
new
DriverAuditHistoryEntity
();
driverAuditHistoryEntity
.
setCarrierId
(
form
.
getCarrierId
());
driverAuditHistoryEntity
.
setDriverId
(
driverId
);
driverAuditHistoryEntity
.
setAuditStatus
(
DriverConstants
.
ACCOUNT_AUDIT_STATUS_UNAUDITED
);
driverAuditHistoryEntity
.
setRemark
(
"用户通过终端APP注册帐号"
);
driverAuditHistoryEntity
.
setOperateUser
(
ReqUtils
.
getRequestUserAccount
());
this
.
driverAuditHistoryService
.
getBaseMapper
().
insert
(
driverAuditHistoryEntity
);
return
driverId
;
}
}
\ No newline at end of file
src/main/java/com/esv/freight/customer/module/driver/validator/groups/ValidatorRegister.java
0 → 100644
View file @
0a48f425
package
com
.
esv
.
freight
.
customer
.
module
.
driver
.
validator
.
groups
;
import
javax.validation.groups.Default
;
/**
* @description: 参数校验分组:注册
* @project: SpringCloudTemplate
* @name: com.esv.freight.customer.module.driver.validator.groups.ValidatorRegister
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/03/12 17:58
* @version:1.0
*/
public
interface
ValidatorRegister
extends
Default
{
}
src/main/resources/application-dev.yml
View file @
0a48f425
...
...
@@ -150,6 +150,7 @@ error-message:
1002
:
身份证号码已存在
1003
:
驾驶证号码已存在
1004
:
从业资格证号已存在
1005
:
无效的承运商ID
edit
:
1001
:
无效的账号ID
1002
:
身份证号码已存在
...
...
@@ -165,4 +166,7 @@ error-message:
1002
:
帐号已停用
unblock
:
1001
:
无效的账号ID
1002
:
帐号已启用
\ No newline at end of file
1002
:
帐号已启用
register
:
1001
:
帐号已存在
1002
:
无效的承运商ID
\ No newline at end of file
src/test/java/com/esv/freight/customer/module/driver/controller/DriverAccountAddTest.java
View file @
0a48f425
...
...
@@ -430,4 +430,58 @@ public class DriverAccountAddTest extends BaseTestController {
JSONObject
result
=
JSONObject
.
parseObject
(
responseStr
);
Assert
.
assertEquals
(
ECode
.
PARAM_ERROR
.
code
(),
result
.
getIntValue
(
"code"
));
}
/**
* 新增司机:无效的承运商ID
**/
@Test
@Rollback
public
void
a8_add_vehicle_wrong_carrierId_failure_test
()
throws
Exception
{
String
url
=
"/carrier/driver/add"
;
// 构造数据
DriverInfoForm
form
=
new
DriverInfoForm
();
form
.
setCarrierId
(
99999L
);
form
.
setAccount
(
"18512340013"
);
form
.
setPassword
(
"e10adc3949ba59abbe56e057f20f883e"
);
form
.
setName
(
"路上跳"
);
form
.
setIdCard
(
"210104198106036252"
);
form
.
setIdCardExpireDate
(
"2030/10/31"
);
form
.
setIdCardFrontUrl
(
"http://127.0.0.1/id_card_front_url_18512340012.jpg"
);
form
.
setIdCardBackUrl
(
"http://127.0.0.1/id_card_back_url_18512340012.jpg"
);
form
.
setSettlementType
(
1
);
// 结算对象(字典表):1-个人、2-所属承运商
form
.
setSex
(
1
);
// 性别(字典表):1-男、2-女、3-未知
form
.
setBirthDate
(
"1981/6/3"
);
form
.
setNation
(
"满族"
);
form
.
setNativePlace
(
"辽宁沈阳"
);
form
.
setProvinceCode
(
"210000"
);
form
.
setCityCode
(
"210100"
);
form
.
setDistrictCode
(
"210103"
);
form
.
setDetailAddress
(
"青年大街245号河畔花园1-1"
);
form
.
setDrivingLicense
(
"210104198106036252"
);
form
.
setDrivingLicenseType
(
7
);
// 驾驶证类型(字典表):1-A1、2-A2、3-A3、4-A1A2、5-A2E、6-A2D、7-B1、8-B2、9-C1、0-其他
form
.
setDrivingLicenseStartDate
(
"2015/8/1"
);
form
.
setDrivingLicenseEndDate
(
"2021/7/30"
);
form
.
setDrivingLicenseIssueDepartment
(
"沈阳市公安局交通警察支队大东分局"
);
form
.
setDrivingLicenseInitDate
(
"2015/8/1"
);
form
.
setDrivingLicenseUrl
(
"http://127.0.0.1/driving_license_url_18512340013.jpg"
);
form
.
setCertificateVehicle
(
DriverConstants
.
ACCOUNT_DRIVING_VEHICLE_TYPE_1
);
// 道路运输从业资格证-所驾驶车辆(字典表):1-4.5吨及以下、2-4.5吨以上
form
.
setRemark
(
"测试数据"
);
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
(
1005
,
result
.
getIntValue
(
"code"
));
}
}
src/test/java/com/esv/freight/customer/module/driver/controller/DriverAccountTest.java
View file @
0a48f425
...
...
@@ -5,6 +5,7 @@ import com.esv.freight.customer.BaseTestController;
import
com.esv.freight.customer.common.response.ECode
;
import
com.esv.freight.customer.module.driver.DriverConstants
;
import
com.esv.freight.customer.module.driver.form.DriverAuditForm
;
import
com.esv.freight.customer.module.driver.form.DriverInfoForm
;
import
com.esv.freight.customer.module.driver.form.DriverQueryForm
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Assert
;
...
...
@@ -388,4 +389,96 @@ public class DriverAccountTest extends BaseTestController {
JSONObject
result
=
JSONObject
.
parseObject
(
responseStr
);
Assert
.
assertEquals
(
1002
,
result
.
getIntValue
(
"code"
));
}
/**
* 注册司机
**/
@Test
// @Rollback
public
void
d1_register_success_test
()
throws
Exception
{
String
url
=
"/carrier/driver/register"
;
// 构造数据
DriverInfoForm
form
=
new
DriverInfoForm
();
form
.
setAccount
(
"18512341001"
);
form
.
setCarrierId
(
1L
);
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
d2_register_wrong_account_failure_test
()
throws
Exception
{
String
url
=
"/carrier/driver/register"
;
// 构造数据
DriverInfoForm
form
=
new
DriverInfoForm
();
form
.
setAccount
(
"18512341001"
);
form
.
setCarrierId
(
1L
);
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
d3_register_wrong_CarrierId_failure_test
()
throws
Exception
{
String
url
=
"/carrier/driver/register"
;
// 构造数据
DriverInfoForm
form
=
new
DriverInfoForm
();
form
.
setAccount
(
"18512341002"
);
form
.
setCarrierId
(
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
(
1002
,
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