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
1368af06
Commit
1368af06
authored
Apr 30, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
承运商接口:司机帐号密码校验
parent
e1efd106
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
241 additions
and
18 deletions
+241
-18
ErrorMessageComponent.java
...ight/customer/common/component/ErrorMessageComponent.java
+5
-0
DriverController.java
...t/customer/module/driver/controller/DriverController.java
+61
-3
DriverAccountDao.java
.../freight/customer/module/driver/dao/DriverAccountDao.java
+11
-2
DriverInfoForm.java
...v/freight/customer/module/driver/form/DriverInfoForm.java
+5
-4
DriverQueryForm.java
.../freight/customer/module/driver/form/DriverQueryForm.java
+2
-1
DriverAccountService.java
.../customer/module/driver/service/DriverAccountService.java
+20
-2
DriverAccountServiceImpl.java
.../module/driver/service/impl/DriverAccountServiceImpl.java
+12
-4
ValidatorDetailAccount.java
...odule/driver/validator/groups/ValidatorDetailAccount.java
+15
-0
ValidatorLogin.java
...stomer/module/driver/validator/groups/ValidatorLogin.java
+15
-0
application-dev.yml
src/main/resources/application-dev.yml
+4
-1
DriverAccountDao.xml
src/main/resources/mapper/driver/DriverAccountDao.xml
+10
-1
DriverAccountTest.java
.../customer/module/driver/controller/DriverAccountTest.java
+81
-0
No files found.
src/main/java/com/esv/freight/customer/common/component/ErrorMessageComponent.java
View file @
1368af06
...
...
@@ -244,4 +244,9 @@ public class ErrorMessageComponent {
private
String
carrierDriverVehicleUnbind1020
;
@Value
(
"${error-message.carrier.driver.vehicle-unbind.1021}"
)
private
String
carrierDriverVehicleUnbind1021
;
@Value
(
"${error-message.carrier.driver.account-check.1001}"
)
private
String
carrierDriverAccountCheck1001
;
@Value
(
"${error-message.carrier.driver.account-check.1002}"
)
private
String
carrierDriverAccountCheck1002
;
}
src/main/java/com/esv/freight/customer/module/driver/controller/DriverController.java
View file @
1368af06
...
...
@@ -2,6 +2,7 @@ package com.esv.freight.customer.module.driver.controller;
import
com.alibaba.fastjson.JSONObject
;
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.response.ECode
;
import
com.esv.freight.customer.common.response.EResponse
;
...
...
@@ -18,6 +19,8 @@ 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.ValidatorDetailAccount
;
import
com.esv.freight.customer.module.driver.validator.groups.ValidatorLogin
;
import
com.esv.freight.customer.module.driver.validator.groups.ValidatorRegister
;
import
com.esv.freight.customer.module.driver.vo.DriverAuditHistoryVO
;
import
com.esv.freight.customer.module.driver.vo.DriverDetailVO
;
...
...
@@ -51,11 +54,15 @@ public class DriverController {
private
ErrorMessageComponent
errorMessageComponent
;
private
PasswordComponent
passwordComponent
;
private
DriverAccountService
driverAccountService
;
@Autowired
public
DriverController
(
ErrorMessageComponent
errorMessageComponent
,
DriverAccountService
driverAccountService
)
{
public
DriverController
(
ErrorMessageComponent
errorMessageComponent
,
PasswordComponent
passwordComponent
,
DriverAccountService
driverAccountService
)
{
this
.
errorMessageComponent
=
errorMessageComponent
;
this
.
passwordComponent
=
passwordComponent
;
this
.
driverAccountService
=
driverAccountService
;
}
...
...
@@ -112,7 +119,7 @@ public class DriverController {
}
/**
* description 查询司机详情
* description 查询司机详情
-通过ID
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
...
...
@@ -120,7 +127,29 @@ public class DriverController {
**/
@PostMapping
(
"/detail"
)
public
EResponse
detail
(
@RequestBody
@Validated
(
ValidatorDetail
.
class
)
DriverQueryForm
form
)
throws
EException
{
DriverDetailDto
dto
=
driverAccountService
.
getDriverDetail
(
form
.
getId
());
DriverDetailDto
dto
=
driverAccountService
.
getDriverDetailById
(
form
.
getId
());
if
(
null
==
dto
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getCarrierDriverDetail1001
());
}
// 数据转换
DriverDetailVO
vo
=
new
DriverDetailVO
();
BeanUtils
.
copyProperties
(
dto
,
vo
);
vo
.
setCreateTime
(
dto
.
getCreateTime
().
getTime
());
return
EResponse
.
ok
(
vo
);
}
/**
* description 查询司机详情-通过帐号
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/28 20:26
**/
@PostMapping
(
"/detailByAccount"
)
public
EResponse
detailByAccount
(
@RequestBody
@Validated
(
ValidatorDetailAccount
.
class
)
DriverQueryForm
form
)
throws
EException
{
DriverDetailDto
dto
=
driverAccountService
.
getDriverDetailByAccount
(
form
.
getAccount
());
if
(
null
==
dto
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getCarrierDriverDetail1001
());
}
...
...
@@ -229,4 +258,33 @@ public class DriverController {
public
EResponse
list
(
@RequestBody
@Validated
(
ValidatorList
.
class
)
DriverQueryForm
form
)
throws
EException
{
return
EResponse
.
ok
(
driverAccountService
.
getDriver4Page
(
form
));
}
/**
* description 帐号密码校验
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/30 11:14
**/
@PostMapping
(
"/account/check"
)
public
EResponse
accountCheck
(
@RequestBody
@Validated
(
ValidatorLogin
.
class
)
DriverInfoForm
form
)
throws
EException
{
// 查询司机详情-通过帐号
DriverDetailDto
dto
=
driverAccountService
.
getDriverDetailByAccount
(
form
.
getAccount
());
// 校验
if
(
null
==
dto
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getCarrierDriverAccountCheck1001
());
}
String
password
=
passwordComponent
.
generatePwd4Salt
(
form
.
getPassword
(),
dto
.
getSalt
());
if
(!
password
.
equals
(
dto
.
getPassword
()))
{
throw
new
EException
(
1002
,
errorMessageComponent
.
getCarrierDriverAccountCheck1002
());
}
// 数据转换
DriverDetailVO
vo
=
new
DriverDetailVO
();
BeanUtils
.
copyProperties
(
dto
,
vo
);
vo
.
setCreateTime
(
dto
.
getCreateTime
().
getTime
());
return
EResponse
.
ok
(
vo
);
}
}
src/main/java/com/esv/freight/customer/module/driver/dao/DriverAccountDao.java
View file @
1368af06
...
...
@@ -19,13 +19,22 @@ import org.apache.ibatis.annotations.Mapper;
public
interface
DriverAccountDao
extends
BaseMapper
<
DriverAccountEntity
>
{
/**
* description 查询司机详情
* description 查询司机详情
-通过ID
* param [id]
* return com.esv.freight.customer.module.driver.dto.DriverDetailDto
* author Administrator
* createTime 2020/04/28 20:21
**/
DriverDetailDto
selectDriverDetail
(
Long
id
);
DriverDetailDto
selectDetailById
(
Long
id
);
/**
* description 查询司机详情-通过帐号
* param [account]
* return com.esv.freight.customer.module.driver.dto.DriverDetailDto
* author Administrator
* createTime 2020/04/30 11:24
**/
DriverDetailDto
selectDetailByAccount
(
String
account
);
/**
* description 分页查询司机列表
...
...
src/main/java/com/esv/freight/customer/module/driver/form/DriverInfoForm.java
View file @
1368af06
...
...
@@ -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.ValidatorLogin
;
import
com.esv.freight.customer.module.driver.validator.groups.ValidatorRegister
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
...
...
@@ -37,14 +38,14 @@ public class DriverInfoForm {
/**
* 登录帐号,司机手机号
*/
@Length
(
min
=
11
,
max
=
11
,
message
=
"参数account长度不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorRegister
.
class
})
@NotBlank
(
message
=
"参数account不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
@Length
(
min
=
11
,
max
=
11
,
message
=
"参数account长度不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorRegister
.
class
,
ValidatorLogin
.
class
})
@NotBlank
(
message
=
"参数account不能为空"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorLogin
.
class
})
private
String
account
;
/**
* 密码
*/
@Length
(
min
=
32
,
max
=
32
,
message
=
"参数password长度不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorUpdate
.
class
})
@NotBlank
(
message
=
"参数password不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
@Length
(
min
=
32
,
max
=
32
,
message
=
"参数password长度不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorUpdate
.
class
,
ValidatorLogin
.
class
})
@NotBlank
(
message
=
"参数password不能为空"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorLogin
.
class
})
private
String
password
;
/**
* 帐号状态:1-正常、2-停用
...
...
src/main/java/com/esv/freight/customer/module/driver/form/DriverQueryForm.java
View file @
1368af06
...
...
@@ -2,6 +2,7 @@ package com.esv.freight.customer.module.driver.form;
import
com.esv.freight.customer.common.validator.groups.ValidatorDetail
;
import
com.esv.freight.customer.common.validator.groups.ValidatorList
;
import
com.esv.freight.customer.module.driver.validator.groups.ValidatorDetailAccount
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
...
...
@@ -54,7 +55,7 @@ public class DriverQueryForm {
/**
* 登录帐号,司机手机号
*/
@Length
(
max
=
11
,
message
=
"参数account长度不合法"
,
groups
=
{
ValidatorList
.
class
})
@Length
(
max
=
11
,
message
=
"参数account长度不合法"
,
groups
=
{
ValidatorList
.
class
,
ValidatorDetailAccount
.
class
})
private
String
account
;
/**
* keywords
...
...
src/main/java/com/esv/freight/customer/module/driver/service/DriverAccountService.java
View file @
1368af06
...
...
@@ -39,13 +39,22 @@ public interface DriverAccountService extends IService<DriverAccountEntity> {
Integer
updateDriver
(
DriverInfoForm
form
);
/**
* description 查询司机详情
* description 查询司机详情
-通过ID
* param [id]
* return com.esv.freight.customer.module.driver.dto.DriverDetailDto
* author Administrator
* createTime 2020/04/28 20:22
**/
DriverDetailDto
getDriverDetail
(
Long
id
);
DriverDetailDto
getDriverDetailById
(
Long
id
);
/**
* description 查询司机详情-通过帐号
* param [account]
* return com.esv.freight.customer.module.driver.dto.DriverDetailDto
* author Administrator
* createTime 2020/04/30 11:30
**/
DriverDetailDto
getDriverDetailByAccount
(
String
account
);
/**
* description 审核司机信息
...
...
@@ -101,5 +110,14 @@ public interface DriverAccountService extends IService<DriverAccountEntity> {
**/
PageResultVO
getDriver4Page
(
DriverQueryForm
queryObj
);
/**
* description 帐号密码校验
* param [form]
* return com.esv.freight.customer.module.driver.dto.DriverDetailDto
* author Administrator
* createTime 2020/04/30 11:21
**/
DriverDetailDto
checkAccount
(
DriverInfoForm
form
);
}
src/main/java/com/esv/freight/customer/module/driver/service/impl/DriverAccountServiceImpl.java
View file @
1368af06
...
...
@@ -11,10 +11,8 @@ import com.esv.freight.customer.common.exception.EException;
import
com.esv.freight.customer.common.util.ReqUtils
;
import
com.esv.freight.customer.common.vo.PageResultVO
;
import
com.esv.freight.customer.module.carrier.CarrierConstants
;
import
com.esv.freight.customer.module.carrier.dto.CarrierInfoDto
;
import
com.esv.freight.customer.module.carrier.entity.CarrierAccountEntity
;
import
com.esv.freight.customer.module.carrier.service.CarrierAccountService
;
import
com.esv.freight.customer.module.carrier.vo.CarrierInfoListVO
;
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
;
...
...
@@ -179,8 +177,13 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv
}
@Override
public
DriverDetailDto
getDriverDetail
(
Long
id
)
{
return
this
.
baseMapper
.
selectDriverDetail
(
id
);
public
DriverDetailDto
getDriverDetailById
(
Long
id
)
{
return
this
.
baseMapper
.
selectDetailById
(
id
);
}
@Override
public
DriverDetailDto
getDriverDetailByAccount
(
String
account
)
{
return
this
.
baseMapper
.
selectDetailByAccount
(
account
);
}
@Override
...
...
@@ -329,4 +332,9 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv
return
new
PageResultVO
(
page
,
targetRecordList
);
}
@Override
public
DriverDetailDto
checkAccount
(
DriverInfoForm
form
)
{
return
null
;
}
}
\ No newline at end of file
src/main/java/com/esv/freight/customer/module/driver/validator/groups/ValidatorDetailAccount.java
0 → 100644
View file @
1368af06
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.ValidatorDetailAccount
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/03/12 17:58
* @version:1.0
*/
public
interface
ValidatorDetailAccount
extends
Default
{
}
src/main/java/com/esv/freight/customer/module/driver/validator/groups/ValidatorLogin.java
0 → 100644
View file @
1368af06
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.ValidatorLogin
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/03/12 17:58
* @version:1.0
*/
public
interface
ValidatorLogin
extends
Default
{
}
src/main/resources/application-dev.yml
View file @
1368af06
...
...
@@ -188,4 +188,7 @@ error-message:
1001
:
无效的司机ID
1010
:
无效的车辆ID
1020
:
车辆与司机未绑定
1021
:
司机自主绑定的车辆,平台不可解绑
\ No newline at end of file
1021
:
司机自主绑定的车辆,平台不可解绑
account-check
:
1001
:
无效的手机号
1002
:
密码错误
\ No newline at end of file
src/main/resources/mapper/driver/DriverAccountDao.xml
View file @
1368af06
...
...
@@ -24,7 +24,7 @@
</resultMap>
<!-- 查询司机详情 -->
<select
id=
"selectD
riverDetail
"
parameterType=
"java.lang.Long"
resultType=
"com.esv.freight.customer.module.driver.dto.DriverDetailDto"
>
<select
id=
"selectD
etailById
"
parameterType=
"java.lang.Long"
resultType=
"com.esv.freight.customer.module.driver.dto.DriverDetailDto"
>
select a.*, b.name, b.id_card, b.id_card_expire_date, b.id_card_front_url, b.id_card_back_url, b.settlement_type, b.sex, b.birth_date,
b.nation, b.native_place, b.province_code, b.city_code, b.district_code, b.detail_address, b.driving_license, b.driving_license_type,
b.driving_license_start_date, b.driving_license_end_date, b.driving_license_issue_department, b.driving_license_init_date, b.driving_license_url,
...
...
@@ -33,6 +33,15 @@
where a.id = b.driver_id and a.id = #{id}
</select>
<select
id=
"selectDetailByAccount"
parameterType=
"java.lang.String"
resultType=
"com.esv.freight.customer.module.driver.dto.DriverDetailDto"
>
select a.*, b.name, b.id_card, b.id_card_expire_date, b.id_card_front_url, b.id_card_back_url, b.settlement_type, b.sex, b.birth_date,
b.nation, b.native_place, b.province_code, b.city_code, b.district_code, b.detail_address, b.driving_license, b.driving_license_type,
b.driving_license_start_date, b.driving_license_end_date, b.driving_license_issue_department, b.driving_license_init_date, b.driving_license_url,
b.certificate_vehicle, b.certificate_end_date, b.certificate_number, b.certificate_url, b.remark
from driver_account a, driver_info b
where a.id = b.driver_id and a.account = #{account}
</select>
<!-- 分页查询司机列表 -->
<select
id=
"selectDriver4Page"
parameterType=
"com.esv.freight.customer.module.driver.form.DriverQueryForm"
resultType=
"com.esv.freight.customer.module.driver.dto.DriverDetailDto"
>
...
...
src/test/java/com/esv/freight/customer/module/driver/controller/DriverAccountTest.java
View file @
1368af06
...
...
@@ -562,4 +562,85 @@ public class DriverAccountTest extends BaseTestController {
Assert
.
assertTrue
(
result
.
getJSONObject
(
"data"
).
containsKey
(
"records"
));
}
/**
* 帐号密码校验
**/
@Test
public
void
g1_accountCheck_success_test
()
throws
Exception
{
String
url
=
"/carrier/driver/account/check"
;
// 构造数据
DriverInfoForm
form
=
new
DriverInfoForm
();
form
.
setAccount
(
"18512340001"
);
form
.
setPassword
(
"e10adc3949ba59abbe56e057f20f883e"
);
MvcResult
mvcResult
=
this
.
getMockMvc
().
perform
(
MockMvcRequestBuilders
.
post
(
url
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
.
headers
(
this
.
getDefaultHttpHeaders
())
.
content
(
form
.
toString
()))
.
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
public
void
g2_accountCheck_wrong_account_failure_test
()
throws
Exception
{
String
url
=
"/carrier/driver/account/check"
;
// 构造数据
DriverInfoForm
form
=
new
DriverInfoForm
();
form
.
setAccount
(
"18912340001"
);
form
.
setPassword
(
"e10adc3949ba59abbe56e057f20f883e"
);
MvcResult
mvcResult
=
this
.
getMockMvc
().
perform
(
MockMvcRequestBuilders
.
post
(
url
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
.
headers
(
this
.
getDefaultHttpHeaders
())
.
content
(
form
.
toString
()))
.
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
public
void
g3_accountCheck_wrong_password_failure_test
()
throws
Exception
{
String
url
=
"/carrier/driver/account/check"
;
// 构造数据
DriverInfoForm
form
=
new
DriverInfoForm
();
form
.
setAccount
(
"18512340001"
);
form
.
setPassword
(
"f10adc3949ba59abbe56e057f20f883e"
);
MvcResult
mvcResult
=
this
.
getMockMvc
().
perform
(
MockMvcRequestBuilders
.
post
(
url
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
.
headers
(
this
.
getDefaultHttpHeaders
())
.
content
(
form
.
toString
()))
.
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