Commit 0ea4b27f authored by huangcb's avatar huangcb

新增货主接口:查询货主所有常跑路线

parent cea55b71
......@@ -10,6 +10,7 @@ import com.esv.freight.customer.common.validator.groups.ValidatorUpdate;
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.service.RegularlyRouteService;
import com.esv.freight.customer.module.goodsowner.validator.groups.RouteOwner;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
......@@ -96,4 +97,16 @@ public class RegularlyRouteController {
public EResponse detail(@RequestBody @Validated(ValidatorDetail.class) RegularlyRouteForm form) throws EException {
return EResponse.ok(regularlyRouteService.getRouteDetail(form));
}
/**
* description 查询货主所有常跑路线
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/22 16:08
**/
@PostMapping("/all")
public EResponse all(@RequestBody @Validated(RouteOwner.class) RegularlyRouteForm form) throws EException {
return EResponse.ok(regularlyRouteService.getRouteOwner(form));
}
}
......@@ -5,6 +5,8 @@ import com.esv.freight.customer.module.goodsowner.dto.RouteDetailDto;
import com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 货主常跑线路表
*
......@@ -23,5 +25,14 @@ public interface RegularlyRouteDao extends BaseMapper<RegularlyRouteEntity> {
* createTime 2020/04/22 15:22
**/
RouteDetailDto selectRouteDetail(Long id);
/**
* description 查询货主所有常跑路线
* param [id]
* return java.util.List<com.esv.freight.customer.module.goodsowner.dto.RouteDetailDto>
* author Administrator
* createTime 2020/04/22 15:51
**/
List<RouteDetailDto> selectRouteOwner(Long id);
}
......@@ -3,6 +3,7 @@ package com.esv.freight.customer.module.goodsowner.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.ValidatorUpdate;
import com.esv.freight.customer.module.goodsowner.validator.groups.RouteOwner;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
......@@ -30,7 +31,7 @@ public class RegularlyRouteForm {
@NotBlank(message = "参数routeName不能为空", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String routeName;
@NotNull(message = "参数ownerId不能为空", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotNull(message = "参数ownerId不能为空", groups = {ValidatorInsert.class, ValidatorUpdate.class, RouteOwner.class})
private Long ownerId;
@NotNull(message = "参数deliveryId不能为空", groups = {ValidatorInsert.class, ValidatorUpdate.class})
......
......@@ -5,6 +5,7 @@ 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.vo.RouteDetailVO;
import com.esv.freight.customer.module.goodsowner.vo.RouteOwnerVO;
import java.util.List;
......@@ -62,5 +63,14 @@ public interface RegularlyRouteService extends IService<RegularlyRouteEntity> {
**/
RouteDetailVO getRouteDetail(RegularlyRouteForm form);
/**
* description 查询货主所有常跑路线
* param [form]
* return java.util.List<com.esv.freight.customer.module.goodsowner.vo.RouteOwnerVO>
* author Administrator
* createTime 2020/04/22 16:04
**/
List<RouteOwnerVO> getRouteOwner(RegularlyRouteForm form);
}
......@@ -18,10 +18,12 @@ 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.RouteOwnerVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
......@@ -167,6 +169,24 @@ public class RegularlyRouteServiceImpl extends ServiceImpl<RegularlyRouteDao, Re
return vo;
}
@Override
public List<RouteOwnerVO> getRouteOwner(RegularlyRouteForm form) {
List<RouteDetailDto> dtoList = this.baseMapper.selectRouteOwner(form.getOwnerId());
List<RouteOwnerVO> voList = new ArrayList<>();
dtoList.forEach(dto -> {
RouteOwnerVO vo = new RouteOwnerVO();
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 voList;
}
@Override
public List<RegularlyRouteEntity> getOwnerRouteByName(RegularlyRouteForm form) {
QueryWrapper<RegularlyRouteEntity> queryWrapper = new QueryWrapper<>();
......
package com.esv.freight.customer.module.goodsowner.validator.groups;
import javax.validation.groups.Default;
/**
* @description: 参数校验分组
* @project: SpringCloudTemplate
* @name: com.esv.freight.customer.module.goodsowner.validator.groups.RouteOwner
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/03/12 17:58
* @version:1.0
*/
public interface RouteOwner extends Default {
}
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 RouteOwnerVO implements Serializable {
private static final long serialVersionUID = -5969073471487300582L;
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);
}
}
......@@ -32,4 +32,17 @@
where a.id = #{id}
</select>
<select id="selectRouteOwner" parameterType="java.lang.Long" 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 a.owner_id = #{id}
order by route_number asc
</select>
</mapper>
\ No newline at end of file
......@@ -468,4 +468,31 @@ public class RegularlyRouteControllerTest extends BaseTestController {
Assert.assertEquals(1001, result.getIntValue("code"));
}
/**
* 查询货主所有常跑路线
**/
@Test
public void e1_all_success_test() throws Exception {
String url = "/goodsowner/regularly/route/all";
// 构造数据
RegularlyRouteForm form = new RegularlyRouteForm();
form.setOwnerId(1L);
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"));
}
}
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