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
461d436f
Commit
461d436f
authored
Apr 22, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增货主接口:查询常跑路线列表
parent
0ea4b27f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
240 additions
and
5 deletions
+240
-5
RegularlyRouteController.java
...odule/goodsowner/controller/RegularlyRouteController.java
+18
-4
RegularlyRouteDao.java
...ght/customer/module/goodsowner/dao/RegularlyRouteDao.java
+11
-0
RegularlyRouteListForm.java
...stomer/module/goodsowner/form/RegularlyRouteListForm.java
+50
-0
RegularlyRouteService.java
...omer/module/goodsowner/service/RegularlyRouteService.java
+11
-0
RegularlyRouteServiceImpl.java
...le/goodsowner/service/impl/RegularlyRouteServiceImpl.java
+31
-1
RouteListVO.java
...sv/freight/customer/module/goodsowner/vo/RouteListVO.java
+61
-0
RegularlyRouteDao.xml
src/main/resources/mapper/goodsowner/RegularlyRouteDao.xml
+25
-0
RegularlyRouteControllerTest.java
...e/goodsowner/controller/RegularlyRouteControllerTest.java
+33
-0
No files found.
src/main/java/com/esv/freight/customer/module/goodsowner/controller/RegularlyRouteController.java
View file @
461d436f
...
...
@@ -3,15 +3,14 @@ package com.esv.freight.customer.module.goodsowner.controller;
import
com.alibaba.fastjson.JSONObject
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.response.EResponse
;
import
com.esv.freight.customer.common.validator.groups.ValidatorDelete
;
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.ValidatorUpdate
;
import
com.esv.freight.customer.common.validator.groups.*
;
import
com.esv.freight.customer.module.goodsowner.form.DeleteAddressForm
;
import
com.esv.freight.customer.module.goodsowner.form.RegularlyRouteForm
;
import
com.esv.freight.customer.module.goodsowner.form.RegularlyRouteListForm
;
import
com.esv.freight.customer.module.goodsowner.service.RegularlyRouteService
;
import
com.esv.freight.customer.module.goodsowner.validator.groups.RouteOwner
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -109,4 +108,19 @@ public class RegularlyRouteController {
public
EResponse
all
(
@RequestBody
@Validated
(
RouteOwner
.
class
)
RegularlyRouteForm
form
)
throws
EException
{
return
EResponse
.
ok
(
regularlyRouteService
.
getRouteOwner
(
form
));
}
/**
* description 查询常跑路线列表
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/22 16:40
**/
@PostMapping
(
"/list"
)
public
EResponse
list
(
@RequestBody
@Validated
(
ValidatorList
.
class
)
RegularlyRouteListForm
form
)
throws
EException
{
form
.
setOwnerName
(
StringUtils
.
trimToNull
(
form
.
getOwnerName
()));
form
.
setDeliveryAddressName
(
StringUtils
.
trimToNull
(
form
.
getDeliveryAddressName
()));
form
.
setReceiveAddressName
(
StringUtils
.
trimToNull
(
form
.
getReceiveAddressName
()));
return
EResponse
.
ok
(
regularlyRouteService
.
getRouteList
(
form
));
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/dao/RegularlyRouteDao.java
View file @
461d436f
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.esv.freight.customer.module.goodsowner.dto.RouteDetailDto
;
import
com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity
;
import
com.esv.freight.customer.module.goodsowner.form.RegularlyRouteListForm
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
...
...
@@ -34,5 +36,14 @@ public interface RegularlyRouteDao extends BaseMapper<RegularlyRouteEntity> {
* createTime 2020/04/22 15:51
**/
List
<
RouteDetailDto
>
selectRouteOwner
(
Long
id
);
/**
* description 查询常跑路线列表
* param [page, queryObj]
* return com.baomidou.mybatisplus.core.metadata.IPage
* author Administrator
* createTime 2020/04/22 16:34
**/
IPage
selectRouteList
(
IPage
page
,
RegularlyRouteListForm
queryObj
);
}
src/main/java/com/esv/freight/customer/module/goodsowner/form/RegularlyRouteListForm.java
0 → 100644
View file @
461d436f
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
form
;
import
com.esv.freight.customer.common.validator.groups.ValidatorList
;
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
;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.form.RegularlyRouteListForm
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/17 16:11
* @version:1.0
*/
@Data
public
class
RegularlyRouteListForm
{
@Length
(
max
=
50
,
message
=
"参数ownerName长度不合法"
,
groups
=
{
ValidatorList
.
class
})
private
String
ownerName
;
@Length
(
max
=
50
,
message
=
"参数deliveryAddressName长度不合法"
,
groups
=
{
ValidatorList
.
class
})
private
String
deliveryAddressName
;
@Length
(
max
=
50
,
message
=
"参数receiveAddressName长度不合法"
,
groups
=
{
ValidatorList
.
class
})
private
String
receiveAddressName
;
/**
* 页码
**/
@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/goodsowner/service/RegularlyRouteService.java
View file @
461d436f
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.esv.freight.customer.common.vo.PageResultVO
;
import
com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity
;
import
com.esv.freight.customer.module.goodsowner.form.DeleteAddressForm
;
import
com.esv.freight.customer.module.goodsowner.form.RegularlyRouteForm
;
import
com.esv.freight.customer.module.goodsowner.form.RegularlyRouteListForm
;
import
com.esv.freight.customer.module.goodsowner.vo.RouteDetailVO
;
import
com.esv.freight.customer.module.goodsowner.vo.RouteOwnerVO
;
...
...
@@ -72,5 +74,14 @@ public interface RegularlyRouteService extends IService<RegularlyRouteEntity> {
**/
List
<
RouteOwnerVO
>
getRouteOwner
(
RegularlyRouteForm
form
);
/**
* description 查询常跑路线列表
* param [form]
* return com.esv.freight.customer.common.vo.PageResultVO
* author Administrator
* createTime 2020/04/22 16:35
**/
PageResultVO
getRouteList
(
RegularlyRouteListForm
form
);
}
src/main/java/com/esv/freight/customer/module/goodsowner/service/impl/RegularlyRouteServiceImpl.java
View file @
461d436f
...
...
@@ -2,22 +2,30 @@ package com.esv.freight.customer.module.goodsowner.service.impl;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
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.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.goodsowner.GoodsOwnerConstants
;
import
com.esv.freight.customer.module.goodsowner.dao.RegularlyRouteDao
;
import
com.esv.freight.customer.module.goodsowner.dto.RouteDetailDto
;
import
com.esv.freight.customer.module.goodsowner.entity.*
;
import
com.esv.freight.customer.module.goodsowner.entity.AccountEntity
;
import
com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity
;
import
com.esv.freight.customer.module.goodsowner.entity.ReceiveAddressEntity
;
import
com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity
;
import
com.esv.freight.customer.module.goodsowner.form.DeleteAddressForm
;
import
com.esv.freight.customer.module.goodsowner.form.RegularlyRouteForm
;
import
com.esv.freight.customer.module.goodsowner.form.RegularlyRouteListForm
;
import
com.esv.freight.customer.module.goodsowner.service.AccountService
;
import
com.esv.freight.customer.module.goodsowner.service.DeliveryAddressService
;
import
com.esv.freight.customer.module.goodsowner.service.ReceiveAddressService
;
import
com.esv.freight.customer.module.goodsowner.service.RegularlyRouteService
;
import
com.esv.freight.customer.module.goodsowner.vo.RouteDetailVO
;
import
com.esv.freight.customer.module.goodsowner.vo.RouteListVO
;
import
com.esv.freight.customer.module.goodsowner.vo.RouteOwnerVO
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -194,4 +202,26 @@ public class RegularlyRouteServiceImpl extends ServiceImpl<RegularlyRouteDao, Re
queryWrapper
.
eq
(
"route_name"
,
form
.
getRouteName
());
return
this
.
baseMapper
.
selectList
(
queryWrapper
);
}
@Override
public
PageResultVO
getRouteList
(
RegularlyRouteListForm
form
)
{
IPage
<
RouteDetailDto
>
page
=
new
Page
<>(
form
.
getPageNum
(),
form
.
getPageSize
());
this
.
baseMapper
.
selectRouteList
(
page
,
form
);
// 数据转换
List
<
RouteDetailDto
>
dtoList
=
page
.
getRecords
();
List
<
RouteListVO
>
voList
=
new
ArrayList
<>();
dtoList
.
forEach
(
dto
->
{
RouteListVO
vo
=
new
RouteListVO
();
BeanUtils
.
copyProperties
(
dto
,
vo
);
if
(
GoodsOwnerConstants
.
OWNER_TYPE_PERSONAL
.
equals
(
dto
.
getOwnerType
()))
{
vo
.
setOwnerName
(
dto
.
getContactor
());
}
else
{
vo
.
setOwnerName
(
dto
.
getOwnerFullName
());
}
voList
.
add
(
vo
);
});
return
new
PageResultVO
(
page
,
voList
);
}
}
\ No newline at end of file
src/main/java/com/esv/freight/customer/module/goodsowner/vo/RouteListVO.java
0 → 100644
View file @
461d436f
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
vo
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
java.io.Serializable
;
/**
* 常跑路线详情VO
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-17 13:54:57
*/
@Data
public
class
RouteListVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
6938917297450101782L
;
private
Long
id
;
/**
* 线路编码
*/
private
String
routeNumber
;
/**
* 线路名称
*/
private
String
routeName
;
/**
* 货主ID
*/
private
Long
ownerId
;
/**
* 货主名称
*/
private
String
ownerName
;
/**
* 发货地址ID
*/
private
Long
deliveryAddressId
;
/**
* 发货地址名称
*/
private
String
deliveryAddressName
;
/**
* 收货地址ID
*/
private
Long
receiveAddressId
;
/**
* 收货地址名称
*/
private
String
receiveAddressName
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
}
}
src/main/resources/mapper/goodsowner/RegularlyRouteDao.xml
View file @
461d436f
...
...
@@ -45,4 +45,29 @@
order by route_number asc
</select>
<select
id=
"selectRouteList"
parameterType=
"com.esv.freight.customer.module.goodsowner.form.RegularlyRouteListForm"
resultType=
"com.esv.freight.customer.module.goodsowner.dto.RouteDetailDto"
>
select a.id, a.route_number as routeNumber, a.route_name as routeName, a.owner_id as ownerId,
b.owner_type as ownerType, b.owner_full_name as ownerFullName, b.contactor,
c.id as deliveryAddressId, c.address_name as deliveryAddressName,
d.id as receiveAddressId, d.address_name as receiveAddressName
from goods_owner_regularly_route a
left join goods_owner_info b on a.owner_id = b.account_id
left join goods_owner_delivery_address c on a.delivery_id = c.id
left join goods_owner_receive_address d on a.receive_id = d.id
where 1 = 1
<if
test=
"queryObj.receiveAddressName != null"
>
and d.address_name like CONCAT('%', #{queryObj.receiveAddressName},'%')
</if>
<if
test=
"queryObj.deliveryAddressName != null"
>
and c.address_name like CONCAT('%', #{queryObj.deliveryAddressName},'%')
</if>
<if
test=
"queryObj.ownerName != null"
>
and (b.owner_full_name like CONCAT('%', #{queryObj.ownerName},'%')
or b.owner_brief_name like CONCAT('%', #{queryObj.ownerName},'%')
or b.contactor like CONCAT('%',#{queryObj.ownerName},'%'))
</if>
order by route_number asc
</select>
</mapper>
\ No newline at end of file
src/test/java/com/esv/freight/customer/module/goodsowner/controller/RegularlyRouteControllerTest.java
View file @
461d436f
...
...
@@ -5,6 +5,7 @@ import com.esv.freight.customer.BaseTestController;
import
com.esv.freight.customer.common.response.ECode
;
import
com.esv.freight.customer.module.goodsowner.form.DeleteAddressForm
;
import
com.esv.freight.customer.module.goodsowner.form.RegularlyRouteForm
;
import
com.esv.freight.customer.module.goodsowner.form.RegularlyRouteListForm
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Assert
;
import
org.junit.FixMethodOrder
;
...
...
@@ -495,4 +496,36 @@ public class RegularlyRouteControllerTest extends BaseTestController {
Assert
.
assertEquals
(
ECode
.
SUCCESS
.
code
(),
result
.
getIntValue
(
"code"
));
}
/**
* 查询常跑路线列表
**/
@Test
public
void
f1_list_success_test
()
throws
Exception
{
String
url
=
"/goodsowner/regularly/route/list"
;
// 构造数据
RegularlyRouteListForm
form
=
new
RegularlyRouteListForm
();
form
.
setOwnerName
(
"黄"
);
form
.
setDeliveryAddressName
(
"沈阳"
);
form
.
setReceiveAddressName
(
"植物园"
);
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