diff --git a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/product/DeleteCartRequest.java b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/product/DeleteCartRequest.java new file mode 100644 index 000000000..659106579 --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/product/DeleteCartRequest.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.shop.request.product; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + +/** + * @Title:DelectCartRequest + * @Description: TODO + * @author: tangqian + * @date: 2023/5/25 13:03 + * @version: V1.0.0 + */ +@Data +public class DeleteCartRequest implements Serializable { + private static final long serialVersionUID = 8471460222619043734L; + @Schema(description = "商品id") + private List ids; +} diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/cart/CartController.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/cart/CartController.java index 0867dbd9c..e0277e6d7 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/cart/CartController.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/cart/CartController.java @@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.module.shop.request.product.CartNumRequest; import cn.iocoder.yudao.module.shop.request.product.CartRequest; import cn.iocoder.yudao.module.shop.request.product.CartResetRequest; +import cn.iocoder.yudao.module.shop.request.product.DeleteCartRequest; import cn.iocoder.yudao.module.shop.response.product.CartInfoResponse; import cn.iocoder.yudao.module.shop.service.product.StoreCartService; import com.github.pagehelper.PageInfo; @@ -78,12 +79,11 @@ public class CartController { /** * 删除购物车表 - * @param ids 购物车ids */ @Operation(summary = "删除") @RequestMapping(value = "/delete", method = RequestMethod.POST) - public CommonResult delete(@RequestParam(value = "ids") List ids) { - if (storeCartService.deleteCartByIds(ids)) { + public CommonResult delete(@RequestBody @Validated DeleteCartRequest request) { + if (storeCartService.deleteCartByIds(request.getIds())) { return CommonResult.success("删除购物车成功"); } else { return CommonResult.error(GlobalErrorCodeConstants.OPERATION_ERROR.getCode(), "删除购物车失败"); diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/PhoneRecordServiceImpl.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/PhoneRecordServiceImpl.java index bbe6284c5..4d532996f 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/PhoneRecordServiceImpl.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/PhoneRecordServiceImpl.java @@ -7,7 +7,10 @@ import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; import cn.iocoder.yudao.module.shop.controller.app.recharge.vo.PhoneRecordAdd; +import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -70,11 +73,12 @@ public class PhoneRecordServiceImpl implements PhoneRecordService { // 校验存在 validatePhoneRecordExists(id); // 删除 - phoneRecordMapper.deleteById(id); + phoneRecordMapper.delete(Wrappers.lambdaQuery().eq(PhoneRecordDO::getRechargeOrderId,id)); } private void validatePhoneRecordExists(Long id) { - if (phoneRecordMapper.selectById(id) == null) { + PhoneRecordDO phoneRecordDO = phoneRecordMapper.selectOne(Wrappers.lambdaQuery().eq(PhoneRecordDO::getRechargeOrderId, id)); + if (phoneRecordDO == null) { throw exception(PHONE_RECORD_NOT_EXISTS); } }