feat(shopping): 添加购物车删除功能
- 实现了购物车删除接口,支持通过ID删除指定购物车 - 添加事务注解确保删除操作的数据一致性 - 集成业务验证逻辑,检查购物车是否存在及状态是否允许删除 - 实现关联数据清理,包括购物车项目、配件和服务的级联删除 - 优化代码格式,统一方法体内的空格规范
This commit is contained in:
parent
94bdcf4a6b
commit
6439afad38
|
|
@ -238,8 +238,30 @@ public class ShoppingController extends ControllerBase {
|
||||||
* 查询购物车
|
* 查询购物车
|
||||||
*/
|
*/
|
||||||
@PostMapping("/search")
|
@PostMapping("/search")
|
||||||
public ApiResult<PageData<ShoppingSearchVO>> search(@Valid @RequestBody ShoppingSearchRequest request){
|
public ApiResult<PageData<ShoppingSearchVO>> search(@Valid @RequestBody ShoppingSearchRequest request) {
|
||||||
return ApiResult.success(shoppingCartService.search(request,MultilingualUtil.getLanguage()));
|
return ApiResult.success(shoppingCartService.search(request, MultilingualUtil.getLanguage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除购物车
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public ApiResult<Void> delete(@RequestParam Long id) {
|
||||||
|
QuotationShoppingCart cart = shoppingCartService.getById(id);
|
||||||
|
VUtils.trueThrowBusinessError(Objects.isNull(cart)).throwMessage("未找到购物车信息");
|
||||||
|
VUtils.trueThrowBusinessError(cart.getStatus() == 1).throwMessage("已生成报价单不能删除");
|
||||||
|
shoppingCartItemService.lambdaUpdate()
|
||||||
|
.eq(QuotationShoppingCartItem::getCartId, id)
|
||||||
|
.remove();
|
||||||
|
shoppingCartAccessoryService.lambdaUpdate()
|
||||||
|
.eq(QuotationShoppingCartAccessory::getCartId, id)
|
||||||
|
.remove();
|
||||||
|
shoppingCartServiceService.lambdaUpdate()
|
||||||
|
.eq(QuotationShoppingCartService::getCartId, id)
|
||||||
|
.remove();
|
||||||
|
shoppingCartService.removeById(id);
|
||||||
|
return ApiResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pair<BigDecimal, BigDecimal> getRatio(Long modelId, Long categoryId) {
|
private Pair<BigDecimal, BigDecimal> getRatio(Long modelId, Long categoryId) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue