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
2299e8be
Commit
2299e8be
authored
May 07, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
承运商接口:查询指定车辆绑定的司机列表
parent
b14c1383
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
225 additions
and
8 deletions
+225
-8
ErrorMessageComponent.java
...ight/customer/common/component/ErrorMessageComponent.java
+5
-0
DriverVehicleController.java
...mer/module/driver/controller/DriverVehicleController.java
+13
-0
DriverVehicleService.java
.../customer/module/driver/service/DriverVehicleService.java
+10
-0
DriverVehicleServiceImpl.java
.../module/driver/service/impl/DriverVehicleServiceImpl.java
+19
-4
VehicleDriverListVO.java
...reight/customer/module/driver/vo/VehicleDriverListVO.java
+48
-0
VehicleDriverDao.java
...freight/customer/module/vehicle/dao/VehicleDriverDao.java
+10
-0
VehicleDriverService.java
...customer/module/vehicle/service/VehicleDriverService.java
+10
-0
VehicleDriverServiceImpl.java
...module/vehicle/service/impl/VehicleDriverServiceImpl.java
+6
-0
application-dev.yml
src/main/resources/application-dev.yml
+3
-0
application-test.yml
src/main/resources/application-test.yml
+3
-0
bootstrap.yml
src/main/resources/bootstrap.yml
+1
-1
VehicleDriverDao.xml
src/main/resources/mapper/vehicle/VehicleDriverDao.xml
+14
-0
DriverVehicleControllerTest.java
...module/driver/controller/DriverVehicleControllerTest.java
+83
-3
No files found.
src/main/java/com/esv/freight/customer/common/component/ErrorMessageComponent.java
View file @
2299e8be
...
...
@@ -222,6 +222,11 @@ public class ErrorMessageComponent {
@Value
(
"${error-message.carrier.driver.vehicle-list.1002}"
)
private
String
carrierDriverVehicleList1002
;
@Value
(
"${error-message.carrier.driver.driver-list.1001}"
)
private
String
carrierDriverDriverList1001
;
@Value
(
"${error-message.carrier.driver.driver-list.1002}"
)
private
String
carrierDriverDriverList1002
;
@Value
(
"${error-message.carrier.driver.vehicle-bind.1001}"
)
private
String
carrierDriverVehicleBind1001
;
@Value
(
"${error-message.carrier.driver.vehicle-bind.1002}"
)
...
...
src/main/java/com/esv/freight/customer/module/driver/controller/DriverVehicleController.java
View file @
2299e8be
...
...
@@ -10,6 +10,7 @@ import com.esv.freight.customer.module.driver.service.DriverVehicleService;
import
com.esv.freight.customer.module.driver.validator.groups.ValidatorBind
;
import
com.esv.freight.customer.module.driver.validator.groups.ValidatorCheckBind
;
import
com.esv.freight.customer.module.driver.validator.groups.ValidatorUnbind
;
import
com.esv.freight.customer.module.vehicle.form.VehicleQueryForm
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
...
...
@@ -52,6 +53,18 @@ public class DriverVehicleController {
return
EResponse
.
ok
(
driverVehicleService
.
getDriverBindVehicleList
(
form
.
getId
()));
}
/**
* description 查询指定车辆绑定的司机列表
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/05/07 16:25
**/
@PostMapping
(
"/listByVehicle"
)
public
EResponse
listByVehicle
(
@RequestBody
@Validated
(
ValidatorDetail
.
class
)
VehicleQueryForm
form
)
throws
EException
{
return
EResponse
.
ok
(
driverVehicleService
.
getVehicleBindDriverList
(
form
.
getId
()));
}
/**
* description 绑定司机与车辆
* param [form]
...
...
src/main/java/com/esv/freight/customer/module/driver/service/DriverVehicleService.java
View file @
2299e8be
...
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.esv.freight.customer.module.driver.form.DriverVehicleForm
;
import
com.esv.freight.customer.module.driver.vo.CarrierDriverVehicleVO
;
import
com.esv.freight.customer.module.driver.vo.DriverVehicleListVO
;
import
com.esv.freight.customer.module.driver.vo.VehicleDriverListVO
;
import
com.esv.freight.customer.module.vehicle.entity.VehicleDriverEntity
;
import
java.util.List
;
...
...
@@ -27,6 +28,15 @@ public interface DriverVehicleService {
* createTime 2020/04/29 16:55
**/
List
<
DriverVehicleListVO
>
getDriverBindVehicleList
(
Long
id
);
/**
* description 获取车辆绑定的司机列表
* param [id]
* return java.util.List<com.esv.freight.customer.module.driver.vo.VehicleDriverListVO>
* author Administrator
* createTime 2020/05/07 16:21
**/
List
<
VehicleDriverListVO
>
getVehicleBindDriverList
(
Long
id
);
/**
* description 绑定司机与车辆
...
...
src/main/java/com/esv/freight/customer/module/driver/service/impl/DriverVehicleServiceImpl.java
View file @
2299e8be
...
...
@@ -13,10 +13,7 @@ import com.esv.freight.customer.module.driver.entity.DriverAccountEntity;
import
com.esv.freight.customer.module.driver.form.DriverVehicleForm
;
import
com.esv.freight.customer.module.driver.service.DriverAccountService
;
import
com.esv.freight.customer.module.driver.service.DriverVehicleService
;
import
com.esv.freight.customer.module.driver.vo.CarrierDriverBindVehicleVO
;
import
com.esv.freight.customer.module.driver.vo.CarrierDriverVehicleVO
;
import
com.esv.freight.customer.module.driver.vo.DriverDetailVO
;
import
com.esv.freight.customer.module.driver.vo.DriverVehicleListVO
;
import
com.esv.freight.customer.module.driver.vo.*
;
import
com.esv.freight.customer.module.vehicle.VehicleConstants
;
import
com.esv.freight.customer.module.vehicle.dto.VehicleDetailDto
;
import
com.esv.freight.customer.module.vehicle.entity.VehicleDriverEntity
;
...
...
@@ -76,6 +73,24 @@ public class DriverVehicleServiceImpl implements DriverVehicleService {
return
voList
;
}
@Override
public
List
<
VehicleDriverListVO
>
getVehicleBindDriverList
(
Long
id
)
{
// 1:校验是否有效车辆ID
int
count
=
this
.
vehicleService
.
getBaseMapper
().
selectCount
(
new
QueryWrapper
<
VehicleEntity
>().
lambda
()
.
eq
(
VehicleEntity:
:
getId
,
id
));
if
(
0
==
count
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getCarrierDriverDriverList1001
());
}
// 2:查询司机绑定的车辆列表
List
<
VehicleDriverListVO
>
voList
=
this
.
vehicleDriverService
.
getVehicleBindDriverList
(
id
);
if
(
0
==
voList
.
size
())
{
throw
new
EException
(
1002
,
errorMessageComponent
.
getCarrierDriverDriverList1002
());
}
return
voList
;
}
@Override
public
Integer
driverBindVehicle
(
DriverVehicleForm
form
)
{
// 1:校验
...
...
src/main/java/com/esv/freight/customer/module/driver/vo/VehicleDriverListVO.java
0 → 100644
View file @
2299e8be
package
com
.
esv
.
freight
.
customer
.
module
.
driver
.
vo
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.driver.vo.VehicleDriverListVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/07 16:02
* @version:1.0
*/
@Data
public
class
VehicleDriverListVO
{
/**
*
*/
private
Long
id
;
/**
* 登录帐号,司机手机号
*/
private
String
account
;
/**
* 姓名
*/
private
String
name
;
/**
* 帐号状态:1-正常、2-停用
*/
private
Integer
accountStatus
;
/**
* 创建来源:1-平台创建、2-自行注册
*/
private
Integer
sourceType
;
/**
* 审核状态(字典表):0-待审核、1-审核成功,2-审核失败
*/
private
Integer
auditStatus
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
}
}
src/main/java/com/esv/freight/customer/module/vehicle/dao/VehicleDriverDao.java
View file @
2299e8be
...
...
@@ -3,6 +3,7 @@ package com.esv.freight.customer.module.vehicle.dao;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.esv.freight.customer.module.driver.dto.DriverVehicleDto
;
import
com.esv.freight.customer.module.driver.vo.DriverVehicleListVO
;
import
com.esv.freight.customer.module.driver.vo.VehicleDriverListVO
;
import
com.esv.freight.customer.module.vehicle.entity.VehicleDriverEntity
;
import
org.apache.ibatis.annotations.Mapper
;
...
...
@@ -27,6 +28,15 @@ public interface VehicleDriverDao extends BaseMapper<VehicleDriverEntity> {
**/
List
<
DriverVehicleListVO
>
selectDriverBindVehicleList
(
Long
driverId
);
/**
* description 查询车辆绑定的司机列表
* param [vehicleId]
* return java.util.List<com.esv.freight.customer.module.driver.vo.VehicleDriverListVO>
* author Administrator
* createTime 2020/05/07 16:15
**/
List
<
VehicleDriverListVO
>
selectVehicleBindDriverList
(
Long
vehicleId
);
/**
* description 查询指定承运商的司机与车辆绑定列表
* param [carrierId]
...
...
src/main/java/com/esv/freight/customer/module/vehicle/service/VehicleDriverService.java
View file @
2299e8be
...
...
@@ -3,6 +3,7 @@ package com.esv.freight.customer.module.vehicle.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.esv.freight.customer.module.driver.dto.DriverVehicleDto
;
import
com.esv.freight.customer.module.driver.vo.DriverVehicleListVO
;
import
com.esv.freight.customer.module.driver.vo.VehicleDriverListVO
;
import
com.esv.freight.customer.module.vehicle.entity.VehicleDriverEntity
;
import
java.util.List
;
...
...
@@ -25,6 +26,15 @@ public interface VehicleDriverService extends IService<VehicleDriverEntity> {
**/
List
<
DriverVehicleListVO
>
getDriverBindVehicleList
(
Long
driverId
);
/**
* description 查询车辆绑定的司机列表
* param [vehicleId]
* return java.util.List<com.esv.freight.customer.module.driver.vo.VehicleDriverListVO>
* author Administrator
* createTime 2020/05/07 16:16
**/
List
<
VehicleDriverListVO
>
getVehicleBindDriverList
(
Long
vehicleId
);
/**
* description 查询指定承运商的司机与车辆绑定列表
* param [carrierId]
...
...
src/main/java/com/esv/freight/customer/module/vehicle/service/impl/VehicleDriverServiceImpl.java
View file @
2299e8be
...
...
@@ -3,6 +3,7 @@ package com.esv.freight.customer.module.vehicle.service.impl;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.esv.freight.customer.module.driver.dto.DriverVehicleDto
;
import
com.esv.freight.customer.module.driver.vo.DriverVehicleListVO
;
import
com.esv.freight.customer.module.driver.vo.VehicleDriverListVO
;
import
com.esv.freight.customer.module.vehicle.dao.VehicleDriverDao
;
import
com.esv.freight.customer.module.vehicle.entity.VehicleDriverEntity
;
import
com.esv.freight.customer.module.vehicle.service.VehicleDriverService
;
...
...
@@ -23,4 +24,9 @@ public class VehicleDriverServiceImpl extends ServiceImpl<VehicleDriverDao, Vehi
public
List
<
DriverVehicleDto
>
getDriverVehicle4Carrier
(
Long
carrierId
)
{
return
this
.
baseMapper
.
selectDriverVehicle4Carrier
(
carrierId
);
}
@Override
public
List
<
VehicleDriverListVO
>
getVehicleBindDriverList
(
Long
vehicleId
)
{
return
this
.
baseMapper
.
selectVehicleBindDriverList
(
vehicleId
);
}
}
\ No newline at end of file
src/main/resources/application-dev.yml
View file @
2299e8be
...
...
@@ -177,6 +177,9 @@ error-message:
vehicle-list
:
1001
:
无效的司机ID
1002
:
该司机未绑定车辆
driver-list
:
1001
:
无效的车辆ID
1002
:
该车辆未绑定司机
vehicle-bind
:
1001
:
无效的司机ID
1002
:
司机帐号已停用
...
...
src/main/resources/application-test.yml
View file @
2299e8be
...
...
@@ -177,6 +177,9 @@ error-message:
vehicle-list
:
1001
:
无效的司机ID
1002
:
该司机未绑定车辆
driver-list
:
1001
:
无效的车辆ID
1002
:
该车辆未绑定司机
vehicle-bind
:
1001
:
无效的司机ID
1002
:
司机帐号已停用
...
...
src/main/resources/bootstrap.yml
View file @
2299e8be
...
...
@@ -5,7 +5,7 @@ server:
nacos
:
url
:
127.0.0.1:8848
namespace
:
548b506d-8d19-4d54-9715-bb0ac3a655b2
group
:
FREIGH
T_GROUP
group
:
DEFAUL
T_GROUP
spring
:
application
:
name
:
freight-customer-service
...
...
src/main/resources/mapper/vehicle/VehicleDriverDao.xml
View file @
2299e8be
...
...
@@ -26,6 +26,20 @@
order by b.selected desc
</select>
<!-- 查询车辆绑定的司机列表 -->
<select
id=
"selectVehicleBindDriverList"
parameterType=
"java.lang.Long"
resultType=
"com.esv.freight.customer.module.driver.vo.VehicleDriverListVO"
>
select ab.*, c.name
from (
select a.id, a.account, a.account_status, a.audit_status, a.source_type,
b.vehicle_id
from driver_account a, vehicle_driver b
where a.id = b.driver_id
and b.vehicle_id = #{vehicleId}
)ab
left join driver_info c on ab.id = c.driver_id
order by ab.account asc
</select>
<!-- 查询指定承运商的司机与车辆绑定列表 -->
<select
id=
"selectDriverVehicle4Carrier"
parameterType=
"java.lang.Long"
resultType=
"com.esv.freight.customer.module.driver.dto.DriverVehicleDto"
>
select ab.*,
...
...
src/test/java/com/esv/freight/customer/module/driver/controller/DriverVehicleControllerTest.java
View file @
2299e8be
...
...
@@ -6,6 +6,7 @@ import com.esv.freight.customer.common.response.ECode;
import
com.esv.freight.customer.module.driver.form.CarrierForm
;
import
com.esv.freight.customer.module.driver.form.DriverQueryForm
;
import
com.esv.freight.customer.module.driver.form.DriverVehicleForm
;
import
com.esv.freight.customer.module.vehicle.form.VehicleQueryForm
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Assert
;
import
org.junit.FixMethodOrder
;
...
...
@@ -43,7 +44,7 @@ public class DriverVehicleControllerTest extends BaseTestController {
* 查询指定司机绑定的车辆列表
**/
@Test
public
void
a1_list_success_test
()
throws
Exception
{
public
void
a1_list
ByDriver
_success_test
()
throws
Exception
{
String
url
=
"/carrier/driver/vehicle/listByDriver"
;
// 构造数据
...
...
@@ -70,7 +71,7 @@ public class DriverVehicleControllerTest extends BaseTestController {
* 查询指定司机绑定的车辆列表:无效的司机ID
**/
@Test
public
void
a2_list_wrong_id_failure_test
()
throws
Exception
{
public
void
a2_list
ByDriver
_wrong_id_failure_test
()
throws
Exception
{
String
url
=
"/carrier/driver/vehicle/listByDriver"
;
// 构造数据
...
...
@@ -96,7 +97,7 @@ public class DriverVehicleControllerTest extends BaseTestController {
* 查询指定司机绑定的车辆列表:该司机未绑定车辆
**/
@Test
public
void
a3_list_not_bind_vehicle_failure_test
()
throws
Exception
{
public
void
a3_list
ByDriver
_not_bind_vehicle_failure_test
()
throws
Exception
{
String
url
=
"/carrier/driver/vehicle/listByDriver"
;
// 构造数据
...
...
@@ -339,4 +340,83 @@ public class DriverVehicleControllerTest extends BaseTestController {
Assert
.
assertEquals
(
ECode
.
SUCCESS
.
code
(),
result
.
getIntValue
(
"code"
));
Assert
.
assertTrue
(
0
==
result
.
getJSONArray
(
"data"
).
size
());
}
/**
* 查询指定车辆绑定的司机列表
**/
@Test
public
void
f1_listByVehicle_success_test
()
throws
Exception
{
String
url
=
"/carrier/driver/vehicle/listByVehicle"
;
// 构造数据
VehicleQueryForm
form
=
new
VehicleQueryForm
();
form
.
setId
(
3L
);
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
(
null
!=
result
.
getJSONArray
(
"data"
));
}
/**
* 查询指定车辆绑定的司机列表:无效的车辆ID
**/
@Test
public
void
f2_listByVehicle_wrong_id_failure_test
()
throws
Exception
{
String
url
=
"/carrier/driver/vehicle/listByVehicle"
;
// 构造数据
VehicleQueryForm
form
=
new
VehicleQueryForm
();
form
.
setId
(
99999L
);
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
f3_listByVehicle_not_bind_driver_failure_test
()
throws
Exception
{
String
url
=
"/carrier/driver/vehicle/listByVehicle"
;
// 构造数据
VehicleQueryForm
form
=
new
VehicleQueryForm
();
form
.
setId
(
2L
);
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