Commit 023a7b14d88f2ae8f56e9f46fdfb680aa54d3775
1 parent
f4a55d3e
✨ 统一 JDK8 和 JDK21 相关代码
Showing
5 changed files
with
8 additions
and
98 deletions
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; |
| 9 | 9 | import cn.iocoder.yudao.framework.common.pojo.SortingField; |
| 10 | 10 | import org.springframework.util.Assert; |
| 11 | 11 | |
| 12 | -import java.util.List; | |
| 12 | +import static java.util.Collections.singletonList; | |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * {@link cn.iocoder.yudao.framework.common.pojo.PageParam} 工具类 |
| ... | ... | @@ -60,7 +60,7 @@ public class PageUtils { |
| 60 | 60 | */ |
| 61 | 61 | public static <T> void buildDefaultSortingField(SortablePageParam sortablePageParam, Func1<T, ?> func) { |
| 62 | 62 | if (sortablePageParam != null && CollUtil.isEmpty(sortablePageParam.getSortingFields())) { |
| 63 | - sortablePageParam.setSortingFields(List.of(buildSortingField(func))); | |
| 63 | + sortablePageParam.setSortingFields(singletonList(buildSortingField(func))); | |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | ... | ... |
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; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.date.DateUtil; |
| 4 | 4 | import cn.hutool.core.util.RandomUtil; |
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | 5 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 7 | -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO; | |
| 8 | 6 | import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyReqVO; |
| 9 | -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentRespVO; | |
| 10 | 7 | import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO; |
| 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.convert.comment.ProductCommentConvert; | |
| 14 | 8 | import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; |
| 15 | 9 | import cn.iocoder.yudao.module.product.dal.mysql.comment.ProductCommentMapper; |
| 16 | -import cn.iocoder.yudao.module.product.enums.comment.ProductCommentScoresEnum; | |
| 17 | 10 | import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; |
| 18 | 11 | import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; |
| 12 | +import jakarta.annotation.Resource; | |
| 19 | 13 | import org.junit.jupiter.api.Disabled; |
| 20 | 14 | import org.junit.jupiter.api.Test; |
| 21 | 15 | import org.springframework.boot.test.mock.mockito.MockBean; |
| 22 | 16 | import org.springframework.context.annotation.Import; |
| 23 | 17 | import org.springframework.context.annotation.Lazy; |
| 24 | 18 | |
| 25 | -import jakarta.annotation.Resource; | |
| 26 | -import java.time.LocalDateTime; | |
| 27 | 19 | import java.util.Date; |
| 28 | 20 | |
| 29 | -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 30 | 21 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; |
| 31 | 22 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; |
| 32 | 23 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| ... | ... | @@ -75,87 +66,6 @@ public class ProductCommentServiceImplTest extends BaseDbUnitTest { |
| 75 | 66 | } |
| 76 | 67 | |
| 77 | 68 | @Test |
| 78 | - public void testGetCommentPage_success() { | |
| 79 | - // 准备参数 | |
| 80 | - ProductCommentDO productComment = randomPojo(ProductCommentDO.class, o -> { | |
| 81 | - o.setUserNickname("王二狗"); | |
| 82 | - o.setSpuName("感冒药"); | |
| 83 | - o.setScores(ProductCommentScoresEnum.FOUR.getScores()); | |
| 84 | - o.setReplyStatus(Boolean.TRUE); | |
| 85 | - o.setVisible(Boolean.TRUE); | |
| 86 | - o.setId(generateId()); | |
| 87 | - o.setUserId(generateId()); | |
| 88 | - o.setAnonymous(Boolean.TRUE); | |
| 89 | - o.setOrderId(generateId()); | |
| 90 | - o.setOrderItemId(generateId()); | |
| 91 | - o.setSpuId(generateId()); | |
| 92 | - o.setSkuId(generateId()); | |
| 93 | - o.setDescriptionScores(ProductCommentScoresEnum.FOUR.getScores()); | |
| 94 | - o.setBenefitScores(ProductCommentScoresEnum.FOUR.getScores()); | |
| 95 | - o.setContent("真好吃"); | |
| 96 | - o.setReplyUserId(generateId()); | |
| 97 | - o.setReplyContent("确实"); | |
| 98 | - o.setReplyTime(LocalDateTime.now()); | |
| 99 | - o.setCreateTime(LocalDateTime.now()); | |
| 100 | - o.setUpdateTime(LocalDateTime.now()); | |
| 101 | - }); | |
| 102 | - productCommentMapper.insert(productComment); | |
| 103 | - | |
| 104 | - Long orderId = productComment.getOrderId(); | |
| 105 | - Long spuId = productComment.getSpuId(); | |
| 106 | - | |
| 107 | - // 测试 userNickname 不匹配 | |
| 108 | - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setUserNickname("王三").setScores(ProductCommentScoresEnum.ONE.getScores()))); | |
| 109 | - // 测试 orderId 不匹配 | |
| 110 | - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setOrderId(generateId()))); | |
| 111 | - // 测试 spuId 不匹配 | |
| 112 | - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setSpuId(generateId()))); | |
| 113 | - // 测试 spuName 不匹配 | |
| 114 | - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setSpuName("感康"))); | |
| 115 | - // 测试 scores 不匹配 | |
| 116 | - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setScores(ProductCommentScoresEnum.ONE.getScores()))); | |
| 117 | - // 测试 replied 不匹配 | |
| 118 | - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setReplyStatus(Boolean.FALSE))); | |
| 119 | - // 测试 visible 不匹配 | |
| 120 | - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setVisible(Boolean.FALSE))); | |
| 121 | - | |
| 122 | - // 调用 | |
| 123 | - ProductCommentPageReqVO productCommentPageReqVO = new ProductCommentPageReqVO(); | |
| 124 | - productCommentPageReqVO.setUserNickname("王二"); | |
| 125 | - productCommentPageReqVO.setOrderId(orderId); | |
| 126 | - productCommentPageReqVO.setSpuId(spuId); | |
| 127 | - productCommentPageReqVO.setSpuName("感冒药"); | |
| 128 | - productCommentPageReqVO.setScores(ProductCommentScoresEnum.FOUR.getScores()); | |
| 129 | - productCommentPageReqVO.setReplyStatus(Boolean.TRUE); | |
| 130 | - | |
| 131 | - PageResult<ProductCommentDO> commentPage = productCommentService.getCommentPage(productCommentPageReqVO); | |
| 132 | - PageResult<ProductCommentRespVO> result = ProductCommentConvert.INSTANCE.convertPage(productCommentMapper.selectPage(productCommentPageReqVO)); | |
| 133 | - assertEquals(result.getTotal(), commentPage.getTotal()); | |
| 134 | - | |
| 135 | - PageResult<ProductCommentDO> all = productCommentService.getCommentPage(new ProductCommentPageReqVO()); | |
| 136 | - assertEquals(8, all.getTotal()); | |
| 137 | - | |
| 138 | - // 测试获取所有商品分页评论数据 | |
| 139 | - PageResult<ProductCommentDO> result1 = productCommentService.getCommentPage(new AppCommentPageReqVO(), Boolean.TRUE); | |
| 140 | - assertEquals(7, result1.getTotal()); | |
| 141 | - | |
| 142 | - // 测试获取所有商品分页中评数据 | |
| 143 | - PageResult<ProductCommentDO> result2 = productCommentService.getCommentPage(new AppCommentPageReqVO().setType(AppCommentPageReqVO.MEDIOCRE_COMMENT), Boolean.TRUE); | |
| 144 | - assertEquals(2, result2.getTotal()); | |
| 145 | - | |
| 146 | - // 测试获取指定 spuId 商品分页中评数据 | |
| 147 | - PageResult<ProductCommentDO> result3 = productCommentService.getCommentPage(new AppCommentPageReqVO().setSpuId(spuId).setType(AppCommentPageReqVO.MEDIOCRE_COMMENT), Boolean.TRUE); | |
| 148 | - assertEquals(2, result3.getTotal()); | |
| 149 | - | |
| 150 | - // 测试分页 tab count | |
| 151 | - AppCommentStatisticsRespVO tabsCount = productCommentService.getCommentStatistics(spuId, Boolean.TRUE); | |
| 152 | - assertEquals(4, tabsCount.getGoodCount()); | |
| 153 | - assertEquals(2, tabsCount.getMediocreCount()); | |
| 154 | - assertEquals(0, tabsCount.getNegativeCount()); | |
| 155 | - | |
| 156 | - } | |
| 157 | - | |
| 158 | - @Test | |
| 159 | 69 | public void testUpdateCommentVisible_success() { |
| 160 | 70 | // mock 测试 |
| 161 | 71 | ProductCommentDO productComment = randomPojo(ProductCommentDO.class, o -> { | ... | ... |
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.*; |
| 29 | 29 | |
| 30 | 30 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 31 | 31 | import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; |
| 32 | +import static java.util.Collections.singletonList; | |
| 32 | 33 | |
| 33 | 34 | @Tag(name = "用户 App - 优惠劵模板") |
| 34 | 35 | @RestController |
| ... | ... | @@ -53,7 +54,7 @@ public class AppCouponTemplateController { |
| 53 | 54 | return success(null); |
| 54 | 55 | } |
| 55 | 56 | // 处理是否可领取 |
| 56 | - Map<Long, Boolean> canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), List.of(template)); | |
| 57 | + Map<Long, Boolean> canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), singletonList(template)); | |
| 57 | 58 | return success(BeanUtils.toBean(template, AppCouponTemplateRespVO.class) |
| 58 | 59 | .setCanTake(canCanTakeMap.get(template.getId()))); |
| 59 | 60 | } |
| ... | ... | @@ -72,7 +73,7 @@ public class AppCouponTemplateController { |
| 72 | 73 | // 1.1 处理查询条件:商品范围编号 |
| 73 | 74 | Long productScopeValue = getProductScopeValue(productScope, spuId); |
| 74 | 75 | // 1.2 处理查询条件:领取方式 = 直接领取 |
| 75 | - List<Integer> canTakeTypes = Collections.singletonList(CouponTakeTypeEnum.USER.getValue()); | |
| 76 | + List<Integer> canTakeTypes = singletonList(CouponTakeTypeEnum.USER.getValue()); | |
| 76 | 77 | |
| 77 | 78 | // 2. 查询 |
| 78 | 79 | List<CouponTemplateDO> list = couponTemplateService.getCouponTemplateList(canTakeTypes, productScope, |
| ... | ... | @@ -104,7 +105,7 @@ public class AppCouponTemplateController { |
| 104 | 105 | // 1.1 处理查询条件:商品范围编号 |
| 105 | 106 | Long productScopeValue = getProductScopeValue(pageReqVO.getProductScope(), pageReqVO.getSpuId()); |
| 106 | 107 | // 1.2 处理查询条件:领取方式 = 直接领取 |
| 107 | - List<Integer> canTakeTypes = Collections.singletonList(CouponTakeTypeEnum.USER.getValue()); | |
| 108 | + List<Integer> canTakeTypes = singletonList(CouponTakeTypeEnum.USER.getValue()); | |
| 108 | 109 | |
| 109 | 110 | // 2. 分页查询 |
| 110 | 111 | PageResult<CouponTemplateDO> pageResult = couponTemplateService.getCouponTemplatePage( | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/log/AppAfterSaleLogRespVO.java
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 { |
| 37 | 37 | |
| 38 | 38 | OperateLogV2RespDTO convert(OperateLogV2DO operateLogV2DO); |
| 39 | 39 | |
| 40 | - private List<OperateLogV2RespDTO> setUserInfo(List<OperateLogV2DO> logList, List<AdminUserDO> userList) { | |
| 40 | + default List<OperateLogV2RespDTO> setUserInfo(List<OperateLogV2DO> logList, List<AdminUserDO> userList) { | |
| 41 | 41 | Map<Long, AdminUserDO> userMap = convertMap(userList, AdminUserDO::getId); |
| 42 | 42 | return CollectionUtils.convertList(logList, item -> { |
| 43 | 43 | OperateLogV2RespDTO respDTO = convert(item); | ... | ... |