Commit 2299e8be authored by huangcb's avatar huangcb

承运商接口:查询指定车辆绑定的司机列表

parent b14c1383
......@@ -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}")
......
......@@ -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]
......
......@@ -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 绑定司机与车辆
......
......@@ -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:校验
......
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);
}
}
......@@ -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]
......
......@@ -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]
......
......@@ -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
......@@ -177,6 +177,9 @@ error-message:
vehicle-list:
1001: 无效的司机ID
1002: 该司机未绑定车辆
driver-list:
1001: 无效的车辆ID
1002: 该车辆未绑定司机
vehicle-bind:
1001: 无效的司机ID
1002: 司机帐号已停用
......
......@@ -177,6 +177,9 @@ error-message:
vehicle-list:
1001: 无效的司机ID
1002: 该司机未绑定车辆
driver-list:
1001: 无效的车辆ID
1002: 该车辆未绑定司机
vehicle-bind:
1001: 无效的司机ID
1002: 司机帐号已停用
......
......@@ -5,7 +5,7 @@ server:
nacos:
url: 127.0.0.1:8848
namespace: 548b506d-8d19-4d54-9715-bb0ac3a655b2
group: FREIGHT_GROUP
group: DEFAULT_GROUP
spring:
application:
name: freight-customer-service
......
......@@ -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.*,
......
......@@ -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_listByDriver_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_listByDriver_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_listByDriver_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"));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment