Commit cea55b71 authored by huangcb's avatar huangcb

新增货主接口:查询常跑路线详情

parent 2943bdf5
......@@ -98,4 +98,7 @@ public class ErrorMessageComponent {
@Value("${error-message.goodsowner.regularly-route.edit.1005}")
private String goodsOwnerRegularlyRouteEdit1005;
@Value("${error-message.goodsowner.regularly-route.detail.1001}")
private String goodsOwnerRegularlyRouteDetail1001;
}
......@@ -4,6 +4,7 @@ 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.module.goodsowner.form.DeleteAddressForm;
......@@ -83,4 +84,16 @@ public class RegularlyRouteController {
data.put("count", count);
return EResponse.ok(data);
}
/**
* description 查询常跑路线详情
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/22 15:29
**/
@PostMapping("/detail")
public EResponse detail(@RequestBody @Validated(ValidatorDetail.class) RegularlyRouteForm form) throws EException {
return EResponse.ok(regularlyRouteService.getRouteDetail(form));
}
}
package com.esv.freight.customer.module.goodsowner.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.esv.freight.customer.module.goodsowner.dto.RouteDetailDto;
import com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity;
import org.apache.ibatis.annotations.Mapper;
......@@ -13,5 +14,14 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface RegularlyRouteDao extends BaseMapper<RegularlyRouteEntity> {
/**
* description 查询常跑路线详情
* param [id]
* return com.esv.freight.customer.module.goodsowner.dto.RouteDetailDto
* author Administrator
* createTime 2020/04/22 15:22
**/
RouteDetailDto selectRouteDetail(Long id);
}
package com.esv.freight.customer.module.goodsowner.dto;
import lombok.Data;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.dto.RouteDetailDto
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/22 15:18
* @version:1.0
*/
@Data
public class RouteDetailDto {
private Long id;
/**
* 线路编码
*/
private String routeNumber;
/**
* 线路名称
*/
private String routeName;
/**
* 货主ID
*/
private Long ownerId;
/**
* 货主类型:1-个人、2-企业
*/
private String ownerType;
/**
* 客户名称
*/
private String ownerFullName;
/**
* (个人或企业)联系人
*/
private String contactor;
/**
* 发货地址ID
*/
private Long deliveryAddressId;
/**
* 发货地址名称
*/
private String deliveryAddressName;
/**
* 收货地址ID
*/
private Long receiveAddressId;
/**
* 收货地址名称
*/
private String receiveAddressName;
}
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 lombok.Data;
......@@ -22,7 +23,7 @@ import javax.validation.constraints.NotNull;
@Data
public class RegularlyRouteForm {
@NotNull(message = "参数id不能为空", groups = {ValidatorUpdate.class})
@NotNull(message = "参数id不能为空", groups = {ValidatorUpdate.class, ValidatorDetail.class})
private Long id;
@Length(max = 50, message = "参数routeName长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
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 java.util.List;
......@@ -52,5 +53,14 @@ public interface RegularlyRouteService extends IService<RegularlyRouteEntity> {
**/
Integer delete(DeleteAddressForm form);
/**
* description 查询常跑路线详情
* param [form]
* return com.esv.freight.customer.module.goodsowner.vo.RouteDetailVO
* author Administrator
* createTime 2020/04/22 15:26
**/
RouteDetailVO getRouteDetail(RegularlyRouteForm form);
}
......@@ -7,7 +7,9 @@ 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.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.form.DeleteAddressForm;
import com.esv.freight.customer.module.goodsowner.form.RegularlyRouteForm;
......@@ -15,6 +17,7 @@ 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 org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -147,6 +150,23 @@ public class RegularlyRouteServiceImpl extends ServiceImpl<RegularlyRouteDao, Re
return count;
}
@Override
public RouteDetailVO getRouteDetail(RegularlyRouteForm form) {
RouteDetailDto dto = this.baseMapper.selectRouteDetail(form.getId());
if (null == dto) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerRegularlyRouteDetail1001());
}
RouteDetailVO vo = new RouteDetailVO();
BeanUtils.copyProperties(dto, vo);
if (GoodsOwnerConstants.OWNER_TYPE_PERSONAL.equals(dto.getOwnerType())) {
vo.setOwnerName(dto.getContactor());
} else {
vo.setOwnerName(dto.getOwnerFullName());
}
return vo;
}
@Override
public List<RegularlyRouteEntity> getOwnerRouteByName(RegularlyRouteForm form) {
QueryWrapper<RegularlyRouteEntity> queryWrapper = new QueryWrapper<>();
......
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 RouteDetailVO implements Serializable {
private static final long serialVersionUID = -6456734699222085498L;
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);
}
}
......@@ -98,4 +98,6 @@ error-message:
1002: 重复的常跑线路名称
1003: 无效的货主ID
1004: 无效的发货地址ID
1005: 无效的收货地址ID
\ No newline at end of file
1005: 无效的收货地址ID
detail:
1001: 无效的常跑线路ID
\ No newline at end of file
......@@ -20,5 +20,16 @@
<result property="updateTime" column="update_time"/>
</resultMap>
<select id="selectRouteDetail" 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.id = #{id}
</select>
</mapper>
\ No newline at end of file
......@@ -413,4 +413,59 @@ public class RegularlyRouteControllerTest extends BaseTestController {
Assert.assertTrue(result.getJSONObject("data").containsKey("count"));
}
/**
* 查询常跑路线详情
**/
@Test
public void d1_detail_success_test() throws Exception {
String url = "/goodsowner/regularly/route/detail";
// 构造数据
RegularlyRouteForm form = new RegularlyRouteForm();
form.setId(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"));
Assert.assertTrue(result.getJSONObject("data").containsKey("id"));
}
/**
* 查询常跑路线详情:无效的常跑线路ID
**/
@Test
public void d2_detail_wrong_id_failure_test() throws Exception {
String url = "/goodsowner/regularly/route/detail";
// 构造数据
RegularlyRouteForm form = new RegularlyRouteForm();
form.setId(99999L);
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(1001, 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