Commit 2eda488d authored by huangcb's avatar huangcb

承运商接口:编辑司机信息

parent 6812bc24
......@@ -176,4 +176,13 @@ public class ErrorMessageComponent {
private String carrierDriverAdd1003;
@Value("${error-message.carrier.driver.add.1004}")
private String carrierDriverAdd1004;
@Value("${error-message.carrier.driver.edit.1001}")
private String carrierDriverEdit1001;
@Value("${error-message.carrier.driver.edit.1002}")
private String carrierDriverEdit1002;
@Value("${error-message.carrier.driver.edit.1003}")
private String carrierDriverEdit1003;
@Value("${error-message.carrier.driver.edit.1004}")
private String carrierDriverEdit1004;
}
......@@ -8,6 +8,7 @@ import com.esv.freight.customer.common.response.EResponse;
import com.esv.freight.customer.common.util.ReqUtils;
import com.esv.freight.customer.common.util.VerifyUtils;
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.DriverConstants;
import com.esv.freight.customer.module.driver.form.DriverInfoForm;
import com.esv.freight.customer.module.driver.service.DriverAccountService;
......@@ -71,4 +72,29 @@ public class DriverController {
data.put("id", id);
return EResponse.ok(data);
}
/**
* description 编辑司机信息
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/28 19:26
**/
@PostMapping("/edit")
public EResponse edit(@RequestBody @Validated(ValidatorUpdate.class) DriverInfoForm form) throws EException {
/****************************** 参数校验 ******************************/
// 所驾驶车辆4.5吨以上必填道路运输从业资格证信息
if (DriverConstants.ACCOUNT_DRIVING_VEHICLE_TYPE_2.equals(form.getCertificateVehicle())) {
String[] notBlankParams = new String[] {"certificateEndDate", "certificateNumber", "certificateUrl"};
ReqUtils.checkParamsNotBlank(JSONObject.parseObject(form.toString()), notBlankParams);
}
// 校验身份证号码
if (StringUtils.isNotBlank(form.getIdCard()) && !VerifyUtils.isValidIdCard18(form.getIdCard())) {
throw new EException(ECode.PARAM_ERROR.code(), "无效的身份证号码");
}
/****************************** 参数校验 ******************************/
driverAccountService.updateDriver(form);
return EResponse.ok();
}
}
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 lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
......@@ -25,6 +26,7 @@ public class DriverInfoForm {
/**
*
*/
@NotNull(message = "参数id不能为空", groups = {ValidatorUpdate.class})
private Long id;
/**
* 承运商帐号ID
......@@ -40,7 +42,7 @@ public class DriverInfoForm {
/**
* 密码
*/
@Length(min = 32, max = 32, message = "参数password长度不合法", groups = {ValidatorInsert.class})
@Length(min = 32, max = 32, message = "参数password长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数password不能为空", groups = {ValidatorInsert.class})
private String password;
/**
......@@ -54,142 +56,142 @@ public class DriverInfoForm {
/**
* 姓名
*/
@Length(max = 20, message = "参数name长度不合法", groups = {ValidatorInsert.class})
@Length(max = 20, message = "参数name长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数name不能为空", groups = {ValidatorInsert.class})
private String name;
/**
* 身份证号码
*/
@Length(max = 18, message = "参数idCard长度不合法", groups = {ValidatorInsert.class})
@Length(max = 18, message = "参数idCard长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数idCard不能为空", groups = {ValidatorInsert.class})
private String idCard;
/**
* 身份证有效期
*/
@Length(max = 20, message = "参数idCardExpireDate长度不合法", groups = {ValidatorInsert.class})
@Length(max = 20, message = "参数idCardExpireDate长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数idCardExpireDate不能为空", groups = {ValidatorInsert.class})
private String idCardExpireDate;
/**
* 身份证正面图片URL
*/
@Length(max = 200, message = "参数idCardFrontUrl长度不合法", groups = {ValidatorInsert.class})
@Length(max = 200, message = "参数idCardFrontUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数idCardFrontUrl不能为空", groups = {ValidatorInsert.class})
private String idCardFrontUrl;
/**
* 身份证背面图片URL
*/
@Length(max = 200, message = "参数idCardBackUrl长度不合法", groups = {ValidatorInsert.class})
@Length(max = 200, message = "参数idCardBackUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数idCardBackUrl不能为空", groups = {ValidatorInsert.class})
private String idCardBackUrl;
/**
* 结算对象(字典表):1-个人、2-所属承运商
*/
@Range(min = 1, max = 2, message = "参数settlementType不合法", groups = {ValidatorInsert.class})
@Range(min = 1, max = 2, message = "参数settlementType不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotNull(message = "参数settlementType不能为空", groups = {ValidatorInsert.class})
private Integer settlementType;
/**
* 性别(字典表):1-男、2-女、3-未知
*/
@Range(min = 1, max = 3, message = "参数sex不合法", groups = {ValidatorInsert.class})
@Range(min = 1, max = 3, message = "参数sex不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotNull(message = "参数sex不能为空", groups = {ValidatorInsert.class})
private Integer sex;
/**
* 出生日期
*/
@Length(max = 20, message = "参数birthDate长度不合法", groups = {ValidatorInsert.class})
@Length(max = 20, message = "参数birthDate长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String birthDate;
/**
* 名族
*/
@Length(max = 20, message = "参数nation长度不合法", groups = {ValidatorInsert.class})
@Length(max = 20, message = "参数nation长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String nation;
/**
* 籍贯
*/
@Length(max = 20, message = "参数nativePlace长度不合法", groups = {ValidatorInsert.class})
@Length(max = 20, message = "参数nativePlace长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String nativePlace;
/**
* 住址-省份代码
*/
@Length(min = 6, max = 6, message = "参数provinceCode长度不合法", groups = {ValidatorInsert.class})
@Length(min = 6, max = 6, message = "参数provinceCode长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String provinceCode;
/**
* 住址-市代码
*/
@Length(min = 6, max = 6, message = "参数cityCode长度不合法", groups = {ValidatorInsert.class})
@Length(min = 6, max = 6, message = "参数cityCode长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String cityCode;
/**
* 住址-区县代码
*/
@Length(min = 6, max = 6, message = "参数districtCode长度不合法", groups = {ValidatorInsert.class})
@Length(min = 6, max = 6, message = "参数districtCode长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String districtCode;
/**
* 住址-详细地址
*/
@Length(max = 200, message = "参数detailAddress长度不合法", groups = {ValidatorInsert.class})
@Length(max = 200, message = "参数detailAddress长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String detailAddress;
/**
* 驾驶证号码
*/
@Length(max = 20, message = "参数drivingLicense长度不合法", groups = {ValidatorInsert.class})
@Length(max = 20, message = "参数drivingLicense长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数drivingLicense不能为空", groups = {ValidatorInsert.class})
private String drivingLicense;
/**
* 驾驶证类型(字典表):1-A1、2-A2、3-A3、4-A1A2、5-A2E、6-A2D、7-B1、8-B2、9-C1、0-其他
*/
@Range(min = 0, max = 9, message = "参数drivingLicenseType不合法", groups = {ValidatorInsert.class})
@Range(min = 0, max = 9, message = "参数drivingLicenseType不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotNull(message = "参数drivingLicenseType不能为空", groups = {ValidatorInsert.class})
private Integer drivingLicenseType;
/**
* 驾驶证有效期起
*/
@Length(max = 20, message = "参数drivingLicenseStartDate长度不合法", groups = {ValidatorInsert.class})
@Length(max = 20, message = "参数drivingLicenseStartDate长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String drivingLicenseStartDate;
/**
* 驾驶证有效期止
*/
@Length(max = 20, message = "参数drivingLicenseEndDate长度不合法", groups = {ValidatorInsert.class})
@Length(max = 20, message = "参数drivingLicenseEndDate长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String drivingLicenseEndDate;
/**
* 发证机关
*/
@Length(max = 50, message = "参数drivingLicenseIssueDepartment长度不合法", groups = {ValidatorInsert.class})
@Length(max = 50, message = "参数drivingLicenseIssueDepartment长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String drivingLicenseIssueDepartment;
/**
* 初次获得驾驶证日期
*/
@Length(max = 20, message = "参数drivingLicenseInitDate长度不合法", groups = {ValidatorInsert.class})
@Length(max = 20, message = "参数drivingLicenseInitDate长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String drivingLicenseInitDate;
/**
* 驾驶证正面图片URL
*/
@Length(max = 200, message = "参数drivingLicenseUrl长度不合法", groups = {ValidatorInsert.class})
@Length(max = 200, message = "参数drivingLicenseUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String drivingLicenseUrl;
/**
* 道路运输从业资格证-所驾驶车辆(字典表):1-4.5吨及以下、2-4.5吨以上
*/
@Range(min = 1, max = 2, message = "参数certificateVehicle不合法", groups = {ValidatorInsert.class})
@Range(min = 1, max = 2, message = "参数certificateVehicle不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotNull(message = "参数certificateVehicle不能为空", groups = {ValidatorInsert.class})
private Integer certificateVehicle;
/**
* 道路运输从业资格证-有效期止
*/
@Length(max = 20, message = "参数certificateEndDate长度不合法", groups = {ValidatorInsert.class})
@Length(max = 20, message = "参数certificateEndDate长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String certificateEndDate;
/**
* 道路运输从业资格证-从业资格证号
*/
@Length(max = 20, message = "参数certificateNumber长度不合法", groups = {ValidatorInsert.class})
@Length(max = 20, message = "参数certificateNumber长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String certificateNumber;
/**
* 道路运输从业资格证-正面图片URL
*/
@Length(max = 200, message = "参数certificateUrl长度不合法", groups = {ValidatorInsert.class})
@Length(max = 200, message = "参数certificateUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String certificateUrl;
/**
* 备注
*/
@Length(max = 100, message = "参数remark长度不合法", groups = {ValidatorInsert.class})
@Length(max = 100, message = "参数remark长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String remark;
@Override
......
......@@ -22,5 +22,14 @@ public interface DriverAccountService extends IService<DriverAccountEntity> {
**/
Long insertDriver(DriverInfoForm form);
/**
* description 更新司机信息
* param [form]
* return java.lang.Integer
* author Administrator
* createTime 2020/04/28 19:13
**/
Integer updateDriver(DriverInfoForm form);
}
package com.esv.freight.customer.module.driver.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.esv.freight.customer.common.component.ErrorMessageComponent;
import com.esv.freight.customer.common.component.PasswordComponent;
......@@ -103,4 +104,54 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv
return driverId;
}
@Override
public Integer updateDriver(DriverInfoForm form) {
// 1:校验
// 1.1:校验账号ID是否有效
DriverAccountEntity driverAccountEntity = this.baseMapper.selectById(form.getId());
if (null == driverAccountEntity) {
throw new EException(1001, errorMessageComponent.getCarrierDriverEdit1001());
}
// 1.2:校验身份证号码是否已存在
Integer count = this.driverInfoService.getBaseMapper().selectCount(new QueryWrapper<DriverInfoEntity>().lambda()
.ne(DriverInfoEntity::getDriverId, form.getId())
.eq(DriverInfoEntity::getIdCard, form.getIdCard()));
if (0 < count) {
throw new EException(1002, errorMessageComponent.getCarrierDriverEdit1002());
}
// 1.3:校验驾驶证号码是否已存在
count = this.driverInfoService.getBaseMapper().selectCount(new QueryWrapper<DriverInfoEntity>().lambda()
.ne(DriverInfoEntity::getDriverId, form.getId())
.eq(DriverInfoEntity::getDrivingLicense, form.getDrivingLicense()));
if (0 < count) {
throw new EException(1003, errorMessageComponent.getCarrierDriverEdit1003());
}
// 1.4:校验从业资格证号是否已存在
if (StringUtils.isNotBlank(form.getCertificateNumber())) {
count = this.driverInfoService.getBaseMapper().selectCount(new QueryWrapper<DriverInfoEntity>().lambda()
.ne(DriverInfoEntity::getDriverId, form.getId())
.eq(DriverInfoEntity::getCertificateNumber, form.getCertificateNumber()));
if (0 < count) {
throw new EException(1004, errorMessageComponent.getCarrierDriverEdit1004());
}
}
// 2:更新密码
int flag = 0;
if (StringUtils.isNotBlank(form.getPassword())) {
DriverAccountEntity accountEntity = new DriverAccountEntity();
accountEntity.setId(form.getId());
accountEntity.setPassword(passwordComponent.generatePwd4Salt(form.getPassword(), driverAccountEntity.getSalt()));
flag += this.baseMapper.updateById(accountEntity);
}
// 3:更新帐号信息
DriverInfoEntity driverInfoEntity = new DriverInfoEntity();
BeanUtils.copyProperties(form, driverInfoEntity);
flag += this.driverInfoService.getBaseMapper().update(driverInfoEntity, new UpdateWrapper<DriverInfoEntity>().lambda()
.eq(DriverInfoEntity::getDriverId, form.getId()));
return flag;
}
}
\ No newline at end of file
......@@ -150,3 +150,8 @@ error-message:
1002: 身份证号码已存在
1003: 驾驶证号码已存在
1004: 从业资格证号已存在
edit:
1001: 无效的账号ID
1002: 身份证号码已存在
1003: 驾驶证号码已存在
1004: 从业资格证号已存在
\ No newline at end of file
package com.esv.freight.customer.module.driver.controller;
import com.alibaba.fastjson.JSONObject;
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.DriverInfoForm;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.transaction.annotation.Transactional;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.driver.controller.DriverAccountEditTest
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/28 17:26
* @version:1.0
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Transactional
@Rollback(false)
public class DriverAccountEditTest extends BaseTestController {
/**
* 编辑司机信息:更新密码
**/
@Test
@Rollback
public void a1_edit_vehicle_success_test() throws Exception {
String url = "/carrier/driver/edit";
// 构造数据
DriverInfoForm form = new DriverInfoForm();
form.setId(1L);
form.setPassword("e10adc3949ba59abbe56e057f20f883e");
form.setName("路上飞");
form.setIdCard("210102198003076734");
form.setIdCardExpireDate("2030/10/31");
form.setIdCardFrontUrl("http://127.0.0.1/id_card_front_url_18512340001.jpg");
form.setIdCardBackUrl("http://127.0.0.1/id_card_back_url_18512340001.jpg");
form.setSettlementType(1); // 结算对象(字典表):1-个人、2-所属承运商
form.setSex(1); // 性别(字典表):1-男、2-女、3-未知
form.setBirthDate("1980/3/7");
form.setNation("满族");
form.setNativePlace("辽宁沈阳");
form.setProvinceCode("210000");
form.setCityCode("210100");
form.setDistrictCode("210102");
form.setDetailAddress("青年大街1号河畔花园1-1");
form.setDrivingLicense("210102198003076734");
form.setDrivingLicenseType(8); // 驾驶证类型(字典表):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_18512340001.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(ECode.SUCCESS.code(), result.getIntValue("code"));
}
/**
* 编辑司机信息:无效的账号ID
**/
@Test
@Rollback
public void a2_edit_vehicle_wrong_id_failure_test() throws Exception {
String url = "/carrier/driver/edit";
// 构造数据
DriverInfoForm form = new DriverInfoForm();
form.setId(99999L);
form.setPassword("e10adc3949ba59abbe56e057f20f883e");
form.setName("路上跑");
form.setIdCard("210102198003079775");
form.setIdCardExpireDate("2030/10/31");
form.setIdCardFrontUrl("http://127.0.0.1/id_card_front_url_18512340002.jpg");
form.setIdCardBackUrl("http://127.0.0.1/id_card_back_url_18512340002.jpg");
form.setSettlementType(1); // 结算对象(字典表):1-个人、2-所属承运商
form.setSex(1); // 性别(字典表):1-男、2-女、3-未知
form.setBirthDate("1980/3/7");
form.setNation("满族");
form.setNativePlace("辽宁沈阳");
form.setProvinceCode("210000");
form.setCityCode("210100");
form.setDistrictCode("210102");
form.setDetailAddress("青年大街1号河畔花园1-1");
form.setDrivingLicense("210102198003079775");
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_18512340002.jpg");
form.setCertificateVehicle(DriverConstants.ACCOUNT_DRIVING_VEHICLE_TYPE_2); // 道路运输从业资格证-所驾驶车辆(字典表):1-4.5吨及以下、2-4.5吨以上
form.setCertificateNumber("210102198003079775");
form.setCertificateEndDate("2025/5/30");
form.setCertificateUrl("http://127.0.0.1/certificate_url_18512340002.jpg");
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(1001, result.getIntValue("code"));
}
/**
* 编辑司机信息:无效的身份证号码
**/
@Test
@Rollback
public void a3_edit_vehicle_wrong_IdCard_failure_test() throws Exception {
String url = "/carrier/driver/edit";
// 构造数据
DriverInfoForm form = new DriverInfoForm();
form.setId(1L);
form.setPassword("e10adc3949ba59abbe56e057f20f883e");
form.setName("路上跑");
form.setIdCard("210102198003071234");
form.setIdCardExpireDate("2030/10/31");
form.setIdCardFrontUrl("http://127.0.0.1/id_card_front_url_18512340002.jpg");
form.setIdCardBackUrl("http://127.0.0.1/id_card_back_url_18512340002.jpg");
form.setSettlementType(1); // 结算对象(字典表):1-个人、2-所属承运商
form.setSex(1); // 性别(字典表):1-男、2-女、3-未知
form.setBirthDate("1980/3/7");
form.setNation("满族");
form.setNativePlace("辽宁沈阳");
form.setProvinceCode("210000");
form.setCityCode("210100");
form.setDistrictCode("210102");
form.setDetailAddress("青年大街1号河畔花园1-1");
form.setDrivingLicense("210102198003079775");
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_18512340002.jpg");
form.setCertificateVehicle(DriverConstants.ACCOUNT_DRIVING_VEHICLE_TYPE_2); // 道路运输从业资格证-所驾驶车辆(字典表):1-4.5吨及以下、2-4.5吨以上
form.setCertificateNumber("210102198003079775");
form.setCertificateEndDate("2025/5/30");
form.setCertificateUrl("http://127.0.0.1/certificate_url_18512340002.jpg");
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(ECode.PARAM_ERROR.code(), result.getIntValue("code"));
}
/**
* 编辑司机信息:身份证号码已存在
**/
@Test
@Rollback
public void a4_edit_vehicle_wrong_IdCard_failure_test() throws Exception {
String url = "/carrier/driver/edit";
// 构造数据
DriverInfoForm form = new DriverInfoForm();
form.setId(1L);
form.setPassword("e10adc3949ba59abbe56e057f20f883e");
form.setName("路上跑");
form.setIdCard("210102198003079775");
form.setIdCardExpireDate("2030/10/31");
form.setIdCardFrontUrl("http://127.0.0.1/id_card_front_url_18512340002.jpg");
form.setIdCardBackUrl("http://127.0.0.1/id_card_back_url_18512340002.jpg");
form.setSettlementType(1); // 结算对象(字典表):1-个人、2-所属承运商
form.setSex(1); // 性别(字典表):1-男、2-女、3-未知
form.setBirthDate("1980/3/7");
form.setNation("满族");
form.setNativePlace("辽宁沈阳");
form.setProvinceCode("210000");
form.setCityCode("210100");
form.setDistrictCode("210102");
form.setDetailAddress("青年大街1号河畔花园1-1");
form.setDrivingLicense("210102198003079775");
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_18512340002.jpg");
form.setCertificateVehicle(DriverConstants.ACCOUNT_DRIVING_VEHICLE_TYPE_2); // 道路运输从业资格证-所驾驶车辆(字典表):1-4.5吨及以下、2-4.5吨以上
form.setCertificateNumber("210102198003079775");
form.setCertificateEndDate("2025/5/30");
form.setCertificateUrl("http://127.0.0.1/certificate_url_18512340002.jpg");
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(1002, result.getIntValue("code"));
}
/**
* 编辑司机信息:驾驶证号码已存在
**/
@Test
@Rollback
public void a5_edit_vehicle_wrong_DrivingLicense_failure_test() throws Exception {
String url = "/carrier/driver/edit";
// 构造数据
DriverInfoForm form = new DriverInfoForm();
form.setId(1L);
form.setPassword("e10adc3949ba59abbe56e057f20f883e");
form.setName("路上跑");
form.setIdCard("210102198003079492");
form.setIdCardExpireDate("2030/10/31");
form.setIdCardFrontUrl("http://127.0.0.1/id_card_front_url_18512340002.jpg");
form.setIdCardBackUrl("http://127.0.0.1/id_card_back_url_18512340002.jpg");
form.setSettlementType(1); // 结算对象(字典表):1-个人、2-所属承运商
form.setSex(1); // 性别(字典表):1-男、2-女、3-未知
form.setBirthDate("1980/3/7");
form.setNation("满族");
form.setNativePlace("辽宁沈阳");
form.setProvinceCode("210000");
form.setCityCode("210100");
form.setDistrictCode("210102");
form.setDetailAddress("青年大街1号河畔花园1-1");
form.setDrivingLicense("210102198003079775");
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_18512340002.jpg");
form.setCertificateVehicle(DriverConstants.ACCOUNT_DRIVING_VEHICLE_TYPE_2); // 道路运输从业资格证-所驾驶车辆(字典表):1-4.5吨及以下、2-4.5吨以上
form.setCertificateNumber("210102198003079775");
form.setCertificateEndDate("2025/5/30");
form.setCertificateUrl("http://127.0.0.1/certificate_url_18512340002.jpg");
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(1003, result.getIntValue("code"));
}
/**
* 编辑司机信息:从业资格证号已存在
**/
@Test
@Rollback
public void a6_edit_vehicle_wrong_DrivingLicense_failure_test() throws Exception {
String url = "/carrier/driver/edit";
// 构造数据
DriverInfoForm form = new DriverInfoForm();
form.setId(1L);
form.setPassword("e10adc3949ba59abbe56e057f20f883e");
form.setName("路上跑");
form.setIdCard("210102198003079492");
form.setIdCardExpireDate("2030/10/31");
form.setIdCardFrontUrl("http://127.0.0.1/id_card_front_url_18512340002.jpg");
form.setIdCardBackUrl("http://127.0.0.1/id_card_back_url_18512340002.jpg");
form.setSettlementType(1); // 结算对象(字典表):1-个人、2-所属承运商
form.setSex(1); // 性别(字典表):1-男、2-女、3-未知
form.setBirthDate("1980/3/7");
form.setNation("满族");
form.setNativePlace("辽宁沈阳");
form.setProvinceCode("210000");
form.setCityCode("210100");
form.setDistrictCode("210102");
form.setDetailAddress("青年大街1号河畔花园1-1");
form.setDrivingLicense("210102198003079492");
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_18512340002.jpg");
form.setCertificateVehicle(DriverConstants.ACCOUNT_DRIVING_VEHICLE_TYPE_2); // 道路运输从业资格证-所驾驶车辆(字典表):1-4.5吨及以下、2-4.5吨以上
form.setCertificateNumber("210102198003079775");
form.setCertificateEndDate("2025/5/30");
form.setCertificateUrl("http://127.0.0.1/certificate_url_18512340002.jpg");
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(1004, result.getIntValue("code"));
}
/**
* 编辑司机信息:无道路运输从业资格证信息
**/
@Test
@Rollback
public void a7_edit_vehicle_no_Certificate_failure_test() throws Exception {
String url = "/carrier/driver/edit";
// 构造数据
DriverInfoForm form = new DriverInfoForm();
form.setCarrierId(2L);
form.setAccount("18512340012");
form.setPassword("e10adc3949ba59abbe56e057f20f883e");
form.setName("路上跑");
form.setIdCard("210102198003072477");
form.setIdCardExpireDate("2030/10/31");
form.setIdCardFrontUrl("http://127.0.0.1/id_card_front_url_18512340002.jpg");
form.setIdCardBackUrl("http://127.0.0.1/id_card_back_url_18512340002.jpg");
form.setSettlementType(1); // 结算对象(字典表):1-个人、2-所属承运商
form.setSex(1); // 性别(字典表):1-男、2-女、3-未知
form.setBirthDate("1980/3/7");
form.setNation("满族");
form.setNativePlace("辽宁沈阳");
form.setProvinceCode("210000");
form.setCityCode("210100");
form.setDistrictCode("210102");
form.setDetailAddress("青年大街1号河畔花园1-1");
form.setDrivingLicense("210102198003072477");
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_18512340002.jpg");
form.setCertificateVehicle(DriverConstants.ACCOUNT_DRIVING_VEHICLE_TYPE_2); // 道路运输从业资格证-所驾驶车辆(字典表):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(ECode.PARAM_ERROR.code(), 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