mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-19 11:40:05 +08:00
Merge remote-tracking branch 'yudao/develop' into develop
This commit is contained in:
commit
0c30f59e02
@ -496,7 +496,8 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
|
||||
Expression allExpression = null;
|
||||
for (DataPermissionRule rule : ContextHolder.getRules()) {
|
||||
// 判断表名是否匹配
|
||||
if (!rule.getTableNames().contains(table.getName())) {
|
||||
String tableName = MyBatisUtils.getTableName(table);
|
||||
if (!rule.getTableNames().contains(tableName)) {
|
||||
continue;
|
||||
}
|
||||
// 如果有匹配的规则,说明可重写。
|
||||
@ -505,7 +506,6 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
|
||||
ContextHolder.setRewrite(true);
|
||||
|
||||
// 单条规则的条件
|
||||
String tableName = MyBatisUtils.getTableName(table);
|
||||
Expression oneExpress = rule.getExpression(tableName, table.getAlias());
|
||||
if (oneExpress == null){
|
||||
continue;
|
||||
|
@ -1,22 +1,21 @@
|
||||
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.framework.common.util.object.BeanUtils;
|
||||
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.controller.admin.category.vo.ProductCategorySaveReqVO;
|
||||
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 jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@ -34,14 +33,14 @@ public class ProductCategoryController {
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建商品分类")
|
||||
@PreAuthorize("@ss.hasPermission('product:category:create')")
|
||||
public CommonResult<Long> createCategory(@Valid @RequestBody ProductCategoryCreateReqVO createReqVO) {
|
||||
public CommonResult<Long> createCategory(@Valid @RequestBody ProductCategorySaveReqVO createReqVO) {
|
||||
return success(categoryService.createCategory(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新商品分类")
|
||||
@PreAuthorize("@ss.hasPermission('product:category:update')")
|
||||
public CommonResult<Boolean> updateCategory(@Valid @RequestBody ProductCategoryUpdateReqVO updateReqVO) {
|
||||
public CommonResult<Boolean> updateCategory(@Valid @RequestBody ProductCategorySaveReqVO updateReqVO) {
|
||||
categoryService.updateCategory(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
@ -61,7 +60,7 @@ public class ProductCategoryController {
|
||||
@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));
|
||||
return success(BeanUtils.toBean(category, ProductCategoryRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ -70,7 +69,7 @@ public class ProductCategoryController {
|
||||
public CommonResult<List<ProductCategoryRespVO>> getCategoryList(@Valid ProductCategoryListReqVO listReqVO) {
|
||||
List<ProductCategoryDO> list = categoryService.getCategoryList(listReqVO);
|
||||
list.sort(Comparator.comparing(ProductCategoryDO::getSort));
|
||||
return success(ProductCategoryConvert.INSTANCE.convertList(list));
|
||||
return success(BeanUtils.toBean(list, ProductCategoryRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
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 jakarta.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;
|
||||
|
||||
}
|
@ -2,20 +2,34 @@ 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 {
|
||||
public class ProductCategoryRespVO {
|
||||
|
||||
@Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "父分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "办公文具")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "移动端分类图", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = "分类排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "分类描述", example = "描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
@ -1,17 +1,16 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.category.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商品分类 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Schema(description = "管理后台 - 商品分类新增/更新 Request VO")
|
||||
@Data
|
||||
public class ProductCategoryBaseVO {
|
||||
public class ProductCategorySaveReqVO {
|
||||
|
||||
@Schema(description = "分类编号", example = "2")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "父分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "父分类编号不能为空")
|
||||
@ -25,9 +24,6 @@ public class ProductCategoryBaseVO {
|
||||
@NotBlank(message = "移动端分类图不能为空")
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = "PC 端分类图")
|
||||
private String bigPicUrl;
|
||||
|
||||
@Schema(description = "分类排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer sort;
|
||||
|
||||
@ -35,4 +31,7 @@ public class ProductCategoryBaseVO {
|
||||
@NotNull(message = "开启状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "分类描述", example = "描述")
|
||||
private String description;
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
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 jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.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;
|
||||
|
||||
}
|
@ -2,19 +2,18 @@ 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.framework.common.util.object.BeanUtils;
|
||||
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 jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@ -32,7 +31,7 @@ public class ProductCommentController {
|
||||
@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));
|
||||
return success(BeanUtils.toBean(pageResult, ProductCommentRespVO.class));
|
||||
}
|
||||
|
||||
@PutMapping("/update-visible")
|
||||
|
@ -1,47 +0,0 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.comment.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.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;
|
||||
|
||||
}
|
@ -1,14 +1,49 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.comment.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 商品评价创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ProductCommentCreateReqVO extends ProductCommentBaseVO {
|
||||
public class ProductCommentCreateReqVO {
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
|
@ -2,32 +2,68 @@ package cn.iocoder.yudao.module.product.controller.admin.comment.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 商品评价 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ProductCommentRespVO extends ProductCommentBaseVO {
|
||||
public class ProductCommentRespVO {
|
||||
|
||||
@Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24965")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "评价人", requiredMode = Schema.RequiredMode.REQUIRED, example = "16868")
|
||||
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 = "false")
|
||||
private Boolean anonymous;
|
||||
|
||||
@Schema(description = "交易订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24428")
|
||||
private Long orderId;
|
||||
|
||||
@Schema(description = "评价订单项", requiredMode = Schema.RequiredMode.REQUIRED, example = "19292")
|
||||
private Long orderItemId;
|
||||
|
||||
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉丝滑透气小短袖")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long skuId;
|
||||
|
||||
@Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
private String spuName;
|
||||
|
||||
@Schema(description = "商品 SKU 图片地址", example = "https://www.iocoder.cn/yudao.jpg")
|
||||
private String skuPicUrl;
|
||||
|
||||
@Schema(description = "商品 SKU 规格值数组")
|
||||
private List<ProductSkuSaveReqVO.Property> skuProperties;
|
||||
|
||||
@Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Boolean visible;
|
||||
|
||||
@Schema(description = "评分星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
|
||||
private Integer scores;
|
||||
|
||||
@Schema(description = "描述星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
|
||||
private Integer descriptionScores;
|
||||
|
||||
@Schema(description = "服务星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
|
||||
private Integer benefitScores;
|
||||
|
||||
@Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "穿起来非常丝滑凉快")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png]")
|
||||
private List<String> picUrls;
|
||||
|
||||
@Schema(description = "商家是否回复", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Boolean replyStatus;
|
||||
|
||||
@ -43,21 +79,4 @@ public class ProductCommentRespVO extends ProductCommentBaseVO {
|
||||
@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<ProductSkuSaveReqVO.Property> skuProperties;
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
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;
|
||||
|
@ -3,31 +3,21 @@ 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.framework.common.util.object.BeanUtils;
|
||||
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 jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
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 jakarta.annotation.Resource;
|
||||
import jakarta.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
|
||||
@ -38,43 +28,22 @@ 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()));
|
||||
PageResult<ProductCommentDO> pageResult = productCommentService.getCommentPage(pageVO, Boolean.TRUE);
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return success(PageResult.empty(pageResult.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));
|
||||
pageResult.getList().forEach(item -> {
|
||||
if (Boolean.TRUE.equals(item.getAnonymous())) {
|
||||
item.setUserNickname(ProductCommentDO.NICKNAME_ANONYMOUS);
|
||||
}
|
||||
});
|
||||
return success(BeanUtils.toBean(pageResult, AppProductCommentRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
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;
|
||||
|
||||
}
|
@ -91,7 +91,8 @@ public class AppProductCommentRespVO {
|
||||
@NotNull(message = "评论内容不能为空")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png]")
|
||||
@Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", requiredMode = Schema.RequiredMode.REQUIRED,
|
||||
example = "[https://www.iocoder.cn/xx.png]")
|
||||
@Size(max = 9, message = "评论图片地址数组长度不能超过 9 张")
|
||||
private List<String> picUrls;
|
||||
|
||||
|
@ -28,7 +28,6 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
// TODO 芋艿:后面再看
|
||||
@Tag(name = "用户 APP - 商品浏览记录")
|
||||
@RestController
|
||||
@RequestMapping("/product/browse-history")
|
||||
@ -50,18 +49,11 @@ public class AppProductBrowseHistoryController {
|
||||
@DeleteMapping(value = "/clean")
|
||||
@Operation(summary = "清空商品浏览记录")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Boolean> cleanBrowseHistory() {
|
||||
public CommonResult<Boolean> deleteBrowseHistory() {
|
||||
productBrowseHistoryService.hideUserBrowseHistory(getLoginUserId(), null);
|
||||
return success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/get-count")
|
||||
@Operation(summary = "获得商品浏览记录数量")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Long> getBrowseHistoryCount() {
|
||||
return success(productBrowseHistoryService.getBrowseHistoryCount(getLoginUserId(), false));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/page")
|
||||
@Operation(summary = "获得商品浏览记录分页")
|
||||
@PreAuthenticated
|
||||
|
@ -1,31 +0,0 @@
|
||||
package cn.iocoder.yudao.module.product.convert.category;
|
||||
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO;
|
||||
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.controller.app.category.vo.AppCategoryRespVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品分类 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProductCategoryConvert {
|
||||
|
||||
ProductCategoryConvert INSTANCE = Mappers.getMapper(ProductCategoryConvert.class);
|
||||
|
||||
ProductCategoryDO convert(ProductCategoryCreateReqVO bean);
|
||||
|
||||
ProductCategoryDO convert(ProductCategoryUpdateReqVO bean);
|
||||
|
||||
ProductCategoryRespVO convert(ProductCategoryDO bean);
|
||||
|
||||
List<ProductCategoryRespVO> convertList(List<ProductCategoryDO> list);
|
||||
|
||||
}
|
@ -1,29 +1,17 @@
|
||||
package cn.iocoder.yudao.module.product.convert.comment;
|
||||
|
||||
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.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentRespVO;
|
||||
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.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Named;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
|
||||
|
||||
/**
|
||||
* 商品评价 Convert
|
||||
@ -35,48 +23,35 @@ public interface ProductCommentConvert {
|
||||
|
||||
ProductCommentConvert INSTANCE = Mappers.getMapper(ProductCommentConvert.class);
|
||||
|
||||
ProductCommentRespVO convert(ProductCommentDO bean);
|
||||
|
||||
@Mapping(target = "scores", expression = "java(calculateOverallScore(goodCount, mediocreCount, negativeCount))")
|
||||
AppCommentStatisticsRespVO convert(Long goodCount, Long mediocreCount, Long negativeCount);
|
||||
|
||||
@Named("calculateOverallScore")
|
||||
default double calculateOverallScore(long goodCount, long mediocreCount, long negativeCount) {
|
||||
return (goodCount * 5 + mediocreCount * 3 + negativeCount) / (double) (goodCount + mediocreCount + negativeCount);
|
||||
default ProductCommentDO convert(ProductCommentCreateReqDTO createReqDTO,
|
||||
ProductSpuDO spu, ProductSkuDO sku, MemberUserRespDTO user) {
|
||||
ProductCommentDO comment = BeanUtils.toBean(createReqDTO, ProductCommentDO.class)
|
||||
.setScores(convertScores(createReqDTO.getDescriptionScores(), createReqDTO.getBenefitScores()));
|
||||
if (user != null) {
|
||||
comment.setUserId(user.getId()).setUserNickname(user.getNickname()).setUserAvatar(user.getAvatar());
|
||||
}
|
||||
if (spu != null) {
|
||||
comment.setSpuId(spu.getId()).setSpuName(spu.getName());
|
||||
}
|
||||
if (sku != null) {
|
||||
comment.setSkuPicUrl(sku.getPicUrl()).setSkuProperties(sku.getProperties());
|
||||
}
|
||||
return comment;
|
||||
}
|
||||
|
||||
List<ProductCommentRespVO> convertList(List<ProductCommentDO> list);
|
||||
|
||||
PageResult<ProductCommentRespVO> convertPage(PageResult<ProductCommentDO> page);
|
||||
|
||||
PageResult<AppProductCommentRespVO> convertPage01(PageResult<ProductCommentDO> pageResult);
|
||||
|
||||
default PageResult<AppProductCommentRespVO> convertPage02(PageResult<ProductCommentDO> pageResult,
|
||||
List<ProductSkuDO> skuList) {
|
||||
Map<Long, ProductSkuDO> skuMap = CollectionUtils.convertMap(skuList, ProductSkuDO::getId);
|
||||
PageResult<AppProductCommentRespVO> page = convertPage01(pageResult);
|
||||
page.getList().forEach(item -> {
|
||||
// 判断用户是否选择匿名
|
||||
if (ObjectUtil.equal(item.getAnonymous(), true)) {
|
||||
item.setUserNickname(ProductCommentDO.NICKNAME_ANONYMOUS);
|
||||
}
|
||||
// 设置 SKU 规格值
|
||||
findAndThen(skuMap, item.getSkuId(),
|
||||
sku -> item.setSkuProperties(convertList01(sku.getProperties())));
|
||||
});
|
||||
return page;
|
||||
default ProductCommentDO convert(ProductCommentCreateReqVO createReq, ProductSpuDO spu, ProductSkuDO sku) {
|
||||
ProductCommentDO comment = BeanUtils.toBean(createReq, ProductCommentDO.class)
|
||||
.setVisible(true).setUserId(0L).setAnonymous(false)
|
||||
.setScores(convertScores(createReq.getDescriptionScores(), createReq.getBenefitScores()));
|
||||
if (spu != null) {
|
||||
comment.setSpuId(spu.getId()).setSpuName(spu.getName());
|
||||
}
|
||||
if (sku != null) {
|
||||
comment.setSkuPicUrl(sku.getPicUrl()).setSkuProperties(sku.getProperties());
|
||||
}
|
||||
return comment;
|
||||
}
|
||||
|
||||
List<AppProductPropertyValueDetailRespVO> convertList01(List<ProductSkuDO.Property> properties);
|
||||
|
||||
/**
|
||||
* 计算综合评分
|
||||
*
|
||||
* @param descriptionScores 描述星级
|
||||
* @param benefitScores 服务星级
|
||||
* @return 综合评分
|
||||
*/
|
||||
@Named("convertScores")
|
||||
default Integer convertScores(Integer descriptionScores, Integer benefitScores) {
|
||||
// 计算评价最终综合评分 最终星数 = (商品评星 + 服务评星) / 2
|
||||
BigDecimal sumScore = new BigDecimal(descriptionScores + benefitScores);
|
||||
@ -84,50 +59,4 @@ public interface ProductCommentConvert {
|
||||
return divide.intValue();
|
||||
}
|
||||
|
||||
@Mapping(target = "scores",
|
||||
expression = "java(convertScores(createReqDTO.getDescriptionScores(), createReqDTO.getBenefitScores()))")
|
||||
ProductCommentDO convert(ProductCommentCreateReqDTO createReqDTO);
|
||||
|
||||
default ProductCommentDO convert(ProductCommentCreateReqDTO createReqDTO,
|
||||
ProductSpuDO spu, ProductSkuDO sku, MemberUserRespDTO user) {
|
||||
ProductCommentDO comment = convert(createReqDTO).setReplyStatus(false);
|
||||
if (user != null) {
|
||||
comment.setUserId(user.getId());
|
||||
comment.setUserNickname(user.getNickname());
|
||||
comment.setUserAvatar(user.getAvatar());
|
||||
}
|
||||
if (spu != null) {
|
||||
comment.setSpuId(spu.getId());
|
||||
comment.setSpuName(spu.getName());
|
||||
}
|
||||
if (sku != null) {
|
||||
comment.setSkuPicUrl(sku.getPicUrl());
|
||||
comment.setSkuProperties(sku.getProperties());
|
||||
}
|
||||
return comment;
|
||||
}
|
||||
|
||||
@Mapping(target = "visible", constant = "true")
|
||||
@Mapping(target = "replyStatus", constant = "false")
|
||||
@Mapping(target = "userId", constant = "0L")
|
||||
@Mapping(target = "orderId", constant = "0L")
|
||||
@Mapping(target = "orderItemId", constant = "0L")
|
||||
@Mapping(target = "anonymous", expression = "java(Boolean.FALSE)")
|
||||
@Mapping(target = "scores",
|
||||
expression = "java(convertScores(createReq.getDescriptionScores(), createReq.getBenefitScores()))")
|
||||
ProductCommentDO convert(ProductCommentCreateReqVO createReq);
|
||||
|
||||
List<AppProductCommentRespVO> convertList02(List<ProductCommentDO> list);
|
||||
|
||||
default ProductCommentDO convert(ProductCommentCreateReqVO createReq, ProductSpuDO spu, ProductSkuDO sku) {
|
||||
ProductCommentDO commentDO = convert(createReq);
|
||||
if (spu != null) {
|
||||
commentDO.setSpuId(spu.getId()).setSpuName(spu.getName());
|
||||
}
|
||||
if (sku != null) {
|
||||
commentDO.setSkuPicUrl(sku.getPicUrl()).setSkuProperties(sku.getProperties());
|
||||
}
|
||||
return commentDO;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -48,12 +48,6 @@ public class ProductCategoryDO extends BaseDO {
|
||||
* 建议 180*180 分辨率
|
||||
*/
|
||||
private String picUrl;
|
||||
/**
|
||||
* PC 端分类图
|
||||
*
|
||||
* 建议 468*340 分辨率
|
||||
*/
|
||||
private String bigPicUrl;
|
||||
/**
|
||||
* 分类排序
|
||||
*/
|
||||
|
@ -144,13 +144,6 @@ public class ProductSpuDO extends BaseDO {
|
||||
* 赠送积分
|
||||
*/
|
||||
private Integer giveIntegral;
|
||||
/**
|
||||
* 赠送的优惠劵编号的数组
|
||||
*
|
||||
* 对应 CouponTemplateDO 的 id 属性
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<Long> giveCouponTemplateIds;
|
||||
|
||||
// TODO @puhui999:字段估计要改成 brokerageType
|
||||
/**
|
||||
|
@ -1,7 +1,6 @@
|
||||
package cn.iocoder.yudao.module.product.dal.mysql.comment;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
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;
|
||||
@ -59,21 +58,4 @@ public interface ProductCommentMapper extends BaseMapperX<ProductCommentDO> {
|
||||
.eq(ProductCommentDO::getOrderItemId, orderItemId));
|
||||
}
|
||||
|
||||
default Long selectCountBySpuId(Long spuId, Boolean visible, Integer type) {
|
||||
LambdaQueryWrapperX<ProductCommentDO> queryWrapper = new LambdaQueryWrapperX<ProductCommentDO>()
|
||||
.eqIfPresent(ProductCommentDO::getSpuId, spuId)
|
||||
.eqIfPresent(ProductCommentDO::getVisible, visible);
|
||||
// 构建评价查询语句
|
||||
appendTabQuery(queryWrapper, type);
|
||||
return selectCount(queryWrapper);
|
||||
}
|
||||
|
||||
default PageResult<ProductCommentDO> selectCommentList(Long spuId, Integer count) {
|
||||
// 构建分页查询条件
|
||||
return selectPage(new PageParam().setPageSize(count), new LambdaQueryWrapperX<ProductCommentDO>()
|
||||
.eqIfPresent(ProductCommentDO::getSpuId, spuId)
|
||||
.orderByDesc(ProductCommentDO::getCreateTime)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,12 @@ import java.util.Collection;
|
||||
@Mapper
|
||||
public interface ProductBrowseHistoryMapper extends BaseMapperX<ProductBrowseHistoryDO> {
|
||||
|
||||
default ProductBrowseHistoryDO selectByUserIdAndSpuId(Long userId, Long spuId) {
|
||||
return selectOne(new LambdaQueryWrapperX<ProductBrowseHistoryDO>()
|
||||
.eq(ProductBrowseHistoryDO::getUserId, userId)
|
||||
.eq(ProductBrowseHistoryDO::getSpuId, spuId));
|
||||
}
|
||||
|
||||
default PageResult<ProductBrowseHistoryDO> selectPage(ProductBrowseHistoryPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ProductBrowseHistoryDO>()
|
||||
.eqIfPresent(ProductBrowseHistoryDO::getUserId, reqVO.getUserId())
|
||||
@ -36,12 +42,6 @@ public interface ProductBrowseHistoryMapper extends BaseMapperX<ProductBrowseHis
|
||||
.set(ProductBrowseHistoryDO::getUserDeleted, userDeleted));
|
||||
}
|
||||
|
||||
default Long selectCountByUserIdAndUserDeleted(Long userId, Boolean userDeleted) {
|
||||
return selectCount(new LambdaQueryWrapperX<ProductBrowseHistoryDO>()
|
||||
.eq(ProductBrowseHistoryDO::getUserId, userId)
|
||||
.eqIfPresent(ProductBrowseHistoryDO::getUserDeleted, userDeleted));
|
||||
}
|
||||
|
||||
default Page<ProductBrowseHistoryDO> selectPageByUserIdOrderByCreateTimeAsc(Long userId, Integer pageNo, Integer pageSize) {
|
||||
Page<ProductBrowseHistoryDO> page = Page.of(pageNo, pageSize);
|
||||
return selectPage(page, new LambdaQueryWrapperX<ProductBrowseHistoryDO>()
|
||||
|
@ -1,11 +1,10 @@
|
||||
package cn.iocoder.yudao.module.product.service.category;
|
||||
|
||||
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.ProductCategoryUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategorySaveReqVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@ -22,14 +21,14 @@ public interface ProductCategoryService {
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createCategory(@Valid ProductCategoryCreateReqVO createReqVO);
|
||||
Long createCategory(@Valid ProductCategorySaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新商品分类
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateCategory(@Valid ProductCategoryUpdateReqVO updateReqVO);
|
||||
void updateCategory(@Valid ProductCategorySaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除商品分类
|
||||
|
@ -3,18 +3,17 @@ package cn.iocoder.yudao.module.product.service.category;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO;
|
||||
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.controller.admin.category.vo.ProductCategorySaveReqVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.category.ProductCategoryMapper;
|
||||
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -40,26 +39,26 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
|
||||
private ProductSpuService productSpuService;
|
||||
|
||||
@Override
|
||||
public Long createCategory(ProductCategoryCreateReqVO createReqVO) {
|
||||
public Long createCategory(ProductCategorySaveReqVO createReqVO) {
|
||||
// 校验父分类存在
|
||||
validateParentProductCategory(createReqVO.getParentId());
|
||||
|
||||
// 插入
|
||||
ProductCategoryDO category = ProductCategoryConvert.INSTANCE.convert(createReqVO);
|
||||
ProductCategoryDO category = BeanUtils.toBean(createReqVO, ProductCategoryDO.class);
|
||||
productCategoryMapper.insert(category);
|
||||
// 返回
|
||||
return category.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCategory(ProductCategoryUpdateReqVO updateReqVO) {
|
||||
public void updateCategory(ProductCategorySaveReqVO updateReqVO) {
|
||||
// 校验分类是否存在
|
||||
validateProductCategoryExists(updateReqVO.getId());
|
||||
// 校验父分类存在
|
||||
validateParentProductCategory(updateReqVO.getParentId());
|
||||
|
||||
// 更新
|
||||
ProductCategoryDO updateObj = ProductCategoryConvert.INSTANCE.convert(updateReqVO);
|
||||
ProductCategoryDO updateObj = BeanUtils.toBean(updateReqVO, ProductCategoryDO.class);
|
||||
productCategoryMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
|
@ -7,14 +7,10 @@ import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommen
|
||||
import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO;
|
||||
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.dal.dataobject.comment.ProductCommentDO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品评论 Service 接口
|
||||
*
|
||||
@ -73,22 +69,4 @@ public interface ProductCommentService {
|
||||
*/
|
||||
PageResult<ProductCommentDO> getCommentPage(AppCommentPageReqVO pageVO, Boolean visible);
|
||||
|
||||
/**
|
||||
* 获得商品的评价统计
|
||||
*
|
||||
* @param spuId spu id
|
||||
* @param visible 是否可见
|
||||
* @return 评价统计
|
||||
*/
|
||||
AppCommentStatisticsRespVO getCommentStatistics(Long spuId, Boolean visible);
|
||||
|
||||
/**
|
||||
* 得到评论列表
|
||||
*
|
||||
* @param spuId 商品 id
|
||||
* @param count 数量
|
||||
* @return {@link Object}
|
||||
*/
|
||||
List<AppProductCommentRespVO> getCommentList(Long spuId, Integer count);
|
||||
|
||||
}
|
||||
|
@ -9,8 +9,6 @@ import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommen
|
||||
import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO;
|
||||
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.dal.dataobject.sku.ProductSkuDO;
|
||||
@ -18,13 +16,12 @@ import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.comment.ProductCommentMapper;
|
||||
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
|
||||
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
|
||||
@ -54,28 +51,28 @@ public class ProductCommentServiceImpl implements ProductCommentService {
|
||||
@Override
|
||||
public void createComment(ProductCommentCreateReqVO createReqVO) {
|
||||
// 校验 SKU
|
||||
ProductSkuDO skuDO = validateSku(createReqVO.getSkuId());
|
||||
ProductSkuDO sku = validateSku(createReqVO.getSkuId());
|
||||
// 校验 SPU
|
||||
ProductSpuDO spuDO = validateSpu(skuDO.getSpuId());
|
||||
ProductSpuDO spu = validateSpu(sku.getSpuId());
|
||||
|
||||
// 创建评论
|
||||
ProductCommentDO comment = ProductCommentConvert.INSTANCE.convert(createReqVO, spuDO, skuDO);
|
||||
ProductCommentDO comment = ProductCommentConvert.INSTANCE.convert(createReqVO, spu, sku);
|
||||
productCommentMapper.insert(comment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long createComment(ProductCommentCreateReqDTO createReqDTO) {
|
||||
// 校验 SKU
|
||||
ProductSkuDO skuDO = validateSku(createReqDTO.getSkuId());
|
||||
ProductSkuDO sku = validateSku(createReqDTO.getSkuId());
|
||||
// 校验 SPU
|
||||
ProductSpuDO spuDO = validateSpu(skuDO.getSpuId());
|
||||
ProductSpuDO spu = validateSpu(sku.getSpuId());
|
||||
// 校验评论
|
||||
validateCommentExists(createReqDTO.getUserId(), createReqDTO.getOrderId());
|
||||
// 获取用户详细信息
|
||||
MemberUserRespDTO user = memberUserApi.getUser(createReqDTO.getUserId());
|
||||
|
||||
// 创建评论
|
||||
ProductCommentDO comment = ProductCommentConvert.INSTANCE.convert(createReqDTO, spuDO, skuDO, user);
|
||||
ProductCommentDO comment = ProductCommentConvert.INSTANCE.convert(createReqDTO, spu, sku, user);
|
||||
productCommentMapper.insert(comment);
|
||||
return comment.getId();
|
||||
}
|
||||
@ -137,23 +134,6 @@ public class ProductCommentServiceImpl implements ProductCommentService {
|
||||
return productComment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppCommentStatisticsRespVO getCommentStatistics(Long spuId, Boolean visible) {
|
||||
return ProductCommentConvert.INSTANCE.convert(
|
||||
// 查询商品 id = spuId 的所有好评数量
|
||||
productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.GOOD_COMMENT),
|
||||
// 查询商品 id = spuId 的所有中评数量
|
||||
productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.MEDIOCRE_COMMENT),
|
||||
// 查询商品 id = spuId 的所有差评数量
|
||||
productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.NEGATIVE_COMMENT)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppProductCommentRespVO> getCommentList(Long spuId, Integer count) {
|
||||
return ProductCommentConvert.INSTANCE.convertList02(productCommentMapper.selectCommentList(spuId, count).getList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProductCommentDO> getCommentPage(AppCommentPageReqVO pageVO, Boolean visible) {
|
||||
return productCommentMapper.selectPage(pageVO, visible);
|
||||
|
@ -19,10 +19,9 @@ public interface ProductBrowseHistoryService {
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param spuId SPU 编号
|
||||
* @return 编号
|
||||
*/
|
||||
@Async
|
||||
Long createBrowseHistory(Long userId, Long spuId);
|
||||
void createBrowseHistory(Long userId, Long spuId);
|
||||
|
||||
/**
|
||||
* 隐藏用户商品浏览记录
|
||||
@ -32,15 +31,6 @@ public interface ProductBrowseHistoryService {
|
||||
*/
|
||||
void hideUserBrowseHistory(Long userId, Collection<Long> spuId);
|
||||
|
||||
/**
|
||||
* 获取用户记录数量
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param userDeleted 用户是否删除
|
||||
* @return 数量
|
||||
*/
|
||||
Long getBrowseHistoryCount(Long userId, Boolean userDeleted);
|
||||
|
||||
/**
|
||||
* 获得商品浏览记录分页
|
||||
*
|
||||
|
@ -20,27 +20,28 @@ import java.util.Collection;
|
||||
@Service
|
||||
@Validated
|
||||
public class ProductBrowseHistoryServiceImpl implements ProductBrowseHistoryService {
|
||||
|
||||
private static final int USER_STORE_MAXIMUM = 100;
|
||||
|
||||
@Resource
|
||||
private ProductBrowseHistoryMapper browseHistoryMapper;
|
||||
|
||||
@Override
|
||||
public Long createBrowseHistory(Long userId, Long spuId) {
|
||||
public void createBrowseHistory(Long userId, Long spuId) {
|
||||
// 用户未登录时不记录
|
||||
if (userId == null) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
// 情况一:同一个商品,只保留最新的一条记录
|
||||
ProductBrowseHistoryDO historyDO = browseHistoryMapper.selectOne(ProductBrowseHistoryDO::getUserId, userId, ProductBrowseHistoryDO::getSpuId, spuId);
|
||||
if (historyDO != null) {
|
||||
browseHistoryMapper.deleteById(historyDO);
|
||||
ProductBrowseHistoryDO history = browseHistoryMapper.selectByUserIdAndSpuId(userId, spuId);
|
||||
if (history != null) {
|
||||
browseHistoryMapper.deleteById(history);
|
||||
} else {
|
||||
// 情况二:限制每个用户的浏览记录的条数(只查一条最早地记录、记录总数)
|
||||
// TODO @疯狂:这里最好先查询一次数量。如果发现超过了,再删除;主要考虑,可能有部分不超过,提前就多了一次 sql 查询了
|
||||
Page<ProductBrowseHistoryDO> pageResult = browseHistoryMapper.selectPageByUserIdOrderByCreateTimeAsc(userId, 1, 1);
|
||||
if (pageResult.getTotal() >= USER_STORE_MAXIMUM) {
|
||||
// 删除最早的一条
|
||||
browseHistoryMapper.deleteById(CollUtil.getFirst(pageResult.getRecords()));
|
||||
}
|
||||
}
|
||||
@ -50,7 +51,6 @@ public class ProductBrowseHistoryServiceImpl implements ProductBrowseHistoryServ
|
||||
.setUserId(userId)
|
||||
.setSpuId(spuId);
|
||||
browseHistoryMapper.insert(browseHistory);
|
||||
return browseHistory.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -58,11 +58,6 @@ public class ProductBrowseHistoryServiceImpl implements ProductBrowseHistoryServ
|
||||
browseHistoryMapper.updateUserDeletedByUserId(userId, spuIds, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getBrowseHistoryCount(Long userId, Boolean userDeleted) {
|
||||
return browseHistoryMapper.selectCountByUserIdAndUserDeleted(userId, userDeleted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProductBrowseHistoryDO> getBrowseHistoryPage(ProductBrowseHistoryPageReqVO pageReqVO) {
|
||||
return browseHistoryMapper.selectPage(pageReqVO);
|
||||
|
@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
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.ProductCategoryUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategorySaveReqVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.category.ProductCategoryMapper;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
@ -65,7 +65,7 @@ public class ProductCategoryServiceImplTest extends BaseDbUnitTest {
|
||||
ProductCategoryDO dbCategory = randomPojo(ProductCategoryDO.class);
|
||||
productCategoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
ProductCategoryUpdateReqVO reqVO = randomPojo(ProductCategoryUpdateReqVO.class, o -> {
|
||||
ProductCategorySaveReqVO reqVO = randomPojo(ProductCategorySaveReqVO.class, o -> {
|
||||
o.setId(dbCategory.getId()); // 设置更新的 ID
|
||||
});
|
||||
// mock 父类
|
||||
@ -82,7 +82,7 @@ public class ProductCategoryServiceImplTest extends BaseDbUnitTest {
|
||||
@Test
|
||||
public void testUpdateCategory_notExists() {
|
||||
// 准备参数
|
||||
ProductCategoryUpdateReqVO reqVO = randomPojo(ProductCategoryUpdateReqVO.class);
|
||||
ProductCategorySaveReqVO reqVO = randomPojo(ProductCategorySaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> productCategoryService.updateCategory(reqVO), CATEGORY_NOT_EXISTS);
|
||||
|
@ -1,7 +1,11 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.combination;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordDetailRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordSummaryRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert;
|
||||
@ -13,6 +17,9 @@ 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 jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -20,8 +27,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -73,8 +78,18 @@ public class AppCombinationRecordController {
|
||||
@RequestParam(value = "activityId", required = false) Long activityId,
|
||||
@RequestParam("status") Integer status,
|
||||
@RequestParam(value = "count", defaultValue = "20") @Max(20) Integer count) {
|
||||
return success(CombinationActivityConvert.INSTANCE.convertList3(
|
||||
combinationRecordService.getHeadCombinationRecordList(activityId, status, count)));
|
||||
List<CombinationRecordDO> list = combinationRecordService.getHeadCombinationRecordList(activityId, status, count);
|
||||
return success(BeanUtils.toBean(list, AppCombinationRecordRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得我的拼团记录分页")
|
||||
@PreAuthenticated
|
||||
public CommonResult<PageResult<AppCombinationRecordRespVO>> getCombinationRecordPage(
|
||||
@Valid AppCombinationRecordPageReqVO pageReqVO) {
|
||||
PageResult<CombinationRecordDO> pageResult = combinationRecordService.getCombinationRecordPage(
|
||||
getLoginUserId(), pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, AppCombinationRecordRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get-detail")
|
||||
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "用户 App - 拼团记录分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class AppCombinationRecordPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "拼团状态", example = "1")
|
||||
@InEnum(value = CombinationRecordStatusEnum.class, message = "拼团状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -33,12 +33,18 @@ public class AppCombinationRecordRespVO {
|
||||
@Schema(description = "拼团状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
|
||||
private Long orderId;
|
||||
|
||||
@Schema(description = "商品名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是大黄豆")
|
||||
private String spuName;
|
||||
|
||||
@Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png")
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = "购买的商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer count;
|
||||
|
||||
@Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private Integer combinationPrice;
|
||||
|
||||
|
@ -22,6 +22,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
@RequestMapping("/promotion/diy-page")
|
||||
@Validated
|
||||
public class AppDiyPageController {
|
||||
|
||||
@Resource
|
||||
private DiyPageService diyPageService;
|
||||
|
||||
|
@ -60,7 +60,6 @@ public interface CombinationActivityConvert {
|
||||
|
||||
List<CombinationActivityRespVO> convertList(List<CombinationActivityDO> list);
|
||||
|
||||
|
||||
default PageResult<CombinationActivityPageItemRespVO> convertPage(PageResult<CombinationActivityDO> page,
|
||||
List<CombinationProductDO> productList,
|
||||
Map<Long, Integer> groupCountMap,
|
||||
@ -125,7 +124,6 @@ public interface CombinationActivityConvert {
|
||||
.setNickname(user.getNickname()).setAvatar(user.getAvatar())
|
||||
// 商品信息
|
||||
.setSpuName(spu.getName()).setPicUrl(sku.getPicUrl());
|
||||
|
||||
}
|
||||
|
||||
List<AppCombinationActivityRespVO> convertAppList(List<CombinationActivityDO> list);
|
||||
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@ -143,4 +144,11 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO
|
||||
return selectList(CombinationRecordDO::getHeadId, headId);
|
||||
}
|
||||
|
||||
default PageResult<CombinationRecordDO> selectPage(Long userId, AppCombinationRecordPageReqVO pageReqVO) {
|
||||
LambdaQueryWrapperX<CombinationRecordDO> queryWrapper = new LambdaQueryWrapperX<CombinationRecordDO>()
|
||||
.eq(CombinationRecordDO::getUserId, userId)
|
||||
.eqIfPresent(CombinationRecordDO::getStatus, pageReqVO.getStatus());
|
||||
return selectPage(pageReqVO, queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
||||
@ -163,4 +164,13 @@ public interface CombinationRecordService {
|
||||
*/
|
||||
KeyValue<Integer, Integer> expireCombinationRecord();
|
||||
|
||||
/**
|
||||
* 获得拼团记录分页数据
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param pageReqVO 分页请求
|
||||
* @return 拼团记录分页数据
|
||||
*/
|
||||
PageResult<CombinationRecordDO> getCombinationRecordPage(Long userId, AppCombinationRecordPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO;
|
||||
@ -23,14 +24,14 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationR
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationRecordMapper;
|
||||
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
|
||||
import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@ -159,7 +160,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||
// 2.1. 如果是团长需要设置 headId 为 CombinationRecordDO#HEAD_ID_GROUP
|
||||
if (record.getHeadId() == null) {
|
||||
record.setStartTime(LocalDateTime.now())
|
||||
.setExpireTime(keyValue.getKey().getStartTime().plusHours(keyValue.getKey().getLimitDuration()))
|
||||
.setExpireTime(LocalDateTime.now().plusHours(keyValue.getKey().getLimitDuration()))
|
||||
.setHeadId(CombinationRecordDO.HEAD_ID_GROUP);
|
||||
} else {
|
||||
// 2.2.有团长的情况下需要设置开始时间和过期时间为团长的
|
||||
@ -408,6 +409,11 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||
return records;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<CombinationRecordDO> getCombinationRecordPage(Long userId, AppCombinationRecordPageReqVO pageReqVO) {
|
||||
return combinationRecordMapper.selectPage(userId, pageReqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得自身的代理对象,解决 AOP 生效问题
|
||||
*
|
||||
|
@ -21,18 +21,17 @@ import com.google.common.collect.Maps;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "用户 App - 交易订单")
|
||||
|
Loading…
Reference in New Issue
Block a user