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