Commit 461b64dc authored by huangcb's avatar huangcb

线下文本合同:货主合同-删除

parent 77b116e5
......@@ -281,4 +281,7 @@ public class ErrorMessageComponent {
private String contractOfflineGoodsOwnerEdit1001;
@Value("${error-message.contract.offline.goods-owner.edit.1002}")
private String contractOfflineGoodsOwnerEdit1002;
@Value("${error-message.contract.offline.goods-owner.delete.1001}")
private String contractOfflineGoodsOwnerDelete1001;
}
......@@ -64,4 +64,17 @@ public class ContractOfflineGoodsOwnerController {
contractOfflineGoodsOwnerService.editOfflineContract(form);
return EResponse.ok();
}
/**
* description 删除合同
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/05/20 9:26
**/
@PostMapping("/delete")
public EResponse delete(@RequestBody @Validated(ValidatorUpdate.class) ContractOfflineGoodsOwnerForm form) throws EException {
contractOfflineGoodsOwnerService.deleteOfflineContract(form);
return EResponse.ok();
}
}
package com.esv.freight.customer.module.contract.form;
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.ValidatorUpdate;
import lombok.Data;
......@@ -26,7 +27,7 @@ public class ContractOfflineGoodsOwnerForm {
/**
*
*/
@NotNull(message = "参数id不能为空", groups = {ValidatorUpdate.class})
@NotNull(message = "参数id不能为空", groups = {ValidatorUpdate.class, ValidatorDelete.class})
private Long id;
/**
* 货主帐号ID
......
......@@ -31,5 +31,14 @@ public interface ContractOfflineGoodsOwnerService extends IService<ContractOffli
**/
Integer editOfflineContract(ContractOfflineGoodsOwnerForm form);
/**
* description 删除线下文本合同(货主)
* param [form]
* return java.lang.Integer
* author Administrator
* createTime 2020/05/20 9:24
**/
Integer deleteOfflineContract(ContractOfflineGoodsOwnerForm form);
}
......@@ -79,4 +79,14 @@ public class ContractOfflineGoodsOwnerServiceImpl extends ServiceImpl<ContractOf
return this.baseMapper.updateById(contractOfflineGoodsOwnerEntity);
}
@Override
public Integer deleteOfflineContract(ContractOfflineGoodsOwnerForm form) {
ContractOfflineGoodsOwnerEntity dbEntity = this.baseMapper.selectById(form.getId());
if (null == dbEntity) {
throw new EException(1001, errorMessageComponent.getContractOfflineGoodsOwnerDelete1001());
}
return this.baseMapper.deleteById(form.getId());
}
}
\ No newline at end of file
......@@ -226,4 +226,6 @@ error-message:
1002: 合同编号已存在
edit:
1001: 无效的合同ID
1002: 合同编号已存在
\ No newline at end of file
1002: 合同编号已存在
delete:
1001: 无效的合同ID
\ No newline at end of file
......@@ -244,4 +244,58 @@ public class ContractOfflineGoodsOwnerControllerTest extends BaseTestController
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(1002, result.getIntValue("code"));
}
/**
* 删除合同
**/
@Test
@Rollback
public void c1_delete_success_test() throws Exception {
String url = "/contract/offline/goodsowner/delete";
// 构造数据
ContractOfflineGoodsOwnerForm form = new ContractOfflineGoodsOwnerForm();
form.setId(1L);
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(form.toString()))
.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"));
}
/**
* 删除合同:无效的合同ID
**/
@Test
@Rollback
public void c2_delete_success_test() throws Exception {
String url = "/contract/offline/goodsowner/delete";
// 构造数据
ContractOfflineGoodsOwnerForm form = new ContractOfflineGoodsOwnerForm();
form.setId(99999L);
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(form.toString()))
.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