product:初始化代码

pull/58/head
YunaiV 2023-10-22 17:01:10 +08:00
parent 6a51097e1d
commit 6653c074fa
164 changed files with 10026 additions and 0 deletions

View File

@ -19,6 +19,7 @@
<module>yudao-module-pay</module>
<module>yudao-module-report</module>
<module>yudao-module-mp</module>
<module>yudao-module-mall</module>
</modules>
<name>${project.artifactId}</name>

View File

@ -59,6 +59,11 @@ public class DictFrameworkUtils {
log.info("[init][初始化 DictFrameworkUtils 成功]");
}
@SneakyThrows
public static String getDictDataLabel(String dictType, Integer value) {
return GET_DICT_DATA_CACHE.get(new KeyValue<>(dictType, String.valueOf(value))).getLabel();
}
@SneakyThrows
public static String getDictDataLabel(String dictType, String value) {
return GET_DICT_DATA_CACHE.get(new KeyValue<>(dictType, value)).getLabel();

31
yudao-module-mall/pom.xml Normal file
View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>yudao</artifactId>
<groupId>cn.iocoder.cloud</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>yudao-module-mall</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>
商城大模块,由 product 商品、promotion 营销、trade 交易、statistics 统计等组成
</description>
<modules>
<!-- <module>yudao-module-promotion-api</module>-->
<!-- <module>yudao-module-promotion-biz</module>-->
<module>yudao-module-product-api</module>
<module>yudao-module-product-biz</module>
<!-- <module>yudao-module-trade-api</module>-->
<!-- <module>yudao-module-trade-biz</module>-->
<!-- <module>yudao-module-statistics-api</module>-->
<!-- <module>yudao-module-statistics-biz</module>-->
</modules>
</project>

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-module-mall</artifactId>
<version>${revision}</version>
</parent>
<artifactId>yudao-module-product-api</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>
product 模块 API暴露给其它模块调用
</description>
<dependencies>
<dependency>
<groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-common</artifactId>
</dependency>
<!-- Web 相关 -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<scope>provided</scope>
</dependency>
<!-- 参数校验 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<optional>true</optional>
</dependency>
<!-- RPC 远程调用相关 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.product.api.category;
import java.util.Collection;
/**
* API
*
* @author owen
*/
public interface ProductCategoryApi {
/**
*
* 1.
* 2.
*
* @param ids
*/
void validateCategoryList(Collection<Long> ids);
}

View File

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.product.api.comment;
import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO;
/**
* API
*
* @author HUIHUI
*/
public interface ProductCommentApi {
/**
*
*
* @param createReqDTO
* @return id
*/
Long createComment(ProductCommentCreateReqDTO createReqDTO);
}

View File

@ -0,0 +1,59 @@
package cn.iocoder.yudao.module.product.api.comment.dto;
import lombok.Data;
import java.util.List;
/**
* DTO
*
* @author HUIHUI
*/
@Data
public class ProductCommentCreateReqDTO {
/**
* SKU
*/
private Long skuId;
/**
*
*/
private Long orderId;
/**
*
*/
private Long orderItemId;
/**
* 1-5
*/
private Integer scores;
/**
* 1-5
*/
private Integer descriptionScores;
/**
* 1-5
*/
private Integer benefitScores;
/**
*
*/
private String content;
/**
* 9
*/
private List<String> picUrls;
/**
*
*/
private Boolean anonymous;
/**
*
*/
private Long userId;
}

View File

@ -0,0 +1,4 @@
/**
*
*/
package cn.iocoder.yudao.module.product.api;

View File

@ -0,0 +1,23 @@
package cn.iocoder.yudao.module.product.api.property;
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
import java.util.Collection;
import java.util.List;
/**
* API
*
* @author
*/
public interface ProductPropertyValueApi {
/**
*
*
* @param ids
* @return
*/
List<ProductPropertyValueDetailRespDTO> getPropertyValueDetailList(Collection<Long> ids);
}

View File

@ -0,0 +1,33 @@
package cn.iocoder.yudao.module.product.api.property.dto;
import lombok.Data;
/**
* Response DTO
*
* @author
*/
@Data
public class ProductPropertyValueDetailRespDTO {
/**
*
*/
private Long propertyId;
/**
*
*/
private String propertyName;
/**
*
*/
private Long valueId;
/**
*
*/
private String valueName;
}

View File

@ -0,0 +1,48 @@
package cn.iocoder.yudao.module.product.api.sku;
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO;
import java.util.Collection;
import java.util.List;
/**
* SKU API
*
* @author LeeYan9
* @since 2022-08-26
*/
public interface ProductSkuApi {
/**
* SKU
*
* @param id SKU
* @return SKU
*/
ProductSkuRespDTO getSku(Long id);
/**
* SKU
*
* @param ids SKU
* @return SKU
*/
List<ProductSkuRespDTO> getSkuList(Collection<Long> ids);
/**
* SKU
*
* @param spuIds SPU
* @return SKU
*/
List<ProductSkuRespDTO> getSkuListBySpuId(Collection<Long> spuIds);
/**
* SKU or
*
* @param updateStockReqDTO
*/
void updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO);
}

View File

@ -0,0 +1,71 @@
package cn.iocoder.yudao.module.product.api.sku.dto;
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
import lombok.Data;
import java.util.List;
/**
* SKU Response DTO
*
* @author LeeYan9
* @since 2022-08-26
*/
@Data
public class ProductSkuRespDTO {
/**
* SKU
*/
private Long id;
/**
* SPU
*/
private Long spuId;
/**
*
*/
private List<ProductPropertyValueDetailRespDTO> properties;
/**
*
*/
private Integer price;
/**
*
*/
private Integer marketPrice;
/**
*
*/
private Integer costPrice;
/**
* SKU
*/
private String barCode;
/**
*
*/
private String picUrl;
/**
*
*/
private Integer stock;
/**
* kg
*/
private Double weight;
/**
* m^3
*/
private Double volume;
/**
*
*/
private Integer firstBrokeragePrice;
/**
*
*/
private Integer secondBrokeragePrice;
}

View File

@ -0,0 +1,47 @@
package cn.iocoder.yudao.module.product.api.sku.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* SKU Request DTO
*
* @author LeeYan9
* @since 2022-08-26
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ProductSkuUpdateStockReqDTO {
/**
* SKU
*/
@NotNull(message = "商品 SKU 不能为空")
private List<Item> items;
@Data
public static class Item {
/**
* SKU
*/
@NotNull(message = "商品 SKU 编号不能为空")
private Long id;
/**
*
*
*
*
*/
@NotNull(message = "库存变化数量不能为空")
private Integer incrCount;
}
}

View File

@ -0,0 +1,43 @@
package cn.iocoder.yudao.module.product.api.spu;
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
import java.util.Collection;
import java.util.List;
/**
* SPU API
*
* @author LeeYan9
* @since 2022-08-26
*/
public interface ProductSpuApi {
/**
* SPU
*
* @param ids SPU
* @return SPU
*/
List<ProductSpuRespDTO> getSpuList(Collection<Long> ids);
/**
* SPU SPU
*
*
* 1.
* 2.
*
* @param ids SPU
* @return SPU
*/
List<ProductSpuRespDTO> validateSpuList(Collection<Long> ids);
/**
* SPU
*
* @return SPU
*/
ProductSpuRespDTO getSpu(Long id);
}

View File

@ -0,0 +1,152 @@
package cn.iocoder.yudao.module.product.api.spu.dto;
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
import lombok.Data;
import java.util.List;
/**
* SPU Response DTO
*
* @author LeeYan9
* @since 2022-08-26
*/
@Data
public class ProductSpuRespDTO {
/**
* SPU
*/
private Long id;
// ========== 基本信息 =========
/**
*
*/
private String name;
/**
*
*/
private String keyword;
/**
*
*
* product_unit
*/
private Integer unit;
/**
*
*/
private String introduction;
/**
*
*/
private String description;
// TODO @芋艿:是不是要删除
/**
*
*/
private String barCode;
/**
*
*/
private Long categoryId;
/**
*
*/
private Long brandId;
/**
*
*/
private String picUrl;
/**
*
*/
private List<String> sliderPicUrls;
/**
*
*/
private String videoUrl;
/**
*
*/
private Integer sort;
/**
*
* <p>
* {@link ProductSpuStatusEnum}
*/
private Integer status;
// ========== SKU 相关字段 =========
/**
*
*
* false -
* true -
*/
private Boolean specType;
/**
* 使
*/
private Integer price;
/**
* 使
*/
private Integer marketPrice;
/**
* 使
*/
private Integer costPrice;
/**
*
*/
private Integer stock;
// ========== 物流相关字段 =========
/**
*
*
* TradeDeliveryExpressTemplateDO id
*/
private Long deliveryTemplateId;
// ========== 营销相关字段 =========
/**
*
*/
private Integer giveIntegral;
// ========== 统计相关字段 =========
/**
*
*/
private Integer salesCount;
/**
*
*/
private Integer virtualSalesCount;
/**
*
*/
private Integer clickCount;
// ========== 分销相关字段 =========
/**
*
*
* false -
* true -
*/
private Boolean subCommissionType;
}

View File

@ -0,0 +1,13 @@
package cn.iocoder.yudao.module.product.enums;
/**
* product
*
* @author HUIHUI
*/
public interface DictTypeConstants {
String PRODUCT_UNIT = "product_unit"; // 商品单位
String PRODUCT_SPU_STATUS = "product_spu_status"; // 商品 SPU 状态
}

View File

@ -0,0 +1,56 @@
package cn.iocoder.yudao.module.product.enums;
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
/**
* Product
*
* product 使 1-008-000-000
*/
public interface ErrorCodeConstants {
// ========== 商品分类相关 1-008-001-000 ============
ErrorCode CATEGORY_NOT_EXISTS = new ErrorCode(1_008_001_000, "商品分类不存在");
ErrorCode CATEGORY_PARENT_NOT_EXISTS = new ErrorCode(1_008_001_001, "父分类不存在");
ErrorCode CATEGORY_PARENT_NOT_FIRST_LEVEL = new ErrorCode(1_008_001_002, "父分类不能是二级分类");
ErrorCode CATEGORY_EXISTS_CHILDREN = new ErrorCode(1_008_001_003, "存在子分类,无法删除");
ErrorCode CATEGORY_DISABLED = new ErrorCode(1_008_001_004, "商品分类({})已禁用,无法使用");
ErrorCode CATEGORY_HAVE_BIND_SPU = new ErrorCode(1_008_001_005, "类别下存在商品,无法删除");
// ========== 商品品牌相关编号 1-008-002-000 ==========
ErrorCode BRAND_NOT_EXISTS = new ErrorCode(1_008_002_000, "品牌不存在");
ErrorCode BRAND_DISABLED = new ErrorCode(1_008_002_001, "品牌已禁用");
ErrorCode BRAND_NAME_EXISTS = new ErrorCode(1_008_002_002, "品牌名称已存在");
// ========== 商品属性项 1-008-003-000 ==========
ErrorCode PROPERTY_NOT_EXISTS = new ErrorCode(1_008_003_000, "属性项不存在");
ErrorCode PROPERTY_EXISTS = new ErrorCode(1_008_003_001, "属性项的名称已存在");
ErrorCode PROPERTY_DELETE_FAIL_VALUE_EXISTS = new ErrorCode(1_008_003_002, "属性项下存在属性值,无法删除");
// ========== 商品属性值 1-008-004-000 ==========
ErrorCode PROPERTY_VALUE_NOT_EXISTS = new ErrorCode(1_008_004_000, "属性值不存在");
ErrorCode PROPERTY_VALUE_EXISTS = new ErrorCode(1_008_004_001, "属性值的名称已存在");
// ========== 商品 SPU 1-008-005-000 ==========
ErrorCode SPU_NOT_EXISTS = new ErrorCode(1_008_005_000, "商品 SPU 不存在");
ErrorCode SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR = new ErrorCode(1_008_005_001, "商品分类不正确,原因:必须使用第二级的商品分类及以下");
ErrorCode SPU_SAVE_FAIL_COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1_008_005_002, "商品 SPU 保存失败,原因:优惠卷不存在");
ErrorCode SPU_NOT_ENABLE = new ErrorCode(1_008_005_003, "商品 SPU【{}】不处于上架状态");
ErrorCode SPU_NOT_RECYCLE = new ErrorCode(1_008_005_004, "商品 SPU 不处于回收站状态");
// ========== 商品 SKU 1-008-006-000 ==========
ErrorCode SKU_NOT_EXISTS = new ErrorCode(1_008_006_000, "商品 SKU 不存在");
ErrorCode SKU_PROPERTIES_DUPLICATED = new ErrorCode(1_008_006_001, "商品 SKU 的属性组合存在重复");
ErrorCode SPU_ATTR_NUMBERS_MUST_BE_EQUALS = new ErrorCode(1_008_006_002, "一个 SPU 下的每个 SKU其属性项必须一致");
ErrorCode SPU_SKU_NOT_DUPLICATE = new ErrorCode(1_008_006_003, "一个 SPU 下的每个 SKU必须不重复");
ErrorCode SKU_STOCK_NOT_ENOUGH = new ErrorCode(1_008_006_004, "商品 SKU 库存不足");
// ========== 商品 评价 1-008-007-000 ==========
ErrorCode COMMENT_NOT_EXISTS = new ErrorCode(1_008_007_000, "商品评价不存在");
ErrorCode COMMENT_ORDER_EXISTS = new ErrorCode(1_008_007_001, "订单的商品评价已存在");
// ========== 商品 收藏 1-008-008-000 ==========
ErrorCode FAVORITE_EXISTS = new ErrorCode(1_008_008_000, "该商品已经被收藏");
ErrorCode FAVORITE_NOT_EXISTS = new ErrorCode(1_008_008_001, "商品收藏不存在");
}

View File

@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.product.enums;
/**
* Product
*
* @author HUIHUI
*/
public interface ProductConstants {
/**
* TODO 10使
*/
int ALERT_STOCK = 10;
}

View File

@ -0,0 +1,38 @@
package cn.iocoder.yudao.module.product.enums.comment;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
*
*
* @author
*/
@Getter
@AllArgsConstructor
public enum ProductCommentAuditStatusEnum implements IntArrayValuable {
NONE(1, "待审核"),
APPROVE(2, "审批通过"),
REJECT(2, "审批不通过"),;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductCommentAuditStatusEnum::getStatus).toArray();
/**
*
*/
private final Integer status;
/**
*
*/
private final String name;
@Override
public int[] array() {
return ARRAYS;
}
}

View File

@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.product.enums.comment;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
*
*
* @author wangzhs
*/
@Getter
@AllArgsConstructor
public enum ProductCommentScoresEnum implements IntArrayValuable {
ONE(1, "1星"),
TWO(2, "2星"),
THREE(3, "3星"),
FOUR(4, "4星"),
FIVE(5, "5星");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductCommentScoresEnum::getScores).toArray();
/**
*
*/
private final Integer scores;
/**
*
*/
private final String name;
@Override
public int[] array() {
return ARRAYS;
}
}

View File

@ -0,0 +1,38 @@
package cn.iocoder.yudao.module.product.enums.group;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
*
*
* @author
*/
@Getter
@AllArgsConstructor
public enum ProductGroupStyleEnum implements IntArrayValuable {
ONE(1, "每列一个"),
TWO(2, "每列两个"),
THREE(2, "每列三个"),;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductGroupStyleEnum::getStyle).toArray();
/**
*
*/
private final Integer style;
/**
*
*/
private final String name;
@Override
public int[] array() {
return ARRAYS;
}
}

View File

@ -0,0 +1,48 @@
package cn.iocoder.yudao.module.product.enums.spu;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
* SPU
*
* @author
*/
@Getter
@AllArgsConstructor
public enum ProductSpuStatusEnum implements IntArrayValuable {
RECYCLE(-1, "回收站"),
DISABLE(0, "下架"),
ENABLE(1, "上架");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductSpuStatusEnum::getStatus).toArray();
/**
*
*/
private final Integer status;
/**
*
*/
private final String name;
@Override
public int[] array() {
return ARRAYS;
}
/**
*
*
* @param status
* @return
*/
public static boolean isEnable(Integer status) {
return ENABLE.getStatus().equals(status);
}
}

View File

@ -0,0 +1,19 @@
## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性
## 感谢复旦核博士的建议!灰子哥,牛皮!
FROM eclipse-temurin:8-jre
## 创建目录,并使用它作为工作目录
RUN mkdir -p /yudao-module-product-biz
WORKDIR /yudao-module-product-biz
## 将后端项目的 Jar 文件,复制到镜像中
COPY ./target/yudao-module-product-biz.jar app.jar
## 设置 TZ 时区
## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖
ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m"
## 暴露后端项目的 48080 端口
EXPOSE 48100
## 启动后端项目
CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar

View File

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-module-mall</artifactId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>yudao-module-product-biz</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>
product 模块,主要实现商品相关功能
例如品牌、商品分类、spu、sku等功能。
</description>
<dependencies>
<!-- Spring Cloud 基础 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-spring-boot-starter-env</artifactId>
</dependency>
<!-- 依赖服务 -->
<dependency>
<groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-module-product-api</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-module-member-api</artifactId>
<version>${revision}</version>
</dependency>
<!-- 业务组件 -->
<dependency>
<groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-spring-boot-starter-biz-dict</artifactId>
</dependency>
<!-- Web 相关 -->
<dependency>
<groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-spring-boot-starter-security</artifactId>
</dependency>
<!-- DB 相关 -->
<dependency>
<groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-spring-boot-starter-mybatis</artifactId>
</dependency>
<!-- RPC 远程调用相关 -->
<dependency>
<groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-spring-boot-starter-rpc</artifactId>
</dependency>
<!-- Registry 注册中心相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- Config 配置中心相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- Test 测试相关 -->
<dependency>
<groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-spring-boot-starter-test</artifactId>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-spring-boot-starter-excel</artifactId>
</dependency>
<!-- 监控相关 -->
<dependency>
<groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-spring-boot-starter-monitor</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.product;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
*
*
* https://cloud.iocoder.cn/quick-start/ 文章
* https://cloud.iocoder.cn/quick-start/ 文章
* https://cloud.iocoder.cn/quick-start/ 文章
*
* @author
*/
@SpringBootApplication
public class ProductServerApplication {
public static void main(String[] args) {
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
SpringApplication.run(ProductServerApplication.class, args);
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
}
}

View File

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.product.api.category;
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
/**
* API
*
* @author owen
*/
@Service
@Validated
public class ProductCategoryApiImpl implements ProductCategoryApi {
@Resource
private ProductCategoryService productCategoryService;
@Override
public void validateCategoryList(Collection<Long> ids) {
productCategoryService.validateCategoryList(ids);
}
}

View File

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.product.api.comment;
import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO;
import cn.iocoder.yudao.module.product.service.comment.ProductCommentService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
/**
* API
*
* @author HUIHUI
*/
@Service
@Validated
public class ProductCommentApiImpl implements ProductCommentApi {
@Resource
private ProductCommentService productCommentService;
@Override
public Long createComment(ProductCommentCreateReqDTO createReqDTO) {
return productCommentService.createComment(createReqDTO);
}
}

View File

@ -0,0 +1 @@
package cn.iocoder.yudao.module.product.api;

View File

@ -0,0 +1,31 @@
package cn.iocoder.yudao.module.product.api.property;
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
import cn.iocoder.yudao.module.product.convert.property.ProductPropertyValueConvert;
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
/**
* API
*
* @author
*/
@Service
@Validated
public class ProductPropertyValueApiImpl implements ProductPropertyValueApi {
@Resource
private ProductPropertyValueService productPropertyValueService;
@Override
public List<ProductPropertyValueDetailRespDTO> getPropertyValueDetailList(Collection<Long> ids) {
return ProductPropertyValueConvert.INSTANCE.convertList02(
productPropertyValueService.getPropertyValueDetailList(ids));
}
}

View File

@ -0,0 +1,59 @@
package cn.iocoder.yudao.module.product.api.sku;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO;
import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* SKU API
*
* @author LeeYan9
* @since 2022-09-06
*/
@Service
@Validated
public class ProductSkuApiImpl implements ProductSkuApi {
@Resource
private ProductSkuService productSkuService;
@Override
public ProductSkuRespDTO getSku(Long id) {
ProductSkuDO sku = productSkuService.getSku(id);
return ProductSkuConvert.INSTANCE.convert02(sku);
}
@Override
public List<ProductSkuRespDTO> getSkuList(Collection<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
List<ProductSkuDO> skus = productSkuService.getSkuList(ids);
return ProductSkuConvert.INSTANCE.convertList04(skus);
}
@Override
public List<ProductSkuRespDTO> getSkuListBySpuId(Collection<Long> spuIds) {
if (CollUtil.isEmpty(spuIds)) {
return Collections.emptyList();
}
List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spuIds);
return ProductSkuConvert.INSTANCE.convertList04(skus);
}
@Override
public void updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO) {
productSkuService.updateSkuStock(updateStockReqDTO);
}
}

View File

@ -0,0 +1,46 @@
package cn.iocoder.yudao.module.product.api.spu;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert;
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* SPU API
*
* @author LeeYan9
* @since 2022-09-06
*/
@Service
@Validated
public class ProductSpuApiImpl implements ProductSpuApi {
@Resource
private ProductSpuService spuService;
@Override
public List<ProductSpuRespDTO> getSpuList(Collection<Long> ids) {
if (CollectionUtil.isEmpty(ids)) {
return Collections.emptyList();
}
return ProductSpuConvert.INSTANCE.convertList2(spuService.getSpuList(ids));
}
@Override
public List<ProductSpuRespDTO> validateSpuList(Collection<Long> ids) {
return ProductSpuConvert.INSTANCE.convertList2(spuService.validateSpuList(ids));
}
@Override
public ProductSpuRespDTO getSpu(Long id) {
return ProductSpuConvert.INSTANCE.convert02(spuService.getSpu(id));
}
}

View File

@ -0,0 +1,92 @@
package cn.iocoder.yudao.module.product.controller.admin.brand;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.product.controller.admin.brand.vo.*;
import cn.iocoder.yudao.module.product.convert.brand.ProductBrandConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO;
import cn.iocoder.yudao.module.product.service.brand.ProductBrandService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Comparator;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 商品品牌")
@RestController
@RequestMapping("/product/brand")
@Validated
public class ProductBrandController {
@Resource
private ProductBrandService brandService;
@PostMapping("/create")
@Operation(summary = "创建品牌")
@PreAuthorize("@ss.hasPermission('product:brand:create')")
public CommonResult<Long> createBrand(@Valid @RequestBody ProductBrandCreateReqVO createReqVO) {
return success(brandService.createBrand(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新品牌")
@PreAuthorize("@ss.hasPermission('product:brand:update')")
public CommonResult<Boolean> updateBrand(@Valid @RequestBody ProductBrandUpdateReqVO updateReqVO) {
brandService.updateBrand(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除品牌")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('product:brand:delete')")
public CommonResult<Boolean> deleteBrand(@RequestParam("id") Long id) {
brandService.deleteBrand(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得品牌")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('product:brand:query')")
public CommonResult<ProductBrandRespVO> getBrand(@RequestParam("id") Long id) {
ProductBrandDO brand = brandService.getBrand(id);
return success(ProductBrandConvert.INSTANCE.convert(brand));
}
@GetMapping("/list-all-simple")
@Operation(summary = "获取品牌精简信息列表", description = "主要用于前端的下拉选项")
public CommonResult<List<ProductBrandSimpleRespVO>> getSimpleBrandList() {
// 获取品牌列表,只要开启状态的
List<ProductBrandDO> list = brandService.getBrandListByStatus(CommonStatusEnum.ENABLE.getStatus());
// 排序后,返回给前端
return success(ProductBrandConvert.INSTANCE.convertList1(list));
}
@GetMapping("/page")
@Operation(summary = "获得品牌分页")
@PreAuthorize("@ss.hasPermission('product:brand:query')")
public CommonResult<PageResult<ProductBrandRespVO>> getBrandPage(@Valid ProductBrandPageReqVO pageVO) {
PageResult<ProductBrandDO> pageResult = brandService.getBrandPage(pageVO);
return success(ProductBrandConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/list")
@Operation(summary = "获得品牌列表")
@PreAuthorize("@ss.hasPermission('product:brand:query')")
public CommonResult<List<ProductBrandRespVO>> getBrandList(@Valid ProductBrandListReqVO listVO) {
List<ProductBrandDO> list = brandService.getBrandList(listVO);
list.sort(Comparator.comparing(ProductBrandDO::getSort));
return success(ProductBrandConvert.INSTANCE.convertList(list));
}
}

View File

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.product.controller.admin.brand.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* Base VO VO 使
* VO Swagger
*/
@Data
public class ProductBrandBaseVO {
@Schema(description = "品牌名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "苹果")
@NotNull(message = "品牌名称不能为空")
private String name;
@Schema(description = "品牌图片", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "品牌图片不能为空")
private String picUrl;
@Schema(description = "品牌排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "品牌排序不能为空")
private Integer sort;
@Schema(description = "品牌描述", example = "描述")
private String description;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
@NotNull(message = "状态不能为空")
private Integer status;
}

View File

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.product.controller.admin.brand.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "管理后台 - 商品品牌创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductBrandCreateReqVO extends ProductBrandBaseVO {
}

View File

@ -0,0 +1,13 @@
package cn.iocoder.yudao.module.product.controller.admin.brand.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 商品品牌分页 Request VO")
@Data
public class ProductBrandListReqVO {
@Schema(description = "品牌名称", example = "苹果")
private String name;
}

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.product.controller.admin.brand.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 商品品牌分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductBrandPageReqVO extends PageParam {
@Schema(description = "品牌名称", example = "苹果")
private String name;
@Schema(description = "状态", example = "0")
private Integer status;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@Schema(description = "创建时间")
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.product.controller.admin.brand.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 品牌 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductBrandRespVO extends ProductBrandBaseVO {
@Schema(description = "品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long id;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
}

View File

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.product.controller.admin.brand.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Schema(description = "管理后台 - 品牌精简信息 Response VO")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ProductBrandSimpleRespVO {
@Schema(description = "品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long id;
@Schema(description = "品牌名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "苹果")
private String name;
}

View File

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.product.controller.admin.brand.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 商品品牌更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductBrandUpdateReqVO extends ProductBrandBaseVO {
@Schema(description = "品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "品牌编号不能为空")
private Long id;
}

View File

@ -0,0 +1,76 @@
package cn.iocoder.yudao.module.product.controller.admin.category;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO;
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO;
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryRespVO;
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO;
import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Comparator;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 商品分类")
@RestController
@RequestMapping("/product/category")
@Validated
public class ProductCategoryController {
@Resource
private ProductCategoryService categoryService;
@PostMapping("/create")
@Operation(summary = "创建商品分类")
@PreAuthorize("@ss.hasPermission('product:category:create')")
public CommonResult<Long> createCategory(@Valid @RequestBody ProductCategoryCreateReqVO createReqVO) {
return success(categoryService.createCategory(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新商品分类")
@PreAuthorize("@ss.hasPermission('product:category:update')")
public CommonResult<Boolean> updateCategory(@Valid @RequestBody ProductCategoryUpdateReqVO updateReqVO) {
categoryService.updateCategory(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除商品分类")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('product:category:delete')")
public CommonResult<Boolean> deleteCategory(@RequestParam("id") Long id) {
categoryService.deleteCategory(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得商品分类")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('product:category:query')")
public CommonResult<ProductCategoryRespVO> getCategory(@RequestParam("id") Long id) {
ProductCategoryDO category = categoryService.getCategory(id);
return success(ProductCategoryConvert.INSTANCE.convert(category));
}
@GetMapping("/list")
@Operation(summary = "获得商品分类列表")
@PreAuthorize("@ss.hasPermission('product:category:query')")
public CommonResult<List<ProductCategoryRespVO>> getCategoryList(@Valid ProductCategoryListReqVO treeListReqVO) {
List<ProductCategoryDO> list = categoryService.getEnableCategoryList(treeListReqVO);
list.sort(Comparator.comparing(ProductCategoryDO::getSort));
return success(ProductCategoryConvert.INSTANCE.convertList(list));
}
}

View File

@ -0,0 +1,38 @@
package cn.iocoder.yudao.module.product.controller.admin.category.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* Base VO VO 使
* VO Swagger
*/
@Data
public class ProductCategoryBaseVO {
@Schema(description = "父分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "父分类编号不能为空")
private Long parentId;
@Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "办公文具")
@NotBlank(message = "分类名称不能为空")
private String name;
@Schema(description = "移动端分类图", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "移动端分类图不能为空")
private String picUrl;
@Schema(description = "PC 端分类图")
private String bigPicUrl;
@Schema(description = "分类排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer sort;
@Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
@NotNull(message = "开启状态不能为空")
private Integer status;
}

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.product.controller.admin.category.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotBlank;
@Schema(description = "管理后台 - 商品分类创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductCategoryCreateReqVO extends ProductCategoryBaseVO {
@Schema(description = "分类描述", example = "描述")
private String description;
}

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.product.controller.admin.category.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 商品分类列表查询 Request VO")
@Data
public class ProductCategoryListReqVO {
@Schema(description = "分类名称", example = "办公文具")
private String name;
@Schema(description = "开启状态", example = "0")
private Integer status;
@Schema(description = "父分类编号", example = "1")
private Long parentId;
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.product.controller.admin.category.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 商品分类 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductCategoryRespVO extends ProductCategoryBaseVO {
@Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
private Long id;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
}

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.product.controller.admin.category.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 商品分类更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductCategoryUpdateReqVO extends ProductCategoryBaseVO {
@Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "分类编号不能为空")
private Long id;
@Schema(description = "分类描述", example = "描述")
private String description;
}

View File

@ -0,0 +1,62 @@
package cn.iocoder.yudao.module.product.controller.admin.comment;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.product.controller.admin.comment.vo.*;
import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO;
import cn.iocoder.yudao.module.product.service.comment.ProductCommentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@Tag(name = "管理后台 - 商品评价")
@RestController
@RequestMapping("/product/comment")
@Validated
public class ProductCommentController {
@Resource
private ProductCommentService productCommentService;
@GetMapping("/page")
@Operation(summary = "获得商品评价分页")
@PreAuthorize("@ss.hasPermission('product:comment:query')")
public CommonResult<PageResult<ProductCommentRespVO>> getCommentPage(@Valid ProductCommentPageReqVO pageVO) {
PageResult<ProductCommentDO> pageResult = productCommentService.getCommentPage(pageVO);
return success(ProductCommentConvert.INSTANCE.convertPage(pageResult));
}
@PutMapping("/update-visible")
@Operation(summary = "显示 / 隐藏评论")
@PreAuthorize("@ss.hasPermission('product:comment:update')")
public CommonResult<Boolean> updateCommentVisible(@Valid @RequestBody ProductCommentUpdateVisibleReqVO updateReqVO) {
productCommentService.updateCommentVisible(updateReqVO);
return success(true);
}
@PutMapping("/reply")
@Operation(summary = "商家回复")
@PreAuthorize("@ss.hasPermission('product:comment:update')")
public CommonResult<Boolean> commentReply(@Valid @RequestBody ProductCommentReplyReqVO replyVO) {
productCommentService.replyComment(replyVO, getLoginUserId());
return success(true);
}
@PostMapping("/create")
@Operation(summary = "添加自评")
@PreAuthorize("@ss.hasPermission('product:comment:update')")
public CommonResult<Boolean> createComment(@Valid @RequestBody ProductCommentCreateReqVO createReqVO) {
productCommentService.createComment(createReqVO);
return success(true);
}
}

View File

@ -0,0 +1,47 @@
package cn.iocoder.yudao.module.product.controller.admin.comment.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
@Data
public class ProductCommentBaseVO {
@Schema(description = "评价人", requiredMode = Schema.RequiredMode.REQUIRED, example = "16868")
private Long userId;
@Schema(description = "评价订单项", requiredMode = Schema.RequiredMode.REQUIRED, example = "19292")
private Long orderItemId;
@Schema(description = "评价人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小姑凉")
@NotNull(message = "评价人名称不能为空")
private String userNickname;
@Schema(description = "评价人头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png")
@NotNull(message = "评价人头像不能为空")
private String userAvatar;
@Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "商品 SKU 编号不能为空")
private Long skuId;
@Schema(description = "描述星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
@NotNull(message = "描述星级不能为空")
private Integer descriptionScores;
@Schema(description = "服务星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
@NotNull(message = "服务星级分不能为空")
private Integer benefitScores;
@Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "穿起来非常丝滑凉快")
@NotNull(message = "评论内容不能为空")
private String content;
@Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png]")
@Size(max = 9, message = "评论图片地址数组长度不能超过 9 张")
private List<String> picUrls;
}

View File

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.product.controller.admin.comment.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "管理后台 - 商品评价创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductCommentCreateReqVO extends ProductCommentBaseVO {
}

View File

@ -0,0 +1,45 @@
package cn.iocoder.yudao.module.product.controller.admin.comment.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.product.enums.comment.ProductCommentScoresEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 商品评价分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductCommentPageReqVO extends PageParam {
@Schema(description = "评价人名称", example = "王二狗")
private String userNickname;
@Schema(description = "交易订单编号", example = "24428")
private Long orderId;
@Schema(description = "商品SPU编号", example = "29502")
private Long spuId;
@Schema(description = "商品SPU名称", example = "感冒药")
private String spuName;
@Schema(description = "评分星级 1-5 分", example = "5")
@InEnum(ProductCommentScoresEnum.class)
private Integer scores;
@Schema(description = "商家是否回复", example = "true")
private Boolean replyStatus;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,23 @@
package cn.iocoder.yudao.module.product.controller.admin.comment.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 商品评价的商家回复 Request VO")
@Data
@ToString(callSuper = true)
public class ProductCommentReplyReqVO {
@Schema(description = "评价编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721")
@NotNull(message = "评价编号不能为空")
private Long id;
@Schema(description = "商家回复内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "谢谢亲")
@NotEmpty(message = "商家回复内容不能为空")
private String replyContent;
}

View File

@ -0,0 +1,63 @@
package cn.iocoder.yudao.module.product.controller.admin.comment.vo;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - 商品评价 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductCommentRespVO extends ProductCommentBaseVO {
@Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24965")
private Long id;
@Schema(description = "是否匿名", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
private Boolean anonymous;
@Schema(description = "交易订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24428")
private Long orderId;
@Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean visible;
@Schema(description = "商家是否回复", requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean replyStatus;
@Schema(description = "回复管理员编号", example = "9527")
private Long replyUserId;
@Schema(description = "商家回复内容", example = "感谢好评哦亲(づ ̄3 ̄)づ╭❤~")
private String replyContent;
@Schema(description = "商家回复时间", example = "2023-08-08 12:20:55")
private LocalDateTime replyTime;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
@Schema(description = "评分星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
private Integer scores;
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉丝滑透气小短袖")
@NotNull(message = "商品 SPU 编号不能为空")
private Long spuId;
@Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
@NotNull(message = "商品 SPU 名称不能为空")
private String spuName;
@Schema(description = "商品 SKU 图片地址", example = "https://www.iocoder.cn/yudao.jpg")
private String skuPicUrl;
@Schema(description = "商品 SKU 规格值数组")
private List<ProductSkuBaseVO.Property> skuProperties;
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.product.controller.admin.comment.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 商品评价可见修改 Request VO")
@Data
@ToString(callSuper = true)
public class ProductCommentUpdateVisibleReqVO {
@Schema(description = "评价编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721")
@NotNull(message = "评价编号不能为空")
private Long id;
@Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
@NotNull(message = "是否可见不能为空")
private Boolean visible;
}

View File

@ -0,0 +1,100 @@
package cn.iocoder.yudao.module.product.controller.admin.property;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.*;
import cn.iocoder.yudao.module.product.convert.property.ProductPropertyConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
import cn.iocoder.yudao.module.product.service.property.ProductPropertyService;
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Collections;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
@Tag(name = "管理后台 - 商品属性项")
@RestController
@RequestMapping("/product/property")
@Validated
public class ProductPropertyController {
@Resource
private ProductPropertyService productPropertyService;
@Resource
private ProductPropertyValueService productPropertyValueService;
@PostMapping("/create")
@Operation(summary = "创建属性项")
@PreAuthorize("@ss.hasPermission('product:property:create')")
public CommonResult<Long> createProperty(@Valid @RequestBody ProductPropertyCreateReqVO createReqVO) {
return success(productPropertyService.createProperty(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新属性项")
@PreAuthorize("@ss.hasPermission('product:property:update')")
public CommonResult<Boolean> updateProperty(@Valid @RequestBody ProductPropertyUpdateReqVO updateReqVO) {
productPropertyService.updateProperty(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除属性项")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('product:property:delete')")
public CommonResult<Boolean> deleteProperty(@RequestParam("id") Long id) {
productPropertyService.deleteProperty(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得属性项")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('product:property:query')")
public CommonResult<ProductPropertyRespVO> getProperty(@RequestParam("id") Long id) {
return success(ProductPropertyConvert.INSTANCE.convert(productPropertyService.getProperty(id)));
}
@GetMapping("/list")
@Operation(summary = "获得属性项列表")
@PreAuthorize("@ss.hasPermission('product:property:query')")
public CommonResult<List<ProductPropertyRespVO>> getPropertyList(@Valid ProductPropertyListReqVO listReqVO) {
return success(ProductPropertyConvert.INSTANCE.convertList(productPropertyService.getPropertyList(listReqVO)));
}
@GetMapping("/page")
@Operation(summary = "获得属性项分页")
@PreAuthorize("@ss.hasPermission('product:property:query')")
public CommonResult<PageResult<ProductPropertyRespVO>> getPropertyPage(@Valid ProductPropertyPageReqVO pageVO) {
return success(ProductPropertyConvert.INSTANCE.convertPage(productPropertyService.getPropertyPage(pageVO)));
}
@PostMapping("/get-value-list")
@Operation(summary = "获得属性项列表")
@PreAuthorize("@ss.hasPermission('product:property:query')")
public CommonResult<List<ProductPropertyAndValueRespVO>> getPropertyAndValueList(
@Valid @RequestBody ProductPropertyListReqVO listReqVO) {
// 查询属性项
List<ProductPropertyDO> keys = productPropertyService.getPropertyList(listReqVO);
if (CollUtil.isEmpty(keys)) {
return success(Collections.emptyList());
}
// 查询属性值
List<ProductPropertyValueDO> values = productPropertyValueService.getPropertyValueListByPropertyId(
convertSet(keys, ProductPropertyDO::getId));
return success(ProductPropertyConvert.INSTANCE.convertList(keys, values));
}
}

View File

@ -0,0 +1,70 @@
package cn.iocoder.yudao.module.product.controller.admin.property;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
import cn.iocoder.yudao.module.product.convert.property.ProductPropertyValueConvert;
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 商品属性值")
@RestController
@RequestMapping("/product/property/value")
@Validated
public class ProductPropertyValueController {
@Resource
private ProductPropertyValueService productPropertyValueService;
@PostMapping("/create")
@Operation(summary = "创建属性值")
@PreAuthorize("@ss.hasPermission('product:property:create')")
public CommonResult<Long> createPropertyValue(@Valid @RequestBody ProductPropertyValueCreateReqVO createReqVO) {
return success(productPropertyValueService.createPropertyValue(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新属性值")
@PreAuthorize("@ss.hasPermission('product:property:update')")
public CommonResult<Boolean> updatePropertyValue(@Valid @RequestBody ProductPropertyValueUpdateReqVO updateReqVO) {
productPropertyValueService.updatePropertyValue(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除属性值")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('product:property:delete')")
public CommonResult<Boolean> deletePropertyValue(@RequestParam("id") Long id) {
productPropertyValueService.deletePropertyValue(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得属性值")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('product:property:query')")
public CommonResult<ProductPropertyValueRespVO> getPropertyValue(@RequestParam("id") Long id) {
return success(ProductPropertyValueConvert.INSTANCE.convert(productPropertyValueService.getPropertyValue(id)));
}
@GetMapping("/page")
@Operation(summary = "获得属性值分页")
@PreAuthorize("@ss.hasPermission('product:property:query')")
public CommonResult<PageResult<ProductPropertyValueRespVO>> getPropertyValuePage(@Valid ProductPropertyValuePageReqVO pageVO) {
return success(ProductPropertyValueConvert.INSTANCE.convertPage(productPropertyValueService.getPropertyValuePage(pageVO)));
}
}

View File

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
@Schema(description = "管理后台 - 商品属性项 + 属性值 Response VO")
@Data
public class ProductPropertyAndValueRespVO {
@Schema(description = "属性项的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long id;
@Schema(description = "属性项的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色")
private String name;
/**
*
*/
private List<Value> values;
@Schema(description = "管理后台 - 属性值的简单 Response VO")
@Data
public static class Value {
@Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
private Long id;
@Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色")
private String name;
}
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* Base VO VO 使
* VO Swagger
*/
@Data
public class ProductPropertyBaseVO {
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色")
@NotBlank(message = "名称不能为空")
private String name;
@Schema(description = "备注", example = "颜色")
private String remark;
}

View File

@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "管理后台 - 属性项创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductPropertyCreateReqVO extends ProductPropertyBaseVO {
}

View File

@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
import java.util.List;
@Schema(description = "管理后台 - 属性项 List Request VO")
@Data
@ToString(callSuper = true)
public class ProductPropertyListReqVO {
@Schema(description = "属性名称", example = "颜色")
private String name;
}

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 属性项 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductPropertyPageReqVO extends PageParam {
@Schema(description = "名称", example = "颜色")
private String name;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer status;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@Schema(description = "创建时间")
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 属性项 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductPropertyRespVO extends ProductPropertyBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long id;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
}

View File

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 属性项更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductPropertyUpdateReqVO extends ProductPropertyBaseVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "主键不能为空")
private Long id;
}

View File

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* Base VO VO 使
* VO Swagger
*/
@Data
public class ProductPropertyValueBaseVO {
@Schema(description = "属性项的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "属性项的编号不能为空")
private Long propertyId;
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色")
@NotEmpty(message = "名称名字不能为空")
private String name;
@Schema(description = "备注", example = "颜色")
private String remark;
}

View File

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "管理后台 - 商品属性值创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductPropertyValueCreateReqVO extends ProductPropertyValueBaseVO {
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 商品属性值的明细 Response VO")
@Data
public class ProductPropertyValueDetailRespVO {
@Schema(description = "属性的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long propertyId;
@Schema(description = "属性的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色")
private String propertyName;
@Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long valueId;
@Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色")
private String valueName;
}

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "管理后台 - 商品属性值分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductPropertyValuePageReqVO extends PageParam {
@Schema(description = "属性项的编号", example = "1024")
private String propertyId;
@Schema(description = "名称", example = "红色")
private String name;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer status;
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 商品属性值 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductPropertyValueRespVO extends ProductPropertyValueBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
private Long id;
@Schema(description = "创建时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 商品属性值更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductPropertyValueUpdateReqVO extends ProductPropertyValueBaseVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "主键不能为空")
private Long id;
}

View File

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.product.controller.admin.sku;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Tag(name = "管理后台 - 商品 SKU")
@RestController
@RequestMapping("/product/sku")
@Validated
public class ProductSkuController {
}

View File

@ -0,0 +1,82 @@
package cn.iocoder.yudao.module.product.controller.admin.sku.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* SKU Base VO VO 使
* VO Swagger
*/
@Data
public class ProductSkuBaseVO {
@Schema(description = "商品 SKU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖")
@NotEmpty(message = "商品 SKU 名字不能为空")
private String name;
@Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999")
@NotNull(message = "销售价格,单位:分不能为空")
private Integer price;
@Schema(description = "市场价", example = "2999")
private Integer marketPrice;
@Schema(description = "成本价", example = "19")
private Integer costPrice;
@Schema(description = "条形码", example = "15156165456")
private String barCode;
@Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png")
@NotNull(message = "图片地址不能为空")
private String picUrl;
@Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "200")
@NotNull(message = "库存不能为空")
private Integer stock;
@Schema(description = "预警预存", example = "10")
private Integer warnStock;
@Schema(description = "商品重量,单位kg 千克", example = "1.2")
private Double weight;
@Schema(description = "商品体积,单位m^3 平米", example = "2.5")
private Double volume;
@Schema(description = "一级分销的佣金,单位:分", example = "199")
private Integer firstBrokeragePrice;
@Schema(description = "二级分销的佣金,单位:分", example = "19")
private Integer secondBrokeragePrice;
@Schema(description = "属性数组")
private List<Property> properties;
@Schema(description = "商品属性")
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class Property {
@Schema(description = "属性编号", example = "10")
private Long propertyId;
@Schema(description = "属性名字", example = "颜色")
private String propertyName;
@Schema(description = "属性值编号", example = "10")
private Long valueId;
@Schema(description = "属性值名字", example = "红色")
private String valueName;
}
}

View File

@ -0,0 +1,16 @@
package cn.iocoder.yudao.module.product.controller.admin.sku.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.List;
@Schema(description = "管理后台 - 商品 SKU 创建/更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductSkuCreateOrUpdateReqVO extends ProductSkuBaseVO {
}

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.product.controller.admin.sku.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.validation.constraints.NotNull;
import java.util.List;
@Schema(description = "管理后台 - 商品 SKU Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductSkuRespVO extends ProductSkuBaseVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long id;
}

View File

@ -0,0 +1,4 @@
### 获得商品 SPU 明细
GET {{baseUrl}}/product/spu/get-detail?id=4
Authorization: Bearer {{token}}
tenant-id: {{adminTenentId}}

View File

@ -0,0 +1,147 @@
package cn.iocoder.yudao.module.product.controller.admin.spu;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*;
import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
//import cn.iocoder.yudao.module.promotion.api.coupon.CouponTemplateApi;
//import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS;
@Tag(name = "管理后台 - 商品 SPU")
@RestController
@RequestMapping("/product/spu")
@Validated
public class ProductSpuController {
@Resource
private ProductSpuService productSpuService;
@Resource
private ProductSkuService productSkuService;
//
// @Resource
// private CouponTemplateApi couponTemplateApi;
@PostMapping("/create")
@Operation(summary = "创建商品 SPU")
@PreAuthorize("@ss.hasPermission('product:spu:create')")
public CommonResult<Long> createProductSpu(@Valid @RequestBody ProductSpuCreateReqVO createReqVO) {
return success(productSpuService.createSpu(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新商品 SPU")
@PreAuthorize("@ss.hasPermission('product:spu:update')")
public CommonResult<Boolean> updateSpu(@Valid @RequestBody ProductSpuUpdateReqVO updateReqVO) {
productSpuService.updateSpu(updateReqVO);
return success(true);
}
@PutMapping("/update-status")
@Operation(summary = "更新商品 SPU Status")
@PreAuthorize("@ss.hasPermission('product:spu:update')")
public CommonResult<Boolean> updateStatus(@Valid @RequestBody ProductSpuUpdateStatusReqVO updateReqVO) {
productSpuService.updateSpuStatus(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除商品 SPU")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('product:spu:delete')")
public CommonResult<Boolean> deleteSpu(@RequestParam("id") Long id) {
productSpuService.deleteSpu(id);
return success(true);
}
@GetMapping("/get-detail")
@Operation(summary = "获得商品 SPU 明细")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('product:spu:query')")
public CommonResult<ProductSpuDetailRespVO> getSpuDetail(@RequestParam("id") Long id) {
// 获得商品 SPU
ProductSpuDO spu = productSpuService.getSpu(id);
if (spu == null) {
throw exception(SPU_NOT_EXISTS);
}
// 查询商品 SKU
List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId());
// 查询优惠卷
// TODO @puhui999优惠劵的信息要不交给前端读取主要是为了避免商品依赖 promotion 模块哈;
// List<CouponTemplateRespDTO> couponTemplateList = couponTemplateApi.getCouponTemplateListByIds(
// spu.getGiveCouponTemplateIds());
return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus));
}
@GetMapping("/list-all-simple")
@Operation(summary = "获得商品 SPU 精简列表")
@PreAuthorize("@ss.hasPermission('product:spu:query')")
public CommonResult<List<ProductSpuSimpleRespVO>> getSpuSimpleList() {
List<ProductSpuDO> list = productSpuService.getSpuListByStatus(ProductSpuStatusEnum.ENABLE.getStatus());
// 降序排序后,返回给前端
list.sort(Comparator.comparing(ProductSpuDO::getSort).reversed());
return success(ProductSpuConvert.INSTANCE.convertList02(list));
}
@GetMapping("/list")
@Operation(summary = "获得商品 SPU 详情列表")
@Parameter(name = "spuIds", description = "spu 编号列表", required = true, example = "[1,2,3]")
@PreAuthorize("@ss.hasPermission('product:spu:query')")
public CommonResult<List<ProductSpuDetailRespVO>> getSpuList(@RequestParam("spuIds") Collection<Long> spuIds) {
return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespListVO(
productSpuService.getSpuList(spuIds), productSkuService.getSkuListBySpuId(spuIds)));
}
@GetMapping("/page")
@Operation(summary = "获得商品 SPU 分页")
@PreAuthorize("@ss.hasPermission('product:spu:query')")
public CommonResult<PageResult<ProductSpuRespVO>> getSpuPage(@Valid ProductSpuPageReqVO pageVO) {
return success(ProductSpuConvert.INSTANCE.convertPage(productSpuService.getSpuPage(pageVO)));
}
@GetMapping("/get-count")
@Operation(summary = "获得商品 SPU 分页 tab count")
@PreAuthorize("@ss.hasPermission('product:spu:query')")
public CommonResult<Map<Integer, Long>> getSpuCount() {
return success(productSpuService.getTabsCount());
}
@GetMapping("/export")
@Operation(summary = "导出商品")
@PreAuthorize("@ss.hasPermission('product:spu:export')")
@OperateLog(type = EXPORT)
public void exportUserList(@Validated ProductSpuExportReqVO reqVO,
HttpServletResponse response) throws IOException {
List<ProductSpuDO> spuList = productSpuService.getSpuList(reqVO);
// 导出 Excel
List<ProductSpuExcelVO> datas = ProductSpuConvert.INSTANCE.convertList03(spuList);
ExcelUtils.write(response, "商品列表.xls", "数据", ProductSpuExcelVO.class, datas);
}
}

View File

@ -0,0 +1,126 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* SPU Base VO VO 使
* VO Swagger
*
* @author HUIHUI
*/
@Data
public class ProductSpuBaseVO {
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖")
@NotEmpty(message = "商品名称不能为空")
private String name;
@Schema(description = "关键字", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉丝滑不出汗")
@NotEmpty(message = "商品关键字不能为空")
private String keyword;
@Schema(description = "商品简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖简介")
@NotEmpty(message = "商品简介不能为空")
private String introduction;
@Schema(description = "商品详情", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖详情")
@NotEmpty(message = "商品详情不能为空")
private String description;
@Schema(description = "商品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "商品分类不能为空")
private Long categoryId;
@Schema(description = "商品品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "商品品牌不能为空")
private Long brandId;
@Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png")
@NotEmpty(message = "商品封面图不能为空")
private String picUrl;
@Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]")
private List<String> sliderPicUrls;
@Schema(description = "商品视频", example = "https://www.iocoder.cn/xx.mp4")
private String videoUrl;
@Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "商品单位不能为空")
private Integer unit;
@Schema(description = "排序字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "商品排序字段不能为空")
private Integer sort;
// ========== SKU 相关字段 =========
@Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@NotNull(message = "商品规格类型不能为空")
private Boolean specType;
// ========== 物流相关字段 =========
@Schema(description = "物流配置模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "111")
@NotNull(message = "物流配置模板编号不能为空")
private Long deliveryTemplateId;
// ========== 营销相关字段 =========
@Schema(description = "是否热卖推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@NotNull(message = "商品推荐不能为空")
private Boolean recommendHot;
@Schema(description = "是否优惠推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@NotNull(message = "商品推荐不能为空")
private Boolean recommendBenefit;
@Schema(description = "是否精品推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@NotNull(message = "商品推荐不能为空")
private Boolean recommendBest;
@Schema(description = "是否新品推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@NotNull(message = "商品推荐不能为空")
private Boolean recommendNew;
@Schema(description = "是否优品推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@NotNull(message = "商品推荐不能为空")
private Boolean recommendGood;
@Schema(description = "赠送积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "111")
@NotNull(message = "商品赠送积分不能为空")
private Integer giveIntegral;
@Schema(description = "赠送的优惠劵数组包含优惠券编号和名称")
private List<GiveCouponTemplate> giveCouponTemplates;
@Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@NotNull(message = "商品分销类型不能为空")
private Boolean subCommissionType;
@Schema(description = "活动展示顺序", example = "[1, 3, 2, 4, 5]")
private List<Integer> activityOrders;
// ========== 统计相关字段 =========
@Schema(description = "虚拟销量", example = "66")
private Integer virtualSalesCount;
@Schema(description = "管理后台 - 商品 SPU 赠送的优惠卷")
@Data
public static class GiveCouponTemplate {
@Schema(description = "模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long id;
@Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送")
private String name;
}
}

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.Valid;
import java.util.List;
@Schema(description = "管理后台 - 商品 SPU 创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductSpuCreateReqVO extends ProductSpuBaseVO {
// ========== SKU 相关字段 =========
@Schema(description = "SKU 数组")
@Valid
private List<ProductSkuCreateOrUpdateReqVO> skus;
}

View File

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.List;
@Schema(description = "管理后台 - 商品 SPU 详细 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductSpuDetailRespVO extends ProductSpuBaseVO {
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1212")
private Long id;
@Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000")
private Integer salesCount;
@Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20000")
private Integer browseCount;
@Schema(description = "商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer status;
// ========== SKU 相关字段 =========
@Schema(description = "SKU 数组")
private List<ProductSkuRespVO> skus;
}

View File

@ -0,0 +1,112 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.module.product.enums.DictTypeConstants;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* Spu Excel VO TODO
*
* @author HUIHUI
*/
@Data
public class ProductSpuExcelVO {
@ExcelProperty("商品编号")
private Long id;
@ExcelProperty("商品名称")
private String name;
@ExcelProperty("关键字")
private String keyword;
@ExcelProperty("商品简介")
private String introduction;
@ExcelProperty("商品详情")
private String description;
@ExcelProperty("条形码")
private String barCode;
@ExcelProperty("商品分类编号")
private Long categoryId;
@ExcelProperty("商品品牌编号")
private Long brandId;
@ExcelProperty("商品封面图")
private String picUrl;
@ExcelProperty("商品视频")
private String videoUrl;
@ExcelProperty(value = "商品单位", converter = DictConvert.class)
@DictFormat(DictTypeConstants.PRODUCT_UNIT)
private Integer unit;
@ExcelProperty("排序字段")
private Integer sort;
@ExcelProperty(value = "商品状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.PRODUCT_SPU_STATUS)
private Integer status;
@ExcelProperty("规格类型")
private Boolean specType;
@ExcelProperty("商品价格")
private Integer price;
@ExcelProperty("市场价")
private Integer marketPrice;
@ExcelProperty("成本价")
private Integer costPrice;
@ExcelProperty("库存")
private Integer stock;
@ExcelProperty("物流配置模板编号")
private Long deliveryTemplateId;
@ExcelProperty("是否热卖推荐")
private Boolean recommendHot;
@ExcelProperty("是否优惠推荐")
private Boolean recommendBenefit;
@ExcelProperty("是否精品推荐")
private Boolean recommendBest;
@ExcelProperty("是否新品推荐")
private Boolean recommendNew;
@ExcelProperty("是否优品推荐")
private Boolean recommendGood;
@ExcelProperty("赠送积分")
private Integer giveIntegral;
@ExcelProperty("分销类型")
private Boolean subCommissionType;
@ExcelProperty("商品销量")
private Integer salesCount;
@ExcelProperty("虚拟销量")
private Integer virtualSalesCount;
@ExcelProperty("商品点击量")
private Integer browseCount;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,32 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 商品 SPU 导出 Request VO参数和 ProductSpuPageReqVO 是一致的")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ProductSpuExportReqVO {
@Schema(description = "商品名称", example = "清凉小短袖")
private String name;
@Schema(description = "前端请求的tab类型", example = "1")
private Integer tabType;
@Schema(description = "商品分类编号", example = "100")
private Long categoryId;
@Schema(description = "创建时间", example = "[2022-07-01 00:00:00,2022-07-01 23:59:59]")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,58 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 商品 SPU 分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductSpuPageReqVO extends PageParam {
/**
*
*/
public static final Integer FOR_SALE = 0;
/**
*
*/
public static final Integer IN_WAREHOUSE = 1;
/**
*
*/
public static final Integer SOLD_OUT = 2;
/**
*
*/
public static final Integer ALERT_STOCK = 3;
/**
*
*/
public static final Integer RECYCLE_BIN = 4;
@Schema(description = "商品名称", example = "清凉小短袖")
private String name;
@Schema(description = "前端请求的tab类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer tabType;
@Schema(description = "商品分类编号", example = "1")
private Long categoryId;
@Schema(description = "创建时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,43 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 商品 SPU Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductSpuRespVO extends ProductSpuBaseVO {
@Schema(description = "spuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "111")
private Long id;
@Schema(description = "商品价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999")
private Integer price;
@Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000")
private Integer salesCount;
@Schema(description = "市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "199")
private Integer marketPrice;
@Schema(description = "成本价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "19")
private Integer costPrice;
@Schema(description = "商品库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000")
private Integer stock;
@Schema(description = "商品创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-05-24 00:00:00")
private LocalDateTime createTime;
@Schema(description = "商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer status;
@Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "888")
private Integer browseCount;
}

View File

@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
@Schema(description = "管理后台 - 商品 SPU 精简 Response VO")
@Data
@ToString(callSuper = true)
public class ProductSpuSimpleRespVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "213")
private Long id;
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖")
private String name;
@Schema(description = "商品价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999")
private Integer price;
@Schema(description = "商品市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "199")
private Integer marketPrice;
@Schema(description = "商品成本价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "19")
private Integer costPrice;
@Schema(description = "商品库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000")
private Integer stock;
// ========== 统计相关字段 =========
@Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "200")
private Integer salesCount;
@Schema(description = "商品虚拟销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20000")
private Integer virtualSalesCount;
@Schema(description = "商品浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000")
private Integer browseCount;
}

View File

@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO;
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
@Schema(description = "管理后台 - 商品 SPU 更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductSpuUpdateReqVO extends ProductSpuBaseVO {
@Schema(description = "商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "商品编号不能为空")
private Long id;
@Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999")
private Integer salesCount;
@Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999")
private Integer browseCount;
@Schema(description = "商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@InEnum(ProductSpuStatusEnum.class)
private Integer status;
// ========== SKU 相关字段 =========
@Schema(description = "SKU 数组")
@Valid
private List<ProductSkuCreateOrUpdateReqVO> skus;
}

View File

@ -0,0 +1,23 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 商品 SPU Status 更新 Request VO")
@Data
public class ProductSpuUpdateStatusReqVO{
@Schema(description = "商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "商品编号不能为空")
private Long id;
@Schema(description = "商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "商品状态不能为空")
@InEnum(ProductSpuStatusEnum.class)
private Integer status;
}

View File

@ -0,0 +1,38 @@
package cn.iocoder.yudao.module.product.controller.app.category;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryRespVO;
import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "用户 APP - 商品分类")
@RestController
@RequestMapping("/product/category")
@Validated
public class AppCategoryController {
@Resource
private ProductCategoryService categoryService;
@GetMapping("/list")
@Operation(summary = "获得商品分类列表")
public CommonResult<List<AppCategoryRespVO>> getProductCategoryList() {
List<ProductCategoryDO> list = categoryService.getEnableCategoryList();
list.sort(Comparator.comparing(ProductCategoryDO::getSort));
return success(ProductCategoryConvert.INSTANCE.convertList03(list));
}
}

View File

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.product.controller.app.category.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Data
@Schema(description = "用户 APP - 商品分类 Response VO")
public class AppCategoryRespVO {
@Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
private Long id;
@Schema(description = "父分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "父分类编号不能为空")
private Long parentId;
@Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "办公文具")
@NotBlank(message = "分类名称不能为空")
private String name;
@Schema(description = "分类图片", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "分类图片不能为空")
private String picUrl;
}

View File

@ -0,0 +1,80 @@
package cn.iocoder.yudao.module.product.controller.app.comment;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO;
import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentStatisticsRespVO;
import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppProductCommentRespVO;
import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO;
import cn.iocoder.yudao.module.product.service.comment.ProductCommentService;
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.context.annotation.Lazy;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Set;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
@Tag(name = "用户 APP - 商品评价")
@RestController
@RequestMapping("/product/comment")
@Validated
public class AppProductCommentController {
@Resource
private ProductCommentService productCommentService;
@Resource
@Lazy
private ProductSkuService productSkuService;
@GetMapping("/list")
@Operation(summary = "获得最近的 n 条商品评价")
@Parameters({
@Parameter(name = "spuId", description = "商品 SPU 编号", required = true, example = "1024"),
@Parameter(name = "count", description = "数量", required = true, example = "10")
})
public CommonResult<List<AppProductCommentRespVO>> getCommentList(
@RequestParam("spuId") Long spuId,
@RequestParam(value = "count", defaultValue = "10") Integer count) {
return success(productCommentService.getCommentList(spuId, count));
}
@GetMapping("/page")
@Operation(summary = "获得商品评价分页")
public CommonResult<PageResult<AppProductCommentRespVO>> getCommentPage(@Valid AppCommentPageReqVO pageVO) {
// 查询评论分页
PageResult<ProductCommentDO> commentPageResult = productCommentService.getCommentPage(pageVO, Boolean.TRUE);
if (CollUtil.isEmpty(commentPageResult.getList())) {
return success(PageResult.empty(commentPageResult.getTotal()));
}
// 拼接返回
Set<Long> skuIds = convertSet(commentPageResult.getList(), ProductCommentDO::getSkuId);
PageResult<AppProductCommentRespVO> commentVOPageResult = ProductCommentConvert.INSTANCE.convertPage02(
commentPageResult, productSkuService.getSkuList(skuIds));
return success(commentVOPageResult);
}
// TODO 芋艿:需要搞下
@GetMapping("/statistics")
@Operation(summary = "获得商品的评价统计")
public CommonResult<AppCommentStatisticsRespVO> getCommentStatistics(@Valid @RequestParam("spuId") Long spuId) {
return success(productCommentService.getCommentStatistics(spuId, Boolean.TRUE));
}
}

View File

@ -0,0 +1,38 @@
package cn.iocoder.yudao.module.product.controller.app.comment.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "用户 App - 商品评价分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class AppCommentPageReqVO extends PageParam {
/**
*
*/
public static final Integer GOOD_COMMENT = 1;
/**
*
*/
public static final Integer MEDIOCRE_COMMENT = 2;
/**
*
*/
public static final Integer NEGATIVE_COMMENT = 3;
@Schema(description = "商品SPU编号", example = "29502")
@NotNull(message = "商品SPU编号不能为空")
private Long spuId;
@Schema(description = "app 评论页 tab 类型 (0 全部、1 好评、2 中评、3 差评)", example = "0")
@NotNull(message = "商品SPU编号不能为空")
private Integer type;
}

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.product.controller.app.comment.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
@Schema(description = "APP - 商品评价页评论分类数统计 Response VO")
@Data
@ToString(callSuper = true)
public class AppCommentStatisticsRespVO {
@Schema(description = "好评数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721")
private Long goodCount;
@Schema(description = "中评数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721")
private Long mediocreCount;
@Schema(description = "差评数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721")
private Long negativeCount;
@Schema(description = "总平均分", requiredMode = Schema.RequiredMode.REQUIRED, example = "3.55")
private Double scores;
}

View File

@ -0,0 +1,98 @@
package cn.iocoder.yudao.module.product.controller.app.comment.vo;
import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "用户 App - 商品评价详情 Response VO")
@Data
@ToString(callSuper = true)
public class AppProductCommentRespVO {
@Schema(description = "评价人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721")
private Long userId;
@Schema(description = "评价人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
private String userNickname;
@Schema(description = "评价人头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png")
private String userAvatar;
@Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24965")
private Long id;
@Schema(description = "是否匿名", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
private Boolean anonymous;
@Schema(description = "交易订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24428")
private Long orderId;
@Schema(description = "交易订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8233")
private Long orderItemId;
@Schema(description = "商家是否回复", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
private Boolean replyStatus;
@Schema(description = "回复管理员编号", example = "22212")
private Long replyUserId;
@Schema(description = "商家回复内容", example = "亲,你的好评就是我的动力(*^▽^*)")
private String replyContent;
@Schema(description = "商家回复时间")
private LocalDateTime replyTime;
@Schema(description = "追加评价内容", example = "穿了很久都很丝滑诶")
private String additionalContent;
@Schema(description = "追评评价图片地址数组,以逗号分隔最多上传 9 张", example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]")
private List<String> additionalPicUrls;
@Schema(description = "追加评价时间")
private LocalDateTime additionalTime;
@Schema(description = "创建时间")
private LocalDateTime createTime;
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "91192")
@NotNull(message = "商品 SPU 编号不能为空")
private Long spuId;
@Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉丝滑小短袖")
@NotNull(message = "商品 SPU 名称不能为空")
private String spuName;
@Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "81192")
@NotNull(message = "商品 SKU 编号不能为空")
private Long skuId;
@Schema(description = "商品 SKU 属性", requiredMode = Schema.RequiredMode.REQUIRED)
private List<AppProductPropertyValueDetailRespVO> skuProperties;
@Schema(description = "评分星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
@NotNull(message = "评分星级 1-5 分不能为空")
private Integer scores;
@Schema(description = "描述星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
@NotNull(message = "描述星级 1-5 分不能为空")
private Integer descriptionScores;
@Schema(description = "服务星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
@NotNull(message = "服务星级 1-5 分不能为空")
private Integer benefitScores;
@Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "哇,真的很丝滑凉快诶,好评")
@NotNull(message = "评论内容不能为空")
private String content;
@Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png]")
@Size(max = 9, message = "评论图片地址数组长度不能超过 9 张")
private List<String> picUrls;
}

View File

@ -0,0 +1,105 @@
package cn.iocoder.yudao.module.product.controller.app.favorite;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteBatchReqVO;
import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoritePageReqVO;
import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteReqVO;
import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteRespVO;
import cn.iocoder.yudao.module.product.convert.favorite.ProductFavoriteConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
import cn.iocoder.yudao.module.product.service.favorite.ProductFavoriteService;
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@Tag(name = "用户 APP - 商品收藏")
@RestController
@RequestMapping("/product/favorite")
public class AppFavoriteController {
@Resource
private ProductFavoriteService productFavoriteService;
@Resource
private ProductSpuService productSpuService;
@PostMapping(value = "/create")
@Operation(summary = "添加商品收藏")
@PreAuthenticated
public CommonResult<Long> createFavorite(@RequestBody @Valid AppFavoriteReqVO reqVO) {
return success(productFavoriteService.createFavorite(getLoginUserId(), reqVO.getSpuId()));
}
@PostMapping(value = "/create-list")
@Operation(summary = "添加多个商品收藏")
@PreAuthenticated
public CommonResult<Boolean> createFavoriteList(@RequestBody @Valid AppFavoriteBatchReqVO reqVO) {
// todo @jason待实现如果有已经收藏的不用报错忽略即可
return success(true);
}
@DeleteMapping(value = "/delete")
@Operation(summary = "取消单个商品收藏")
@PreAuthenticated
public CommonResult<Boolean> deleteFavorite(@RequestBody @Valid AppFavoriteReqVO reqVO) {
productFavoriteService.deleteFavorite(getLoginUserId(), reqVO.getSpuId());
return success(Boolean.TRUE);
}
@DeleteMapping(value = "/delete-list")
@Operation(summary = "取消多个商品收藏")
@PreAuthenticated
public CommonResult<Boolean> deleteFavoriteList(@RequestBody @Valid AppFavoriteBatchReqVO reqVO) {
// todo @jason待实现
// productFavoriteService.deleteFavorite(getLoginUserId(), reqVO.getSpuId());
return success(Boolean.TRUE);
}
@GetMapping(value = "/page")
@Operation(summary = "获得商品收藏分页")
@PreAuthenticated
public CommonResult<PageResult<AppFavoriteRespVO>> getFavoritePage(AppFavoritePageReqVO reqVO) {
PageResult<ProductFavoriteDO> favoritePage = productFavoriteService.getFavoritePage(getLoginUserId(), reqVO);
if (CollUtil.isEmpty(favoritePage.getList())) {
return success(PageResult.empty());
}
// 得到商品 spu 信息
List<ProductFavoriteDO> favorites = favoritePage.getList();
List<Long> spuIds = convertList(favorites, ProductFavoriteDO::getSpuId);
List<ProductSpuDO> spus = productSpuService.getSpuList(spuIds);
// 转换 VO 结果
PageResult<AppFavoriteRespVO> pageResult = new PageResult<>(favoritePage.getTotal());
pageResult.setList(ProductFavoriteConvert.INSTANCE.convertList(favorites, spus));
return success(pageResult);
}
@GetMapping(value = "/exits")
@Operation(summary = "检查是否收藏过商品")
@PreAuthenticated
public CommonResult<Boolean> isFavoriteExists(AppFavoriteReqVO reqVO) {
ProductFavoriteDO favorite = productFavoriteService.getFavorite(getLoginUserId(), reqVO.getSpuId());
return success(favorite != null);
}
@GetMapping(value = "/get-count")
@Operation(summary = "获得商品收藏数量")
@PreAuthenticated
public CommonResult<Long> getFavoriteCount() {
return success(productFavoriteService.getFavoriteCount(getLoginUserId()));
}
}

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.product.controller.app.favorite.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.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")
@NotEmpty(message = "商品 SPU 编号数组不能为空")
private List<Long> spuIds;
}

View File

@ -0,0 +1,10 @@
package cn.iocoder.yudao.module.product.controller.app.favorite.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "用户 App - 商品收藏分页查询 Request VO")
@Data
public class AppFavoritePageReqVO extends PageParam {
}

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.product.controller.app.favorite.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
@Schema(description = "用户 APP - 商品收藏的单个 Request VO") // 用于收藏、取消收藏、获取收藏
@Data
public class AppFavoriteReqVO {
@Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502")
@NotNull(message = "商品 SPU 编号不能为空")
private Long spuId;
}

View File

@ -0,0 +1,28 @@
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")
private Long id;
@Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502")
private Long spuId;
// ========== 商品相关字段 ==========
@Schema(description = "商品 SPU 名称", example = "赵六")
private String spuName;
@Schema(description = "商品封面图", example = "https://domain/pic.png")
private String picUrl;
@Schema(description = "商品单价", example = "100")
private Integer price;
}

View File

@ -0,0 +1,4 @@
/**
* package
*/
package cn.iocoder.yudao.module.product.controller.app.property;

View File

@ -0,0 +1,4 @@
/**
* package
*/
package cn.iocoder.yudao.module.product.controller.app.property.vo.property;

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.product.controller.app.property.vo.value;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "用户 App - 商品属性值的明细 Response VO")
@Data
public class AppProductPropertyValueDetailRespVO {
@Schema(description = "属性的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long propertyId;
@Schema(description = "属性的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色")
private String propertyName;
@Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long valueId;
@Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色")
private String valueName;
}

View File

@ -0,0 +1,18 @@
### 获得订单交易的分页(默认)
GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10
Authorization: Bearer {{appToken}}
tenant-id: {{appTenentId}}
### 获得订单交易的分页(价格)
GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10&sortField=price&sortAsc=true
Authorization: Bearer {{appToken}}
tenant-id: {{appTenentId}}
### 获得订单交易的分页(销售)
GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10&sortField=salesCount&sortAsc=true
Authorization: Bearer {{appToken}}
tenant-id: {{appTenentId}}
### 获得商品 SPU 明细
GET {{appApi}}/product/spu/get-detail?id=102
tenant-id: {{appTenentId}}

Some files were not shown because too many files have changed in this diff Show More