Commit a6879bcf authored by huangcb's avatar huangcb

新增货主接口:新增发货地址

parent 92552b60
......@@ -56,4 +56,7 @@ public class ErrorMessageComponent {
@Value("${error-message.goodsowner.account.register.1001}")
private String goodsOwnerAccountRegister1001;
@Value("${error-message.goodsowner.delivery-address.add.1001}")
private String goodsOwnerDeliveryAddressAdd1001;
}
......@@ -36,4 +36,10 @@ public class GoodsOwnerConstants {
public static final String OWNER_ACCOUNT_STATUS_UNBLOCK = "1";
public static final String OWNER_ACCOUNT_STATUS_BLOCK = "2";
/**
* 是否同为收货地址:0-不是、1-是
**/
public static final String ADDRESS_COPY_NO = "0";
public static final String ADDRESS_COPY_YES = "1";
}
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.ValidatorInsert;
import com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants;
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.ReceiveAddressService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @description: 承运商发货地址Controller
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.controller.DeliveryAddressController
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/21 15:40
* @version:1.0
*/
@Slf4j
@RestController
@RequestMapping("/goodsowner/delivery/address")
@Validated
public class DeliveryAddressController {
private DeliveryAddressService deliveryAddressService;
private ReceiveAddressService receiveAddressService;
@Autowired
public DeliveryAddressController(DeliveryAddressService deliveryAddressService, ReceiveAddressService receiveAddressService) {
this.deliveryAddressService = deliveryAddressService;
this.receiveAddressService = receiveAddressService;
}
/**
* description 新增发货地址
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/21 16:56
**/
@PostMapping("/add")
public EResponse add(@RequestBody @Validated(ValidatorInsert.class) DeliveryAddressForm form) throws EException {
// 判断是否复制地址
if (GoodsOwnerConstants.ADDRESS_COPY_YES.equals(form.getAddressCopy())) {
}
Long id = deliveryAddressService.addAddress(form);
JSONObject data = new JSONObject();
data.put("id", id);
return EResponse.ok(data);
}
}
......@@ -37,7 +37,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* @description:
* @description: 承运商帐号Controller
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.controller.GoodsOwnerController
* @author: 黄朝斌
......
package com.esv.freight.customer.module.goodsowner.dao;
import com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity;
import org.apache.ibatis.annotations.Mapper;
/**
......@@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Mapper;
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-17 13:54:57
* @date 2020-04-21 15:27:27
*/
@Mapper
public interface DeliveryAddressDao extends BaseMapper<DeliveryAddressEntity> {
......
package com.esv.freight.customer.module.goodsowner.dao;
import com.esv.freight.customer.module.goodsowner.entity.ReceiveAddressEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.esv.freight.customer.module.goodsowner.entity.ReceiveAddressEntity;
import org.apache.ibatis.annotations.Mapper;
/**
......@@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Mapper;
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-17 13:54:57
* @date 2020-04-21 15:27:27
*/
@Mapper
public interface ReceiveAddressDao extends BaseMapper<ReceiveAddressEntity> {
......
package com.esv.freight.customer.module.goodsowner.dao;
import com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity;
import org.apache.ibatis.annotations.Mapper;
/**
......@@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Mapper;
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-17 13:54:57
* @date 2020-04-21 15:27:27
*/
@Mapper
public interface RegularlyRouteDao extends BaseMapper<RegularlyRouteEntity> {
......
......@@ -19,8 +19,8 @@ import java.util.Date;
@Data
@TableName("goods_owner_account")
public class AccountEntity implements Serializable {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 5500989619988830120L;
/**
*
*/
......
......@@ -17,8 +17,8 @@ import lombok.Data;
@Data
@TableName("goods_owner_audit_history")
public class AuditHistoryEntity implements Serializable {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 3070587675449333212L;
/**
*
*/
......
......@@ -12,18 +12,28 @@ import lombok.Data;
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-17 13:54:57
* @date 2020-04-21 15:27:27
*/
@Data
@TableName("goods_owner_delivery_address")
public class DeliveryAddressEntity implements Serializable {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = -5505542548412849641L;
/**
*
*/
@TableId
private Long id;
/**
* 租户ID
*/
@TableField(fill = FieldFill.INSERT)
private Long tenantId;
/**
* 部门ID
*/
@TableField(fill = FieldFill.INSERT)
private Long departmentId;
/**
* 货主ID
*/
......@@ -89,12 +99,12 @@ public class DeliveryAddressEntity implements Serializable {
/**
* 修改者
*/
@TableField(fill = FieldFill.INSERT)
@TableField(fill = FieldFill.INSERT_UPDATE)
private String updateUser;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
* 修改时间
......
......@@ -17,8 +17,8 @@ import lombok.Data;
@Data
@TableName("goods_owner_info")
public class InfoEntity implements Serializable {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 6703178702529854078L;
/**
*
*/
......
......@@ -12,18 +12,28 @@ import lombok.Data;
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-17 13:54:57
* @date 2020-04-21 15:27:27
*/
@Data
@TableName("goods_owner_receive_address")
public class ReceiveAddressEntity implements Serializable {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 6330420883281393071L;
/**
*
*/
@TableId
private Long id;
/**
* 租户ID
*/
@TableField(fill = FieldFill.INSERT)
private Long tenantId;
/**
* 部门ID
*/
@TableField(fill = FieldFill.INSERT)
private Long departmentId;
/**
* 货主ID
*/
......@@ -89,12 +99,12 @@ public class ReceiveAddressEntity implements Serializable {
/**
* 修改者
*/
@TableField(fill = FieldFill.INSERT)
@TableField(fill = FieldFill.INSERT_UPDATE)
private String updateUser;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
* 修改时间
......
......@@ -11,18 +11,28 @@ import lombok.Data;
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-17 13:54:57
* @date 2020-04-21 15:27:27
*/
@Data
@TableName("goods_owner_regularly_route")
public class RegularlyRouteEntity implements Serializable {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 5207299128296225089L;
/**
*
*/
@TableId
private Long id;
/**
* 租户ID
*/
@TableField(fill = FieldFill.INSERT)
private Long tenantId;
/**
* 部门ID
*/
@TableField(fill = FieldFill.INSERT)
private Long departmentId;
/**
* 货主ID
*/
......@@ -56,12 +66,12 @@ public class RegularlyRouteEntity implements Serializable {
/**
* 修改者
*/
@TableField(fill = FieldFill.INSERT)
@TableField(fill = FieldFill.INSERT_UPDATE)
private String updateUser;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
* 修改时间
......
package com.esv.freight.customer.module.goodsowner.form;
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 lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/17 16:11
* @version:1.0
*/
@Data
public class DeliveryAddressForm {
@NotNull(message = "参数id不能为空", groups = {ValidatorUpdate.class, ValidatorDetail.class, ValidatorDelete.class})
private Long id;
@NotNull(message = "参数ownerId不能为空", groups = {ValidatorInsert.class})
private Long ownerId;
@Length(max = 50, message = "参数addressName长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "参数addressName不能为空", groups = {ValidatorInsert.class})
private String addressName;
@Length(min = 6, max = 6, message = "参数provinceCode长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "参数provinceCode不能为空", groups = {ValidatorInsert.class})
private String provinceCode;
@Length(min = 6, max = 6, message = "参数cityCode长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "参数cityCode不能为空", groups = {ValidatorInsert.class})
private String cityCode;
@Length(min = 6, max = 6, message = "参数districtCode长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "参数districtCode不能为空", groups = {ValidatorInsert.class})
private String districtCode;
@Length(max = 50, message = "参数detailAddress长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "参数detailAddress不能为空", groups = {ValidatorInsert.class})
private String detailAddress;
@Length(max = 20, message = "参数deliverer长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "参数deliverer不能为空", groups = {ValidatorInsert.class})
private String deliverer;
@Length(min = 11, max = 11, message = "参数delivererPhone长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "参数delivererPhone不能为空", groups = {ValidatorInsert.class})
private String delivererPhone;
@Length(max = 20, message = "参数delivererTelephone长度不合法", groups = {ValidatorInsert.class})
private String delivererTelephone;
@Length(max = 10, message = "参数lon长度不合法", groups = {ValidatorInsert.class})
private String lon;
@Length(max = 10, message = "参数lat长度不合法", groups = {ValidatorInsert.class})
private String lat;
@Pattern(regexp = "[01]", message = "参数addressCopy不合法", groups = {ValidatorInsert.class})
private String addressCopy;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
......@@ -2,15 +2,36 @@ package com.esv.freight.customer.module.goodsowner.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity;
import com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm;
import java.util.List;
/**
* 货主发货地址表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-17 13:54:57
* @date 2020-04-21 15:27:27
*/
public interface DeliveryAddressService extends IService<DeliveryAddressEntity> {
/**
* description 新增发货地址
* param [form]
* return java.lang.Long
* author Administrator
* createTime 2020/04/21 15:59
**/
Long addAddress(DeliveryAddressForm form);
/**
* description 通过地址名称查询地址记录
* param [ownerId, addressName]
* return java.util.List<com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity>
* author Administrator
* createTime 2020/04/21 16:33
**/
List<DeliveryAddressEntity> getAddressByName(Long ownerId, String addressName);
}
......@@ -8,7 +8,7 @@ import com.esv.freight.customer.module.goodsowner.entity.ReceiveAddressEntity;
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-17 13:54:57
* @date 2020-04-21 15:27:27
*/
public interface ReceiveAddressService extends IService<ReceiveAddressEntity> {
......
......@@ -8,7 +8,7 @@ import com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity;
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-17 13:54:57
* @date 2020-04-21 15:27:27
*/
public interface RegularlyRouteService extends IService<RegularlyRouteEntity> {
......
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.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.feign.FeignBaseService;
import com.esv.freight.customer.module.goodsowner.dao.DeliveryAddressDao;
import com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity;
import com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm;
import com.esv.freight.customer.module.goodsowner.service.DeliveryAddressService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service("deliveryAddressService")
public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao, DeliveryAddressEntity> implements DeliveryAddressService {
private FeignBaseService feignBaseService;
private ErrorMessageComponent errorMessageComponent;
@Autowired
public DeliveryAddressServiceImpl(FeignBaseService feignBaseService, ErrorMessageComponent errorMessageComponent) {
this.feignBaseService = feignBaseService;
this.errorMessageComponent = errorMessageComponent;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Long addAddress(DeliveryAddressForm form) {
// 1.判断地址是否重复
List<DeliveryAddressEntity> deliveryAddressEntityList = this.getAddressByName(form.getOwnerId(), form.getAddressName());
if (0 < deliveryAddressEntityList.size()) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerDeliveryAddressAdd1001());
}
// 2.获取地址编码
JSONObject batchIdReqJson = new JSONObject();
batchIdReqJson.put("prefix", "FH");
batchIdReqJson.put("formatter", "yyyyMMdd");
batchIdReqJson.put("length", 13);
JSONObject batchIdResJson;
try {
batchIdResJson = FeignUtils.getFeignResultData(feignBaseService.getBatchId(batchIdReqJson));
} catch (Exception e) {
log.error("调用[基础服务]生成发货地址编号失败");
throw new EException("生成发货地址编号时发生错误");
}
String addressNumber = batchIdResJson.getString("batchId");
// 3.新增地址
DeliveryAddressEntity addressEntity = new DeliveryAddressEntity();
BeanUtils.copyProperties(form, addressEntity);
addressEntity.setAddressNumber(addressNumber);
this.baseMapper.insert(addressEntity);
return addressEntity.getId();
}
@Override
public List<DeliveryAddressEntity> getAddressByName(Long ownerId, String addressName) {
QueryWrapper<DeliveryAddressEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("owner_id", ownerId);
queryWrapper.eq("address_name", addressName);
return this.getBaseMapper().selectList(queryWrapper);
}
}
\ No newline at end of file
......@@ -70,4 +70,7 @@ error-message:
1001: 无效的手机号
1002: 密码错误
register:
1001: 帐号已存在
\ No newline at end of file
1001: 帐号已存在
delivery-address:
add:
1001: 重复的发货地址名称
\ No newline at end of file
......@@ -6,6 +6,8 @@
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity" id="deliveryAddressMap">
<result property="id" column="id"/>
<result property="tenantId" column="tenant_id"/>
<result property="departmentId" column="department_id"/>
<result property="ownerId" column="owner_id"/>
<result property="addressNumber" column="address_number"/>
<result property="addressName" column="address_name"/>
......
......@@ -6,6 +6,8 @@
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.esv.freight.customer.module.goodsowner.entity.ReceiveAddressEntity" id="receiveAddressMap">
<result property="id" column="id"/>
<result property="tenantId" column="tenant_id"/>
<result property="departmentId" column="department_id"/>
<result property="ownerId" column="owner_id"/>
<result property="addressNumber" column="address_number"/>
<result property="addressName" column="address_name"/>
......
......@@ -6,6 +6,8 @@
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity" id="regularlyRouteMap">
<result property="id" column="id"/>
<result property="tenantId" column="tenant_id"/>
<result property="departmentId" column="department_id"/>
<result property="ownerId" column="owner_id"/>
<result property="routeNumber" column="route_number"/>
<result property="routeName" column="route_name"/>
......
package com.esv.freight.customer.module.goodsowner.controller;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.customer.BaseTestController;
import com.esv.freight.customer.common.response.ECode;
import com.esv.freight.customer.module.goodsowner.form.DeliveryAddressForm;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.transaction.annotation.Transactional;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.controller.DeliveryAddressControllerTest
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/21 16:57
* @version:1.0
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Transactional
@Rollback(false)
public class DeliveryAddressControllerTest extends BaseTestController {
/**
* 新增发货地址
**/
@Test
public void a1_add_success_test() throws Exception {
String url = "/goodsowner/delivery/address/add";
// 构造数据
DeliveryAddressForm form = new DeliveryAddressForm();
form.setOwnerId(1L);
form.setAddressName("黄朝斌-发货地址-测试");
form.setProvinceCode("210000");
form.setCityCode("210100");
form.setDistrictCode("210103");
form.setDetailAddress("朝阳街少帅府巷46号");
form.setDeliverer("张作霖");
form.setDelivererPhone("13912340001");
form.setDelivererTelephone("(024)24850576");
form.setLon("123.464052");
form.setLat("41.800415");
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"));
}
/**
* 新增发货地址:地址名称重复
**/
@Test
@Rollback
public void a2_add_repeat_addressName_failure_test() throws Exception {
String url = "/goodsowner/delivery/address/add";
// 构造数据
DeliveryAddressForm form = new DeliveryAddressForm();
form.setOwnerId(1L);
form.setAddressName("黄朝斌-发货地址-测试");
form.setProvinceCode("210000");
form.setCityCode("210100");
form.setDistrictCode("210103");
form.setDetailAddress("朝阳街少帅府巷46号");
form.setDeliverer("张作霖");
form.setDelivererPhone("13912340001");
form.setDelivererTelephone("(024)24850576");
form.setLon("123.464052");
form.setLat("41.800415");
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"));
}
/**
* 新增发货地址:地址名称重复
**/
@Test
@Rollback
public void a3_add_wrong_param_failure_test() throws Exception {
String url = "/goodsowner/delivery/address/add";
// 构造数据
DeliveryAddressForm form = new DeliveryAddressForm();
form.setOwnerId(1L);
// form.setAddressName("黄朝斌-发货地址-测试");
// form.setProvinceCode("210000");
// form.setCityCode("210100");
// form.setDistrictCode("210103");
// form.setDetailAddress("朝阳街少帅府巷46号");
form.setDeliverer("张作霖");
form.setDelivererPhone("13912340001");
form.setDelivererTelephone("(024)24850576");
form.setLon("123.464052");
form.setLat("41.800415");
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.PARAM_ERROR.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