Commit d3c04e69 authored by huangcb's avatar huangcb

新增货主接口:获取所有发货地址列表

parent b552128b
...@@ -12,6 +12,7 @@ import com.esv.freight.customer.module.goodsowner.form.DeleteAddressForm; ...@@ -12,6 +12,7 @@ import com.esv.freight.customer.module.goodsowner.form.DeleteAddressForm;
import com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm; import com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm;
import com.esv.freight.customer.module.goodsowner.service.DeliveryAddressService; 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.ReceiveAddressService;
import com.esv.freight.customer.module.goodsowner.validator.groups.AddressBrief;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -90,6 +91,18 @@ public class DeliveryAddressController { ...@@ -90,6 +91,18 @@ public class DeliveryAddressController {
return EResponse.ok(deliveryAddressService.getAddressDetail(form)); return EResponse.ok(deliveryAddressService.getAddressDetail(form));
} }
/**
* description 获取所有发货地址列表
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/21 20:08
**/
@PostMapping("/all")
public EResponse all(@RequestBody @Validated(AddressBrief.class) DeliveryAddressForm form) throws EException {
return EResponse.ok(deliveryAddressService.getAllAddress(form));
}
/** /**
* description 删除发货地址 * description 删除发货地址
* param [form] * param [form]
......
...@@ -3,6 +3,7 @@ package com.esv.freight.customer.module.goodsowner.form; ...@@ -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.ValidatorDetail;
import com.esv.freight.customer.common.validator.groups.ValidatorInsert; 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.ValidatorUpdate;
import com.esv.freight.customer.module.goodsowner.validator.groups.AddressBrief;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
...@@ -27,7 +28,7 @@ public class DeliveryAddressForm { ...@@ -27,7 +28,7 @@ public class DeliveryAddressForm {
@NotNull(message = "参数id不能为空", groups = {ValidatorUpdate.class, ValidatorDetail.class}) @NotNull(message = "参数id不能为空", groups = {ValidatorUpdate.class, ValidatorDetail.class})
private Long id; private Long id;
@NotNull(message = "参数ownerId不能为空", groups = {ValidatorInsert.class, ValidatorUpdate.class}) @NotNull(message = "参数ownerId不能为空", groups = {ValidatorInsert.class, ValidatorUpdate.class, AddressBrief.class})
private Long ownerId; private Long ownerId;
@Length(max = 50, message = "参数addressName长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class}) @Length(max = 50, message = "参数addressName长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
......
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity; import com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity;
import com.esv.freight.customer.module.goodsowner.form.DeleteAddressForm; import com.esv.freight.customer.module.goodsowner.form.DeleteAddressForm;
import com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm; import com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm;
import com.esv.freight.customer.module.goodsowner.vo.DeliveryAddressBriefVO;
import com.esv.freight.customer.module.goodsowner.vo.DeliveryAddressVO; import com.esv.freight.customer.module.goodsowner.vo.DeliveryAddressVO;
import java.util.List; import java.util.List;
...@@ -53,6 +54,15 @@ public interface DeliveryAddressService extends IService<DeliveryAddressEntity> ...@@ -53,6 +54,15 @@ public interface DeliveryAddressService extends IService<DeliveryAddressEntity>
**/ **/
DeliveryAddressVO getAddressDetail(DeliveryAddressForm form); DeliveryAddressVO getAddressDetail(DeliveryAddressForm form);
/**
* description 获取所有发货地址列表
* param [form]
* return java.util.List<com.esv.freight.customer.module.goodsowner.vo.DeliveryAddressBriefVO>
* author Administrator
* createTime 2020/04/21 20:04
**/
List<DeliveryAddressBriefVO> getAllAddress(DeliveryAddressForm form);
/** /**
* description 通过地址名称查询地址记录 * description 通过地址名称查询地址记录
* param [ownerId, addressName] * param [ownerId, addressName]
......
...@@ -8,11 +8,11 @@ import com.esv.freight.customer.common.exception.EException; ...@@ -8,11 +8,11 @@ import com.esv.freight.customer.common.exception.EException;
import com.esv.freight.customer.common.util.FeignUtils; import com.esv.freight.customer.common.util.FeignUtils;
import com.esv.freight.customer.feign.FeignBaseService; import com.esv.freight.customer.feign.FeignBaseService;
import com.esv.freight.customer.module.goodsowner.dao.DeliveryAddressDao; import com.esv.freight.customer.module.goodsowner.dao.DeliveryAddressDao;
import com.esv.freight.customer.module.goodsowner.entity.AuditHistoryEntity;
import com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity; import com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity;
import com.esv.freight.customer.module.goodsowner.form.DeleteAddressForm; import com.esv.freight.customer.module.goodsowner.form.DeleteAddressForm;
import com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm; import com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm;
import com.esv.freight.customer.module.goodsowner.service.DeliveryAddressService; import com.esv.freight.customer.module.goodsowner.service.DeliveryAddressService;
import com.esv.freight.customer.module.goodsowner.vo.DeliveryAddressBriefVO;
import com.esv.freight.customer.module.goodsowner.vo.DeliveryAddressVO; import com.esv.freight.customer.module.goodsowner.vo.DeliveryAddressVO;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
...@@ -128,6 +129,24 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao, ...@@ -128,6 +129,24 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
return addressVO; return addressVO;
} }
@Override
public List<DeliveryAddressBriefVO> getAllAddress(DeliveryAddressForm form) {
// 查询
QueryWrapper<DeliveryAddressEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("owner_id", form.getOwnerId());
List<DeliveryAddressEntity> deliveryAddressEntityList = this.baseMapper.selectList(queryWrapper);
// 数据转换
List<DeliveryAddressBriefVO> addressBriefVOList = new ArrayList<>();
deliveryAddressEntityList.forEach(entity -> {
DeliveryAddressBriefVO vo = new DeliveryAddressBriefVO();
BeanUtils.copyProperties(entity, vo);
addressBriefVOList.add(vo);
});
return addressBriefVOList;
}
@Override @Override
public List<DeliveryAddressEntity> getAddressByName(Long ownerId, String addressName) { public List<DeliveryAddressEntity> getAddressByName(Long ownerId, String addressName) {
QueryWrapper<DeliveryAddressEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<DeliveryAddressEntity> queryWrapper = new QueryWrapper<>();
......
...@@ -355,4 +355,33 @@ public class DeliveryAddressControllerTest extends BaseTestController { ...@@ -355,4 +355,33 @@ public class DeliveryAddressControllerTest extends BaseTestController {
Assert.assertEquals(1001, result.getIntValue("code")); Assert.assertEquals(1001, result.getIntValue("code"));
} }
/**
* 获取所有发货地址列表
**/
@Test
@Rollback
public void e1_all_success_test() throws Exception {
String url = "/goodsowner/delivery/address/all";
// 构造数据
DeliveryAddressForm form = new DeliveryAddressForm();
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"));
Assert.assertFalse(result.getJSONArray("data").isEmpty());
}
} }
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