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
d639ee12
Commit
d639ee12
authored
Apr 26, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
承运商接口:分页查询承运商信息
parent
1c48a7a3
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
251 additions
and
0 deletions
+251
-0
CarrierAccountController.java
...r/module/carrier/controller/CarrierAccountController.java
+13
-0
CarrierAccountDao.java
...reight/customer/module/carrier/dao/CarrierAccountDao.java
+11
-0
CarrierQueryForm.java
...reight/customer/module/carrier/form/CarrierQueryForm.java
+21
-0
CarrierAccountService.java
...ustomer/module/carrier/service/CarrierAccountService.java
+11
-0
CarrierAccountServiceImpl.java
...odule/carrier/service/impl/CarrierAccountServiceImpl.java
+28
-0
CarrierInfoListVO.java
...freight/customer/module/carrier/vo/CarrierInfoListVO.java
+72
-0
CarrierAccountDao.xml
src/main/resources/mapper/carrier/CarrierAccountDao.xml
+31
-0
CarrierAccountControllerTest.java
...dule/carrier/controller/CarrierAccountControllerTest.java
+64
-0
No files found.
src/main/java/com/esv/freight/customer/module/carrier/controller/CarrierAccountController.java
View file @
d639ee12
...
...
@@ -6,6 +6,7 @@ import com.esv.freight.customer.common.response.EResponse;
import
com.esv.freight.customer.common.util.ReqUtils
;
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.CarrierConstants
;
import
com.esv.freight.customer.module.carrier.dto.CarrierInfoDto
;
...
...
@@ -138,4 +139,16 @@ public class CarrierAccountController {
return
EResponse
.
ok
(
voList
);
}
/**
* description 分页查询帐号列表
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/26 9:34
**/
@PostMapping
(
"/list"
)
public
EResponse
list
(
@RequestBody
@Validated
(
ValidatorList
.
class
)
CarrierQueryForm
form
)
throws
EException
{
return
EResponse
.
ok
(
carrierAccountService
.
getCarrier4Page
(
form
));
}
}
src/main/java/com/esv/freight/customer/module/carrier/dao/CarrierAccountDao.java
View file @
d639ee12
package
com
.
esv
.
freight
.
customer
.
module
.
carrier
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
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.form.CarrierQueryForm
;
import
com.esv.freight.customer.module.goodsowner.form.AccountQueryForm
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
...
...
@@ -27,6 +29,15 @@ public interface CarrierAccountDao extends BaseMapper<CarrierAccountEntity> {
**/
List
<
CarrierInfoDto
>
selectCarrierList
(
CarrierQueryForm
queryObj
);
/**
* description 分页查询帐号列表
* param [page, queryObj]
* return com.baomidou.mybatisplus.core.metadata.IPage
* author Administrator
* createTime 2020/04/26 9:27
**/
IPage
selectCarrier4Page
(
IPage
page
,
CarrierQueryForm
queryObj
);
/**
* description 查询承运商详情
* param [queryObj]
...
...
src/main/java/com/esv/freight/customer/module/carrier/form/CarrierQueryForm.java
View file @
d639ee12
package
com
.
esv
.
freight
.
customer
.
module
.
carrier
.
form
;
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
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
;
...
...
@@ -28,6 +32,7 @@ public class CarrierQueryForm {
/**
* 登录帐号,承运商联系人电话
*/
@Length
(
max
=
11
,
message
=
"参数account长度不合法"
,
groups
=
{
ValidatorList
.
class
})
private
String
account
;
/**
* 帐号状态:1-正常、2-停用
...
...
@@ -36,6 +41,7 @@ public class CarrierQueryForm {
/**
* 客户编码
*/
@Length
(
max
=
20
,
message
=
"参数carrierNumber长度不合法"
,
groups
=
{
ValidatorList
.
class
})
private
String
carrierNumber
;
/**
* 统一社会信用代码
...
...
@@ -52,10 +58,12 @@ public class CarrierQueryForm {
/**
* 承运商名称
*/
@Length
(
max
=
50
,
message
=
"参数carrierName不合法"
,
groups
=
{
ValidatorList
.
class
})
private
String
carrierName
;
/**
* 承运商类别:1-企业承运人、2-个体承运人
*/
@Range
(
min
=
1
,
max
=
2
,
message
=
"参数carrierType不合法"
,
groups
=
{
ValidatorList
.
class
})
private
Integer
carrierType
;
/**
* 承运商车辆类型(字典表):1-自营车、2-外协车、3-其他
...
...
@@ -66,6 +74,19 @@ public class CarrierQueryForm {
*/
private
String
contactor
;
/**
* 页码
**/
@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
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
...
...
src/main/java/com/esv/freight/customer/module/carrier/service/CarrierAccountService.java
View file @
d639ee12
package
com
.
esv
.
freight
.
customer
.
module
.
carrier
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.esv.freight.customer.common.vo.PageResultVO
;
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.form.CarrierInfoForm
;
import
com.esv.freight.customer.module.carrier.form.CarrierQueryForm
;
import
com.esv.freight.customer.module.goodsowner.form.AccountQueryForm
;
import
java.util.List
;
...
...
@@ -62,5 +64,14 @@ public interface CarrierAccountService extends IService<CarrierAccountEntity> {
**/
List
<
CarrierInfoDto
>
getAllCarrierBrief
();
/**
* description 分页查询帐号列表
* param [queryObj]
* return com.esv.freight.customer.common.vo.PageResultVO
* author Administrator
* createTime 2020/04/26 9:29
**/
PageResultVO
getCarrier4Page
(
CarrierQueryForm
queryObj
);
}
src/main/java/com/esv/freight/customer/module/carrier/service/impl/CarrierAccountServiceImpl.java
View file @
d639ee12
...
...
@@ -2,11 +2,14 @@ package com.esv.freight.customer.module.carrier.service.impl;
import
com.alibaba.fastjson.JSONObject
;
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.component.PasswordComponent
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.util.FeignUtils
;
import
com.esv.freight.customer.common.vo.PageResultVO
;
import
com.esv.freight.customer.feign.FeignBaseService
;
import
com.esv.freight.customer.module.carrier.CarrierConstants
;
import
com.esv.freight.customer.module.carrier.dao.CarrierAccountDao
;
...
...
@@ -17,11 +20,13 @@ import com.esv.freight.customer.module.carrier.form.CarrierInfoForm;
import
com.esv.freight.customer.module.carrier.form.CarrierQueryForm
;
import
com.esv.freight.customer.module.carrier.service.CarrierAccountService
;
import
com.esv.freight.customer.module.carrier.service.CarrierInfoService
;
import
com.esv.freight.customer.module.carrier.vo.CarrierInfoListVO
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -191,4 +196,27 @@ public class CarrierAccountServiceImpl extends ServiceImpl<CarrierAccountDao, Ca
public
List
<
CarrierInfoDto
>
getAllCarrierBrief
()
{
return
this
.
baseMapper
.
selectAllCarrierBrief
();
}
@Override
public
PageResultVO
getCarrier4Page
(
CarrierQueryForm
queryObj
)
{
IPage
<
CarrierInfoDto
>
page
=
new
Page
<>(
queryObj
.
getPageNum
(),
queryObj
.
getPageSize
());
this
.
baseMapper
.
selectCarrier4Page
(
page
,
queryObj
);
// 数据转换
List
<
CarrierInfoDto
>
dtoList
=
page
.
getRecords
();
List
<
CarrierInfoListVO
>
targetRecordList
=
new
ArrayList
<>();
for
(
CarrierInfoDto
dto
:
dtoList
)
{
CarrierInfoListVO
vo
=
new
CarrierInfoListVO
();
BeanUtils
.
copyProperties
(
dto
,
vo
);
if
(
CarrierConstants
.
CARRIER_TYPE_COMPANY
.
equals
(
dto
.
getCarrierType
()))
{
vo
.
setCarrierName
(
dto
.
getCarrierFullName
());
}
else
{
vo
.
setCarrierName
(
dto
.
getContactor
());
}
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/carrier/vo/CarrierInfoListVO.java
0 → 100644
View file @
d639ee12
package
com
.
esv
.
freight
.
customer
.
module
.
carrier
.
vo
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
/**
* @description: 承运商分页列表VO
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.carrier.vo.CarrierInfoListVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/24 16:58
* @version:1.0
*/
@Data
public
class
CarrierInfoListVO
{
/**
*
*/
private
Long
id
;
/**
* 登录帐号,承运商联系人电话
*/
private
String
account
;
/**
* 帐号状态:1-正常、2-停用
*/
private
String
accountStatus
;
/**
* 创建者
*/
private
String
createUser
;
/**
* 创建时间
*/
private
Long
createTime
;
/**
* 客户编码
*/
private
String
carrierNumber
;
/**
* 统一社会信用代码
*/
private
String
uniCreditCode
;
/**
* 承运商名称
*/
private
String
carrierName
;
/**
* 承运商类别:1-企业承运人、2-个体承运人
*/
private
Integer
carrierType
;
/**
* 承运商车辆类型(字典表):1-自营车、2-外协车、3-其他
*/
private
Integer
carrierVehicleType
;
/**
* 企业法人姓名
*/
private
String
legalPerson
;
/**
* 道路运输经营许可证号
*/
private
String
roadLicenseNumber
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
}
}
src/main/resources/mapper/carrier/CarrierAccountDao.xml
View file @
d639ee12
...
...
@@ -82,5 +82,36 @@
ORDER BY b.carrier_type ASC, b.carrier_full_name ASC, b.contactor ASC
</select>
<!-- 分页查询帐号列表 -->
<select
id=
"selectCarrier4Page"
parameterType=
"com.esv.freight.customer.module.carrier.form.CarrierQueryForm"
resultType=
"com.esv.freight.customer.module.carrier.dto.CarrierInfoDto"
>
select a.id, a.account, a.account_status, a.create_user, a.create_time,
b.carrier_number, b.uni_credit_code, b.carrier_full_name, b.carrier_brief_name, b.carrier_type, b.carrier_vehicle_type,
b.province_code, b.city_code, b.district_code, b.detail_address, b.legal_person, b.business_license_url, b.road_license_number,
b.business_scope, b.road_license_expire_date, b.road_license_url, b.contactor, b.email, b.credit_score, b.remark
from carrier_account a, carrier_info b
where a.id = b.account_id
<if
test=
"queryObj.account != null"
>
and a.account like CONCAT('%', #{queryObj.account}, '%')
</if>
<if
test=
"queryObj.accountStatus != null"
>
and a.account_status = #{queryObj.accountStatus}
</if>
<if
test=
"queryObj.carrierNumber != null"
>
and b.carrier_number like CONCAT('%', #{queryObj.carrierNumber}, '%')
</if>
<if
test=
"queryObj.uniCreditCode != null"
>
and b.uni_credit_code like CONCAT('%', #{queryObj.uniCreditCode}, '%')
</if>
<if
test=
"queryObj.roadLicenseNumber != null"
>
and b.road_license_number = #{queryObj.roadLicenseNumber}
</if>
<if
test=
"queryObj.carrierName != null"
>
and (b.carrier_full_name like CONCAT('%', #{queryObj.carrierName}, '%')
or b.carrier_brief_name like CONCAT('%', #{queryObj.carrierName}, '%')
or b.contactor like CONCAT('%', #{queryObj.carrierName}, '%'))
</if>
ORDER BY b.carrier_type ASC, b.carrier_full_name ASC, b.contactor ASC
</select>
</mapper>
\ No newline at end of file
src/test/java/com/esv/freight/customer/module/carrier/controller/CarrierAccountControllerTest.java
View file @
d639ee12
...
...
@@ -660,4 +660,68 @@ public class CarrierAccountControllerTest extends BaseTestController {
Assert
.
assertEquals
(
ECode
.
SUCCESS
.
code
(),
result
.
getIntValue
(
"code"
));
Assert
.
assertFalse
(
result
.
getJSONArray
(
"data"
).
isEmpty
());
}
/**
* 分页查询承运商信息
**/
@Test
@Rollback
public
void
e1_list_success_test
()
throws
Exception
{
String
url
=
"/carrier/account/list"
;
// 构造数据
CarrierQueryForm
form
=
new
CarrierQueryForm
();
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
e2_list_4_param_success_test
()
throws
Exception
{
String
url
=
"/carrier/account/list"
;
// 构造数据
CarrierQueryForm
form
=
new
CarrierQueryForm
();
form
.
setPageNum
(
1
);
form
.
setPageSize
(
10
);
form
.
setAccount
(
"1"
);
form
.
setCarrierName
(
"沈阳"
);
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