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
d4857259
Commit
d4857259
authored
Apr 29, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
承运商接口:停用/启用司机帐号
parent
0c42c276
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
278 additions
and
2 deletions
+278
-2
ErrorMessageComponent.java
...ight/customer/common/component/ErrorMessageComponent.java
+10
-0
DriverController.java
...t/customer/module/driver/controller/DriverController.java
+28
-1
DriverAccountService.java
.../customer/module/driver/service/DriverAccountService.java
+18
-0
DriverAccountServiceImpl.java
.../module/driver/service/impl/DriverAccountServiceImpl.java
+39
-0
application-dev.yml
src/main/resources/application-dev.yml
+7
-1
DriverAccountTest.java
.../customer/module/driver/controller/DriverAccountTest.java
+176
-0
No files found.
src/main/java/com/esv/freight/customer/common/component/ErrorMessageComponent.java
View file @
d4857259
...
@@ -193,4 +193,14 @@ public class ErrorMessageComponent {
...
@@ -193,4 +193,14 @@ public class ErrorMessageComponent {
private
String
carrierDriverAudit1001
;
private
String
carrierDriverAudit1001
;
@Value
(
"${error-message.carrier.driver.audit.1002}"
)
@Value
(
"${error-message.carrier.driver.audit.1002}"
)
private
String
carrierDriverAudit1002
;
private
String
carrierDriverAudit1002
;
@Value
(
"${error-message.carrier.driver.block.1001}"
)
private
String
carrierDriverBlock1001
;
@Value
(
"${error-message.carrier.driver.block.1002}"
)
private
String
carrierDriverBlock1002
;
@Value
(
"${error-message.carrier.driver.unblock.1001}"
)
private
String
carrierDriverUnblock1001
;
@Value
(
"${error-message.carrier.driver.unblock.1002}"
)
private
String
carrierDriverUnblock1002
;
}
}
src/main/java/com/esv/freight/customer/module/driver/controller/DriverController.java
View file @
d4857259
...
@@ -143,5 +143,32 @@ public class DriverController {
...
@@ -143,5 +143,32 @@ public class DriverController {
return
EResponse
.
ok
();
return
EResponse
.
ok
();
}
}
/**
* description 停用帐号
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/29 10:10
**/
@PostMapping
(
"/block"
)
public
EResponse
block
(
@RequestBody
@Validated
(
ValidatorDetail
.
class
)
DriverQueryForm
form
)
throws
EException
{
driverAccountService
.
blockDriver
(
form
.
getId
());
return
EResponse
.
ok
();
}
/**
* description 停用帐号
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/29 10:10
**/
@PostMapping
(
"/unblock"
)
public
EResponse
unblock
(
@RequestBody
@Validated
(
ValidatorDetail
.
class
)
DriverQueryForm
form
)
throws
EException
{
driverAccountService
.
unblockDriver
(
form
.
getId
());
return
EResponse
.
ok
();
}
}
}
src/main/java/com/esv/freight/customer/module/driver/service/DriverAccountService.java
View file @
d4857259
...
@@ -51,5 +51,23 @@ public interface DriverAccountService extends IService<DriverAccountEntity> {
...
@@ -51,5 +51,23 @@ public interface DriverAccountService extends IService<DriverAccountEntity> {
**/
**/
Integer
auditDriver
(
DriverAuditForm
form
);
Integer
auditDriver
(
DriverAuditForm
form
);
/**
* description 停用司机帐号
* param [id]
* return java.lang.Integer
* author Administrator
* createTime 2020/04/29 10:03
**/
Integer
blockDriver
(
Long
id
);
/**
* description 启用司机帐号
* param [id]
* return java.lang.Integer
* author Administrator
* createTime 2020/04/29 10:08
**/
Integer
unblockDriver
(
Long
id
);
}
}
src/main/java/com/esv/freight/customer/module/driver/service/impl/DriverAccountServiceImpl.java
View file @
d4857259
...
@@ -163,6 +163,7 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv
...
@@ -163,6 +163,7 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv
}
}
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Integer
auditDriver
(
DriverAuditForm
form
)
{
public
Integer
auditDriver
(
DriverAuditForm
form
)
{
// 1:校验帐号ID是否有效
// 1:校验帐号ID是否有效
DriverAccountEntity
accountEntity
=
this
.
baseMapper
.
selectById
(
form
.
getId
());
DriverAccountEntity
accountEntity
=
this
.
baseMapper
.
selectById
(
form
.
getId
());
...
@@ -190,4 +191,42 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv
...
@@ -190,4 +191,42 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv
return
flag
;
return
flag
;
}
}
@Override
public
Integer
blockDriver
(
Long
id
)
{
// 1:校验帐号ID是否有效
DriverAccountEntity
accountEntity
=
this
.
baseMapper
.
selectById
(
id
);
if
(
null
==
accountEntity
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getCarrierDriverBlock1001
());
}
// 2:校验帐号是否已停用
if
(
DriverConstants
.
ACCOUNT_STATUS_BLOCK
.
equals
(
accountEntity
.
getAccountStatus
()))
{
throw
new
EException
(
1002
,
errorMessageComponent
.
getCarrierDriverBlock1002
());
}
// 3:停用帐号
DriverAccountEntity
driverAccountEntity
=
new
DriverAccountEntity
();
driverAccountEntity
.
setId
(
id
);
driverAccountEntity
.
setAccountStatus
(
DriverConstants
.
ACCOUNT_STATUS_BLOCK
);
return
this
.
baseMapper
.
updateById
(
driverAccountEntity
);
}
@Override
public
Integer
unblockDriver
(
Long
id
)
{
// 1:校验帐号ID是否有效
DriverAccountEntity
accountEntity
=
this
.
baseMapper
.
selectById
(
id
);
if
(
null
==
accountEntity
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getCarrierDriverUnblock1001
());
}
// 2:校验帐号是否已启用
if
(
DriverConstants
.
ACCOUNT_STATUS_UNBLOCK
.
equals
(
accountEntity
.
getAccountStatus
()))
{
throw
new
EException
(
1002
,
errorMessageComponent
.
getCarrierDriverUnblock1002
());
}
// 3:启用帐号
DriverAccountEntity
driverAccountEntity
=
new
DriverAccountEntity
();
driverAccountEntity
.
setId
(
id
);
driverAccountEntity
.
setAccountStatus
(
DriverConstants
.
ACCOUNT_STATUS_UNBLOCK
);
return
this
.
baseMapper
.
updateById
(
driverAccountEntity
);
}
}
}
\ No newline at end of file
src/main/resources/application-dev.yml
View file @
d4857259
...
@@ -159,4 +159,10 @@ error-message:
...
@@ -159,4 +159,10 @@ error-message:
1001
:
无效的账号ID
1001
:
无效的账号ID
audit
:
audit
:
1001
:
无效的账号ID
1001
:
无效的账号ID
1002
:
帐号已审核通过
1002
:
帐号已审核通过
\ No newline at end of file
block
:
1001
:
无效的账号ID
1002
:
帐号已停用
unblock
:
1001
:
无效的账号ID
1002
:
帐号已启用
\ No newline at end of file
src/test/java/com/esv/freight/customer/module/driver/controller/DriverAccountTest.java
View file @
d4857259
...
@@ -159,6 +159,7 @@ public class DriverAccountTest extends BaseTestController {
...
@@ -159,6 +159,7 @@ public class DriverAccountTest extends BaseTestController {
* 审核司机信息:无效的帐号ID
* 审核司机信息:无效的帐号ID
**/
**/
@Test
@Test
@Rollback
public
void
b3_audit_wrong_id_failure_test
()
throws
Exception
{
public
void
b3_audit_wrong_id_failure_test
()
throws
Exception
{
String
url
=
"/carrier/driver/audit"
;
String
url
=
"/carrier/driver/audit"
;
...
@@ -188,6 +189,7 @@ public class DriverAccountTest extends BaseTestController {
...
@@ -188,6 +189,7 @@ public class DriverAccountTest extends BaseTestController {
* 审核司机信息:无帐号已审核通过
* 审核司机信息:无帐号已审核通过
**/
**/
@Test
@Test
@Rollback
public
void
b4_audit_has_passed_failure_test
()
throws
Exception
{
public
void
b4_audit_has_passed_failure_test
()
throws
Exception
{
String
url
=
"/carrier/driver/audit"
;
String
url
=
"/carrier/driver/audit"
;
...
@@ -212,4 +214,178 @@ public class DriverAccountTest extends BaseTestController {
...
@@ -212,4 +214,178 @@ public class DriverAccountTest extends BaseTestController {
JSONObject
result
=
JSONObject
.
parseObject
(
responseStr
);
JSONObject
result
=
JSONObject
.
parseObject
(
responseStr
);
Assert
.
assertEquals
(
1002
,
result
.
getIntValue
(
"code"
));
Assert
.
assertEquals
(
1002
,
result
.
getIntValue
(
"code"
));
}
}
/**
* 停用司机帐号
**/
@Test
@Rollback
public
void
c1_block_success_test
()
throws
Exception
{
String
url
=
"/carrier/driver/block"
;
// 构造数据
DriverQueryForm
form
=
new
DriverQueryForm
();
form
.
setId
(
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"
));
}
/**
* 停用司机帐号:无效的帐号ID
**/
@Test
@Rollback
public
void
c2_block_wrong_id_failure_test
()
throws
Exception
{
String
url
=
"/carrier/driver/block"
;
// 构造数据
DriverQueryForm
form
=
new
DriverQueryForm
();
form
.
setId
(
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
(
1001
,
result
.
getIntValue
(
"code"
));
}
/**
* 停用司机帐号:帐号已停用
**/
@Test
@Rollback
public
void
c3_block_has_block_failure_test
()
throws
Exception
{
String
url
=
"/carrier/driver/block"
;
// 构造数据
DriverQueryForm
form
=
new
DriverQueryForm
();
form
.
setId
(
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
(
1002
,
result
.
getIntValue
(
"code"
));
}
/**
* 启用司机帐号
**/
@Test
@Rollback
public
void
d1_unblock_success_test
()
throws
Exception
{
String
url
=
"/carrier/driver/unblock"
;
// 构造数据
DriverQueryForm
form
=
new
DriverQueryForm
();
form
.
setId
(
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"
));
}
/**
* 启用司机帐号:无效的帐号ID
**/
@Test
@Rollback
public
void
d2_unblock_wrong_id_failure_test
()
throws
Exception
{
String
url
=
"/carrier/driver/unblock"
;
// 构造数据
DriverQueryForm
form
=
new
DriverQueryForm
();
form
.
setId
(
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
(
1001
,
result
.
getIntValue
(
"code"
));
}
/**
* 启用司机帐号:帐号已启用
**/
@Test
@Rollback
public
void
d3_unblock_has_unblock_failure_test
()
throws
Exception
{
String
url
=
"/carrier/driver/unblock"
;
// 构造数据
DriverQueryForm
form
=
new
DriverQueryForm
();
form
.
setId
(
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
(
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