【同步】BOOT 和 CLOUD 的功能
This commit is contained in:
@@ -4,17 +4,15 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
|
||||
|
||||
@Schema(description = "管理后台 - 商品浏览记录 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ProductBrowseHistoryRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = REQUIRED, example = "1")
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502")
|
||||
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29502")
|
||||
private Long spuId;
|
||||
|
||||
// ========== 商品相关字段 ==========
|
||||
@@ -34,4 +32,4 @@ public class ProductBrowseHistoryRespVO {
|
||||
@Schema(description = "库存", example = "100")
|
||||
private Integer stock;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
package cn.iocoder.yudao.module.product.controller.app.favorite.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
|
||||
|
||||
@Schema(description = "用户 APP - 商品收藏的批量 Request VO") // 用于收藏、取消收藏、获取收藏
|
||||
@Data
|
||||
public class AppFavoriteBatchReqVO {
|
||||
|
||||
@Schema(description = "商品 SPU 编号数组", requiredMode = REQUIRED, example = "29502")
|
||||
@Schema(description = "商品 SPU 编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "29502")
|
||||
@NotEmpty(message = "商品 SPU 编号数组不能为空")
|
||||
private List<Long> spuIds;
|
||||
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package cn.iocoder.yudao.module.product.controller.app.favorite.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "用户 APP - 商品收藏的单个 Request VO") // 用于收藏、取消收藏、获取收藏
|
||||
@Data
|
||||
public class AppFavoriteReqVO {
|
||||
|
||||
@Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502")
|
||||
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29502")
|
||||
@NotNull(message = "商品 SPU 编号不能为空")
|
||||
private Long spuId;
|
||||
|
||||
|
||||
@@ -3,16 +3,14 @@ package cn.iocoder.yudao.module.product.controller.app.favorite.vo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
|
||||
|
||||
@Schema(description = "用户 App - 商品收藏 Response VO")
|
||||
@Data
|
||||
public class AppFavoriteRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = REQUIRED, example = "1")
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502")
|
||||
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29502")
|
||||
private Long spuId;
|
||||
|
||||
// ========== 商品相关字段 ==========
|
||||
|
||||
@@ -6,13 +6,11 @@ import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
|
||||
|
||||
@Schema(description = "用户 APP - 删除商品浏览记录的 Request VO")
|
||||
@Data
|
||||
public class AppProductBrowseHistoryDeleteReqVO {
|
||||
|
||||
@Schema(description = "商品 SPU 编号数组", requiredMode = REQUIRED, example = "29502")
|
||||
@Schema(description = "商品 SPU 编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "29502")
|
||||
@NotEmpty(message = "商品 SPU 编号数组不能为空")
|
||||
private List<Long> spuIds;
|
||||
|
||||
|
||||
@@ -3,33 +3,31 @@ package cn.iocoder.yudao.module.product.controller.app.history.vo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
|
||||
|
||||
@Schema(description = "用户 App - 商品浏览记录 Response VO")
|
||||
@Data
|
||||
public class AppProductBrowseHistoryRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = REQUIRED, example = "1")
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502")
|
||||
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29502")
|
||||
private Long spuId;
|
||||
|
||||
// ========== 商品相关字段 ==========
|
||||
|
||||
@Schema(description = "商品 SPU 名称", requiredMode = REQUIRED, example = "赵六")
|
||||
@Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
private String spuName;
|
||||
|
||||
@Schema(description = "商品封面图", requiredMode = REQUIRED, example = "https://www.iocoder.cn/pic.png")
|
||||
@Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/pic.png")
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = "商品单价", requiredMode = REQUIRED, example = "50")
|
||||
@Schema(description = "商品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "50")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "商品销量", requiredMode = REQUIRED, example = "60")
|
||||
@Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "60")
|
||||
private Integer salesCount;
|
||||
|
||||
@Schema(description = "库存", requiredMode = REQUIRED, example = "80")
|
||||
@Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "80")
|
||||
private Integer stock;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -13,6 +15,9 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> {
|
||||
|
||||
@Select("SELECT * FROM product_sku WHERE id = #{id}")
|
||||
ProductSkuDO selectByIdIncludeDeleted(@Param("id") Long id);
|
||||
|
||||
default List<ProductSkuDO> selectListBySpuId(Long spuId) {
|
||||
return selectList(ProductSkuDO::getSpuId, spuId);
|
||||
}
|
||||
@@ -35,7 +40,7 @@ public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> {
|
||||
Assert.isTrue(incrCount > 0);
|
||||
LambdaUpdateWrapper<ProductSkuDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<ProductSkuDO>()
|
||||
.setSql(" stock = stock + " + incrCount
|
||||
+ ", sales_count = sales_count - " + incrCount)
|
||||
+ ", sales_count = sales_count - " + incrCount)
|
||||
.eq(ProductSkuDO::getId, id);
|
||||
update(null, lambdaUpdateWrapper);
|
||||
}
|
||||
@@ -52,7 +57,7 @@ public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> {
|
||||
incrCount = - incrCount; // 取正
|
||||
LambdaUpdateWrapper<ProductSkuDO> updateWrapper = new LambdaUpdateWrapper<ProductSkuDO>()
|
||||
.setSql(" stock = stock - " + incrCount
|
||||
+ ", sales_count = sales_count + " + incrCount)
|
||||
+ ", sales_count = sales_count + " + incrCount)
|
||||
.eq(ProductSkuDO::getId, id)
|
||||
.ge(ProductSkuDO::getStock, incrCount);
|
||||
return update(null, updateWrapper);
|
||||
|
||||
@@ -11,6 +11,8 @@ import cn.iocoder.yudao.module.product.enums.ProductConstants;
|
||||
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
@@ -18,6 +20,9 @@ import java.util.Set;
|
||||
@Mapper
|
||||
public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
|
||||
|
||||
@Select("SELECT * FROM product_spu WHERE id = #{id}")
|
||||
ProductSpuDO selectByIdIncludeDeleted(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 获取商品 SPU 分页列表数据
|
||||
*
|
||||
|
||||
@@ -91,7 +91,7 @@ public class ProductCommentServiceImpl implements ProductCommentService {
|
||||
}
|
||||
|
||||
private ProductSkuDO validateSku(Long skuId) {
|
||||
ProductSkuDO sku = productSkuService.getSku(skuId);
|
||||
ProductSkuDO sku = productSkuService.getSku(skuId, true);
|
||||
if (sku == null) {
|
||||
throw exception(SKU_NOT_EXISTS);
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class ProductCommentServiceImpl implements ProductCommentService {
|
||||
}
|
||||
|
||||
private ProductSpuDO validateSpu(Long spuId) {
|
||||
ProductSpuDO spu = productSpuService.getSpu(spuId);
|
||||
ProductSpuDO spu = productSpuService.getSpu(spuId, true);
|
||||
if (null == spu) {
|
||||
throw exception(SPU_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,15 @@ public interface ProductSkuService {
|
||||
*/
|
||||
ProductSkuDO getSku(Long id);
|
||||
|
||||
/**
|
||||
* 获得商品 SKU 信息
|
||||
*
|
||||
* @param id 编号
|
||||
* @param includeDeleted 是否包含已删除的
|
||||
* @return 商品 SKU 信息
|
||||
*/
|
||||
ProductSkuDO getSku(Long id, boolean includeDeleted);
|
||||
|
||||
/**
|
||||
* 获得商品 SKU 列表
|
||||
*
|
||||
|
||||
@@ -68,6 +68,14 @@ public class ProductSkuServiceImpl implements ProductSkuService {
|
||||
return productSkuMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductSkuDO getSku(Long id, boolean includeDeleted) {
|
||||
if (includeDeleted) {
|
||||
return productSkuMapper.selectByIdIncludeDeleted(id);
|
||||
}
|
||||
return getSku(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductSkuDO> getSkuList(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
|
||||
@@ -51,6 +51,15 @@ public interface ProductSpuService {
|
||||
*/
|
||||
ProductSpuDO getSpu(Long id);
|
||||
|
||||
/**
|
||||
* 获得商品 SPU
|
||||
*
|
||||
* @param id 编号
|
||||
* @param includeDeleted 是否包含已删除的
|
||||
* @return 商品 SPU
|
||||
*/
|
||||
ProductSpuDO getSpu(Long id, boolean includeDeleted);
|
||||
|
||||
/**
|
||||
* 获得商品 SPU 列表
|
||||
*
|
||||
|
||||
@@ -189,6 +189,14 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
return productSpuMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductSpuDO getSpu(Long id, boolean includeDeleted) {
|
||||
if (includeDeleted) {
|
||||
return productSpuMapper.selectByIdIncludeDeleted(id);
|
||||
}
|
||||
return getSpu(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductSpuDO> getSpuList(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
|
||||
Reference in New Issue
Block a user