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
1e4d01f2
Commit
1e4d01f2
authored
Apr 27, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
承运商接口:分页查询车辆列表
parent
cc108409
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
267 additions
and
4 deletions
+267
-4
VehicleController.java
...customer/module/vehicle/controller/VehicleController.java
+13
-0
VehicleDao.java
...m/esv/freight/customer/module/vehicle/dao/VehicleDao.java
+12
-1
VehicleQueryForm.java
...reight/customer/module/vehicle/form/VehicleQueryForm.java
+37
-2
VehicleService.java
...eight/customer/module/vehicle/service/VehicleService.java
+11
-0
VehicleServiceImpl.java
...tomer/module/vehicle/service/impl/VehicleServiceImpl.java
+25
-0
VehicleDetailVO.java
...v/freight/customer/module/vehicle/vo/VehicleDetailVO.java
+1
-1
VehicleListVO.java
...esv/freight/customer/module/vehicle/vo/VehicleListVO.java
+74
-0
VehicleDao.xml
src/main/resources/mapper/vehicle/VehicleDao.xml
+31
-0
VehicleControllerTest.java
...omer/module/vehicle/controller/VehicleControllerTest.java
+63
-0
No files found.
src/main/java/com/esv/freight/customer/module/vehicle/controller/VehicleController.java
View file @
1e4d01f2
...
...
@@ -7,6 +7,7 @@ import com.esv.freight.customer.common.response.ECode;
import
com.esv.freight.customer.common.response.EResponse
;
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.ValidatorList
;
import
com.esv.freight.customer.common.validator.groups.ValidatorUpdate
;
import
com.esv.freight.customer.module.carrier.service.CarrierInfoService
;
import
com.esv.freight.customer.module.vehicle.VehicleConstants
;
...
...
@@ -202,4 +203,16 @@ public class VehicleController {
return
EResponse
.
ok
();
}
/**
* description 分页查询车辆列表
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/27 19:55
**/
@PostMapping
(
"/list"
)
public
EResponse
list
(
@RequestBody
@Validated
(
ValidatorList
.
class
)
VehicleQueryForm
form
)
throws
EException
{
return
EResponse
.
ok
(
vehicleService
.
getVehicle4Page
(
form
));
}
}
src/main/java/com/esv/freight/customer/module/vehicle/dao/VehicleDao.java
View file @
1e4d01f2
package
com
.
esv
.
freight
.
customer
.
module
.
vehicle
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.esv.freight.customer.module.vehicle.dto.VehicleDetailDto
;
import
com.esv.freight.customer.module.vehicle.entity.VehicleEntity
;
import
com.
baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.
esv.freight.customer.module.vehicle.form.VehicleQueryForm
;
import
org.apache.ibatis.annotations.Mapper
;
/**
...
...
@@ -23,5 +25,14 @@ public interface VehicleDao extends BaseMapper<VehicleEntity> {
* createTime 2020/04/27 14:02
**/
VehicleDetailDto
selectVehicleDetail
(
Long
id
);
/**
* description 分页查询车辆列表
* param [page, queryObj]
* return com.baomidou.mybatisplus.core.metadata.IPage
* author Administrator
* createTime 2020/04/27 19:48
**/
IPage
selectVehicle4Page
(
IPage
page
,
VehicleQueryForm
queryObj
);
}
src/main/java/com/esv/freight/customer/module/vehicle/form/VehicleQueryForm.java
View file @
1e4d01f2
package
com
.
esv
.
freight
.
customer
.
module
.
vehicle
.
form
;
import
com.esv.freight.customer.common.validator.groups.ValidatorDetail
;
import
com.esv.freight.customer.common.validator.groups.Validator
Update
;
import
com.esv.freight.customer.common.validator.groups.Validator
List
;
import
com.esv.freight.customer.module.vehicle.validator.groups.ValidatorAuditHistory
;
import
com.esv.freight.customer.module.vehicle.validator.groups.ValidatorBlock
;
import
com.esv.freight.customer.module.vehicle.validator.groups.ValidatorUnblock
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
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.Pattern
;
/**
* @description:
...
...
@@ -32,19 +35,51 @@ public class VehicleQueryForm {
* 承运商帐号ID
*/
private
Long
carrierId
;
/**
* 车辆状态:1-正常、2-停用
*/
@Pattern
(
regexp
=
"[12]"
,
message
=
"参数vehicleStatus不合法"
,
groups
=
{
ValidatorList
.
class
})
private
String
vehicleStatus
;
/**
* 审核状态(字典表):0-待审核、1-审核成功,2-审核失败
*/
@Range
(
min
=
0
,
max
=
2
,
message
=
"参数auditStatus不合法"
,
groups
=
{
ValidatorList
.
class
})
private
Integer
auditStatus
;
/**
* 车牌号
*/
@Length
(
max
=
8
,
message
=
"参数licenseNumber长度不合法"
,
groups
=
{
ValidatorList
.
class
})
private
String
licenseNumber
;
/**
* 行驶证档案编号
*/
@Length
(
max
=
20
,
message
=
"参数vehicleLicenseNumber长度不合法"
,
groups
=
{
ValidatorList
.
class
})
private
String
vehicleLicenseNumber
;
/**
* 道路运输证号
*/
@Length
(
max
=
50
,
message
=
"参数ownerName长度不合法"
,
groups
=
{
ValidatorList
.
class
})
private
String
roadCertificateNumber
;
/**
* 车辆类型(字典表)
*/
private
Integer
vehicleType
;
/**
* 二级车辆类型(字典表)
*/
private
Integer
vehicleType2
;
/**
* 页码
**/
@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
public
String
toString
()
{
...
...
src/main/java/com/esv/freight/customer/module/vehicle/service/VehicleService.java
View file @
1e4d01f2
package
com
.
esv
.
freight
.
customer
.
module
.
vehicle
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.esv.freight.customer.common.vo.PageResultVO
;
import
com.esv.freight.customer.module.vehicle.dto.VehicleDetailDto
;
import
com.esv.freight.customer.module.vehicle.entity.VehicleEntity
;
import
com.esv.freight.customer.module.vehicle.form.VehicleAuditForm
;
import
com.esv.freight.customer.module.vehicle.form.VehicleInfoForm
;
import
com.esv.freight.customer.module.vehicle.form.VehicleQueryForm
;
/**
* 车辆表
...
...
@@ -78,5 +80,14 @@ public interface VehicleService extends IService<VehicleEntity> {
**/
Integer
unBlockVehicle
(
Long
id
);
/**
* description 分页查询车辆列表
* param [queryObj]
* return com.esv.freight.customer.common.vo.PageResultVO
* author Administrator
* createTime 2020/04/27 19:52
**/
PageResultVO
getVehicle4Page
(
VehicleQueryForm
queryObj
);
}
src/main/java/com/esv/freight/customer/module/vehicle/service/impl/VehicleServiceImpl.java
View file @
1e4d01f2
...
...
@@ -2,12 +2,15 @@ package com.esv.freight.customer.module.vehicle.service.impl;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
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.esv.freight.customer.common.component.ErrorMessageComponent
;
import
com.esv.freight.customer.common.constants.CommonConstants
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.response.ECode
;
import
com.esv.freight.customer.common.util.ReqUtils
;
import
com.esv.freight.customer.common.vo.PageResultVO
;
import
com.esv.freight.customer.module.carrier.entity.CarrierAccountEntity
;
import
com.esv.freight.customer.module.carrier.service.CarrierAccountService
;
import
com.esv.freight.customer.module.vehicle.VehicleConstants
;
...
...
@@ -18,9 +21,11 @@ import com.esv.freight.customer.module.vehicle.entity.VehicleAuditHistoryEntity;
import
com.esv.freight.customer.module.vehicle.entity.VehicleEntity
;
import
com.esv.freight.customer.module.vehicle.form.VehicleAuditForm
;
import
com.esv.freight.customer.module.vehicle.form.VehicleInfoForm
;
import
com.esv.freight.customer.module.vehicle.form.VehicleQueryForm
;
import
com.esv.freight.customer.module.vehicle.service.AttachmentService
;
import
com.esv.freight.customer.module.vehicle.service.VehicleAuditHistoryService
;
import
com.esv.freight.customer.module.vehicle.service.VehicleService
;
import
com.esv.freight.customer.module.vehicle.vo.VehicleListVO
;
import
com.esv.gateway.common.GatewayHeaders
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -29,6 +34,8 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.List
;
@Service
(
"vehicleService"
)
...
...
@@ -255,4 +262,22 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleDao, VehicleEntity> i
updateEntity
.
setVehicleStatus
(
VehicleConstants
.
VEHICLE_ACCOUNT_STATUS_UNBLOCK
);
return
this
.
baseMapper
.
updateById
(
updateEntity
);
}
@Override
public
PageResultVO
getVehicle4Page
(
VehicleQueryForm
queryObj
)
{
IPage
<
VehicleDetailDto
>
page
=
new
Page
<>(
queryObj
.
getPageNum
(),
queryObj
.
getPageSize
());
this
.
baseMapper
.
selectVehicle4Page
(
page
,
queryObj
);
// 数据转换
List
<
VehicleDetailDto
>
dtoList
=
page
.
getRecords
();
List
<
VehicleListVO
>
targetRecordList
=
new
ArrayList
<>();
for
(
VehicleDetailDto
dto
:
dtoList
)
{
VehicleListVO
vo
=
new
VehicleListVO
();
BeanUtils
.
copyProperties
(
dto
,
vo
);
vo
.
setCreateTime
(
dto
.
getCreateTime
().
getTime
());
targetRecordList
.
add
(
vo
);
}
return
new
PageResultVO
(
page
,
targetRecordList
);
}
}
\ No newline at end of file
src/main/java/com/esv/freight/customer/module/vehicle/vo/VehicleDetailVO.java
View file @
1e4d01f2
...
...
@@ -191,7 +191,7 @@ public class VehicleDetailVO {
*/
private
String
createUser
;
/**
*
修改者
*
创建时间
*/
private
Long
createTime
;
/**
...
...
src/main/java/com/esv/freight/customer/module/vehicle/vo/VehicleListVO.java
0 → 100644
View file @
1e4d01f2
package
com
.
esv
.
freight
.
customer
.
module
.
vehicle
.
vo
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
java.math.BigDecimal
;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.vehicle.vo.VehicleListVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/27 13:40
* @version:1.0
*/
@Data
public
class
VehicleListVO
{
/**
*
*/
private
Long
id
;
/**
* 车牌号
*/
private
String
licenseNumber
;
/**
* 车辆状态:1-正常、2-停用
*/
private
String
vehicleStatus
;
/**
* 审核状态(字典表):0-待审核、1-审核成功,2-审核失败
*/
private
Integer
auditStatus
;
/**
* 车辆类型(字典表)
*/
private
Integer
vehicleType
;
/**
* 二级车辆类型(字典表)
*/
private
Integer
vehicleType2
;
/**
* 行驶证档案编号
*/
private
String
vehicleLicenseNumber
;
/**
* 道路运输证号
*/
private
String
roadCertificateNumber
;
/**
* 核定载质量(吨)
*/
private
BigDecimal
loadCapacity
;
/**
* 创建来源:1-平台创建、2-司机创建
*/
private
String
sourceType
;
/**
* 创建者
*/
private
String
createUser
;
/**
* 创建时间
*/
private
Long
createTime
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
}
}
src/main/resources/mapper/vehicle/VehicleDao.xml
View file @
1e4d01f2
...
...
@@ -64,4 +64,35 @@
and a.id = #{id}
</select>
<!-- 分页查询车辆列表 -->
<select
id=
"selectVehicle4Page"
parameterType=
"com.esv.freight.customer.module.vehicle.form.VehicleQueryForm"
resultType=
"com.esv.freight.customer.module.vehicle.dto.VehicleDetailDto"
>
select a.*, b.vehicle_head_url, b.vehicle_head_person_url, b.vehicle_license_front_url,
b.vehicle_license_back_url, b.road_certificate_front_url, b.attached_statement_url
from vehicle a, vehicle_attachment b
where a.id = b.vehicle_id
<if
test=
"queryObj.licenseNumber != null"
>
and a.license_number like CONCAT('%', #{queryObj.licenseNumber}, '%')
</if>
<if
test=
"queryObj.vehicleType != null"
>
and a.vehicle_type = #{queryObj.vehicleType}
</if>
<if
test=
"queryObj.vehicleType2 != null"
>
and a.vehicle_type2 = #{queryObj.vehicleType2}
</if>
<if
test=
"queryObj.vehicleStatus != null"
>
and a.vehicle_status = #{queryObj.vehicleStatus}
</if>
<if
test=
"queryObj.auditStatus != null"
>
and a.audit_status = #{queryObj.auditStatus}
</if>
<if
test=
"queryObj.vehicleLicenseNumber != null"
>
and a.vehicle_license_number like CONCAT('%', #{queryObj.vehicleLicenseNumber}, '%')
</if>
<if
test=
"queryObj.roadCertificateNumber != null"
>
and a.road_certificate_number like CONCAT('%', #{queryObj.roadCertificateNumber}, '%')
</if>
ORDER BY a.update_time DESC, a.license_number ASC
</select>
</mapper>
\ No newline at end of file
src/test/java/com/esv/freight/customer/module/vehicle/controller/VehicleControllerTest.java
View file @
1e4d01f2
...
...
@@ -449,4 +449,67 @@ public class VehicleControllerTest extends BaseTestController {
JSONObject
result
=
JSONObject
.
parseObject
(
responseStr
);
Assert
.
assertEquals
(
1002
,
result
.
getIntValue
(
"code"
));
}
/**
* 分页查询车辆列表
**/
@Test
@Rollback
public
void
f1_list_success_test
()
throws
Exception
{
String
url
=
"/carrier/vehicle/list"
;
// 构造数据
VehicleQueryForm
form
=
new
VehicleQueryForm
();
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
@Rollback
public
void
f2_list_with_param_success_test
()
throws
Exception
{
String
url
=
"/carrier/vehicle/list"
;
// 构造数据
VehicleQueryForm
form
=
new
VehicleQueryForm
();
form
.
setLicenseNumber
(
"辽A"
);
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"
));
}
}
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