diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/object/PageUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/object/PageUtils.java index 0abdf7be22..cf077dbe7a 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/object/PageUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/object/PageUtils.java @@ -9,7 +9,7 @@ import cn.iocoder.yudao.framework.common.pojo.SortablePageParam; import cn.iocoder.yudao.framework.common.pojo.SortingField; import org.springframework.util.Assert; -import java.util.List; +import static java.util.Collections.singletonList; /** * {@link cn.iocoder.yudao.framework.common.pojo.PageParam} 工具类 @@ -60,7 +60,7 @@ public class PageUtils { */ public static void buildDefaultSortingField(SortablePageParam sortablePageParam, Func1 func) { if (sortablePageParam != null && CollUtil.isEmpty(sortablePageParam.getSortingFields())) { - sortablePageParam.setSortingFields(List.of(buildSortingField(func))); + sortablePageParam.setSortingFields(singletonList(buildSortingField(func))); } } diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java index 83ec2c456b..491eef7645 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java +++ b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java @@ -2,31 +2,22 @@ package cn.iocoder.yudao.module.product.service.comment; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO; import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentRespVO; import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentStatisticsRespVO; -import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert; import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; import cn.iocoder.yudao.module.product.dal.mysql.comment.ProductCommentMapper; -import cn.iocoder.yudao.module.product.enums.comment.ProductCommentScoresEnum; import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; +import jakarta.annotation.Resource; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Lazy; -import jakarta.annotation.Resource; -import java.time.LocalDateTime; import java.util.Date; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -74,87 +65,6 @@ public class ProductCommentServiceImplTest extends BaseDbUnitTest { assertPojoEquals(productComment, comment); } - @Test - public void testGetCommentPage_success() { - // 准备参数 - ProductCommentDO productComment = randomPojo(ProductCommentDO.class, o -> { - o.setUserNickname("王二狗"); - o.setSpuName("感冒药"); - o.setScores(ProductCommentScoresEnum.FOUR.getScores()); - o.setReplyStatus(Boolean.TRUE); - o.setVisible(Boolean.TRUE); - o.setId(generateId()); - o.setUserId(generateId()); - o.setAnonymous(Boolean.TRUE); - o.setOrderId(generateId()); - o.setOrderItemId(generateId()); - o.setSpuId(generateId()); - o.setSkuId(generateId()); - o.setDescriptionScores(ProductCommentScoresEnum.FOUR.getScores()); - o.setBenefitScores(ProductCommentScoresEnum.FOUR.getScores()); - o.setContent("真好吃"); - o.setReplyUserId(generateId()); - o.setReplyContent("确实"); - o.setReplyTime(LocalDateTime.now()); - o.setCreateTime(LocalDateTime.now()); - o.setUpdateTime(LocalDateTime.now()); - }); - productCommentMapper.insert(productComment); - - Long orderId = productComment.getOrderId(); - Long spuId = productComment.getSpuId(); - - // 测试 userNickname 不匹配 - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setUserNickname("王三").setScores(ProductCommentScoresEnum.ONE.getScores()))); - // 测试 orderId 不匹配 - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setOrderId(generateId()))); - // 测试 spuId 不匹配 - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setSpuId(generateId()))); - // 测试 spuName 不匹配 - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setSpuName("感康"))); - // 测试 scores 不匹配 - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setScores(ProductCommentScoresEnum.ONE.getScores()))); - // 测试 replied 不匹配 - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setReplyStatus(Boolean.FALSE))); - // 测试 visible 不匹配 - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setVisible(Boolean.FALSE))); - - // 调用 - ProductCommentPageReqVO productCommentPageReqVO = new ProductCommentPageReqVO(); - productCommentPageReqVO.setUserNickname("王二"); - productCommentPageReqVO.setOrderId(orderId); - productCommentPageReqVO.setSpuId(spuId); - productCommentPageReqVO.setSpuName("感冒药"); - productCommentPageReqVO.setScores(ProductCommentScoresEnum.FOUR.getScores()); - productCommentPageReqVO.setReplyStatus(Boolean.TRUE); - - PageResult commentPage = productCommentService.getCommentPage(productCommentPageReqVO); - PageResult result = ProductCommentConvert.INSTANCE.convertPage(productCommentMapper.selectPage(productCommentPageReqVO)); - assertEquals(result.getTotal(), commentPage.getTotal()); - - PageResult all = productCommentService.getCommentPage(new ProductCommentPageReqVO()); - assertEquals(8, all.getTotal()); - - // 测试获取所有商品分页评论数据 - PageResult result1 = productCommentService.getCommentPage(new AppCommentPageReqVO(), Boolean.TRUE); - assertEquals(7, result1.getTotal()); - - // 测试获取所有商品分页中评数据 - PageResult result2 = productCommentService.getCommentPage(new AppCommentPageReqVO().setType(AppCommentPageReqVO.MEDIOCRE_COMMENT), Boolean.TRUE); - assertEquals(2, result2.getTotal()); - - // 测试获取指定 spuId 商品分页中评数据 - PageResult result3 = productCommentService.getCommentPage(new AppCommentPageReqVO().setSpuId(spuId).setType(AppCommentPageReqVO.MEDIOCRE_COMMENT), Boolean.TRUE); - assertEquals(2, result3.getTotal()); - - // 测试分页 tab count - AppCommentStatisticsRespVO tabsCount = productCommentService.getCommentStatistics(spuId, Boolean.TRUE); - assertEquals(4, tabsCount.getGoodCount()); - assertEquals(2, tabsCount.getMediocreCount()); - assertEquals(0, tabsCount.getNegativeCount()); - - } - @Test public void testUpdateCommentVisible_success() { // mock 测试 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java index 27ac4c14ad..586618e925 100755 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java @@ -29,6 +29,7 @@ import java.util.*; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; +import static java.util.Collections.singletonList; @Tag(name = "用户 App - 优惠劵模板") @RestController @@ -53,7 +54,7 @@ public class AppCouponTemplateController { return success(null); } // 处理是否可领取 - Map canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), List.of(template)); + Map canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), singletonList(template)); return success(BeanUtils.toBean(template, AppCouponTemplateRespVO.class) .setCanTake(canCanTakeMap.get(template.getId()))); } @@ -72,7 +73,7 @@ public class AppCouponTemplateController { // 1.1 处理查询条件:商品范围编号 Long productScopeValue = getProductScopeValue(productScope, spuId); // 1.2 处理查询条件:领取方式 = 直接领取 - List canTakeTypes = Collections.singletonList(CouponTakeTypeEnum.USER.getValue()); + List canTakeTypes = singletonList(CouponTakeTypeEnum.USER.getValue()); // 2. 查询 List list = couponTemplateService.getCouponTemplateList(canTakeTypes, productScope, @@ -104,7 +105,7 @@ public class AppCouponTemplateController { // 1.1 处理查询条件:商品范围编号 Long productScopeValue = getProductScopeValue(pageReqVO.getProductScope(), pageReqVO.getSpuId()); // 1.2 处理查询条件:领取方式 = 直接领取 - List canTakeTypes = Collections.singletonList(CouponTakeTypeEnum.USER.getValue()); + List canTakeTypes = singletonList(CouponTakeTypeEnum.USER.getValue()); // 2. 分页查询 PageResult pageResult = couponTemplateService.getCouponTemplatePage( diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/log/AppAfterSaleLogRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/log/AppAfterSaleLogRespVO.java index 94af3136c5..4d7fb66a49 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/log/AppAfterSaleLogRespVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/log/AppAfterSaleLogRespVO.java @@ -1,7 +1,6 @@ package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.log; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotNull; import lombok.Data; import java.time.LocalDateTime; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/logger/OperateLogConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/logger/OperateLogConvert.java index ffbf8d6f4a..9500a35f5b 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/logger/OperateLogConvert.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/logger/OperateLogConvert.java @@ -37,7 +37,7 @@ public interface OperateLogConvert { OperateLogV2RespDTO convert(OperateLogV2DO operateLogV2DO); - private List setUserInfo(List logList, List userList) { + default List setUserInfo(List logList, List userList) { Map userMap = convertMap(userList, AdminUserDO::getId); return CollectionUtils.convertList(logList, item -> { OperateLogV2RespDTO respDTO = convert(item);