Commit 2ef37f0c authored by huangcb's avatar huangcb

承运商接口:分页查询司机列表

parent 81be4042
...@@ -23,12 +23,6 @@ public class DriverConstants { ...@@ -23,12 +23,6 @@ public class DriverConstants {
public static final Integer ACCOUNT_SOURCE_TYPE_PLATFORM = 1; public static final Integer ACCOUNT_SOURCE_TYPE_PLATFORM = 1;
public static final Integer ACCOUNT_SOURCE_TYPE_REGISTER = 2; public static final Integer ACCOUNT_SOURCE_TYPE_REGISTER = 2;
/**
* 帐号认证状态:1-未认证、2-已认证
**/
public static final Integer ACCOUNT_AUTHENTICATE_STATUS_NO = 1;
public static final Integer ACCOUNT_AUTHENTICATE_STATUS_YES = 2;
/** /**
* 帐号审核状态:0-待审核、1-审核成功,2-审核失败 * 帐号审核状态:0-待审核、1-审核成功,2-审核失败
**/ **/
......
...@@ -9,6 +9,7 @@ import com.esv.freight.customer.common.util.ReqUtils; ...@@ -9,6 +9,7 @@ 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.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.ValidatorList;
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.dto.DriverDetailDto;
...@@ -216,4 +217,16 @@ public class DriverController { ...@@ -216,4 +217,16 @@ public class DriverController {
return EResponse.ok(voList); return EResponse.ok(voList);
} }
/**
* description 分页查询司机列表
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/29 14:13
**/
@PostMapping("/list")
public EResponse list(@RequestBody @Validated(ValidatorList.class) DriverQueryForm form) throws EException {
return EResponse.ok(driverAccountService.getDriver4Page(form));
}
} }
package com.esv.freight.customer.module.driver.dao; package com.esv.freight.customer.module.driver.dao;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.esv.freight.customer.module.driver.dto.DriverDetailDto; 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 com.esv.freight.customer.module.driver.form.DriverQueryForm;
import com.esv.freight.customer.module.vehicle.form.VehicleQueryForm;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**
...@@ -24,4 +27,13 @@ public interface DriverAccountDao extends BaseMapper<DriverAccountEntity> { ...@@ -24,4 +27,13 @@ public interface DriverAccountDao extends BaseMapper<DriverAccountEntity> {
**/ **/
DriverDetailDto selectDriverDetail(Long id); DriverDetailDto selectDriverDetail(Long id);
/**
* description 分页查询司机列表
* param [page, queryObj]
* return com.baomidou.mybatisplus.core.metadata.IPage
* author Administrator
* createTime 2020/04/29 14:01
**/
IPage selectDriver4Page(IPage page, DriverQueryForm queryObj);
} }
...@@ -38,6 +38,22 @@ public class DriverDetailDto { ...@@ -38,6 +38,22 @@ public class DriverDetailDto {
* 承运商帐号ID * 承运商帐号ID
*/ */
private Long carrierId; private Long carrierId;
/**
* 承运商名称
*/
private String carrierName;
/**
* 承运商类别(字典表):1-企业承运人、2-个体承运人
*/
private Integer carrierType;
/**
* 承运商名称
*/
private String carrierFullName;
/**
* 承运商联系人
*/
private String carrierContactor;
/** /**
* 登录帐号,司机手机号 * 登录帐号,司机手机号
*/ */
...@@ -62,10 +78,6 @@ public class DriverDetailDto { ...@@ -62,10 +78,6 @@ public class DriverDetailDto {
* 审核状态(字典表):0-待审核、1-审核成功,2-审核失败 * 审核状态(字典表):0-待审核、1-审核成功,2-审核失败
*/ */
private Integer auditStatus; private Integer auditStatus;
/**
* 认证状态:1-未认证、2-已认证
*/
private Integer authenticateStatus;
/** /**
* 上报状态(字典表):0-未上报、1-上报成功、2-上报失败 * 上报状态(字典表):0-未上报、1-上报成功、2-上报失败
*/ */
......
...@@ -64,10 +64,6 @@ public class DriverAccountEntity implements Serializable { ...@@ -64,10 +64,6 @@ public class DriverAccountEntity implements Serializable {
* 审核状态(字典表):0-待审核、1-审核成功,2-审核失败 * 审核状态(字典表):0-待审核、1-审核成功,2-审核失败
*/ */
private Integer auditStatus; private Integer auditStatus;
/**
* 认证状态:1-未认证、2-已认证
*/
private Integer authenticateStatus;
/** /**
* 上报状态(字典表):0-未上报、1-上报成功、2-上报失败 * 上报状态(字典表):0-未上报、1-上报成功、2-上报失败
*/ */
......
...@@ -50,10 +50,6 @@ public class DriverInfoForm { ...@@ -50,10 +50,6 @@ public class DriverInfoForm {
* 帐号状态:1-正常、2-停用 * 帐号状态:1-正常、2-停用
*/ */
private Integer accountStatus; private Integer accountStatus;
/**
* 认证状态:1-未认证、2-已认证
*/
private Integer authenticateStatus;
/** /**
* 姓名 * 姓名
*/ */
......
package com.esv.freight.customer.module.driver.form; package com.esv.freight.customer.module.driver.form;
import com.esv.freight.customer.common.validator.groups.ValidatorDetail; import com.esv.freight.customer.common.validator.groups.ValidatorDetail;
import com.esv.freight.customer.common.validator.groups.ValidatorList;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
...@@ -24,6 +27,53 @@ public class DriverQueryForm { ...@@ -24,6 +27,53 @@ public class DriverQueryForm {
*/ */
@NotNull(message = "参数id不能为空", groups = {ValidatorDetail.class}) @NotNull(message = "参数id不能为空", groups = {ValidatorDetail.class})
private Long id; private Long id;
/**
* 承运商帐号ID
*/
private Long carrierId;
/**
* 帐号状态:1-正常、2-停用
*/
@Range(min = 1, max = 2, message = "参数accountStatus不合法", groups = {ValidatorList.class})
private Integer accountStatus;
/**
* 创建来源:1-平台创建、2-自行注册
*/
@Range(min = 1, max = 2, message = "参数accountStatus不合法", groups = {ValidatorList.class})
private Integer sourceType;
/**
* 审核状态(字典表):0-待审核、1-审核成功,2-审核失败
*/
@Range(min = 0, max = 2, message = "参数auditStatus不合法", groups = {ValidatorList.class})
private Integer auditStatus;
/**
* 驾驶证类型(字典表):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 = {ValidatorList.class})
private Integer drivingLicenseType;
/**
* 登录帐号,司机手机号
*/
@Length(max = 11, message = "参数account长度不合法", groups = {ValidatorList.class})
private String account;
/**
* keywords
*/
@Length(max = 20, message = "参数keywords长度不合法", groups = {ValidatorList.class})
private String keywords;
/**
* 页码
**/
@Range(min = 1, max = 65535, message = "无效的pageNum", groups = {ValidatorList.class})
@NotNull(message = "参数pageNum不能为空", groups = {ValidatorList.class})
private Integer pageNum;
/**
* 每页记录条数
**/
@Range(min = 1, max = 100, message = "pageSize", groups = {ValidatorList.class})
@NotNull(message = "参数pageSize不能为空", groups = {ValidatorList.class})
private Integer pageSize;
@Override @Override
public String toString() { public String toString() {
......
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.common.vo.PageResultVO;
import com.esv.freight.customer.module.driver.dto.DriverDetailDto; 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.form.DriverAuditForm; import com.esv.freight.customer.module.driver.form.DriverAuditForm;
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 java.util.List; import java.util.List;
...@@ -90,5 +92,14 @@ public interface DriverAccountService extends IService<DriverAccountEntity> { ...@@ -90,5 +92,14 @@ public interface DriverAccountService extends IService<DriverAccountEntity> {
**/ **/
List<DriverAuditHistoryEntity> getAuditHistory(Long id); List<DriverAuditHistoryEntity> getAuditHistory(Long id);
/**
* description 分页查询司机列表
* param [queryObj]
* return com.esv.freight.customer.common.vo.PageResultVO
* author Administrator
* createTime 2020/04/29 14:09
**/
PageResultVO getDriver4Page(DriverQueryForm queryObj);
} }
...@@ -2,13 +2,19 @@ package com.esv.freight.customer.module.driver.service.impl; ...@@ -2,13 +2,19 @@ package com.esv.freight.customer.module.driver.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.esv.freight.customer.common.component.ErrorMessageComponent; import com.esv.freight.customer.common.component.ErrorMessageComponent;
import com.esv.freight.customer.common.component.PasswordComponent; import com.esv.freight.customer.common.component.PasswordComponent;
import com.esv.freight.customer.common.exception.EException; 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.common.vo.PageResultVO;
import com.esv.freight.customer.module.carrier.CarrierConstants;
import com.esv.freight.customer.module.carrier.dto.CarrierInfoDto;
import com.esv.freight.customer.module.carrier.entity.CarrierAccountEntity; import com.esv.freight.customer.module.carrier.entity.CarrierAccountEntity;
import com.esv.freight.customer.module.carrier.service.CarrierAccountService; import com.esv.freight.customer.module.carrier.service.CarrierAccountService;
import com.esv.freight.customer.module.carrier.vo.CarrierInfoListVO;
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.dto.DriverDetailDto;
...@@ -16,16 +22,19 @@ import com.esv.freight.customer.module.driver.entity.DriverAccountEntity; ...@@ -16,16 +22,19 @@ 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;
import com.esv.freight.customer.module.driver.form.DriverAuditForm; import com.esv.freight.customer.module.driver.form.DriverAuditForm;
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.service.DriverAuditHistoryService; import com.esv.freight.customer.module.driver.service.DriverAuditHistoryService;
import com.esv.freight.customer.module.driver.service.DriverInfoService; import com.esv.freight.customer.module.driver.service.DriverInfoService;
import com.esv.freight.customer.module.driver.form.DriverInfoForm; import com.esv.freight.customer.module.driver.vo.DriverListVO;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -97,7 +106,6 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv ...@@ -97,7 +106,6 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv
driverAccountEntity.setPassword(passwordComponent.generatePwd4Salt(form.getPassword(), salt)); driverAccountEntity.setPassword(passwordComponent.generatePwd4Salt(form.getPassword(), salt));
driverAccountEntity.setAccountStatus(DriverConstants.ACCOUNT_STATUS_UNBLOCK); driverAccountEntity.setAccountStatus(DriverConstants.ACCOUNT_STATUS_UNBLOCK);
driverAccountEntity.setSourceType(DriverConstants.ACCOUNT_SOURCE_TYPE_PLATFORM); driverAccountEntity.setSourceType(DriverConstants.ACCOUNT_SOURCE_TYPE_PLATFORM);
driverAccountEntity.setAuthenticateStatus(DriverConstants.ACCOUNT_AUTHENTICATE_STATUS_YES);
driverAccountEntity.setAuditStatus(DriverConstants.ACCOUNT_AUDIT_STATUS_SUCCESS); driverAccountEntity.setAuditStatus(DriverConstants.ACCOUNT_AUDIT_STATUS_SUCCESS);
this.baseMapper.insert(driverAccountEntity); this.baseMapper.insert(driverAccountEntity);
Long driverId = driverAccountEntity.getId(); Long driverId = driverAccountEntity.getId();
...@@ -266,7 +274,6 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv ...@@ -266,7 +274,6 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv
driverAccountEntity.setSalt(passwordComponent.generateAccountPwdSalt()); driverAccountEntity.setSalt(passwordComponent.generateAccountPwdSalt());
driverAccountEntity.setAccountStatus(DriverConstants.ACCOUNT_STATUS_BLOCK); driverAccountEntity.setAccountStatus(DriverConstants.ACCOUNT_STATUS_BLOCK);
driverAccountEntity.setSourceType(DriverConstants.ACCOUNT_SOURCE_TYPE_REGISTER); driverAccountEntity.setSourceType(DriverConstants.ACCOUNT_SOURCE_TYPE_REGISTER);
driverAccountEntity.setAuthenticateStatus(DriverConstants.ACCOUNT_AUTHENTICATE_STATUS_NO);
driverAccountEntity.setAuditStatus(DriverConstants.ACCOUNT_AUDIT_STATUS_UNAUDITED); driverAccountEntity.setAuditStatus(DriverConstants.ACCOUNT_AUDIT_STATUS_UNAUDITED);
this.baseMapper.insert(driverAccountEntity); this.baseMapper.insert(driverAccountEntity);
Long driverId = driverAccountEntity.getId(); Long driverId = driverAccountEntity.getId();
...@@ -299,4 +306,27 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv ...@@ -299,4 +306,27 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv
return this.driverAuditHistoryService.getBaseMapper().selectList(new QueryWrapper<DriverAuditHistoryEntity>().lambda() return this.driverAuditHistoryService.getBaseMapper().selectList(new QueryWrapper<DriverAuditHistoryEntity>().lambda()
.eq(DriverAuditHistoryEntity::getDriverId, id).orderByAsc(DriverAuditHistoryEntity::getOperateTime)); .eq(DriverAuditHistoryEntity::getDriverId, id).orderByAsc(DriverAuditHistoryEntity::getOperateTime));
} }
@Override
public PageResultVO getDriver4Page(DriverQueryForm queryObj) {
IPage<DriverDetailDto> page = new Page<>(queryObj.getPageNum(), queryObj.getPageSize());
this.baseMapper.selectDriver4Page(page, queryObj);
// 数据转换
List<DriverDetailDto> dtoList = page.getRecords();
List<DriverListVO> targetRecordList = new ArrayList<>();
for (DriverDetailDto dto : dtoList) {
DriverListVO vo = new DriverListVO();
BeanUtils.copyProperties(dto, vo);
if (CarrierConstants.CARRIER_TYPE_COMPANY.equals(dto.getCarrierType())) {
vo.setCarrierName(dto.getCarrierFullName());
} else {
vo.setCarrierName(dto.getCarrierContactor());
}
vo.setCreateTime(dto.getCreateTime().getTime());
targetRecordList.add(vo);
}
return new PageResultVO(page, targetRecordList);
}
} }
\ No newline at end of file
...@@ -42,10 +42,6 @@ public class DriverDetailVO { ...@@ -42,10 +42,6 @@ public class DriverDetailVO {
* 审核状态(字典表):0-待审核、1-审核成功,2-审核失败 * 审核状态(字典表):0-待审核、1-审核成功,2-审核失败
*/ */
private Integer auditStatus; private Integer auditStatus;
/**
* 认证状态:1-未认证、2-已认证
*/
private Integer authenticateStatus;
/** /**
* 姓名 * 姓名
*/ */
......
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.DriverListVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/28 20:08
* @version:1.0
*/
@Data
public class DriverListVO {
/**
*
*/
private Long id;
/**
* 承运商名称
*/
private String carrierName;
/**
* 登录帐号,司机手机号
*/
private String account;
/**
* 帐号状态:1-正常、2-停用
*/
private Integer accountStatus;
/**
* 创建来源:1-平台创建、2-自行注册
*/
private Integer sourceType;
/**
* 审核状态(字典表):0-待审核、1-审核成功,2-审核失败
*/
private Integer auditStatus;
/**
* 姓名
*/
private String name;
/**
* 身份证号码
*/
private String idCard;
/**
* 驾驶证类型(字典表):1-A1、2-A2、3-A3、4-A1A2、5-A2E、6-A2D、7-B1、8-B2、9-C1、0-其他
*/
private Integer drivingLicenseType;
/**
* 道路运输从业资格证-所驾驶车辆(字典表):1-4.5吨及以下、2-4.5吨以上
*/
private Integer certificateVehicle;
/**
* 创建者
*/
private String createUser;
/**
* 创建时间
*/
private Long createTime;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
<result property="accountStatus" column="account_status"/> <result property="accountStatus" column="account_status"/>
<result property="sourceType" column="source_type"/> <result property="sourceType" column="source_type"/>
<result property="auditStatus" column="audit_status"/> <result property="auditStatus" column="audit_status"/>
<result property="authenticateStatus" column="authenticate_status"/>
<result property="reportStatus" column="report_status"/> <result property="reportStatus" column="report_status"/>
<result property="reportTime" column="report_time"/> <result property="reportTime" column="report_time"/>
<result property="createUser" column="create_user"/> <result property="createUser" column="create_user"/>
...@@ -34,4 +33,39 @@ ...@@ -34,4 +33,39 @@
where a.id = b.driver_id and a.id = #{id} where a.id = b.driver_id and a.id = #{id}
</select> </select>
<!-- 分页查询司机列表 -->
<select id="selectDriver4Page" parameterType="com.esv.freight.customer.module.driver.form.DriverQueryForm"
resultType="com.esv.freight.customer.module.driver.dto.DriverDetailDto">
select a.*, b.name, b.id_card, b.driving_license_type, b.certificate_vehicle,
c.carrier_type as carrierType, c.carrier_full_name as carrierFullName, c.contactor as carrierContactor
from driver_account a, driver_info b, carrier_info c
where a.id = b.driver_id
and a.carrier_id = c.account_id
<if test="queryObj.carrierId != null">
and a.carrier_id = #{queryObj.carrierId}
</if>
<if test="queryObj.auditStatus != null">
and a.audit_status = #{queryObj.auditStatus}
</if>
<if test="queryObj.accountStatus != null">
and a.account_status = #{queryObj.accountStatus}
</if>
<if test="queryObj.sourceType != null">
and a.source_type = #{queryObj.sourceType}
</if>
<if test="queryObj.account != null">
and a.account like CONCAT('%', #{queryObj.account}, '%')
</if>
<if test="queryObj.drivingLicenseType != null">
and b.driving_license_type = #{queryObj.drivingLicenseType}
</if>
<if test="queryObj.keywords != null">
and (b.name like CONCAT('%', #{queryObj.keywords}, '%')
or b.id_card like CONCAT('%', #{queryObj.keywords}, '%')
or b.driving_license like CONCAT('%', #{queryObj.keywords}, '%')
or b.certificate_number like CONCAT('%', #{queryObj.keywords}, '%'))
</if>
ORDER BY a.update_time DESC, a.account ASC
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -538,4 +538,66 @@ public class DriverAccountTest extends BaseTestController { ...@@ -538,4 +538,66 @@ public class DriverAccountTest extends BaseTestController {
Assert.assertEquals(1001, result.getIntValue("code")); Assert.assertEquals(1001, result.getIntValue("code"));
} }
/**
* 分页查询司机列表
**/
@Test
public void f1_list_success_test() throws Exception {
String url = "/carrier/driver/list";
// 构造数据
DriverQueryForm form = new DriverQueryForm();
form.setPageNum(1);
form.setPageSize(10);
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(result.getJSONObject("data").containsKey("records"));
}
/**
* 分页查询司机列表:查询条件
**/
@Test
public void f2_list_has_params_success_test() throws Exception {
String url = "/carrier/driver/list";
// 构造数据
DriverQueryForm form = new DriverQueryForm();
form.setAccount("1234");
form.setKeywords("210");
form.setPageNum(1);
form.setPageSize(10);
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(result.getJSONObject("data").containsKey("records"));
}
} }
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