Commit 2943bdf5 authored by huangcb's avatar huangcb

新增货主接口:删除常跑路线

parent 5c1cc31a
...@@ -3,8 +3,10 @@ package com.esv.freight.customer.module.goodsowner.controller; ...@@ -3,8 +3,10 @@ package com.esv.freight.customer.module.goodsowner.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.esv.freight.customer.common.exception.EException; import com.esv.freight.customer.common.exception.EException;
import com.esv.freight.customer.common.response.EResponse; 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.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.form.DeleteAddressForm;
import com.esv.freight.customer.module.goodsowner.form.RegularlyRouteForm; 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.service.RegularlyRouteService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -66,4 +68,19 @@ public class RegularlyRouteController { ...@@ -66,4 +68,19 @@ public class RegularlyRouteController {
return EResponse.ok(); return EResponse.ok();
} }
/**
* description 删除常跑路线
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/22 14:58
**/
@PostMapping("/delete")
public EResponse delete(@RequestBody @Validated(ValidatorDelete.class) DeleteAddressForm form) throws EException {
int count = regularlyRouteService.delete(form);
JSONObject data = new JSONObject();
data.put("count", count);
return EResponse.ok(data);
}
} }
...@@ -2,6 +2,7 @@ package com.esv.freight.customer.module.goodsowner.service; ...@@ -2,6 +2,7 @@ package com.esv.freight.customer.module.goodsowner.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity; 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.RegularlyRouteForm;
import java.util.List; import java.util.List;
...@@ -41,6 +42,15 @@ public interface RegularlyRouteService extends IService<RegularlyRouteEntity> { ...@@ -41,6 +42,15 @@ public interface RegularlyRouteService extends IService<RegularlyRouteEntity> {
* createTime 2020/04/22 14:20 * createTime 2020/04/22 14:20
**/ **/
Integer edit(RegularlyRouteForm form); Integer edit(RegularlyRouteForm form);
/**
* description 删除常跑路线
* param [form]
* return java.lang.Integer
* author Administrator
* createTime 2020/04/22 14:57
**/
Integer delete(DeleteAddressForm form);
} }
...@@ -9,6 +9,7 @@ import com.esv.freight.customer.common.util.FeignUtils; ...@@ -9,6 +9,7 @@ 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.RegularlyRouteDao; import com.esv.freight.customer.module.goodsowner.dao.RegularlyRouteDao;
import com.esv.freight.customer.module.goodsowner.entity.*; 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; import com.esv.freight.customer.module.goodsowner.form.RegularlyRouteForm;
import com.esv.freight.customer.module.goodsowner.service.AccountService; 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.DeliveryAddressService;
...@@ -18,6 +19,7 @@ import org.springframework.beans.BeanUtils; ...@@ -18,6 +19,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List; import java.util.List;
...@@ -138,6 +140,13 @@ public class RegularlyRouteServiceImpl extends ServiceImpl<RegularlyRouteDao, Re ...@@ -138,6 +140,13 @@ public class RegularlyRouteServiceImpl extends ServiceImpl<RegularlyRouteDao, Re
return count; return count;
} }
@Override
public Integer delete(DeleteAddressForm form) {
String[] ids = form.getId().split(",");
int count = this.baseMapper.deleteBatchIds(Arrays.asList(ids));
return count;
}
@Override @Override
public List<RegularlyRouteEntity> getOwnerRouteByName(RegularlyRouteForm form) { public List<RegularlyRouteEntity> getOwnerRouteByName(RegularlyRouteForm form) {
QueryWrapper<RegularlyRouteEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<RegularlyRouteEntity> queryWrapper = new QueryWrapper<>();
......
...@@ -3,6 +3,7 @@ package com.esv.freight.customer.module.goodsowner.controller; ...@@ -3,6 +3,7 @@ package com.esv.freight.customer.module.goodsowner.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.esv.freight.customer.BaseTestController; import com.esv.freight.customer.BaseTestController;
import com.esv.freight.customer.common.response.ECode; 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.RegularlyRouteForm;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.Assert; import org.junit.Assert;
...@@ -383,4 +384,33 @@ public class RegularlyRouteControllerTest extends BaseTestController { ...@@ -383,4 +384,33 @@ public class RegularlyRouteControllerTest extends BaseTestController {
Assert.assertEquals(1005, result.getIntValue("code")); Assert.assertEquals(1005, result.getIntValue("code"));
} }
/**
* 删除常跑路线
**/
@Test
@Rollback
public void c1_delete_success_test() throws Exception {
String url = "/goodsowner/regularly/route/delete";
// 构造数据
DeleteAddressForm form = new DeleteAddressForm();
form.setId("1,2,3,4,5,6,7");
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("count"));
}
} }
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