Commit 8c3ae625 authored by huangcb's avatar huangcb

承运商接口:查询司机详情

parent 2eda488d
...@@ -185,4 +185,7 @@ public class ErrorMessageComponent { ...@@ -185,4 +185,7 @@ public class ErrorMessageComponent {
private String carrierDriverEdit1003; private String carrierDriverEdit1003;
@Value("${error-message.carrier.driver.edit.1004}") @Value("${error-message.carrier.driver.edit.1004}")
private String carrierDriverEdit1004; private String carrierDriverEdit1004;
@Value("${error-message.carrier.driver.detail.1001}")
private String carrierDriverDetail1001;
} }
...@@ -7,13 +7,18 @@ import com.esv.freight.customer.common.response.ECode; ...@@ -7,13 +7,18 @@ import com.esv.freight.customer.common.response.ECode;
import com.esv.freight.customer.common.response.EResponse; import com.esv.freight.customer.common.response.EResponse;
import com.esv.freight.customer.common.util.ReqUtils; import com.esv.freight.customer.common.util.ReqUtils;
import com.esv.freight.customer.common.util.VerifyUtils; import com.esv.freight.customer.common.util.VerifyUtils;
import com.esv.freight.customer.common.validator.groups.ValidatorDetail;
import com.esv.freight.customer.common.validator.groups.ValidatorInsert; import com.esv.freight.customer.common.validator.groups.ValidatorInsert;
import com.esv.freight.customer.common.validator.groups.ValidatorUpdate; import com.esv.freight.customer.common.validator.groups.ValidatorUpdate;
import com.esv.freight.customer.module.driver.DriverConstants; import com.esv.freight.customer.module.driver.DriverConstants;
import com.esv.freight.customer.module.driver.dto.DriverDetailDto;
import com.esv.freight.customer.module.driver.form.DriverInfoForm; 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.service.DriverAccountService;
import com.esv.freight.customer.module.driver.vo.DriverDetailVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -97,4 +102,27 @@ public class DriverController { ...@@ -97,4 +102,27 @@ public class DriverController {
driverAccountService.updateDriver(form); driverAccountService.updateDriver(form);
return EResponse.ok(); return EResponse.ok();
} }
/**
* description 查询司机详情
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/28 20:26
**/
@PostMapping("/detail")
public EResponse detail(@RequestBody @Validated(ValidatorDetail.class) DriverQueryForm form) throws EException {
DriverDetailDto dto = driverAccountService.getDriverDetail(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);
}
} }
package com.esv.freight.customer.module.driver.dao; package com.esv.freight.customer.module.driver.dao;
import com.esv.freight.customer.module.driver.dto.DriverDetailDto;
import com.esv.freight.customer.module.driver.entity.DriverAccountEntity; import com.esv.freight.customer.module.driver.entity.DriverAccountEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
...@@ -13,5 +14,14 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -13,5 +14,14 @@ import org.apache.ibatis.annotations.Mapper;
*/ */
@Mapper @Mapper
public interface DriverAccountDao extends BaseMapper<DriverAccountEntity> { public interface DriverAccountDao extends BaseMapper<DriverAccountEntity> {
/**
* description 查询司机详情
* param [id]
* return com.esv.freight.customer.module.driver.dto.DriverDetailDto
* author Administrator
* createTime 2020/04/28 20:21
**/
DriverDetailDto selectDriverDetail(Long id);
} }
package com.esv.freight.customer.module.driver.dto;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.util.Date;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.driver.dto.DriverDetailDto
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/28 20:11
* @version:1.0
*/
@Data
public class DriverDetailDto {
/**
*
*/
@TableId
private Long id;
/**
* 租户ID
*/
@TableField(fill = FieldFill.INSERT)
private Long tenantId;
/**
* 部门ID
*/
@TableField(fill = FieldFill.INSERT)
private Long departmentId;
/**
* 承运商帐号ID
*/
private Long carrierId;
/**
* 登录帐号,司机手机号
*/
private String account;
/**
* 密码
*/
private String password;
/**
* 密码盐
*/
private String salt;
/**
* 帐号状态:1-正常、2-停用
*/
private Integer accountStatus;
/**
* 创建来源:1-平台创建、2-自行注册
*/
private Integer sourceType;
/**
* 审核状态(字典表):0-待审核、1-审核成功,2-审核失败
*/
private Integer auditStatus;
/**
* 认证状态:1-未认证、2-已认证
*/
private Integer authenticateStatus;
/**
* 上报状态(字典表):0-未上报、1-上报成功、2-上报失败
*/
private Integer reportStatus;
/**
* 上报时间
*/
private Date reportTime;
/**
* 创建者
*/
private String createUser;
/**
* 修改者
*/
private String updateUser;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
/**
* 姓名
*/
private String name;
/**
* 身份证号码
*/
private String idCard;
/**
* 身份证有效期
*/
private String idCardExpireDate;
/**
* 身份证正面图片URL
*/
private String idCardFrontUrl;
/**
* 身份证背面图片URL
*/
private String idCardBackUrl;
/**
* 结算对象(字典表):1-个人、2-所属承运商
*/
private Integer settlementType;
/**
* 性别(字典表):1-男、2-女、3-未知
*/
private Integer sex;
/**
* 出生日期
*/
private String birthDate;
/**
* 名族
*/
private String nation;
/**
* 籍贯
*/
private String nativePlace;
/**
* 住址-省份代码
*/
private String provinceCode;
/**
* 住址-市代码
*/
private String cityCode;
/**
* 住址-区县代码
*/
private String districtCode;
/**
* 住址-详细地址
*/
private String detailAddress;
/**
* 驾驶证号码
*/
private String drivingLicense;
/**
* 驾驶证类型(字典表):1-A1、2-A2、3-A3、4-A1A2、5-A2E、6-A2D、7-B1、8-B2、9-C1、0-其他
*/
private Integer drivingLicenseType;
/**
* 驾驶证有效期起
*/
private String drivingLicenseStartDate;
/**
* 驾驶证有效期止
*/
private String drivingLicenseEndDate;
/**
* 发证机关
*/
private String drivingLicenseIssueDepartment;
/**
* 初次获得驾驶证日期
*/
private String drivingLicenseInitDate;
/**
* 驾驶证正面图片URL
*/
private String drivingLicenseUrl;
/**
* 道路运输从业资格证-所驾驶车辆(字典表):1-4.5吨及以下、2-4.5吨以上
*/
private Integer certificateVehicle;
/**
* 道路运输从业资格证-有效期止
*/
private String certificateEndDate;
/**
* 道路运输从业资格证-从业资格证号
*/
private String certificateNumber;
/**
* 道路运输从业资格证-正面图片URL
*/
private String certificateUrl;
/**
* 备注
*/
private String remark;
}
package com.esv.freight.customer.module.driver.form;
import com.esv.freight.customer.common.validator.groups.ValidatorDetail;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.validation.constraints.NotNull;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.driver.form.DriverQueryForm
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/28 20:13
* @version:1.0
*/
@Data
public class DriverQueryForm {
/**
*
*/
@NotNull(message = "参数id不能为空", groups = {ValidatorDetail.class})
private Long id;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.freight.customer.module.driver.service; package com.esv.freight.customer.module.driver.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.module.driver.dto.DriverDetailDto;
import com.esv.freight.customer.module.driver.entity.DriverAccountEntity; import com.esv.freight.customer.module.driver.entity.DriverAccountEntity;
import com.esv.freight.customer.module.driver.form.DriverInfoForm; import com.esv.freight.customer.module.driver.form.DriverInfoForm;
...@@ -31,5 +32,14 @@ public interface DriverAccountService extends IService<DriverAccountEntity> { ...@@ -31,5 +32,14 @@ public interface DriverAccountService extends IService<DriverAccountEntity> {
**/ **/
Integer updateDriver(DriverInfoForm form); Integer updateDriver(DriverInfoForm form);
/**
* description 查询司机详情
* param [id]
* return com.esv.freight.customer.module.driver.dto.DriverDetailDto
* author Administrator
* createTime 2020/04/28 20:22
**/
DriverDetailDto getDriverDetail(Long id);
} }
...@@ -9,6 +9,7 @@ import com.esv.freight.customer.common.exception.EException; ...@@ -9,6 +9,7 @@ import com.esv.freight.customer.common.exception.EException;
import com.esv.freight.customer.common.util.ReqUtils; import com.esv.freight.customer.common.util.ReqUtils;
import com.esv.freight.customer.module.driver.DriverConstants; import com.esv.freight.customer.module.driver.DriverConstants;
import com.esv.freight.customer.module.driver.dao.DriverAccountDao; import com.esv.freight.customer.module.driver.dao.DriverAccountDao;
import com.esv.freight.customer.module.driver.dto.DriverDetailDto;
import com.esv.freight.customer.module.driver.entity.DriverAccountEntity; import com.esv.freight.customer.module.driver.entity.DriverAccountEntity;
import com.esv.freight.customer.module.driver.entity.DriverAuditHistoryEntity; import com.esv.freight.customer.module.driver.entity.DriverAuditHistoryEntity;
import com.esv.freight.customer.module.driver.entity.DriverInfoEntity; import com.esv.freight.customer.module.driver.entity.DriverInfoEntity;
...@@ -154,4 +155,9 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv ...@@ -154,4 +155,9 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv
return flag; return flag;
} }
@Override
public DriverDetailDto getDriverDetail(Long id) {
return this.baseMapper.selectDriverDetail(id);
}
} }
\ No newline at end of file
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;
import java.util.Date;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.driver.vo.DriverDetailVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/28 20:08
* @version:1.0
*/
@Data
public class DriverDetailVO {
/**
*
*/
private Long id;
/**
* 承运商帐号ID
*/
private Long carrierId;
/**
* 登录帐号,司机手机号
*/
private String account;
/**
* 帐号状态:1-正常、2-停用
*/
private Integer accountStatus;
/**
* 创建来源:1-平台创建、2-自行注册
*/
private Integer sourceType;
/**
* 审核状态(字典表):0-待审核、1-审核成功,2-审核失败
*/
private Integer auditStatus;
/**
* 认证状态:1-未认证、2-已认证
*/
private Integer authenticateStatus;
/**
* 姓名
*/
private String name;
/**
* 身份证号码
*/
private String idCard;
/**
* 身份证有效期
*/
private String idCardExpireDate;
/**
* 身份证正面图片URL
*/
private String idCardFrontUrl;
/**
* 身份证背面图片URL
*/
private String idCardBackUrl;
/**
* 结算对象(字典表):1-个人、2-所属承运商
*/
private Integer settlementType;
/**
* 性别(字典表):1-男、2-女、3-未知
*/
private Integer sex;
/**
* 出生日期
*/
private String birthDate;
/**
* 名族
*/
private String nation;
/**
* 籍贯
*/
private String nativePlace;
/**
* 住址-省份代码
*/
private String provinceCode;
/**
* 住址-市代码
*/
private String cityCode;
/**
* 住址-区县代码
*/
private String districtCode;
/**
* 住址-详细地址
*/
private String detailAddress;
/**
* 驾驶证号码
*/
private String drivingLicense;
/**
* 驾驶证类型(字典表):1-A1、2-A2、3-A3、4-A1A2、5-A2E、6-A2D、7-B1、8-B2、9-C1、0-其他
*/
private Integer drivingLicenseType;
/**
* 驾驶证有效期起
*/
private String drivingLicenseStartDate;
/**
* 驾驶证有效期止
*/
private String drivingLicenseEndDate;
/**
* 发证机关
*/
private String drivingLicenseIssueDepartment;
/**
* 初次获得驾驶证日期
*/
private String drivingLicenseInitDate;
/**
* 驾驶证正面图片URL
*/
private String drivingLicenseUrl;
/**
* 道路运输从业资格证-所驾驶车辆(字典表):1-4.5吨及以下、2-4.5吨以上
*/
private Integer certificateVehicle;
/**
* 道路运输从业资格证-有效期止
*/
private String certificateEndDate;
/**
* 道路运输从业资格证-从业资格证号
*/
private String certificateNumber;
/**
* 道路运输从业资格证-正面图片URL
*/
private String certificateUrl;
/**
* 备注
*/
private String remark;
/**
* 创建者
*/
private String createUser;
/**
* 创建时间
*/
private Long createTime;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
...@@ -154,4 +154,6 @@ error-message: ...@@ -154,4 +154,6 @@ error-message:
1001: 无效的账号ID 1001: 无效的账号ID
1002: 身份证号码已存在 1002: 身份证号码已存在
1003: 驾驶证号码已存在 1003: 驾驶证号码已存在
1004: 从业资格证号已存在 1004: 从业资格证号已存在
\ No newline at end of file detail:
1001: 无效的账号ID
\ No newline at end of file
...@@ -24,5 +24,14 @@ ...@@ -24,5 +24,14 @@
<result property="updateTime" column="update_time"/> <result property="updateTime" column="update_time"/>
</resultMap> </resultMap>
<!-- 查询司机详情 -->
<select id="selectDriverDetail" 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,
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.id = #{id}
</select>
</mapper> </mapper>
\ 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.form.DriverQueryForm;
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.DriverTest
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/28 20:27
* @version:1.0
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Transactional
@Rollback(false)
public class DriverTest extends BaseTestController {
/**
* 查询司机详情
**/
@Test
public void a1_detail_success_test() throws Exception {
String url = "/carrier/driver/detail";
// 构造数据
DriverQueryForm form = new DriverQueryForm();
form.setId(2L);
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"));
Assert.assertTrue(null != result.getJSONObject("data"));
}
/**
* 查询司机详情:无效的账号ID
**/
@Test
public void a2_detail_wrong_id_failure_test() throws Exception {
String url = "/carrier/driver/detail";
// 构造数据
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"));
}
}
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