Merge branch 'master' into feature/mall_product

pull/2/head
perry 2023-05-08 14:45:39 +08:00
commit 90e04bb0d1
48 changed files with 240 additions and 219 deletions

View File

@ -10,6 +10,7 @@
## 🐶 新手必读
* 演示地址【Vue3 + element-plus】<http://dashboard-vue3.yudao.iocoder.cn>
* 演示地址【Vue3 + vben(ant-design-vue)】:<http://dashboard-vben.yudao.iocoder.cn>
* 演示地址【Vue2 + element-ui】<http://dashboard.yudao.iocoder.cn>
* 启动文档:<https://doc.iocoder.cn/quick-start/>
* 视频教程:<https://doc.iocoder.cn/video/>
@ -24,8 +25,8 @@
![架构图](https://static.iocoder.cn/ruoyi-vue-pro-architecture.png?imageView2/2/format/webp)
* 管理后台的 Vue3 版本采用 [vue-element-plus-admin](https://gitee.com/kailong110120130/vue-element-plus-admin) Vue2 版本采用 [vue-element-admin](https://github.com/PanJiaChen/vue-element-admin)
* 管理后台的移动端采用 [uni-app](https://github.com/dcloudio/uni-app) 方案,一份代码多终端适配,同时支持 APP、小程序、H5
* 管理后台的电脑端Vue3 提供 [element-plus](https://gitee.com/yudaocode/yudao-ui-admin-vue3)、[vben(ant-design-vue)](https://gitee.com/yudaocode/yudao-ui-admin-vben) 两个版本Vue2 提供 [element-ui](https://gitee.com/zhijiantianya/ruoyi-vue-pro/tree/master/yudao-ui-admin) 版本
* 管理后台的移动端采用 [uni-app](https://github.com/dcloudio/uni-app) 方案,一份代码多终端适配,同时支持 APP、小程序、H5
* 后端采用 Spring Boot 多模块架构、MySQL + MyBatis Plus、Redis + Redisson
* 数据库可使用 MySQL、Oracle、PostgreSQL、SQL Server、MariaDB、国产达梦 DM、TiDB 等
* 权限认证使用 Spring Security & Token & Redis支持多终端、多种用户的认证系统支持 SSO 单点登录

View File

@ -30,7 +30,7 @@
<url>https://github.com/YunaiV/ruoyi-vue-pro</url>
<properties>
<revision>1.7.1-snapshot</revision>
<revision>1.7.2-snapshot</revision>
<!-- Maven 相关 -->
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>

View File

@ -14,7 +14,7 @@
<url>https://github.com/YunaiV/ruoyi-vue-pro</url>
<properties>
<revision>1.7.1-snapshot</revision>
<revision>1.7.2-snapshot</revision>
<!-- 统一依赖管理 -->
<spring.boot.version>2.7.10</spring.boot.version>
<!-- Web 相关 -->

View File

@ -0,0 +1,7 @@
/**
*
* 1. weixin-java-mp
* 2. weixin-java-miniapp
*/
package cn.iocoder.yudao.framework.weixin;

View File

@ -1,9 +1,10 @@
import request from '@/config/axios'
#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}")
export interface ${simpleClassName}VO {
#foreach ($column in $columns)
#if ($column.createOperation || $column.updateOperation)
#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal")
#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal")
${column.javaField}: number
#elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdatetime")
${column.javaField}: Date
@ -16,30 +17,30 @@ export interface ${simpleClassName}VO {
// 查询${table.classComment}列表
export const get${simpleClassName}Page = async (params: ${simpleClassName}PageReqVO) => {
return await request.get({ url: '${baseURL}/page', params })
return await request.get({ url: `${baseURL}/page`, params })
}
// 查询${table.classComment}详情
export const get${simpleClassName} = async (id: number) => {
return await request.get({ url: '${baseURL}/get?id=' + id })
return await request.get({ url: `${baseURL}/get?id=` + id })
}
// 新增${table.classComment}
export const create${simpleClassName} = async (data: ${simpleClassName}VO) => {
return await request.post({ url: '${baseURL}/create', data })
return await request.post({ url: `${baseURL}/create`, data })
}
// 修改${table.classComment}
export const update${simpleClassName} = async (data: ${simpleClassName}VO) => {
return await request.put({ url: '${baseURL}/update', data })
return await request.put({ url: `${baseURL}/update`, data })
}
// 删除${table.classComment}
export const delete${simpleClassName} = async (id: number) => {
return await request.delete({ url: '${baseURL}/delete?id=' + id })
return await request.delete({ url: `${baseURL}/delete?id=` + id })
}
// 导出${table.classComment} Excel
export const export${simpleClassName}Api = async (params) => {
return await request.download({ url: '${baseURL}/export-excel', params })
export const export${simpleClassName} = async (params) => {
return await request.download({ url: `${baseURL}/export-excel`, params })
}

View File

@ -102,7 +102,7 @@
<el-date-picker
v-model="formData.${javaField}"
type="date"
value-format="timestamp"
value-format="x"
placeholder="选择${comment}"
/>
</el-form-item>

View File

@ -66,7 +66,7 @@
<el-form-item label="${comment}" prop="${javaField}">
<el-date-picker
v-model="queryParams.${javaField}"
value-format="yyyy-MM-dd"
value-format="YYYY-MM-DD"
type="date"
placeholder="选择${comment}"
clearable
@ -77,7 +77,7 @@
<el-form-item label="${comment}" prop="${javaField}">
<el-date-picker
v-model="queryParams.${javaField}"
value-format="yyyy-MM-dd HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"

View File

@ -1,4 +1,5 @@
import request from '@/config/axios'
#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}")
export interface ${simpleClassName}VO {
#foreach ($column in $columns)

View File

@ -1,5 +1,5 @@
import { defHttp } from '@/utils/http/axios'
#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}")
// 查询${table.classComment}列表
export function get${simpleClassName}Page(params) {

View File

@ -48,8 +48,8 @@ public interface ErrorCodeConstants {
ErrorCode COMMENT_ERROR_OPT = new ErrorCode(1008007002, "商品评价非法操作");
ErrorCode COMMENT_ADDITIONAL_EXISTS = new ErrorCode(1008007003, "商品追加评价已存在");
// ========== 喜爱商品 1008008000 ==========
ErrorCode COLLECTION_EXISTS = new ErrorCode(1008008000, "该商品已经被收藏");
ErrorCode COLLECTION_NOT_EXISTS = new ErrorCode(1008008001, "商品收藏不存在");
// ========== 商品 收藏 1008008000 ==========
ErrorCode PRODUCT_FAVORITE_EXISTS = new ErrorCode(1008008000, "该商品已经被收藏");
ErrorCode PRODUCT_FAVORITE_NOT_EXISTS = new ErrorCode(1008008001, "商品收藏不存在");
}

View File

@ -7,17 +7,19 @@ import lombok.Getter;
import java.util.Arrays;
/**
*
*
*
* @author jason
*/
@Getter
@AllArgsConstructor
public enum ProductFavoriteTypeEnum implements IntArrayValuable {
COLLECT(1,"收藏"),
THUMBS_UP(2, "点赞");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductFavoriteTypeEnum::getType).toArray();
/**
*
*/

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.product.enums.spu;
import lombok.AllArgsConstructor;
import lombok.Getter;
// TODO @puhui999中英文之间要有空格 商品 spu Tab 标签枚举;这个类可以改成 ProductSpuPageTabEnum 会更好一点哈;分页 Tab 的意思;
/**
* spu
*
@ -11,11 +12,13 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public enum ProductSpuTabTypeEnum {
FOR_SALE(0,"出售中商品"),
IN_WAREHOUSE(1,"仓库中商品"),
SOLD_OUT(2,"已售空商品"),
ALERT_STOCK(3,"警戒库存"),
RECYCLE_BIN(4,"商品回收站");
/**
*
*/
@ -24,4 +27,5 @@ public enum ProductSpuTabTypeEnum {
*
*/
private final String name;
}

View File

@ -6,6 +6,7 @@ import lombok.Getter;
import java.util.Arrays;
// TODO @puhui999是不是放到数据字典里
/**
*
*
@ -14,6 +15,7 @@ import java.util.Arrays;
@Getter
@AllArgsConstructor
public enum ProductUnitEnum implements IntArrayValuable {
PIECE(1, "个"),
DOZEN(2, "打"),
BOX(3, "盒"),

View File

@ -35,6 +35,7 @@
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
</dependency>
<!-- TODO 芋艿:是不是可以去掉这个依赖呀? -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>

View File

@ -12,7 +12,6 @@ import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueServ
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import oracle.jdbc.proxy.annotation.Post;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -85,7 +84,8 @@ public class ProductPropertyController {
@PostMapping("/get-value-list")
@Operation(summary = "获得属性项列表")
@PreAuthorize("@ss.hasPermission('product:property:query')")
public CommonResult<List<ProductPropertyAndValueRespVO>> getPropertyAndValueList(@Valid @RequestBody ProductPropertyListReqVO listReqVO) {
public CommonResult<List<ProductPropertyAndValueRespVO>> getPropertyAndValueList(
@Valid @RequestBody ProductPropertyListReqVO listReqVO) {
// 查询属性项
List<ProductPropertyDO> keys = productPropertyService.getPropertyList(listReqVO);
if (CollUtil.isEmpty(keys)) {

View File

@ -4,7 +4,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
import javax.validation.constraints.NotEmpty;
import java.util.List;
@Schema(description = "管理后台 - 属性项 List Request VO")
@ -15,6 +14,8 @@ public class ProductPropertyListReqVO {
@Schema(description = "属性名称", example = "颜色")
private String name;
@Schema(description = "属性ids", example = "1,2")
// TODO @puhui999这个查询条件的作用是啥呀
@Schema(description = "属性编号的数组", example = "1,2")
private List<Long> propertyIds;
}

View File

@ -1,11 +1,7 @@
package cn.iocoder.yudao.module.product.controller.admin.sku.vo;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.validation.InEnum;
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;
@ -50,6 +46,7 @@ public class ProductSkuBaseVO {
@Schema(description = "商品体积", example = "1024") // 单位m^3 平米
private Double volume;
// TODO @pitui999注释可以去掉VO 使用 @Schema 作为注释
/**
*
*/

View File

@ -11,6 +11,7 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductSkuCreateOrUpdateReqVO extends ProductSkuBaseVO {
@Schema(description = "商品属性")
@Data
@AllArgsConstructor

View File

@ -4,12 +4,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author HUIHUI
*/
@Schema(description = "管理后台 - 商品 SKU Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ -29,13 +25,17 @@ public class ProductSkuRespVO extends ProductSkuBaseVO {
@NotNull(message = "属性编号不能为空")
private Long propertyId;
// TODO @puhui999:propertyName 是不是也返回下
@Schema(description = "属性值编号", required = true, example = "1024")
@NotNull(message = "属性值编号不能为空")
private Long valueId;
@Schema(description = "属性值", example = "1024")
private String valueName;
}
/**
*
*/

View File

@ -3,12 +3,9 @@ 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.module.product.controller.admin.spu.vo.*;
import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert;
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.service.property.ProductPropertyValueService;
import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO;
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
import io.swagger.v3.oas.annotations.Operation;
@ -23,9 +20,7 @@ import javax.validation.Valid;
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.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS;
@Tag(name = "管理后台 - 商品 SPU")
@RestController
@ -94,6 +89,8 @@ public class ProductSpuController {
public CommonResult<PageResult<ProductSpuPageRespVO>> getSpuPage(@Valid ProductSpuPageReqVO pageVO) {
return success(ProductSpuConvert.INSTANCE.convertPage(productSpuService.getSpuPage(pageVO)));
}
// TODO @tuihui999get-count另外url 使用 - 拆分
@GetMapping("/tabsCount")
@Operation(summary = "获得商品 SPU tabsCount")
@PreAuthorize("@ss.hasPermission('product:spu:query')")

View File

@ -1,13 +1,5 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO;
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
import cn.iocoder.yudao.module.product.dal.dataobject.delivery.DeliveryTemplateDO;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -116,5 +108,4 @@ public class ProductSpuBaseVO {
@Schema(description = "虚拟销量", required = true, example = "芋道")
private Integer virtualSalesCount;
}

View File

@ -1,14 +1,11 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueDetailRespVO;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO;
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 javax.validation.constraints.NotNull;
import java.util.List;
@Schema(description = "管理后台 - 商品 SPU 详细 Response VO") // 包括关联的 SKU 等信息
@ -19,6 +16,7 @@ public class ProductSpuDetailRespVO extends ProductSpuBaseVO {
@Schema(description = "商品编号", example = "1")
private Long id;
// ========== SKU 相关字段 =========
@Schema(description = "SKU 数组", example = "1")

View File

@ -20,6 +20,7 @@ public class ProductSpuPageReqVO extends PageParam {
@Schema(description = "商品名称", example = "yutou")
private String name;
// TODO @puhui999加下 @InEnum 校验
@Schema(description = "前端请求的tab类型", example = "1")
private Integer tabType;

View File

@ -1,15 +1,15 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
// TODO @puhui999可以直接继承 ProductSpuRespVO 么?一般情况下,多返回一些字段问题不大的;另外,是不是使用 ProductSpuRespVO 替代
@Schema(description = "管理后台 - 商品 SPU 分页 response VO")
@Data
public class ProductSpuPageRespVO {
@Schema(description = "spuId", example = "1")
private Long id;
@Schema(description = "商品封面图", example = "1")
@ -28,4 +28,5 @@ public class ProductSpuPageRespVO {
private LocalDateTime createTime;
@Schema(description = "商品状态", example = "1")
private Integer status;
}

View File

@ -1,27 +1,22 @@
package cn.iocoder.yudao.module.product.controller.app.favorite;
import cn.hutool.core.lang.Assert;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
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.service.favorite.ProductFavoriteService;
import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteRespVO;
import cn.iocoder.yudao.module.product.service.favorite.ProductFavoriteService;
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.Objects;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.module.product.enums.favorite.ProductFavoriteTypeEnum.COLLECT;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
/**
* @author jason
*/
@Tag(name = "用户 APP - 喜爱商品")
@Tag(name = "用户 APP - 商品收藏")
@RestController
@RequestMapping("/product/favorite")
public class AppFavoriteController {
@ -29,23 +24,31 @@ public class AppFavoriteController {
@Resource
private ProductFavoriteService productFavoriteService;
@PostMapping(value = "/collect")
@PostMapping(value = "/create")
@Operation(summary = "商品收藏")
public CommonResult<Boolean> collect(@RequestBody @Valid AppFavoriteReqVO reqVO) {
Assert.isTrue(Objects.equals(COLLECT.getType(), reqVO.getType()), "参数type 不匹配");
return success(productFavoriteService.collect(reqVO));
public CommonResult<Boolean> create(@RequestBody @Valid AppFavoriteReqVO reqVO) {
Long loginUserId = getLoginUserId();
return success(productFavoriteService.create(loginUserId, reqVO));
}
@PostMapping(value = "/cancelCollect")
@DeleteMapping(value = "/delete")
@Operation(summary = "取消商品收藏(通过商品详情)")
public CommonResult<Boolean> cancelCollect(@RequestBody @Valid AppFavoriteReqVO reqVO) {
Assert.isTrue(Objects.equals(COLLECT.getType(), reqVO.getType()), "参数type 不匹配");
return success(productFavoriteService.cancelCollect(reqVO));
public CommonResult<Boolean> delete(@RequestBody @Valid AppFavoriteReqVO reqVO) {
Long loginUserId = getLoginUserId();
return success(productFavoriteService.delete(loginUserId,reqVO));
}
@GetMapping(value = "/collectList")
@Operation(summary = "商品收藏列表")
public CommonResult<PageResult<AppFavoriteRespVO>> pageCollectList(AppFavoritePageReqVO reqVO) {
return success(productFavoriteService.pageCollectList(reqVO));
@GetMapping(value = "/page")
@Operation(summary = "分页获取商品收藏列表")
public CommonResult<PageResult<AppFavoriteRespVO>> page(AppFavoritePageReqVO reqVO) {
Long userId = getLoginUserId();
return success(productFavoriteService.page(userId,reqVO));
}
@GetMapping(value = "/checkFavorite")
@Operation(summary = "检查是否收藏过商品")
public CommonResult<Boolean> checkFavorite(AppFavoriteReqVO reqVO) {
Long userId = getLoginUserId();
return success(productFavoriteService.checkFavorite(userId,reqVO));
}
}

View File

@ -10,15 +10,13 @@ import javax.validation.constraints.NotNull;
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
/**
* @author jason
*/
@Schema(description = "用户APP - 喜爱商品分页查询 Request VO")
@Schema(description = "用户APP - 商品收藏分页查询 Request VO")
@Data
public class AppFavoritePageReqVO extends PageParam {
@Schema(description = "类型 1:收藏 2点赞", requiredMode = REQUIRED, example = "1")
@Schema(description = "类型", requiredMode = REQUIRED, example = "1")
@NotNull(message = "类型不能为空")
@InEnum(ProductFavoriteTypeEnum.class)
private Integer type;
}

View File

@ -9,21 +9,17 @@ import javax.validation.constraints.NotNull;
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
/**
* @author jason
*/
@Schema(description = "用户APP - 喜爱商品创建 Request VO")
@Schema(description = "用户 APP - 商品收藏 Request VO")
@Data
public class AppFavoriteReqVO {
@Schema(description = "商品SPU编号", requiredMode = REQUIRED, example = "29502")
@NotNull(message = "商品SPU编号不能为空")
@Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502")
@NotNull(message = "商品 SPU 编号不能为空")
private Long spuId;
@Schema(description = "类型 1:收藏 2点赞", requiredMode = REQUIRED, example = "1")
@Schema(description = "类型", requiredMode = REQUIRED, example = "1")
@NotNull(message = "类型不能为空")
@InEnum(ProductFavoriteTypeEnum.class)
private Integer type;
}

View File

@ -1,23 +1,25 @@
package cn.iocoder.yudao.module.product.controller.app.favorite.vo;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @author jason
*/
@Schema(description = "用户APP - 喜爱商品 Response VO")
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
@Schema(description = "用户APP - 商品收藏 Response VO")
@Data
public class AppFavoriteRespVO {
@Schema(description = "编号", example = "1")
@Schema(description = "编号", requiredMode = REQUIRED, example = "1")
private Long id;
@Schema(description = "商品SPU编号", example = "29502")
@Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502")
private Long spuId;
@Schema(description = "商品SPU名称", example = "赵六")
@Schema(description = "类型", requiredMode = REQUIRED, example = "1")
private Integer type;
// ========== 商品相关字段 ==========
@Schema(description = "商品 SPU 名称", example = "赵六")
private String spuName;
@Schema(description = "商品封面图", example = "https://domain/pic.png")
@ -26,6 +28,4 @@ public class AppFavoriteRespVO {
@Schema(description = "商品单价", example = "100")
private Integer price;
@Schema(description = "类型 1:收藏 2点赞", example = "1")
private Integer type;
}

View File

@ -1,19 +1,20 @@
package cn.iocoder.yudao.module.product.convert.favorite;
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.dal.dataobject.favorite.ProductFavoriteDO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
/**
* Convert
*
* @author jason
*/
@Mapper
public interface ProductFavoriteConvert {
ProductFavoriteConvert INSTANCE = Mappers.getMapper(ProductFavoriteConvert.class);
ProductFavoriteDO convert(Long userId, AppFavoriteReqVO reqVO);
@Mapping(target = "id", source = "favoriteDO.id")
@Mapping(target = "spuName", source = "spuDO.name")
AppFavoriteRespVO convert(ProductSpuDO spuDO, ProductFavoriteDO favoriteDO);
}

View File

@ -47,7 +47,7 @@ public interface ProductSpuConvert {
List<ProductSpuSimpleRespVO> convertList02(List<ProductSpuDO> list);
// TODO @puhui999是不是可以删除啦
default ProductSpuDetailRespVO convert03(ProductSpuDO spu, List<ProductSkuDO> skus,
List<ProductPropertyValueDetailRespBO> propertyValues) {
ProductSpuDetailRespVO spuVO = convert03(spu);

View File

@ -1,7 +1,8 @@
package cn.iocoder.yudao.module.product.dal.dataobject.favorite;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
import cn.iocoder.yudao.module.product.enums.favorite.ProductFavoriteTypeEnum;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@ -20,7 +21,7 @@ import lombok.*;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProductFavoriteDO extends TenantBaseDO {
public class ProductFavoriteDO extends BaseDO {
/**
*
@ -40,7 +41,9 @@ public class ProductFavoriteDO extends TenantBaseDO {
*/
private Long spuId;
/**
* 1 2
*
*
* {@link ProductFavoriteTypeEnum}
*/
private Integer type;

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.product.dal.dataobject.property;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
@ -20,7 +19,7 @@ import lombok.*;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProductPropertyDO extends TenantBaseDO {
public class ProductPropertyDO extends TenantBaseDO { // TODO @puhui999这里是不是用 BaseDO 就可以了?
/**
*

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.product.dal.dataobject.property;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
@ -21,7 +20,7 @@ import lombok.*;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProductPropertyValueDO extends TenantBaseDO {
public class ProductPropertyValueDO extends TenantBaseDO { // TODO @puhui999这里是不是用 BaseDO 就可以了?
/**
*

View File

@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.product.dal.dataobject.sku;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
@ -28,7 +27,7 @@ import java.util.List;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProductSkuDO extends TenantBaseDO {
public class ProductSkuDO extends TenantBaseDO { // TODO @puhui999这里是不是用 BaseDO 就可以了?
/**
* SKU
@ -116,7 +115,7 @@ public class ProductSkuDO extends TenantBaseDO {
// * 冗余 {@link ProductPropertyDO#getName()}
// *
// * 注意:每次属性名字发生变化时,需要更新该冗余
// */ TODO 与已有代码逻辑存在冲突
// */ TODO @puhui999与已有代码逻辑存在冲突;芋艿:冲突点是啥呀?
//private String propertyName;
/**
@ -131,7 +130,7 @@ public class ProductSkuDO extends TenantBaseDO {
// * 冗余 {@link ProductPropertyValueDO#getName()}
// *
// * 注意:每次属性值名字发生变化时,需要更新该冗余
// */ TODO 与已有代码逻辑存在冲突
// */ TODO @puhui999与已有代码逻辑存在冲突;芋艿:冲突点是啥呀?
//private String valueName;
}

View File

@ -8,35 +8,31 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO;
import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteRespVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* Mapper
*
* @author jason
*/
@Mapper
public interface ProductFavoriteMapper extends BaseMapperX<ProductFavoriteDO> {
default ProductFavoriteDO selectByUserAndSpuAndType(Long userId, Long spuId, Integer type){
Assert.notNull(userId, "the userId argument must not be null");
Assert.notNull(spuId, "the spuId argument must not be null");
Assert.notNull(type, "the type argument must not be null");
default ProductFavoriteDO selectByUserAndSpuAndType(Long userId, Long spuId, Integer type) {
Assert.notNull(userId, "the userId must not be null");
Assert.notNull(spuId, "the spuId must not be null");
Assert.notNull(type, "the type must not be null");
return selectOne(new LambdaQueryWrapperX<ProductFavoriteDO>()
.eq(ProductFavoriteDO::getUserId, userId)
.eq(ProductFavoriteDO::getSpuId, spuId)
.eq(ProductFavoriteDO::getType, type));
}
default PageResult<AppFavoriteRespVO> selectPageByUserAndType(Long userId, Integer type, PageParam pageParam){
Page<AppFavoriteRespVO> page = MyBatisUtils.buildPage(pageParam);
page = selectFavoriteProductList(page, userId, type);
return new PageResult<>(page.getRecords(), page.getTotal());
default PageResult<ProductFavoriteDO> selectPageByUserAndType(Long userId, Integer type, PageParam pageParam) {
Assert.notNull(userId, "the userId must not be null");
Assert.notNull(type, "the type must not be null");
Assert.notNull(pageParam, "the pageParam must not be null");
return selectPage(pageParam, new LambdaQueryWrapper<ProductFavoriteDO>()
.eq(ProductFavoriteDO::getUserId, userId)
.eq(ProductFavoriteDO::getType, type)
.orderByDesc(ProductFavoriteDO::getId));
}
Page<AppFavoriteRespVO> selectFavoriteProductList(Page<AppFavoriteRespVO> page,
@Param("userId") Long userId,
@Param("type") Integer type);
}

View File

@ -1,11 +1,9 @@
package cn.iocoder.yudao.module.product.dal.mysql.spu;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO;
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
@ -14,24 +12,14 @@ import cn.iocoder.yudao.module.product.enums.spu.ProductSpuTabTypeEnum;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
/**
* spu Mapper
*
* @author
*/
@Mapper
public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
//default PageResult<ProductSpuDO> selectPage(ProductSpuPageReqVO reqVO) {
// return selectPage(reqVO, new LambdaQueryWrapperX<ProductSpuDO>()
// .likeIfPresent(ProductSpuDO::getName, reqVO.getName())
// .orderByDesc(ProductSpuDO::getSort));
//}
default PageResult<ProductSpuDO> selectPage(ProductSpuPageReqVO reqVO) {
// TODO @puhui999多个 tab写 if else 去补条件,可阅读性会好点哈
return selectPage(reqVO, new LambdaQueryWrapperX<ProductSpuDO>()
// 商品名称
.likeIfPresent(ProductSpuDO::getName, reqVO.getName())
@ -42,7 +30,7 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
.eq(ProductSpuTabTypeEnum.IN_WAREHOUSE.getType().equals(reqVO.getTabType()),ProductSpuDO::getStatus,ProductSpuStatusEnum.DISABLE.getStatus())
// 已售空商品
.eq(ProductSpuTabTypeEnum.SOLD_OUT.getType().equals(reqVO.getTabType()),ProductSpuDO::getStock,0)
// TODO 警戒库存暂时为 10后期需要使用常量或者数据库配置替换
// TODO @phuui999警戒库存暂时为 10后期需要使用常量或者数据库配置替换
.le(ProductSpuTabTypeEnum.ALERT_STOCK.getType().equals(reqVO.getTabType()),ProductSpuDO::getStock,10)
// 回收站
.eq(ProductSpuTabTypeEnum.RECYCLE_BIN.getType().equals(reqVO.getTabType()),ProductSpuDO::getStatus,ProductSpuStatusEnum.RECYCLE.getStatus())

View File

@ -15,20 +15,31 @@ import javax.validation.Valid;
public interface ProductFavoriteService {
/**
*
*
* @param userId id
* @param reqVO vo
*/
Boolean collect(@Valid AppFavoriteReqVO reqVO);
Boolean create(Long userId, @Valid AppFavoriteReqVO reqVO);
/**
* ()
* @param userId id
* @param reqVO vo
*/
Boolean cancelCollect(@Valid AppFavoriteReqVO reqVO);
Boolean delete(Long userId, @Valid AppFavoriteReqVO reqVO);
/**
*
* @param userId id
* @param reqVO vo
*/
PageResult<AppFavoriteRespVO> pageCollectList(@Valid AppFavoritePageReqVO reqVO);
PageResult<AppFavoriteRespVO> page(Long userId, @Valid AppFavoritePageReqVO reqVO);
/**
*
* @param userId id
* @param reqVO vo
* @return true: false:
*/
Boolean checkFavorite(Long userId, @Valid AppFavoriteReqVO reqVO);
}

View File

@ -1,62 +1,93 @@
package cn.iocoder.yudao.module.product.service.favorite;
import cn.hutool.core.lang.Assert;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
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.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.dal.mysql.favorite.ProductFavoriteMapper;
import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteRespVO;
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 javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.COLLECTION_EXISTS;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.COLLECTION_NOT_EXISTS;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PRODUCT_FAVORITE_EXISTS;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PRODUCT_FAVORITE_NOT_EXISTS;
/**
* Service
* Service
*
* @author jason
*/
@Service
@Validated
public class ProductFavoriteServiceImpl implements ProductFavoriteService {
@Resource
private ProductSpuService productSpuService;
@Resource
private ProductFavoriteMapper mapper;
@Override
public Boolean collect(@Valid AppFavoriteReqVO reqVO) {
Long userId = getLoginUserId();
public Boolean create(Long userId, @Valid AppFavoriteReqVO reqVO) {
Assert.notNull(userId, "the userId must not be null");
ProductFavoriteDO favoriteDO = mapper.selectByUserAndSpuAndType(userId, reqVO.getSpuId(), reqVO.getType());
if (Objects.nonNull(favoriteDO)) {
throw exception(COLLECTION_EXISTS);
throw exception(PRODUCT_FAVORITE_EXISTS);
}
ProductFavoriteDO entity = ProductFavoriteConvert.INSTANCE.convert(userId, reqVO);
int count = mapper.insert(entity);
return count == 1;
mapper.insert(entity);
return Boolean.TRUE;
}
@Override
public Boolean cancelCollect(@Valid AppFavoriteReqVO reqVO) {
Long loginUserId = getLoginUserId();
ProductFavoriteDO favoriteDO = mapper.selectByUserAndSpuAndType(loginUserId, reqVO.getSpuId(), reqVO.getType());
public Boolean delete(Long userId, @Valid AppFavoriteReqVO reqVO) {
Assert.notNull(userId, "the userId must not be null ");
ProductFavoriteDO favoriteDO = mapper.selectByUserAndSpuAndType(userId, reqVO.getSpuId(), reqVO.getType());
if (Objects.isNull(favoriteDO)) {
throw exception(COLLECTION_NOT_EXISTS);
throw exception(PRODUCT_FAVORITE_NOT_EXISTS);
}
int count = mapper.deleteById(favoriteDO.getId());
return count == 1;
mapper.deleteById(favoriteDO.getId());
return Boolean.TRUE;
}
@Override
public PageResult<AppFavoriteRespVO> pageCollectList(@Valid AppFavoritePageReqVO reqVO) {
Long userId = getLoginUserId();
return mapper.selectPageByUserAndType(userId, reqVO.getType(), reqVO);
public PageResult<AppFavoriteRespVO> page(Long userId, @Valid AppFavoritePageReqVO reqVO) {
Assert.notNull(userId, "the userId must not be null ");
PageResult<ProductFavoriteDO> favorites = mapper.selectPageByUserAndType(userId, reqVO.getType(), reqVO);
if (favorites.getTotal() > 0) {
PageResult<AppFavoriteRespVO> pageResult = new PageResult<>(favorites.getTotal());
List<ProductFavoriteDO> list = favorites.getList();
//得到商品spu 信息
List<Long> spuIds = CollectionUtils.convertList(list, ProductFavoriteDO::getSpuId);
Map<Long, ProductSpuDO> spuMap = CollectionUtils.convertMap(productSpuService.getSpuList(spuIds), ProductSpuDO::getId, val -> val);
List<AppFavoriteRespVO> resultList = new ArrayList<>(list.size());
for (ProductFavoriteDO item : list) {
ProductSpuDO spuDO = spuMap.get(item.getSpuId());
resultList.add(ProductFavoriteConvert.INSTANCE.convert(spuDO, item));
}
pageResult.setList(resultList);
return pageResult;
}else {
return PageResult.empty();
}
}
@Override
public Boolean checkFavorite(Long userId, @Valid AppFavoriteReqVO reqVO) {
Assert.notNull(userId, "the userId must not be null ");
ProductFavoriteDO favoriteDO = mapper.selectByUserAndSpuAndType(userId, reqVO.getSpuId(), reqVO.getType());
return Objects.nonNull(favoriteDO);
}
}

View File

@ -40,6 +40,7 @@ public interface ProductPropertyService {
/**
*
*
* @param listReqVO
* @return
*/

View File

@ -94,7 +94,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
@Override
public List<ProductPropertyDO> getPropertyList(ProductPropertyListReqVO listReqVO) {
// 增加使用属性id查询
// 增加使用属性 id 查询
if (CollUtil.isNotEmpty(listReqVO.getPropertyIds())){
return productPropertyMapper.selectBatchIds(listReqVO.getPropertyIds());
}

View File

@ -87,7 +87,9 @@ public interface ProductSkuService {
/**
* SPU SKU
* TODO SKUstatus
*
* TODO @puhui999SKUstatus status
*
* @param spuId SPU
* @param status
* @return SKU

View File

@ -1,12 +1,9 @@
package cn.iocoder.yudao.module.product.service.spu;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO;
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*;
@ -23,7 +20,6 @@ import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO;
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -34,7 +30,7 @@ import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR;
@ -63,17 +59,18 @@ public class ProductSpuServiceImpl implements ProductSpuService {
@Override
@Transactional(rollbackFor = Exception.class)
public Long createSpu(ProductSpuCreateReqVO createReqVO) {
// 校验分类 TODO 暂不清楚为什么只能选择第三层的结点
// 校验分类 TODO puhui999暂不清楚为什么只能选择第三层的结点;芋艿:改成二级分类,因为商品只能放在叶子节点级别;
//validateCategory(createReqVO.getCategoryId());
// 校验品牌 TODO 暂不校验,前端没有做品牌选择
// 校验品牌 TODO puhui999暂不校验,前端没有做品牌选择;芋艿:可以加下哈
//brandService.validateProductBrand(createReqVO.getBrandId());
List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = createReqVO.getSkus();
// 校验SKU
// 校验 SKU
productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType());
ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO);
// 初始化SPU中SKU相关属性
// 初始化 SPU SKU 相关属性
initSpuFromSkus(spu, skuSaveReqList);
// 插入 SPU
productSpuMapper.insert(spu);
// 插入 SKU
@ -193,6 +190,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
stockIncrCounts.forEach((id, incCount) -> productSpuMapper.updateStock(id, incCount));
}
// TODO @puhui999Service 尽量不做一些跟 VO 相关的拼接逻辑,目的是让 Service 更加简洁一点哈。
@Override
public ProductSpuDetailRespVO getSpuDetail(Long id) {
// 获得商品 SPU
@ -204,12 +202,17 @@ public class ProductSpuServiceImpl implements ProductSpuService {
// 查询商品 SKU
List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId());
if (CollUtil.isNotEmpty(skus)){
// TODO @puhui999skuVOs 更简洁一点。然后大小写要注释哈。RespVOs因为 VO 是缩写s 是复数
List<ProductSkuRespVO> skuRespVoS = ProductSkuConvert.INSTANCE.convertList(skus);
// 非多规格,不需要处理
// TODO @puhui999统一模型即使是单规格也查询下问题不大的
if (ObjectUtil.equal(productSpuDetailRespVO.getSpecType(), true)) {
// 获取所有的属性值id
Set<Long> valueIds = skus.stream().flatMap(p -> p.getProperties().stream()).map(ProductSkuDO.Property::getValueId).collect(Collectors.toSet());
// 获取所有的属性值 id
Set<Long> valueIds = skus.stream().flatMap(p -> p.getProperties().stream())
.map(ProductSkuDO.Property::getValueId)
.collect(Collectors.toSet());
List<ProductPropertyValueDetailRespBO> valueDetailList = productPropertyValueService.getPropertyValueDetailList(valueIds);
// TODO @puhui999拼接的逻辑最好查询好后丢到 convert 里面统一处理;这样 Service or Controller 也可以更简洁原则上Controller 去组合Service 写逻辑Convert 转换
Map<Long, String> stringMap = valueDetailList.stream().collect(Collectors.toMap(ProductPropertyValueDetailRespBO::getValueId, ProductPropertyValueDetailRespBO::getValueName));
// 设置属性值名称
skuRespVoS.stream().flatMap(p -> p.getProperties().stream()).forEach(item ->item.setValueName(stringMap.get(item.getValueId())));
@ -232,6 +235,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
@Override
public Map<Integer, Long> getTabsCount() {
// TODO @puhui999map =》counts尽量避免出现 map 这种命名,无命名含义哈
Map<Integer, Long> map = new HashMap<>();
// 查询销售中的商品数量
map.put(ProductSpuTabTypeEnum.FOR_SALE.getType(), productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus()));
@ -240,6 +244,8 @@ public class ProductSpuServiceImpl implements ProductSpuService {
// 查询售空的商品数量
map.put(ProductSpuTabTypeEnum.SOLD_OUT.getType(),productSpuMapper.selectCount(ProductSpuDO::getStock, 0));
// 查询触发警戒库存的商品数量 TODO 警戒库存暂时为 10后期需要使用常量或者数据库配置替换
// TODO @puhui999要有空格, productSpuMapper
// TODO @puhui999Service 不要有 Mapper 的逻辑;想想咋抽象一下哈
map.put(ProductSpuTabTypeEnum.ALERT_STOCK.getType(),productSpuMapper.selectCount(new LambdaQueryWrapperX<ProductSpuDO>().le(ProductSpuDO::getStock, 10)));
// 查询回收站中的商品数量
map.put(ProductSpuTabTypeEnum.RECYCLE_BIN.getType(),productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()));

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.product.dal.mysql.favorite.ProductFavoriteMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectFavoriteProductList"
resultType="cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteRespVO">
SELECT f.id, f.type, f.spu_id as spuId , p.name as spuName, p.pic_url as picUrl , p.price
FROM product_favorite f
INNER JOIN product_spu p ON f.spu_id = p.id and f.deleted = 0
where f.type = #{type} and f.user_id = #{userId}
ORDER BY f.id DESC
</select>
</mapper>

View File

@ -5,11 +5,11 @@ import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.RandomUtil;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO;
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*;
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO;
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO;
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageRespVO;
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateReqVO;
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO;
import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
@ -34,7 +34,6 @@ import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
@ -79,13 +78,10 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
@Test
public void testCreateSpu_success() {
// 准备参数
ProductSpuCreateReqVO createReqVO = randomPojo(ProductSpuCreateReqVO.class, o -> {
o.setSpecType(true);
});
ProductSpuCreateReqVO createReqVO = randomPojo(ProductSpuCreateReqVO.class);
Long spu = productSpuService.createSpu(createReqVO);
ProductSpuDO productSpuDO = productSpuMapper.selectById(spu);
assertPojoEquals(createReqVO, productSpuDO);
}
@Test
@ -96,7 +92,6 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
// 准备参数
ProductSpuUpdateReqVO reqVO = randomPojo(ProductSpuUpdateReqVO.class, o -> {
o.setId(createReqVO.getId()); // 设置更新的 ID
o.setSpecType(true);
});
// 调用
productSpuService.updateSpu(reqVO);
@ -107,9 +102,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
@Test
public void testValidateSpuExists_exception() {
ProductSpuUpdateReqVO reqVO = randomPojo(ProductSpuUpdateReqVO.class, o -> {
o.setSpecType(true);
});
ProductSpuUpdateReqVO reqVO = randomPojo(ProductSpuUpdateReqVO.class);
// 调用
Assertions.assertThrows(ServiceException.class, () -> productSpuService.updateSpu(reqVO));
}
@ -174,7 +167,6 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
//o.setMinPrice(1); // TODO ProductSpuDO中已没有相关属性
//o.setMaxPrice(50);
o.setMarketPrice(25);
o.setSpecType(false);
o.setBrandId(brandId);
o.setCategoryId(categoryId);
//o.setClickCount(100);
@ -222,8 +214,8 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
//o.setMinPrice(1); // TODO ProductSpuDO中已没有相关属性
//o.setMaxPrice(1);
o.setMarketPrice(1);
o.setSpecType(false);
o.setBrandId(brandId);
o.setSpecType(false);
o.setCategoryId(categoryId);
//o.setClickCount(1); // TODO ProductSpuDO中已没有相关属性
//o.setCode(generateNo());

View File

@ -66,7 +66,7 @@ public class ProjectReactor {
// 写入文件
files.forEach(file -> {
// 如果是白名单的文件类型,不进行重写,直接拷贝
String fileType = FileTypeUtil.getType(file);
String fileType = getFileType(file);
if (WHITE_FILE_TYPES.contains(fileType)) {
copyFile(file, projectBaseDir, projectBaseDirNew, packageNameNew, artifactIdNew);
return;
@ -106,7 +106,7 @@ public class ProjectReactor {
String titleNew) {
String content = FileUtil.readString(file, StandardCharsets.UTF_8);
// 如果是白名单的文件类型,不进行重写
String fileType = FileTypeUtil.getType(file);
String fileType = getFileType(file);
if (WHITE_FILE_TYPES.contains(fileType)) {
return content;
}
@ -139,4 +139,8 @@ public class ProjectReactor {
.replaceAll(StrUtil.upperFirst(ARTIFACT_ID), StrUtil.upperFirst(artifactIdNew));
}
private static String getFileType(File file) {
return file.length() > 0 ? FileTypeUtil.getType(file) : "";
}
}

View File

@ -1,6 +1,6 @@
{
"name": "yudao-ui-admin",
"version": "1.7.1-snapshot",
"version": "1.7.2-snapshot",
"description": "芋道管理系统",
"author": "芋道",
"license": "MIT",

View File

@ -83,6 +83,14 @@
</div>
</div>
</el-form-item>
<!-- 教程说明 -->
<el-form-item style="width:100%; margin-top:-25px">
<el-link href="https://doc.iocoder.cn/" target="_blank">📚开发指南</el-link>
<el-link href="https://doc.iocoder.cn/video/" target="_blank" style="padding-left: 10px">🔥视频教程</el-link>
<el-link href="https://www.iocoder.cn/Interview/good-collection/" target="_blank" style="padding-left: 10px">面试手册</el-link>
<el-link href="http://static.yudao.iocoder.cn/mp/Aix9975.jpeg" target="_blank" style="padding-left: 10px">🤝外包咨询</el-link>
</el-form-item>
</el-form>
</div>
</div>