Commit 7bc3b7b2ff73a09c766168092d316fda205c8b76
Committed by
Gitee
!666 营销活动:新增文章管理,文章分类管理
Merge pull request !666 from puhui999/feature/mall_product
Showing
50 changed files
with
1918 additions
and
105 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java
| @@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; | @@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; | ||
| 8 | import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; | 8 | import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; |
| 9 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | 9 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 10 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | 10 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 11 | +import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; | ||
| 11 | import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; | 12 | import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; |
| 12 | import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; | 13 | import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; |
| 13 | import io.swagger.v3.oas.annotations.Operation; | 14 | import io.swagger.v3.oas.annotations.Operation; |
| @@ -22,6 +23,7 @@ import javax.servlet.http.HttpServletResponse; | @@ -22,6 +23,7 @@ import javax.servlet.http.HttpServletResponse; | ||
| 22 | import javax.validation.Valid; | 23 | import javax.validation.Valid; |
| 23 | import java.io.IOException; | 24 | import java.io.IOException; |
| 24 | import java.util.Collection; | 25 | import java.util.Collection; |
| 26 | +import java.util.Comparator; | ||
| 25 | import java.util.List; | 27 | import java.util.List; |
| 26 | import java.util.Map; | 28 | import java.util.Map; |
| 27 | 29 | ||
| @@ -88,11 +90,13 @@ public class ProductSpuController { | @@ -88,11 +90,13 @@ public class ProductSpuController { | ||
| 88 | return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus)); | 90 | return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus)); |
| 89 | } | 91 | } |
| 90 | 92 | ||
| 91 | - @GetMapping("/get-simple-list") | 93 | + @GetMapping("/list-all-simple") |
| 92 | @Operation(summary = "获得商品 SPU 精简列表") | 94 | @Operation(summary = "获得商品 SPU 精简列表") |
| 93 | @PreAuthorize("@ss.hasPermission('product:spu:query')") | 95 | @PreAuthorize("@ss.hasPermission('product:spu:query')") |
| 94 | public CommonResult<List<ProductSpuSimpleRespVO>> getSpuSimpleList() { | 96 | public CommonResult<List<ProductSpuSimpleRespVO>> getSpuSimpleList() { |
| 95 | - List<ProductSpuDO> list = productSpuService.getSpuList(); | 97 | + List<ProductSpuDO> list = productSpuService.getSpuListByStatus(ProductSpuStatusEnum.ENABLE.getStatus()); |
| 98 | + // 降序排序后,返回给前端 | ||
| 99 | + list.sort(Comparator.comparing(ProductSpuDO::getSort).reversed()); | ||
| 96 | return success(ProductSpuConvert.INSTANCE.convertList02(list)); | 100 | return success(ProductSpuConvert.INSTANCE.convertList02(list)); |
| 97 | } | 101 | } |
| 98 | 102 |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java
| @@ -68,11 +68,12 @@ public interface ProductSpuService { | @@ -68,11 +68,12 @@ public interface ProductSpuService { | ||
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | /** | 70 | /** |
| 71 | - * 获得所有商品 SPU 列表 | 71 | + * 获得指定状态的商品 SPU 列表 |
| 72 | * | 72 | * |
| 73 | + * @param status 状态 | ||
| 73 | * @return 商品 SPU 列表 | 74 | * @return 商品 SPU 列表 |
| 74 | */ | 75 | */ |
| 75 | - List<ProductSpuDO> getSpuList(); | 76 | + List<ProductSpuDO> getSpuListByStatus(Integer status); |
| 76 | 77 | ||
| 77 | /** | 78 | /** |
| 78 | * 获得所有商品 SPU 列表 | 79 | * 获得所有商品 SPU 列表 |
| @@ -146,4 +147,5 @@ public interface ProductSpuService { | @@ -146,4 +147,5 @@ public interface ProductSpuService { | ||
| 146 | * @return 商品 SPU 列表 | 147 | * @return 商品 SPU 列表 |
| 147 | */ | 148 | */ |
| 148 | List<ProductSpuDO> validateSpuList(Collection<Long> ids); | 149 | List<ProductSpuDO> validateSpuList(Collection<Long> ids); |
| 150 | + | ||
| 149 | } | 151 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java
| @@ -196,8 +196,8 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -196,8 +196,8 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | @Override | 198 | @Override |
| 199 | - public List<ProductSpuDO> getSpuList() { | ||
| 200 | - return productSpuMapper.selectList(); | 199 | + public List<ProductSpuDO> getSpuListByStatus(Integer status) { |
| 200 | + return productSpuMapper.selectList(ProductSpuDO::getStatus, status); | ||
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | @Override | 203 | @Override |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java
| 1 | package cn.iocoder.yudao.module.promotion.api.combination; | 1 | package cn.iocoder.yudao.module.promotion.api.combination; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.core.KeyValue; | ||
| 4 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; | 3 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 4 | +import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; | ||
| 5 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; | 5 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; |
| 6 | 6 | ||
| 7 | import javax.validation.Valid; | 7 | import javax.validation.Valid; |
| @@ -28,9 +28,9 @@ public interface CombinationRecordApi { | @@ -28,9 +28,9 @@ public interface CombinationRecordApi { | ||
| 28 | * 创建开团记录 | 28 | * 创建开团记录 |
| 29 | * | 29 | * |
| 30 | * @param reqDTO 请求 DTO | 30 | * @param reqDTO 请求 DTO |
| 31 | - * @return key 开团记录编号、value 团长编号 | 31 | + * @return 团信息 |
| 32 | */ | 32 | */ |
| 33 | - KeyValue<Long, Long> createCombinationRecord(@Valid CombinationRecordCreateReqDTO reqDTO); | 33 | + CombinationRecordCreateRespDTO createCombinationRecord(@Valid CombinationRecordCreateReqDTO reqDTO); |
| 34 | 34 | ||
| 35 | /** | 35 | /** |
| 36 | * 查询拼团记录是否成功 | 36 | * 查询拼团记录是否成功 |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateRespDTO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.api.combination.dto; | ||
| 2 | + | ||
| 3 | +import lombok.Data; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 拼团记录的创建 Response DTO | ||
| 7 | + * | ||
| 8 | + * @author HUIHUI | ||
| 9 | + */ | ||
| 10 | +@Data | ||
| 11 | +public class CombinationRecordCreateRespDTO { | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * 拼团活动编号 | ||
| 15 | + * | ||
| 16 | + * 关联 CombinationActivityDO 的 id 字段 | ||
| 17 | + */ | ||
| 18 | + private Long combinationActivityId; | ||
| 19 | + /** | ||
| 20 | + * 拼团团长编号 | ||
| 21 | + * | ||
| 22 | + * 关联 CombinationRecordDO 的 headId 字段 | ||
| 23 | + */ | ||
| 24 | + private Long combinationHeadId; | ||
| 25 | + /** | ||
| 26 | + * 拼团记录编号 | ||
| 27 | + * | ||
| 28 | + * 关联 CombinationRecordDO 的 id 字段 | ||
| 29 | + */ | ||
| 30 | + private Long combinationRecordId; | ||
| 31 | + | ||
| 32 | +} |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/DictTypeConstants.java
0 → 100644
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java
| @@ -110,4 +110,10 @@ public interface ErrorCodeConstants { | @@ -110,4 +110,10 @@ public interface ErrorCodeConstants { | ||
| 110 | ErrorCode BARGAIN_HELP_CREATE_FAIL_CONFLICT = new ErrorCode(1_013_014_003, "助力失败,请重试"); | 110 | ErrorCode BARGAIN_HELP_CREATE_FAIL_CONFLICT = new ErrorCode(1_013_014_003, "助力失败,请重试"); |
| 111 | ErrorCode BARGAIN_HELP_CREATE_FAIL_HELP_EXISTS = new ErrorCode(1_013_014_004, "助力失败,您已经助力过了"); | 111 | ErrorCode BARGAIN_HELP_CREATE_FAIL_HELP_EXISTS = new ErrorCode(1_013_014_004, "助力失败,您已经助力过了"); |
| 112 | 112 | ||
| 113 | + // ========== 文章分类 1-013-015-000 ========== | ||
| 114 | + ErrorCode ARTICLE_CATEGORY_NOT_EXISTS = new ErrorCode(1_013_015_000, "分类不存在"); | ||
| 115 | + | ||
| 116 | + // ========== 文章管理 1-013-016-000 ========== | ||
| 117 | + ErrorCode ARTICLE_NOT_EXISTS = new ErrorCode(1_013_016_000, "文章管理不存在"); | ||
| 118 | + | ||
| 113 | } | 119 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java
| 1 | package cn.iocoder.yudao.module.promotion.api.combination; | 1 | package cn.iocoder.yudao.module.promotion.api.combination; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.core.KeyValue; | ||
| 4 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; | 3 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 4 | +import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; | ||
| 5 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; | 5 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; |
| 6 | +import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; | ||
| 6 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; |
| 7 | import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; | 8 | import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; |
| 8 | import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; | 9 | import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; |
| @@ -29,10 +30,9 @@ public class CombinationRecordApiImpl implements CombinationRecordApi { | @@ -29,10 +30,9 @@ public class CombinationRecordApiImpl implements CombinationRecordApi { | ||
| 29 | recordService.validateCombinationRecord(userId, activityId, headId, skuId, count); | 30 | recordService.validateCombinationRecord(userId, activityId, headId, skuId, count); |
| 30 | } | 31 | } |
| 31 | 32 | ||
| 32 | - // TODO @puhui999:搞个创建的 RespDTO 哈; | ||
| 33 | @Override | 33 | @Override |
| 34 | - public KeyValue<Long, Long> createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { | ||
| 35 | - return recordService.createCombinationRecord(reqDTO); | 34 | + public CombinationRecordCreateRespDTO createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { |
| 35 | + return CombinationActivityConvert.INSTANCE.convert4(recordService.createCombinationRecord(reqDTO)); | ||
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | @Override | 38 | @Override |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleCategoryController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 7 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.*; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; | ||
| 10 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; | ||
| 11 | +import cn.iocoder.yudao.module.promotion.service.article.ArticleCategoryService; | ||
| 12 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 13 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 14 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 15 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 16 | +import org.springframework.validation.annotation.Validated; | ||
| 17 | +import org.springframework.web.bind.annotation.*; | ||
| 18 | + | ||
| 19 | +import javax.annotation.Resource; | ||
| 20 | +import javax.servlet.http.HttpServletResponse; | ||
| 21 | +import javax.validation.Valid; | ||
| 22 | +import java.io.IOException; | ||
| 23 | +import java.util.Collection; | ||
| 24 | +import java.util.Comparator; | ||
| 25 | +import java.util.List; | ||
| 26 | + | ||
| 27 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 28 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | ||
| 29 | + | ||
| 30 | +@Tag(name = "管理后台 - 文章分类") | ||
| 31 | +@RestController | ||
| 32 | +@RequestMapping("/promotion/article-category") | ||
| 33 | +@Validated | ||
| 34 | +public class ArticleCategoryController { | ||
| 35 | + | ||
| 36 | + @Resource | ||
| 37 | + private ArticleCategoryService articleCategoryService; | ||
| 38 | + | ||
| 39 | + @PostMapping("/create") | ||
| 40 | + @Operation(summary = "创建文章分类") | ||
| 41 | + @PreAuthorize("@ss.hasPermission('promotion:article-category:create')") | ||
| 42 | + public CommonResult<Long> createArticleCategory(@Valid @RequestBody ArticleCategoryCreateReqVO createReqVO) { | ||
| 43 | + return success(articleCategoryService.createArticleCategory(createReqVO)); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @PutMapping("/update") | ||
| 47 | + @Operation(summary = "更新文章分类") | ||
| 48 | + @PreAuthorize("@ss.hasPermission('promotion:article-category:update')") | ||
| 49 | + public CommonResult<Boolean> updateArticleCategory(@Valid @RequestBody ArticleCategoryUpdateReqVO updateReqVO) { | ||
| 50 | + articleCategoryService.updateArticleCategory(updateReqVO); | ||
| 51 | + return success(true); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @DeleteMapping("/delete") | ||
| 55 | + @Operation(summary = "删除文章分类") | ||
| 56 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 57 | + @PreAuthorize("@ss.hasPermission('promotion:article-category:delete')") | ||
| 58 | + public CommonResult<Boolean> deleteArticleCategory(@RequestParam("id") Long id) { | ||
| 59 | + articleCategoryService.deleteArticleCategory(id); | ||
| 60 | + return success(true); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + @GetMapping("/get") | ||
| 64 | + @Operation(summary = "获得文章分类") | ||
| 65 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 66 | + @PreAuthorize("@ss.hasPermission('promotion:article-category:query')") | ||
| 67 | + public CommonResult<ArticleCategoryRespVO> getArticleCategory(@RequestParam("id") Long id) { | ||
| 68 | + ArticleCategoryDO articleCategory = articleCategoryService.getArticleCategory(id); | ||
| 69 | + return success(ArticleCategoryConvert.INSTANCE.convert(articleCategory)); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @GetMapping("/list") | ||
| 73 | + @Operation(summary = "获得文章分类列表") | ||
| 74 | + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") | ||
| 75 | + @PreAuthorize("@ss.hasPermission('promotion:article-category:query')") | ||
| 76 | + public CommonResult<List<ArticleCategoryRespVO>> getArticleCategoryList(@RequestParam("ids") Collection<Long> ids) { | ||
| 77 | + List<ArticleCategoryDO> list = articleCategoryService.getArticleCategoryList(ids); | ||
| 78 | + return success(ArticleCategoryConvert.INSTANCE.convertList(list)); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + @GetMapping("/list-all-simple") | ||
| 82 | + @Operation(summary = "获取文章分类精简信息列表", description = "只包含被开启的文章分类,主要用于前端的下拉选项") | ||
| 83 | + public CommonResult<List<ArticleCategorySimpleRespVO>> getSimpleDeptList() { | ||
| 84 | + // 获得部门列表,只要开启状态的 | ||
| 85 | + List<ArticleCategoryDO> list = articleCategoryService.getArticleCategoryListByStatus(CommonStatusEnum.ENABLE.getStatus()); | ||
| 86 | + // 降序排序后,返回给前端 | ||
| 87 | + list.sort(Comparator.comparing(ArticleCategoryDO::getSort).reversed()); | ||
| 88 | + return success(ArticleCategoryConvert.INSTANCE.convertList03(list)); | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + @GetMapping("/page") | ||
| 92 | + @Operation(summary = "获得文章分类分页") | ||
| 93 | + @PreAuthorize("@ss.hasPermission('promotion:article-category:query')") | ||
| 94 | + public CommonResult<PageResult<ArticleCategoryRespVO>> getArticleCategoryPage(@Valid ArticleCategoryPageReqVO pageVO) { | ||
| 95 | + PageResult<ArticleCategoryDO> pageResult = articleCategoryService.getArticleCategoryPage(pageVO); | ||
| 96 | + return success(ArticleCategoryConvert.INSTANCE.convertPage(pageResult)); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + @GetMapping("/export-excel") | ||
| 100 | + @Operation(summary = "导出文章分类 Excel") | ||
| 101 | + @PreAuthorize("@ss.hasPermission('promotion:article-category:export')") | ||
| 102 | + @OperateLog(type = EXPORT) | ||
| 103 | + public void exportArticleCategoryExcel(@Valid ArticleCategoryExportReqVO exportReqVO, | ||
| 104 | + HttpServletResponse response) throws IOException { | ||
| 105 | + List<ArticleCategoryDO> list = articleCategoryService.getArticleCategoryList(exportReqVO); | ||
| 106 | + // 导出 Excel | ||
| 107 | + List<ArticleCategoryExcelVO> datas = ArticleCategoryConvert.INSTANCE.convertList02(list); | ||
| 108 | + ExcelUtils.write(response, "文章分类.xls", "数据", ArticleCategoryExcelVO.class, datas); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 6 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.*; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; | ||
| 10 | +import cn.iocoder.yudao.module.promotion.service.article.ArticleService; | ||
| 11 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 12 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 13 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 14 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 15 | +import org.springframework.validation.annotation.Validated; | ||
| 16 | +import org.springframework.web.bind.annotation.*; | ||
| 17 | + | ||
| 18 | +import javax.annotation.Resource; | ||
| 19 | +import javax.servlet.http.HttpServletResponse; | ||
| 20 | +import javax.validation.Valid; | ||
| 21 | +import java.io.IOException; | ||
| 22 | +import java.util.Collection; | ||
| 23 | +import java.util.List; | ||
| 24 | + | ||
| 25 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 26 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | ||
| 27 | + | ||
| 28 | +@Tag(name = "管理后台 - 文章管理") | ||
| 29 | +@RestController | ||
| 30 | +@RequestMapping("/promotion/article") | ||
| 31 | +@Validated | ||
| 32 | +public class ArticleController { | ||
| 33 | + | ||
| 34 | + @Resource | ||
| 35 | + private ArticleService articleService; | ||
| 36 | + | ||
| 37 | + @PostMapping("/create") | ||
| 38 | + @Operation(summary = "创建文章管理") | ||
| 39 | + @PreAuthorize("@ss.hasPermission('promotion:article:create')") | ||
| 40 | + public CommonResult<Long> createArticle(@Valid @RequestBody ArticleCreateReqVO createReqVO) { | ||
| 41 | + return success(articleService.createArticle(createReqVO)); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + @PutMapping("/update") | ||
| 45 | + @Operation(summary = "更新文章管理") | ||
| 46 | + @PreAuthorize("@ss.hasPermission('promotion:article:update')") | ||
| 47 | + public CommonResult<Boolean> updateArticle(@Valid @RequestBody ArticleUpdateReqVO updateReqVO) { | ||
| 48 | + articleService.updateArticle(updateReqVO); | ||
| 49 | + return success(true); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + @DeleteMapping("/delete") | ||
| 53 | + @Operation(summary = "删除文章管理") | ||
| 54 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 55 | + @PreAuthorize("@ss.hasPermission('promotion:article:delete')") | ||
| 56 | + public CommonResult<Boolean> deleteArticle(@RequestParam("id") Long id) { | ||
| 57 | + articleService.deleteArticle(id); | ||
| 58 | + return success(true); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + @GetMapping("/get") | ||
| 62 | + @Operation(summary = "获得文章管理") | ||
| 63 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 64 | + @PreAuthorize("@ss.hasPermission('promotion:article:query')") | ||
| 65 | + public CommonResult<ArticleRespVO> getArticle(@RequestParam("id") Long id) { | ||
| 66 | + ArticleDO article = articleService.getArticle(id); | ||
| 67 | + return success(ArticleConvert.INSTANCE.convert(article)); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @GetMapping("/list") | ||
| 71 | + @Operation(summary = "获得文章管理列表") | ||
| 72 | + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") | ||
| 73 | + @PreAuthorize("@ss.hasPermission('promotion:article:query')") | ||
| 74 | + public CommonResult<List<ArticleRespVO>> getArticleList(@RequestParam("ids") Collection<Long> ids) { | ||
| 75 | + List<ArticleDO> list = articleService.getArticleList(ids); | ||
| 76 | + return success(ArticleConvert.INSTANCE.convertList(list)); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @GetMapping("/page") | ||
| 80 | + @Operation(summary = "获得文章管理分页") | ||
| 81 | + @PreAuthorize("@ss.hasPermission('promotion:article:query')") | ||
| 82 | + public CommonResult<PageResult<ArticleRespVO>> getArticlePage(@Valid ArticlePageReqVO pageVO) { | ||
| 83 | + PageResult<ArticleDO> pageResult = articleService.getArticlePage(pageVO); | ||
| 84 | + return success(ArticleConvert.INSTANCE.convertPage(pageResult)); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + @GetMapping("/export-excel") | ||
| 88 | + @Operation(summary = "导出文章管理 Excel") | ||
| 89 | + @PreAuthorize("@ss.hasPermission('promotion:article:export')") | ||
| 90 | + @OperateLog(type = EXPORT) | ||
| 91 | + public void exportArticleExcel(@Valid ArticleExportReqVO exportReqVO, | ||
| 92 | + HttpServletResponse response) throws IOException { | ||
| 93 | + List<ArticleDO> list = articleService.getArticleList(exportReqVO); | ||
| 94 | + // 导出 Excel | ||
| 95 | + List<ArticleExcelVO> datas = ArticleConvert.INSTANCE.convertList02(list); | ||
| 96 | + ExcelUtils.write(response, "文章管理.xls", "数据", ArticleExcelVO.class, datas); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import javax.validation.constraints.NotNull; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 文章管理 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 10 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 11 | + */ | ||
| 12 | +@Data | ||
| 13 | +public class ArticleBaseVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15458") | ||
| 16 | + @NotNull(message = "文章分类编号不能为空") | ||
| 17 | + private Long categoryId; | ||
| 18 | + | ||
| 19 | + @Schema(description = "关联商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22378") | ||
| 20 | + @NotNull(message = "关联商品不能为空") | ||
| 21 | + private Long spuId; | ||
| 22 | + | ||
| 23 | + @Schema(description = "文章标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是一个标题") | ||
| 24 | + @NotNull(message = "文章标题不能为空") | ||
| 25 | + private String title; | ||
| 26 | + | ||
| 27 | + @Schema(description = "文章作者", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") | ||
| 28 | + private String author; | ||
| 29 | + | ||
| 30 | + @Schema(description = "文章封面图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn") | ||
| 31 | + @NotNull(message = "文章封面图片地址不能为空") | ||
| 32 | + private String picUrl; | ||
| 33 | + | ||
| 34 | + @Schema(description = "文章简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是一个简介") | ||
| 35 | + private String introduction; | ||
| 36 | + | ||
| 37 | + @Schema(description = "浏览次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") | ||
| 38 | + private String browseCount; | ||
| 39 | + | ||
| 40 | + @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 41 | + @NotNull(message = "排序不能为空") | ||
| 42 | + private Integer sort; | ||
| 43 | + | ||
| 44 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||
| 45 | + @NotNull(message = "状态不能为空") | ||
| 46 | + private Integer status; | ||
| 47 | + | ||
| 48 | + @Schema(description = "是否热门(小程序)", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | ||
| 49 | + @NotNull(message = "是否热门(小程序)不能为空") | ||
| 50 | + private Boolean recommendHot; | ||
| 51 | + | ||
| 52 | + @Schema(description = "是否轮播图(小程序)", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | ||
| 53 | + @NotNull(message = "是否轮播图(小程序)不能为空") | ||
| 54 | + private Boolean recommendBanner; | ||
| 55 | + | ||
| 56 | + @Schema(description = "文章内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是文章内容") | ||
| 57 | + @NotNull(message = "文章内容不能为空") | ||
| 58 | + private String content; | ||
| 59 | + | ||
| 60 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleCreateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.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 | +@Schema(description = "管理后台 - 文章管理创建 Request VO") | ||
| 9 | +@Data | ||
| 10 | +@EqualsAndHashCode(callSuper = true) | ||
| 11 | +@ToString(callSuper = true) | ||
| 12 | +public class ArticleCreateReqVO extends ArticleBaseVO { | ||
| 13 | + | ||
| 14 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleExcelVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | ||
| 4 | +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | ||
| 5 | +import cn.iocoder.yudao.module.system.enums.DictTypeConstants; | ||
| 6 | +import com.alibaba.excel.annotation.ExcelProperty; | ||
| 7 | +import lombok.Data; | ||
| 8 | + | ||
| 9 | +import java.time.LocalDateTime; | ||
| 10 | + | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 文章管理 Excel VO | ||
| 14 | + * | ||
| 15 | + * @author HUIHUI | ||
| 16 | + */ | ||
| 17 | +@Data | ||
| 18 | +public class ArticleExcelVO { | ||
| 19 | + | ||
| 20 | + @ExcelProperty("文章编号") | ||
| 21 | + private Long id; | ||
| 22 | + | ||
| 23 | + @ExcelProperty("文章分类编号") | ||
| 24 | + private Long categoryId; | ||
| 25 | + | ||
| 26 | + @ExcelProperty("关联商品编号") | ||
| 27 | + private Long spuId; | ||
| 28 | + | ||
| 29 | + @ExcelProperty("文章标题") | ||
| 30 | + private String title; | ||
| 31 | + | ||
| 32 | + @ExcelProperty("文章作者") | ||
| 33 | + private String author; | ||
| 34 | + | ||
| 35 | + @ExcelProperty("文章封面图片地址") | ||
| 36 | + private String picUrl; | ||
| 37 | + | ||
| 38 | + @ExcelProperty("文章简介") | ||
| 39 | + private String introduction; | ||
| 40 | + | ||
| 41 | + @ExcelProperty("浏览次数") | ||
| 42 | + private String browseCount; | ||
| 43 | + | ||
| 44 | + @ExcelProperty("排序") | ||
| 45 | + private Integer sort; | ||
| 46 | + | ||
| 47 | + @ExcelProperty(value = "状态", converter = DictConvert.class) | ||
| 48 | + @DictFormat(DictTypeConstants.COMMON_STATUS) | ||
| 49 | + private Integer status; | ||
| 50 | + | ||
| 51 | + @ExcelProperty("是否热门(小程序)") | ||
| 52 | + private Boolean recommendHot; | ||
| 53 | + | ||
| 54 | + @ExcelProperty("是否轮播图(小程序)") | ||
| 55 | + private Boolean recommendBanner; | ||
| 56 | + | ||
| 57 | + @ExcelProperty("文章内容") | ||
| 58 | + private String content; | ||
| 59 | + | ||
| 60 | + @ExcelProperty("创建时间") | ||
| 61 | + private LocalDateTime createTime; | ||
| 62 | + | ||
| 63 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleExportReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 6 | + | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | + | ||
| 9 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 10 | + | ||
| 11 | +@Schema(description = "管理后台 - 文章管理 Excel 导出 Request VO,参数和 ArticlePageReqVO 是一致的") | ||
| 12 | +@Data | ||
| 13 | +public class ArticleExportReqVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "文章分类编号", example = "15458") | ||
| 16 | + private Long categoryId; | ||
| 17 | + | ||
| 18 | + @Schema(description = "关联商品编号", example = "22378") | ||
| 19 | + private Long spuId; | ||
| 20 | + | ||
| 21 | + @Schema(description = "文章标题") | ||
| 22 | + private String title; | ||
| 23 | + | ||
| 24 | + @Schema(description = "文章作者") | ||
| 25 | + private String author; | ||
| 26 | + | ||
| 27 | + @Schema(description = "状态", example = "2") | ||
| 28 | + private Integer status; | ||
| 29 | + | ||
| 30 | + @Schema(description = "是否热门(小程序)") | ||
| 31 | + private Boolean recommendHot; | ||
| 32 | + | ||
| 33 | + @Schema(description = "是否轮播图(小程序)") | ||
| 34 | + private Boolean recommendBanner; | ||
| 35 | + | ||
| 36 | + @Schema(description = "创建时间") | ||
| 37 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 38 | + private LocalDateTime[] createTime; | ||
| 39 | + | ||
| 40 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticlePageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import lombok.EqualsAndHashCode; | ||
| 7 | +import lombok.ToString; | ||
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | + | ||
| 10 | +import java.time.LocalDateTime; | ||
| 11 | + | ||
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 13 | + | ||
| 14 | +@Schema(description = "管理后台 - 文章管理分页 Request VO") | ||
| 15 | +@Data | ||
| 16 | +@EqualsAndHashCode(callSuper = true) | ||
| 17 | +@ToString(callSuper = true) | ||
| 18 | +public class ArticlePageReqVO extends PageParam { | ||
| 19 | + | ||
| 20 | + @Schema(description = "文章分类编号", example = "15458") | ||
| 21 | + private Long categoryId; | ||
| 22 | + | ||
| 23 | + @Schema(description = "关联商品编号", example = "22378") | ||
| 24 | + private Long spuId; | ||
| 25 | + | ||
| 26 | + @Schema(description = "文章标题") | ||
| 27 | + private String title; | ||
| 28 | + | ||
| 29 | + @Schema(description = "文章作者") | ||
| 30 | + private String author; | ||
| 31 | + | ||
| 32 | + @Schema(description = "状态", example = "2") | ||
| 33 | + private Integer status; | ||
| 34 | + | ||
| 35 | + @Schema(description = "是否热门(小程序)") | ||
| 36 | + private Boolean recommendHot; | ||
| 37 | + | ||
| 38 | + @Schema(description = "是否轮播图(小程序)") | ||
| 39 | + private Boolean recommendBanner; | ||
| 40 | + | ||
| 41 | + @Schema(description = "创建时间") | ||
| 42 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 43 | + private LocalDateTime[] createTime; | ||
| 44 | + | ||
| 45 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.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 java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - 文章管理 Response VO") | ||
| 11 | +@Data | ||
| 12 | +@EqualsAndHashCode(callSuper = true) | ||
| 13 | +@ToString(callSuper = true) | ||
| 14 | +public class ArticleRespVO extends ArticleBaseVO { | ||
| 15 | + | ||
| 16 | + @Schema(description = "文章编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8606") | ||
| 17 | + private Long id; | ||
| 18 | + | ||
| 19 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 20 | + private LocalDateTime createTime; | ||
| 21 | + | ||
| 22 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleUpdateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.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 javax.validation.constraints.NotNull; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - 文章管理更新 Request VO") | ||
| 11 | +@Data | ||
| 12 | +@EqualsAndHashCode(callSuper = true) | ||
| 13 | +@ToString(callSuper = true) | ||
| 14 | +public class ArticleUpdateReqVO extends ArticleBaseVO { | ||
| 15 | + | ||
| 16 | + @Schema(description = "文章编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8606") | ||
| 17 | + @NotNull(message = "文章编号不能为空") | ||
| 18 | + private Long id; | ||
| 19 | + | ||
| 20 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import javax.validation.constraints.NotNull; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 文章分类 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 10 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 11 | + */ | ||
| 12 | +@Data | ||
| 13 | +public class ArticleCategoryBaseVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "文章分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "秒杀") | ||
| 16 | + @NotNull(message = "文章分类名称不能为空") | ||
| 17 | + private String name; | ||
| 18 | + | ||
| 19 | + @Schema(description = "图标地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn") | ||
| 20 | + private String picUrl; | ||
| 21 | + | ||
| 22 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 23 | + @NotNull(message = "状态不能为空") | ||
| 24 | + private Integer status; | ||
| 25 | + | ||
| 26 | + @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 27 | + @NotNull(message = "排序不能为空") | ||
| 28 | + private Integer sort; | ||
| 29 | + | ||
| 30 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryCreateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | +import lombok.EqualsAndHashCode; | ||
| 6 | +import lombok.ToString; | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - 文章分类创建 Request VO") | ||
| 9 | +@Data | ||
| 10 | +@EqualsAndHashCode(callSuper = true) | ||
| 11 | +@ToString(callSuper = true) | ||
| 12 | +public class ArticleCategoryCreateReqVO extends ArticleCategoryBaseVO { | ||
| 13 | + | ||
| 14 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryExcelVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | ||
| 4 | +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | ||
| 5 | +import cn.iocoder.yudao.module.system.enums.DictTypeConstants; | ||
| 6 | +import com.alibaba.excel.annotation.ExcelProperty; | ||
| 7 | +import lombok.Data; | ||
| 8 | + | ||
| 9 | +import java.time.LocalDateTime; | ||
| 10 | + | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 文章分类 Excel VO | ||
| 14 | + * | ||
| 15 | + * @author HUIHUI | ||
| 16 | + */ | ||
| 17 | +@Data | ||
| 18 | +public class ArticleCategoryExcelVO { | ||
| 19 | + | ||
| 20 | + @ExcelProperty("文章分类编号") | ||
| 21 | + private Long id; | ||
| 22 | + | ||
| 23 | + @ExcelProperty("文章分类名称") | ||
| 24 | + private String name; | ||
| 25 | + | ||
| 26 | + @ExcelProperty("图标地址") | ||
| 27 | + private String picUrl; | ||
| 28 | + | ||
| 29 | + @ExcelProperty(value = "状态", converter = DictConvert.class) | ||
| 30 | + @DictFormat(DictTypeConstants.COMMON_STATUS) | ||
| 31 | + private Integer status; | ||
| 32 | + | ||
| 33 | + @ExcelProperty("排序") | ||
| 34 | + private Integer sort; | ||
| 35 | + | ||
| 36 | + @ExcelProperty("创建时间") | ||
| 37 | + private LocalDateTime createTime; | ||
| 38 | + | ||
| 39 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryExportReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 6 | + | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | + | ||
| 9 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 10 | + | ||
| 11 | +@Schema(description = "管理后台 - 文章分类 Excel 导出 Request VO,参数和 ArticleCategoryPageReqVO 是一致的") | ||
| 12 | +@Data | ||
| 13 | +public class ArticleCategoryExportReqVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "文章分类名称", example = "秒杀") | ||
| 16 | + private String name; | ||
| 17 | + | ||
| 18 | + @Schema(description = "状态", example = "1") | ||
| 19 | + private Integer status; | ||
| 20 | + | ||
| 21 | + @Schema(description = "创建时间") | ||
| 22 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 23 | + private LocalDateTime[] createTime; | ||
| 24 | + | ||
| 25 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import lombok.EqualsAndHashCode; | ||
| 7 | +import lombok.ToString; | ||
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | + | ||
| 10 | +import java.time.LocalDateTime; | ||
| 11 | + | ||
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 13 | + | ||
| 14 | +@Schema(description = "管理后台 - 文章分类分页 Request VO") | ||
| 15 | +@Data | ||
| 16 | +@EqualsAndHashCode(callSuper = true) | ||
| 17 | +@ToString(callSuper = true) | ||
| 18 | +public class ArticleCategoryPageReqVO extends PageParam { | ||
| 19 | + | ||
| 20 | + @Schema(description = "文章分类名称", example = "秒杀") | ||
| 21 | + private String name; | ||
| 22 | + | ||
| 23 | + @Schema(description = "状态", example = "1") | ||
| 24 | + private Integer status; | ||
| 25 | + | ||
| 26 | + @Schema(description = "创建时间") | ||
| 27 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 28 | + private LocalDateTime[] createTime; | ||
| 29 | + | ||
| 30 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; | ||
| 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 java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - 文章分类 Response VO") | ||
| 11 | +@Data | ||
| 12 | +@EqualsAndHashCode(callSuper = true) | ||
| 13 | +@ToString(callSuper = true) | ||
| 14 | +public class ArticleCategoryRespVO extends ArticleCategoryBaseVO { | ||
| 15 | + | ||
| 16 | + @Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19490") | ||
| 17 | + private Long id; | ||
| 18 | + | ||
| 19 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 20 | + private LocalDateTime createTime; | ||
| 21 | + | ||
| 22 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategorySimpleRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +@Schema(description = "管理后台 - 文章分类精简信息 Response VO") | ||
| 7 | +@Data | ||
| 8 | +public class ArticleCategorySimpleRespVO { | ||
| 9 | + | ||
| 10 | + @Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19490") | ||
| 11 | + private Long id; | ||
| 12 | + | ||
| 13 | + @Schema(description = "文章分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "秒杀") | ||
| 14 | + private String name; | ||
| 15 | + | ||
| 16 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryUpdateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; | ||
| 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 javax.validation.constraints.NotNull; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - 文章分类更新 Request VO") | ||
| 11 | +@Data | ||
| 12 | +@EqualsAndHashCode(callSuper = true) | ||
| 13 | +@ToString(callSuper = true) | ||
| 14 | +public class ArticleCategoryUpdateReqVO extends ArticleCategoryBaseVO { | ||
| 15 | + | ||
| 16 | + @Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19490") | ||
| 17 | + @NotNull(message = "文章分类编号不能为空") | ||
| 18 | + private Long id; | ||
| 19 | + | ||
| 20 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java
| @@ -3,11 +3,11 @@ package cn.iocoder.yudao.module.promotion.controller.admin.combination; | @@ -3,11 +3,11 @@ package cn.iocoder.yudao.module.promotion.controller.admin.combination; | ||
| 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.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordPageItemRespVO; | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordPageItemRespVO; |
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPage2VO; | ||
| 7 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; |
| 8 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordSummaryVO; | 7 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordSummaryVO; |
| 9 | import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; | 8 | import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; |
| 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; | 9 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; |
| 10 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; | ||
| 11 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; | 11 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; |
| 12 | import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; | 12 | import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; |
| 13 | import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService; | 13 | import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService; |
| @@ -40,7 +40,6 @@ public class CombinationRecordController { | @@ -40,7 +40,6 @@ public class CombinationRecordController { | ||
| 40 | @Lazy | 40 | @Lazy |
| 41 | private CombinationRecordService combinationRecordService; | 41 | private CombinationRecordService combinationRecordService; |
| 42 | 42 | ||
| 43 | - // TODO @puhui999:getBargainRecordPage 和 getBargainRecordPage 是不是可以合并;然后 CombinationRecordReqPageVO 加一个 headId; | ||
| 44 | // 然后如果 headId 非空,并且第一页,单独多查询一条 head ;放到第 0 个位置;相当于说,第一页特殊一点; | 43 | // 然后如果 headId 非空,并且第一页,单独多查询一条 head ;放到第 0 个位置;相当于说,第一页特殊一点; |
| 45 | 44 | ||
| 46 | @GetMapping("/page") | 45 | @GetMapping("/page") |
| @@ -48,21 +47,12 @@ public class CombinationRecordController { | @@ -48,21 +47,12 @@ public class CombinationRecordController { | ||
| 48 | @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") | 47 | @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") |
| 49 | public CommonResult<PageResult<CombinationRecordPageItemRespVO>> getBargainRecordPage(@Valid CombinationRecordReqPageVO pageVO) { | 48 | public CommonResult<PageResult<CombinationRecordPageItemRespVO>> getBargainRecordPage(@Valid CombinationRecordReqPageVO pageVO) { |
| 50 | PageResult<CombinationRecordDO> recordPage = combinationRecordService.getCombinationRecordPage(pageVO); | 49 | PageResult<CombinationRecordDO> recordPage = combinationRecordService.getCombinationRecordPage(pageVO); |
| 50 | + // 拼接数据 | ||
| 51 | List<CombinationActivityDO> activities = combinationActivityService.getCombinationActivityListByIds( | 51 | List<CombinationActivityDO> activities = combinationActivityService.getCombinationActivityListByIds( |
| 52 | convertSet(recordPage.getList(), CombinationRecordDO::getActivityId)); | 52 | convertSet(recordPage.getList(), CombinationRecordDO::getActivityId)); |
| 53 | - // TODO @puhui999:商品没读取 | ||
| 54 | - return success(CombinationActivityConvert.INSTANCE.convert(recordPage, activities)); | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - @GetMapping("/page-by-headId") | ||
| 58 | - @Operation(summary = "获得拼团记录分页") | ||
| 59 | - @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") | ||
| 60 | - public CommonResult<PageResult<CombinationRecordPageItemRespVO>> getBargainRecordPage(@Valid CombinationRecordReqPage2VO pageVO) { | ||
| 61 | - // 包含团长和团员的分页记录 | ||
| 62 | - PageResult<CombinationRecordDO> recordPage = combinationRecordService.getCombinationRecordPage2(pageVO); | ||
| 63 | - List<CombinationActivityDO> activities = combinationActivityService.getCombinationActivityListByIds( | 53 | + List<CombinationProductDO> products = combinationActivityService.getCombinationProductListByActivityIds( |
| 64 | convertSet(recordPage.getList(), CombinationRecordDO::getActivityId)); | 54 | convertSet(recordPage.getList(), CombinationRecordDO::getActivityId)); |
| 65 | - return success(CombinationActivityConvert.INSTANCE.convert(recordPage, activities)); | 55 | + return success(CombinationActivityConvert.INSTANCE.convert(recordPage, activities, products)); |
| 66 | } | 56 | } |
| 67 | 57 | ||
| 68 | @GetMapping("/get-summary") | 58 | @GetMapping("/get-summary") |
| @@ -70,7 +60,7 @@ public class CombinationRecordController { | @@ -70,7 +60,7 @@ public class CombinationRecordController { | ||
| 70 | @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") | 60 | @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") |
| 71 | public CommonResult<CombinationRecordSummaryVO> getCombinationRecordSummary() { | 61 | public CommonResult<CombinationRecordSummaryVO> getCombinationRecordSummary() { |
| 72 | CombinationRecordSummaryVO summaryVO = new CombinationRecordSummaryVO(); | 62 | CombinationRecordSummaryVO summaryVO = new CombinationRecordSummaryVO(); |
| 73 | - summaryVO.setUserCount(combinationRecordService.getCombinationRecordCount(null, null, null)); // 获取拼团用户参与数量 | 63 | + summaryVO.setUserCount(combinationRecordService.getCombinationUserCount()); // 获取拼团用户参与数量 |
| 74 | summaryVO.setSuccessCount(combinationRecordService.getCombinationRecordCount( // 获取成团记录 | 64 | summaryVO.setSuccessCount(combinationRecordService.getCombinationRecordCount( // 获取成团记录 |
| 75 | CombinationRecordStatusEnum.SUCCESS.getStatus(), null, CombinationRecordDO.HEAD_ID_GROUP)); | 65 | CombinationRecordStatusEnum.SUCCESS.getStatus(), null, CombinationRecordDO.HEAD_ID_GROUP)); |
| 76 | summaryVO.setVirtualGroupCount(combinationRecordService.getCombinationRecordCount(// 获取虚拟成团记录 | 66 | summaryVO.setVirtualGroupCount(combinationRecordService.getCombinationRecordCount(// 获取虚拟成团记录 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPageVO.java
| @@ -23,6 +23,9 @@ public class CombinationRecordReqPageVO extends PageParam { | @@ -23,6 +23,9 @@ public class CombinationRecordReqPageVO extends PageParam { | ||
| 23 | @InEnum(BargainRecordStatusEnum.class) | 23 | @InEnum(BargainRecordStatusEnum.class) |
| 24 | private Integer status; | 24 | private Integer status; |
| 25 | 25 | ||
| 26 | + @Schema(description = "团长编号", example = "1024") | ||
| 27 | + private Long headId; | ||
| 28 | + | ||
| 26 | @Schema(description = "创建时间") | 29 | @Schema(description = "创建时间") |
| 27 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | 30 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 28 | private LocalDateTime[] createTime; | 31 | private LocalDateTime[] createTime; |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java
| @@ -47,7 +47,7 @@ public class AppCombinationRecordController { | @@ -47,7 +47,7 @@ public class AppCombinationRecordController { | ||
| 47 | public CommonResult<AppCombinationRecordSummaryRespVO> getCombinationRecordSummary() { | 47 | public CommonResult<AppCombinationRecordSummaryRespVO> getCombinationRecordSummary() { |
| 48 | AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO(); | 48 | AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO(); |
| 49 | // 1. 获得拼团参与用户数量 | 49 | // 1. 获得拼团参与用户数量 |
| 50 | - Long count = combinationRecordService.getCombinationRecordCount(null, null, null); | 50 | + Long count = combinationRecordService.getCombinationUserCount(); |
| 51 | if (count == 0) { | 51 | if (count == 0) { |
| 52 | summary.setAvatars(Collections.emptyList()); | 52 | summary.setAvatars(Collections.emptyList()); |
| 53 | summary.setUserCount(count); | 53 | summary.setUserCount(count); |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleCategoryConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.convert.article; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.*; | ||
| 5 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; | ||
| 6 | +import org.mapstruct.Mapper; | ||
| 7 | +import org.mapstruct.factory.Mappers; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * 文章分类 Convert | ||
| 13 | + * | ||
| 14 | + * @author HUIHUI | ||
| 15 | + */ | ||
| 16 | +@Mapper | ||
| 17 | +public interface ArticleCategoryConvert { | ||
| 18 | + | ||
| 19 | + ArticleCategoryConvert INSTANCE = Mappers.getMapper(ArticleCategoryConvert.class); | ||
| 20 | + | ||
| 21 | + ArticleCategoryDO convert(ArticleCategoryCreateReqVO bean); | ||
| 22 | + | ||
| 23 | + ArticleCategoryDO convert(ArticleCategoryUpdateReqVO bean); | ||
| 24 | + | ||
| 25 | + ArticleCategoryRespVO convert(ArticleCategoryDO bean); | ||
| 26 | + | ||
| 27 | + List<ArticleCategoryRespVO> convertList(List<ArticleCategoryDO> list); | ||
| 28 | + | ||
| 29 | + PageResult<ArticleCategoryRespVO> convertPage(PageResult<ArticleCategoryDO> page); | ||
| 30 | + | ||
| 31 | + List<ArticleCategoryExcelVO> convertList02(List<ArticleCategoryDO> list); | ||
| 32 | + | ||
| 33 | + List<ArticleCategorySimpleRespVO> convertList03(List<ArticleCategoryDO> list); | ||
| 34 | + | ||
| 35 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.convert.article; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExcelVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleRespVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; | ||
| 9 | +import org.mapstruct.Mapper; | ||
| 10 | +import org.mapstruct.factory.Mappers; | ||
| 11 | + | ||
| 12 | +import java.util.List; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * 文章管理 Convert | ||
| 16 | + * | ||
| 17 | + * @author HUIHUI | ||
| 18 | + */ | ||
| 19 | +@Mapper | ||
| 20 | +public interface ArticleConvert { | ||
| 21 | + | ||
| 22 | + ArticleConvert INSTANCE = Mappers.getMapper(ArticleConvert.class); | ||
| 23 | + | ||
| 24 | + ArticleDO convert(ArticleCreateReqVO bean); | ||
| 25 | + | ||
| 26 | + ArticleDO convert(ArticleUpdateReqVO bean); | ||
| 27 | + | ||
| 28 | + ArticleRespVO convert(ArticleDO bean); | ||
| 29 | + | ||
| 30 | + List<ArticleRespVO> convertList(List<ArticleDO> list); | ||
| 31 | + | ||
| 32 | + PageResult<ArticleRespVO> convertPage(PageResult<ArticleDO> page); | ||
| 33 | + | ||
| 34 | + List<ArticleExcelVO> convertList02(List<ArticleDO> list); | ||
| 35 | + | ||
| 36 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java
| @@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | @@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | ||
| 8 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; | 8 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; |
| 9 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; | 9 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 10 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; | 10 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 11 | +import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; | ||
| 11 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; | 12 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; |
| 12 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageItemRespVO; | 13 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageItemRespVO; |
| 13 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityRespVO; | 14 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityRespVO; |
| @@ -109,6 +110,11 @@ public interface CombinationActivityConvert { | @@ -109,6 +110,11 @@ public interface CombinationActivityConvert { | ||
| 109 | 110 | ||
| 110 | CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO); | 111 | CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO); |
| 111 | 112 | ||
| 113 | + default CombinationRecordCreateRespDTO convert4(CombinationRecordDO combinationRecord) { | ||
| 114 | + return new CombinationRecordCreateRespDTO().setCombinationActivityId(combinationRecord.getActivityId()) | ||
| 115 | + .setCombinationRecordId(combinationRecord.getId()).setCombinationHeadId(combinationRecord.getHeadId()); | ||
| 116 | + } | ||
| 117 | + | ||
| 112 | default CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO, | 118 | default CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO, |
| 113 | CombinationActivityDO activity, MemberUserRespDTO user, | 119 | CombinationActivityDO activity, MemberUserRespDTO user, |
| 114 | ProductSpuRespDTO spu, ProductSkuRespDTO sku) { | 120 | ProductSpuRespDTO spu, ProductSkuRespDTO sku) { |
| @@ -172,12 +178,14 @@ public interface CombinationActivityConvert { | @@ -172,12 +178,14 @@ public interface CombinationActivityConvert { | ||
| 172 | 178 | ||
| 173 | PageResult<CombinationRecordPageItemRespVO> convert(PageResult<CombinationRecordDO> result); | 179 | PageResult<CombinationRecordPageItemRespVO> convert(PageResult<CombinationRecordDO> result); |
| 174 | 180 | ||
| 175 | - default PageResult<CombinationRecordPageItemRespVO> convert(PageResult<CombinationRecordDO> recordPage, List<CombinationActivityDO> activities) { | 181 | + default PageResult<CombinationRecordPageItemRespVO> convert(PageResult<CombinationRecordDO> recordPage, List<CombinationActivityDO> activities, List<CombinationProductDO> products) { |
| 176 | PageResult<CombinationRecordPageItemRespVO> result = convert(recordPage); | 182 | PageResult<CombinationRecordPageItemRespVO> result = convert(recordPage); |
| 183 | + // 拼接关联属性 | ||
| 177 | Map<Long, CombinationActivityDO> activityMap = convertMap(activities, CombinationActivityDO::getId); | 184 | Map<Long, CombinationActivityDO> activityMap = convertMap(activities, CombinationActivityDO::getId); |
| 185 | + Map<Long, List<CombinationProductDO>> productsMap = convertMultiMap(products, CombinationProductDO::getActivityId); | ||
| 178 | result.setList(CollectionUtils.convertList(result.getList(), item -> { | 186 | result.setList(CollectionUtils.convertList(result.getList(), item -> { |
| 179 | findAndThen(activityMap, item.getActivityId(), activity -> { | 187 | findAndThen(activityMap, item.getActivityId(), activity -> { |
| 180 | - item.setActivity(convert(activity)); | 188 | + item.setActivity(convert(activity).setProducts(convertList2(productsMap.get(item.getActivityId())))); |
| 181 | }); | 189 | }); |
| 182 | return item; | 190 | return item; |
| 183 | })); | 191 | })); |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleCategoryDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.dal.dataobject.article; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 6 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 7 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 8 | +import lombok.*; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 文章分类 DO | ||
| 12 | + * | ||
| 13 | + * @author HUIHUI | ||
| 14 | + */ | ||
| 15 | +@TableName("promotion_article_category") | ||
| 16 | +@KeySequence("promotion_article_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 17 | +@Data | ||
| 18 | +@EqualsAndHashCode(callSuper = true) | ||
| 19 | +@ToString(callSuper = true) | ||
| 20 | +@Builder | ||
| 21 | +@NoArgsConstructor | ||
| 22 | +@AllArgsConstructor | ||
| 23 | +public class ArticleCategoryDO extends BaseDO { | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 文章分类编号 | ||
| 27 | + */ | ||
| 28 | + @TableId | ||
| 29 | + private Long id; | ||
| 30 | + /** | ||
| 31 | + * 文章分类名称 | ||
| 32 | + */ | ||
| 33 | + private String name; | ||
| 34 | + /** | ||
| 35 | + * 图标地址 | ||
| 36 | + */ | ||
| 37 | + private String picUrl; | ||
| 38 | + /** | ||
| 39 | + * 状态 | ||
| 40 | + * | ||
| 41 | + * 枚举 {@link CommonStatusEnum} | ||
| 42 | + */ | ||
| 43 | + private Integer status; | ||
| 44 | + /** | ||
| 45 | + * 排序 | ||
| 46 | + */ | ||
| 47 | + private Integer sort; | ||
| 48 | + | ||
| 49 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.dal.dataobject.article; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 6 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 7 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 8 | +import lombok.*; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 文章管理 DO | ||
| 12 | + * | ||
| 13 | + * @author HUIHUI | ||
| 14 | + */ | ||
| 15 | +@TableName("promotion_article") | ||
| 16 | +@KeySequence("promotion_article_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 17 | +@Data | ||
| 18 | +@EqualsAndHashCode(callSuper = true) | ||
| 19 | +@ToString(callSuper = true) | ||
| 20 | +@Builder | ||
| 21 | +@NoArgsConstructor | ||
| 22 | +@AllArgsConstructor | ||
| 23 | +public class ArticleDO extends BaseDO { | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 文章管理编号 | ||
| 27 | + */ | ||
| 28 | + @TableId | ||
| 29 | + private Long id; | ||
| 30 | + /** | ||
| 31 | + * 分类编号 ArticleCategoryDO#id | ||
| 32 | + */ | ||
| 33 | + private Long categoryId; | ||
| 34 | + /** | ||
| 35 | + * 关联商品编号 ProductSpuDO#id | ||
| 36 | + */ | ||
| 37 | + private Long spuId; | ||
| 38 | + /** | ||
| 39 | + * 文章标题 | ||
| 40 | + */ | ||
| 41 | + private String title; | ||
| 42 | + /** | ||
| 43 | + * 文章作者 | ||
| 44 | + */ | ||
| 45 | + private String author; | ||
| 46 | + /** | ||
| 47 | + * 文章封面图片地址 | ||
| 48 | + */ | ||
| 49 | + private String picUrl; | ||
| 50 | + /** | ||
| 51 | + * 文章简介 | ||
| 52 | + */ | ||
| 53 | + private String introduction; | ||
| 54 | + /** | ||
| 55 | + * 浏览次数 | ||
| 56 | + */ | ||
| 57 | + private String browseCount; | ||
| 58 | + /** | ||
| 59 | + * 排序 | ||
| 60 | + */ | ||
| 61 | + private Integer sort; | ||
| 62 | + /** | ||
| 63 | + * 状态 | ||
| 64 | + * | ||
| 65 | + * 枚举 {@link CommonStatusEnum} | ||
| 66 | + */ | ||
| 67 | + private Integer status; | ||
| 68 | + /** | ||
| 69 | + * 是否热门(小程序) | ||
| 70 | + */ | ||
| 71 | + private Boolean recommendHot; | ||
| 72 | + /** | ||
| 73 | + * 是否轮播图(小程序) | ||
| 74 | + */ | ||
| 75 | + private Boolean recommendBanner; | ||
| 76 | + /** | ||
| 77 | + * 文章内容 | ||
| 78 | + */ | ||
| 79 | + private String content; | ||
| 80 | + | ||
| 81 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleCategoryMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.dal.mysql.article; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryExportReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; | ||
| 9 | +import org.apache.ibatis.annotations.Mapper; | ||
| 10 | + | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * 文章分类 Mapper | ||
| 15 | + * | ||
| 16 | + * @author HUIHUI | ||
| 17 | + */ | ||
| 18 | +@Mapper | ||
| 19 | +public interface ArticleCategoryMapper extends BaseMapperX<ArticleCategoryDO> { | ||
| 20 | + | ||
| 21 | + default PageResult<ArticleCategoryDO> selectPage(ArticleCategoryPageReqVO reqVO) { | ||
| 22 | + return selectPage(reqVO, new LambdaQueryWrapperX<ArticleCategoryDO>() | ||
| 23 | + .likeIfPresent(ArticleCategoryDO::getName, reqVO.getName()) | ||
| 24 | + .eqIfPresent(ArticleCategoryDO::getStatus, reqVO.getStatus()) | ||
| 25 | + .betweenIfPresent(ArticleCategoryDO::getCreateTime, reqVO.getCreateTime()) | ||
| 26 | + .orderByDesc(ArticleCategoryDO::getSort)); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + default List<ArticleCategoryDO> selectList(ArticleCategoryExportReqVO reqVO) { | ||
| 30 | + return selectList(new LambdaQueryWrapperX<ArticleCategoryDO>() | ||
| 31 | + .likeIfPresent(ArticleCategoryDO::getName, reqVO.getName()) | ||
| 32 | + .eqIfPresent(ArticleCategoryDO::getStatus, reqVO.getStatus()) | ||
| 33 | + .betweenIfPresent(ArticleCategoryDO::getCreateTime, reqVO.getCreateTime()) | ||
| 34 | + .orderByDesc(ArticleCategoryDO::getSort)); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.dal.mysql.article; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; | ||
| 9 | +import org.apache.ibatis.annotations.Mapper; | ||
| 10 | + | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * 文章管理 Mapper | ||
| 15 | + * | ||
| 16 | + * @author HUIHUI | ||
| 17 | + */ | ||
| 18 | +@Mapper | ||
| 19 | +public interface ArticleMapper extends BaseMapperX<ArticleDO> { | ||
| 20 | + | ||
| 21 | + default PageResult<ArticleDO> selectPage(ArticlePageReqVO reqVO) { | ||
| 22 | + return selectPage(reqVO, new LambdaQueryWrapperX<ArticleDO>() | ||
| 23 | + .eqIfPresent(ArticleDO::getCategoryId, reqVO.getCategoryId()) | ||
| 24 | + .eqIfPresent(ArticleDO::getTitle, reqVO.getTitle()) | ||
| 25 | + .eqIfPresent(ArticleDO::getAuthor, reqVO.getAuthor()) | ||
| 26 | + .eqIfPresent(ArticleDO::getStatus, reqVO.getStatus()) | ||
| 27 | + .eqIfPresent(ArticleDO::getSpuId, reqVO.getSpuId()) | ||
| 28 | + .eqIfPresent(ArticleDO::getRecommendHot, reqVO.getRecommendHot()) | ||
| 29 | + .eqIfPresent(ArticleDO::getRecommendBanner, reqVO.getRecommendBanner()) | ||
| 30 | + .betweenIfPresent(ArticleDO::getCreateTime, reqVO.getCreateTime()) | ||
| 31 | + .orderByDesc(ArticleDO::getId)); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + default List<ArticleDO> selectList(ArticleExportReqVO reqVO) { | ||
| 35 | + return selectList(new LambdaQueryWrapperX<ArticleDO>() | ||
| 36 | + .eqIfPresent(ArticleDO::getCategoryId, reqVO.getCategoryId()) | ||
| 37 | + .eqIfPresent(ArticleDO::getTitle, reqVO.getTitle()) | ||
| 38 | + .eqIfPresent(ArticleDO::getAuthor, reqVO.getAuthor()) | ||
| 39 | + .eqIfPresent(ArticleDO::getStatus, reqVO.getStatus()) | ||
| 40 | + .eqIfPresent(ArticleDO::getSpuId, reqVO.getSpuId()) | ||
| 41 | + .eqIfPresent(ArticleDO::getRecommendHot, reqVO.getRecommendHot()) | ||
| 42 | + .eqIfPresent(ArticleDO::getRecommendBanner, reqVO.getRecommendBanner()) | ||
| 43 | + .betweenIfPresent(ArticleDO::getCreateTime, reqVO.getCreateTime()) | ||
| 44 | + .orderByDesc(ArticleDO::getId)); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java
| @@ -86,7 +86,7 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> { | @@ -86,7 +86,7 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> { | ||
| 86 | .last("LIMIT " + count)); | 86 | .last("LIMIT " + count)); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | - // TODO @puhui999:是不是返回 BargainActivityDO 更干净哈? | 89 | + // TODO @puhui999:是不是返回 BargainActivityDO 更干净哈?分组后返回 DO 的话需要联表查询 |
| 90 | /** | 90 | /** |
| 91 | * 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 | 91 | * 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 |
| 92 | * | 92 | * |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java
| @@ -6,7 +6,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | @@ -6,7 +6,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 6 | 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.CombinationRecordReqPage2VO; | ||
| 10 | 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; |
| 11 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; | 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; |
| 12 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 11 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| @@ -97,21 +96,19 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | @@ -97,21 +96,19 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | ||
| 97 | } | 96 | } |
| 98 | 97 | ||
| 99 | default PageResult<CombinationRecordDO> selectPage(CombinationRecordReqPageVO pageVO) { | 98 | default PageResult<CombinationRecordDO> selectPage(CombinationRecordReqPageVO pageVO) { |
| 100 | - return selectPage(pageVO, new LambdaQueryWrapperX<CombinationRecordDO>() | 99 | + LambdaQueryWrapperX<CombinationRecordDO> queryWrapper = new LambdaQueryWrapperX<CombinationRecordDO>() |
| 101 | .eqIfPresent(CombinationRecordDO::getStatus, pageVO.getStatus()) | 100 | .eqIfPresent(CombinationRecordDO::getStatus, pageVO.getStatus()) |
| 102 | - .betweenIfPresent(CombinationRecordDO::getCreateTime, pageVO.getCreateTime())); | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - default PageResult<CombinationRecordDO> selectPage(CombinationRecordReqPage2VO pageVO) { | ||
| 106 | - return selectPage(pageVO, new LambdaQueryWrapperX<CombinationRecordDO>() | ||
| 107 | - .eq(CombinationRecordDO::getId, pageVO.getHeadId()) | ||
| 108 | - .or() | ||
| 109 | - .eq(CombinationRecordDO::getHeadId, pageVO.getHeadId())); | 101 | + .betweenIfPresent(CombinationRecordDO::getCreateTime, pageVO.getCreateTime()); |
| 102 | + if (pageVO.getHeadId() != null) { | ||
| 103 | + queryWrapper.eq(CombinationRecordDO::getId, pageVO.getHeadId()) | ||
| 104 | + .or() | ||
| 105 | + .eq(CombinationRecordDO::getHeadId, pageVO.getHeadId()); | ||
| 106 | + } | ||
| 107 | + return selectPage(pageVO, queryWrapper); | ||
| 110 | } | 108 | } |
| 111 | 109 | ||
| 112 | /** | 110 | /** |
| 113 | * 查询指定条件的记录数 | 111 | * 查询指定条件的记录数 |
| 114 | - * 如果参数都为 null 时则查询用户拼团记录(DISTINCT 去重),也就是说查询会员表中的用户有多少人参与过拼团活动每个人只统计一次 | ||
| 115 | * | 112 | * |
| 116 | * @param status 状态,可为 null | 113 | * @param status 状态,可为 null |
| 117 | * @param virtualGroup 是否虚拟成团,可为 null | 114 | * @param virtualGroup 是否虚拟成团,可为 null |
| @@ -119,12 +116,20 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | @@ -119,12 +116,20 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | ||
| 119 | * @return 记录数 | 116 | * @return 记录数 |
| 120 | */ | 117 | */ |
| 121 | default Long selectCountByHeadAndStatusAndVirtualGroup(Integer status, Boolean virtualGroup, Long headId) { | 118 | default Long selectCountByHeadAndStatusAndVirtualGroup(Integer status, Boolean virtualGroup, Long headId) { |
| 119 | + return selectCount(new LambdaQueryWrapperX<CombinationRecordDO>() | ||
| 120 | + .eqIfPresent(CombinationRecordDO::getStatus, status) | ||
| 121 | + .eqIfPresent(CombinationRecordDO::getVirtualGroup, virtualGroup) | ||
| 122 | + .eqIfPresent(CombinationRecordDO::getHeadId, headId)); | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + /** | ||
| 126 | + * 查询用户拼团记录(DISTINCT 去重),也就是说查询会员表中的用户有多少人参与过拼团活动每个人只统计一次 | ||
| 127 | + * | ||
| 128 | + * @return 参加过拼团的用户数 | ||
| 129 | + */ | ||
| 130 | + default Long selectUserDistinctCount() { | ||
| 122 | return selectCount(new QueryWrapper<CombinationRecordDO>() | 131 | return selectCount(new QueryWrapper<CombinationRecordDO>() |
| 123 | - // TODO @puhui999:这种偏逻辑性的,不要给 mapper 哈;可以考虑拆成 2 个 mapper,上层也是 2 个 service; | ||
| 124 | - .select(status == null && virtualGroup == null && headId == null, "DISTINCT (user_id)") | ||
| 125 | - .eq(status != null, "status", status) | ||
| 126 | - .eq(virtualGroup != null, "virtual_group", virtualGroup) | ||
| 127 | - .eq(headId != null, "head_id", headId) | 132 | + .select("DISTINCT (user_id)") |
| 128 | .groupBy("user_id")); | 133 | .groupBy("user_id")); |
| 129 | } | 134 | } |
| 130 | 135 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.article; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryExportReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; | ||
| 9 | + | ||
| 10 | +import javax.validation.Valid; | ||
| 11 | +import java.util.Collection; | ||
| 12 | +import java.util.List; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * 文章分类 Service 接口 | ||
| 16 | + * | ||
| 17 | + * @author HUIHUI | ||
| 18 | + */ | ||
| 19 | +public interface ArticleCategoryService { | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 创建文章分类 | ||
| 23 | + * | ||
| 24 | + * @param createReqVO 创建信息 | ||
| 25 | + * @return 编号 | ||
| 26 | + */ | ||
| 27 | + Long createArticleCategory(@Valid ArticleCategoryCreateReqVO createReqVO); | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 更新文章分类 | ||
| 31 | + * | ||
| 32 | + * @param updateReqVO 更新信息 | ||
| 33 | + */ | ||
| 34 | + void updateArticleCategory(@Valid ArticleCategoryUpdateReqVO updateReqVO); | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 删除文章分类 | ||
| 38 | + * | ||
| 39 | + * @param id 编号 | ||
| 40 | + */ | ||
| 41 | + void deleteArticleCategory(Long id); | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * 获得文章分类 | ||
| 45 | + * | ||
| 46 | + * @param id 编号 | ||
| 47 | + * @return 文章分类 | ||
| 48 | + */ | ||
| 49 | + ArticleCategoryDO getArticleCategory(Long id); | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 获得文章分类列表 | ||
| 53 | + * | ||
| 54 | + * @param ids 编号 | ||
| 55 | + * @return 文章分类列表 | ||
| 56 | + */ | ||
| 57 | + List<ArticleCategoryDO> getArticleCategoryList(Collection<Long> ids); | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * 获得文章分类分页 | ||
| 61 | + * | ||
| 62 | + * @param pageReqVO 分页查询 | ||
| 63 | + * @return 文章分类分页 | ||
| 64 | + */ | ||
| 65 | + PageResult<ArticleCategoryDO> getArticleCategoryPage(ArticleCategoryPageReqVO pageReqVO); | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * 获得文章分类列表, 用于 Excel 导出 | ||
| 69 | + * | ||
| 70 | + * @param exportReqVO 查询条件 | ||
| 71 | + * @return 文章分类列表 | ||
| 72 | + */ | ||
| 73 | + List<ArticleCategoryDO> getArticleCategoryList(ArticleCategoryExportReqVO exportReqVO); | ||
| 74 | + | ||
| 75 | + /** | ||
| 76 | + * 获得指定状态的文章分类列表 | ||
| 77 | + * | ||
| 78 | + * @param status 状态 | ||
| 79 | + * @return 文章分类列表 | ||
| 80 | + */ | ||
| 81 | + List<ArticleCategoryDO> getArticleCategoryListByStatus(Integer status); | ||
| 82 | + | ||
| 83 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.article; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import cn.hutool.core.collection.ListUtil; | ||
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryExportReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; | ||
| 10 | +import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; | ||
| 11 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; | ||
| 12 | +import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleCategoryMapper; | ||
| 13 | +import org.springframework.stereotype.Service; | ||
| 14 | +import org.springframework.validation.annotation.Validated; | ||
| 15 | + | ||
| 16 | +import javax.annotation.Resource; | ||
| 17 | +import java.util.Collection; | ||
| 18 | +import java.util.List; | ||
| 19 | + | ||
| 20 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 21 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS; | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | + * 文章分类 Service 实现类 | ||
| 25 | + * | ||
| 26 | + * @author HUIHUI | ||
| 27 | + */ | ||
| 28 | +@Service | ||
| 29 | +@Validated | ||
| 30 | +public class ArticleCategoryServiceImpl implements ArticleCategoryService { | ||
| 31 | + | ||
| 32 | + @Resource | ||
| 33 | + private ArticleCategoryMapper articleCategoryMapper; | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + public Long createArticleCategory(ArticleCategoryCreateReqVO createReqVO) { | ||
| 37 | + // 插入 | ||
| 38 | + ArticleCategoryDO articleCategory = ArticleCategoryConvert.INSTANCE.convert(createReqVO); | ||
| 39 | + articleCategoryMapper.insert(articleCategory); | ||
| 40 | + // 返回 | ||
| 41 | + return articleCategory.getId(); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + @Override | ||
| 45 | + public void updateArticleCategory(ArticleCategoryUpdateReqVO updateReqVO) { | ||
| 46 | + // 校验存在 | ||
| 47 | + validateArticleCategoryExists(updateReqVO.getId()); | ||
| 48 | + // 更新 | ||
| 49 | + ArticleCategoryDO updateObj = ArticleCategoryConvert.INSTANCE.convert(updateReqVO); | ||
| 50 | + articleCategoryMapper.updateById(updateObj); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + @Override | ||
| 54 | + public void deleteArticleCategory(Long id) { | ||
| 55 | + // 校验存在 | ||
| 56 | + validateArticleCategoryExists(id); | ||
| 57 | + // 删除 | ||
| 58 | + articleCategoryMapper.deleteById(id); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + private void validateArticleCategoryExists(Long id) { | ||
| 62 | + if (articleCategoryMapper.selectById(id) == null) { | ||
| 63 | + throw exception(ARTICLE_CATEGORY_NOT_EXISTS); | ||
| 64 | + } | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + @Override | ||
| 68 | + public ArticleCategoryDO getArticleCategory(Long id) { | ||
| 69 | + return articleCategoryMapper.selectById(id); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @Override | ||
| 73 | + public List<ArticleCategoryDO> getArticleCategoryList(Collection<Long> ids) { | ||
| 74 | + if (CollUtil.isEmpty(ids)) { | ||
| 75 | + return ListUtil.empty(); | ||
| 76 | + } | ||
| 77 | + return articleCategoryMapper.selectBatchIds(ids); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @Override | ||
| 81 | + public PageResult<ArticleCategoryDO> getArticleCategoryPage(ArticleCategoryPageReqVO pageReqVO) { | ||
| 82 | + return articleCategoryMapper.selectPage(pageReqVO); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + @Override | ||
| 86 | + public List<ArticleCategoryDO> getArticleCategoryList(ArticleCategoryExportReqVO exportReqVO) { | ||
| 87 | + return articleCategoryMapper.selectList(exportReqVO); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + @Override | ||
| 91 | + public List<ArticleCategoryDO> getArticleCategoryListByStatus(Integer status) { | ||
| 92 | + return articleCategoryMapper.selectList(ArticleCategoryDO::getStatus, status); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.article; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; | ||
| 9 | + | ||
| 10 | +import javax.validation.Valid; | ||
| 11 | +import java.util.Collection; | ||
| 12 | +import java.util.List; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * 文章管理 Service 接口 | ||
| 16 | + * | ||
| 17 | + * @author HUIHUI | ||
| 18 | + */ | ||
| 19 | +public interface ArticleService { | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 创建文章管理 | ||
| 23 | + * | ||
| 24 | + * @param createReqVO 创建信息 | ||
| 25 | + * @return 编号 | ||
| 26 | + */ | ||
| 27 | + Long createArticle(@Valid ArticleCreateReqVO createReqVO); | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 更新文章管理 | ||
| 31 | + * | ||
| 32 | + * @param updateReqVO 更新信息 | ||
| 33 | + */ | ||
| 34 | + void updateArticle(@Valid ArticleUpdateReqVO updateReqVO); | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 删除文章管理 | ||
| 38 | + * | ||
| 39 | + * @param id 编号 | ||
| 40 | + */ | ||
| 41 | + void deleteArticle(Long id); | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * 获得文章管理 | ||
| 45 | + * | ||
| 46 | + * @param id 编号 | ||
| 47 | + * @return 文章管理 | ||
| 48 | + */ | ||
| 49 | + ArticleDO getArticle(Long id); | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 获得文章管理列表 | ||
| 53 | + * | ||
| 54 | + * @param ids 编号 | ||
| 55 | + * @return 文章管理列表 | ||
| 56 | + */ | ||
| 57 | + List<ArticleDO> getArticleList(Collection<Long> ids); | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * 获得文章管理分页 | ||
| 61 | + * | ||
| 62 | + * @param pageReqVO 分页查询 | ||
| 63 | + * @return 文章管理分页 | ||
| 64 | + */ | ||
| 65 | + PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO); | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * 获得文章管理列表, 用于 Excel 导出 | ||
| 69 | + * | ||
| 70 | + * @param exportReqVO 查询条件 | ||
| 71 | + * @return 文章管理列表 | ||
| 72 | + */ | ||
| 73 | + List<ArticleDO> getArticleList(ArticleExportReqVO exportReqVO); | ||
| 74 | + | ||
| 75 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.article; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import cn.hutool.core.collection.ListUtil; | ||
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO; | ||
| 10 | +import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; | ||
| 11 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; | ||
| 12 | +import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper; | ||
| 13 | +import org.springframework.stereotype.Service; | ||
| 14 | +import org.springframework.validation.annotation.Validated; | ||
| 15 | + | ||
| 16 | +import javax.annotation.Resource; | ||
| 17 | +import java.util.Collection; | ||
| 18 | +import java.util.List; | ||
| 19 | + | ||
| 20 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 21 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_NOT_EXISTS; | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | + * 文章管理 Service 实现类 | ||
| 25 | + * | ||
| 26 | + * @author HUIHUI | ||
| 27 | + */ | ||
| 28 | +@Service | ||
| 29 | +@Validated | ||
| 30 | +public class ArticleServiceImpl implements ArticleService { | ||
| 31 | + | ||
| 32 | + @Resource | ||
| 33 | + private ArticleMapper articleMapper; | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + public Long createArticle(ArticleCreateReqVO createReqVO) { | ||
| 37 | + // 插入 | ||
| 38 | + ArticleDO article = ArticleConvert.INSTANCE.convert(createReqVO); | ||
| 39 | + articleMapper.insert(article); | ||
| 40 | + // 返回 | ||
| 41 | + return article.getId(); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + @Override | ||
| 45 | + public void updateArticle(ArticleUpdateReqVO updateReqVO) { | ||
| 46 | + // 校验存在 | ||
| 47 | + validateArticleExists(updateReqVO.getId()); | ||
| 48 | + // 更新 | ||
| 49 | + ArticleDO updateObj = ArticleConvert.INSTANCE.convert(updateReqVO); | ||
| 50 | + articleMapper.updateById(updateObj); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + @Override | ||
| 54 | + public void deleteArticle(Long id) { | ||
| 55 | + // 校验存在 | ||
| 56 | + validateArticleExists(id); | ||
| 57 | + // 删除 | ||
| 58 | + articleMapper.deleteById(id); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + private void validateArticleExists(Long id) { | ||
| 62 | + if (articleMapper.selectById(id) == null) { | ||
| 63 | + throw exception(ARTICLE_NOT_EXISTS); | ||
| 64 | + } | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + @Override | ||
| 68 | + public ArticleDO getArticle(Long id) { | ||
| 69 | + return articleMapper.selectById(id); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @Override | ||
| 73 | + public List<ArticleDO> getArticleList(Collection<Long> ids) { | ||
| 74 | + if (CollUtil.isEmpty(ids)) { | ||
| 75 | + return ListUtil.empty(); | ||
| 76 | + } | ||
| 77 | + return articleMapper.selectBatchIds(ids); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @Override | ||
| 81 | + public PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO) { | ||
| 82 | + return articleMapper.selectPage(pageReqVO); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + @Override | ||
| 86 | + public List<ArticleDO> getArticleList(ArticleExportReqVO exportReqVO) { | ||
| 87 | + return articleMapper.selectList(exportReqVO); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java
| @@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.common.core.KeyValue; | @@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.common.core.KeyValue; | ||
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | 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.CombinationRecordReqPage2VO; | ||
| 8 | 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; |
| 9 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; |
| 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; | 9 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; |
| @@ -50,9 +49,9 @@ public interface CombinationRecordService { | @@ -50,9 +49,9 @@ public interface CombinationRecordService { | ||
| 50 | * 创建拼团记录 | 49 | * 创建拼团记录 |
| 51 | * | 50 | * |
| 52 | * @param reqDTO 创建信息 | 51 | * @param reqDTO 创建信息 |
| 53 | - * @return key 开团记录编号 value 团长编号 | 52 | + * @return 团信息 |
| 54 | */ | 53 | */ |
| 55 | - KeyValue<Long, Long> createCombinationRecord(CombinationRecordCreateReqDTO reqDTO); | 54 | + CombinationRecordDO createCombinationRecord(CombinationRecordCreateReqDTO reqDTO); |
| 56 | 55 | ||
| 57 | /** | 56 | /** |
| 58 | * 获得拼团记录 | 57 | * 获得拼团记录 |
| @@ -94,7 +93,14 @@ public interface CombinationRecordService { | @@ -94,7 +93,14 @@ public interface CombinationRecordService { | ||
| 94 | * @param headId 团长编号,允许空。目的 headId 设置为 {@link CombinationRecordDO#HEAD_ID_GROUP} 时,可以设置 | 93 | * @param headId 团长编号,允许空。目的 headId 设置为 {@link CombinationRecordDO#HEAD_ID_GROUP} 时,可以设置 |
| 95 | * @return 记录数 | 94 | * @return 记录数 |
| 96 | */ | 95 | */ |
| 97 | - Long getCombinationRecordCount(@Nullable Integer status, @Nullable Boolean virtualGroup, @Nullable Long headId); | 96 | + Long getCombinationRecordCount(@Nullable Integer status, @Nullable Boolean virtualGroup, Long headId); |
| 97 | + | ||
| 98 | + /** | ||
| 99 | + * 查询用户拼团记录(DISTINCT 去重),也就是说查询会员表中的用户有多少人参与过拼团活动每个人只统计一次 | ||
| 100 | + * | ||
| 101 | + * @return 参加过拼团的用户数 | ||
| 102 | + */ | ||
| 103 | + Long getCombinationUserCount(); | ||
| 98 | 104 | ||
| 99 | /** | 105 | /** |
| 100 | * 获取最近的 count 条拼团记录 | 106 | * 获取最近的 count 条拼团记录 |
| @@ -139,14 +145,6 @@ public interface CombinationRecordService { | @@ -139,14 +145,6 @@ public interface CombinationRecordService { | ||
| 139 | PageResult<CombinationRecordDO> getCombinationRecordPage(CombinationRecordReqPageVO pageVO); | 145 | PageResult<CombinationRecordDO> getCombinationRecordPage(CombinationRecordReqPageVO pageVO); |
| 140 | 146 | ||
| 141 | /** | 147 | /** |
| 142 | - * 获取拼团记录分页数据(通过团长查询) | ||
| 143 | - * | ||
| 144 | - * @param pageVO 分页请求 | ||
| 145 | - * @return 拼团记录分页数据(包括团长的) | ||
| 146 | - */ | ||
| 147 | - PageResult<CombinationRecordDO> getCombinationRecordPage2(CombinationRecordReqPage2VO pageVO); | ||
| 148 | - | ||
| 149 | - /** | ||
| 150 | * 【拼团活动】获得拼团记录数量 Map | 148 | * 【拼团活动】获得拼团记录数量 Map |
| 151 | * | 149 | * |
| 152 | * @param activityIds 活动记录编号数组 | 150 | * @param activityIds 活动记录编号数组 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
| @@ -14,7 +14,6 @@ import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; | @@ -14,7 +14,6 @@ import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; | ||
| 14 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; | 14 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 15 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; | 15 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 16 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; | 16 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; |
| 17 | -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPage2VO; | ||
| 18 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; | 17 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; |
| 19 | import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; | 18 | import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; |
| 20 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; | 19 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; |
| @@ -23,7 +22,6 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationR | @@ -23,7 +22,6 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationR | ||
| 23 | import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationRecordMapper; | 22 | import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationRecordMapper; |
| 24 | import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; | 23 | import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; |
| 25 | import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; | 24 | import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; |
| 26 | -import org.springframework.scheduling.annotation.Async; | ||
| 27 | import org.springframework.stereotype.Service; | 25 | import org.springframework.stereotype.Service; |
| 28 | import org.springframework.transaction.annotation.Transactional; | 26 | import org.springframework.transaction.annotation.Transactional; |
| 29 | import org.springframework.validation.annotation.Validated; | 27 | import org.springframework.validation.annotation.Validated; |
| @@ -72,9 +70,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -72,9 +70,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 72 | CombinationRecordDO record = validateCombinationRecord(userId, orderId); | 70 | CombinationRecordDO record = validateCombinationRecord(userId, orderId); |
| 73 | 71 | ||
| 74 | // 更新状态 | 72 | // 更新状态 |
| 75 | - // TODO @puhui999:不要整个更新,new 一个出来;why?例如说,两个线程都去更新,这样存在相互覆盖的问题 | ||
| 76 | - record.setStatus(status); | ||
| 77 | - combinationRecordMapper.updateById(record); | 73 | + combinationRecordMapper.updateById(new CombinationRecordDO().setId(record.getId()).setStatus(status)); |
| 78 | } | 74 | } |
| 79 | 75 | ||
| 80 | private CombinationRecordDO validateCombinationRecord(Long userId, Long orderId) { | 76 | private CombinationRecordDO validateCombinationRecord(Long userId, Long orderId) { |
| @@ -164,7 +160,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -164,7 +160,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 164 | 160 | ||
| 165 | @Override | 161 | @Override |
| 166 | @Transactional(rollbackFor = Exception.class) | 162 | @Transactional(rollbackFor = Exception.class) |
| 167 | - public KeyValue<Long, Long> createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { | 163 | + public CombinationRecordDO createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { |
| 168 | // 1. 校验拼团活动 | 164 | // 1. 校验拼团活动 |
| 169 | KeyValue<CombinationActivityDO, CombinationProductDO> keyValue = validateCombinationRecord(reqDTO.getUserId(), | 165 | KeyValue<CombinationActivityDO, CombinationProductDO> keyValue = validateCombinationRecord(reqDTO.getUserId(), |
| 170 | reqDTO.getActivityId(), reqDTO.getHeadId(), reqDTO.getSkuId(), reqDTO.getCount()); | 166 | reqDTO.getActivityId(), reqDTO.getHeadId(), reqDTO.getSkuId(), reqDTO.getCount()); |
| @@ -191,7 +187,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -191,7 +187,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 191 | if (ObjUtil.notEqual(CombinationRecordDO.HEAD_ID_GROUP, record.getHeadId())) { | 187 | if (ObjUtil.notEqual(CombinationRecordDO.HEAD_ID_GROUP, record.getHeadId())) { |
| 192 | updateCombinationRecordWhenCreate(reqDTO.getHeadId(), keyValue.getKey()); | 188 | updateCombinationRecordWhenCreate(reqDTO.getHeadId(), keyValue.getKey()); |
| 193 | } | 189 | } |
| 194 | - return new KeyValue<>(record.getId(), record.getHeadId()); | 190 | + return record; |
| 195 | } | 191 | } |
| 196 | 192 | ||
| 197 | /** | 193 | /** |
| @@ -250,6 +246,11 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -250,6 +246,11 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 250 | } | 246 | } |
| 251 | 247 | ||
| 252 | @Override | 248 | @Override |
| 249 | + public Long getCombinationUserCount() { | ||
| 250 | + return combinationRecordMapper.selectUserDistinctCount(); | ||
| 251 | + } | ||
| 252 | + | ||
| 253 | + @Override | ||
| 253 | public List<CombinationRecordDO> getLatestCombinationRecordList(int count) { | 254 | public List<CombinationRecordDO> getLatestCombinationRecordList(int count) { |
| 254 | return combinationRecordMapper.selectLatestList(count); | 255 | return combinationRecordMapper.selectLatestList(count); |
| 255 | } | 256 | } |
| @@ -276,11 +277,6 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -276,11 +277,6 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 276 | } | 277 | } |
| 277 | 278 | ||
| 278 | @Override | 279 | @Override |
| 279 | - public PageResult<CombinationRecordDO> getCombinationRecordPage2(CombinationRecordReqPage2VO pageVO) { | ||
| 280 | - return combinationRecordMapper.selectPage(pageVO); | ||
| 281 | - } | ||
| 282 | - | ||
| 283 | - @Override | ||
| 284 | public Map<Long, Integer> getCombinationRecordCountMapByActivity(Collection<Long> activityIds, | 280 | public Map<Long, Integer> getCombinationRecordCountMapByActivity(Collection<Long> activityIds, |
| 285 | @Nullable Integer status, @Nullable Long headId) { | 281 | @Nullable Integer status, @Nullable Long headId) { |
| 286 | return combinationRecordMapper.selectCombinationRecordCountMapByActivityIdAndStatusAndHeadId(activityIds, status, headId); | 282 | return combinationRecordMapper.selectCombinationRecordCountMapByActivityIdAndStatusAndHeadId(activityIds, status, headId); |
| @@ -343,32 +339,28 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -343,32 +339,28 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 343 | 339 | ||
| 344 | @Override | 340 | @Override |
| 345 | public KeyValue<Integer, Integer> expireCombinationRecord() { | 341 | public KeyValue<Integer, Integer> expireCombinationRecord() { |
| 346 | - // TODO @puhui999:数字一般是 1. 2. 这种格式哈 | ||
| 347 | - // 1。获取所有正在进行中的过期的父拼团 | 342 | + // 1.获取所有正在进行中的过期的父拼团 |
| 348 | List<CombinationRecordDO> headExpireRecords = combinationRecordMapper.selectListByHeadIdAndStatusAndExpireTimeLt( | 343 | List<CombinationRecordDO> headExpireRecords = combinationRecordMapper.selectListByHeadIdAndStatusAndExpireTimeLt( |
| 349 | CombinationRecordDO.HEAD_ID_GROUP, CombinationRecordStatusEnum.IN_PROGRESS.getStatus(), LocalDateTime.now()); | 344 | CombinationRecordDO.HEAD_ID_GROUP, CombinationRecordStatusEnum.IN_PROGRESS.getStatus(), LocalDateTime.now()); |
| 350 | if (CollUtil.isEmpty(headExpireRecords)) { | 345 | if (CollUtil.isEmpty(headExpireRecords)) { |
| 351 | return new KeyValue<>(0, 0); | 346 | return new KeyValue<>(0, 0); |
| 352 | } | 347 | } |
| 353 | 348 | ||
| 354 | - // 2. 获取拼团活动 | ||
| 355 | - // TODO @puhui999:在自己模块里,变量可以简略点;例如说 activityList | ||
| 356 | - List<CombinationActivityDO> combinationActivities = combinationActivityService.getCombinationActivityListByIds( | 349 | + // 2.获取拼团活动 |
| 350 | + List<CombinationActivityDO> activities = combinationActivityService.getCombinationActivityListByIds( | ||
| 357 | convertSet(headExpireRecords, CombinationRecordDO::getActivityId)); | 351 | convertSet(headExpireRecords, CombinationRecordDO::getActivityId)); |
| 358 | - Map<Long, CombinationActivityDO> activityMap = convertMap(combinationActivities, CombinationActivityDO::getId); | 352 | + Map<Long, CombinationActivityDO> activityMap = convertMap(activities, CombinationActivityDO::getId); |
| 359 | 353 | ||
| 360 | - // TODO @puhui999:job 一般不建议异步跑;因为可能下次跑,结果上次还没跑完; | ||
| 361 | - // TODO 这里,我们可以每个 record 处理下;然后按照是否需要虚拟拼团,各搞一个方法逻辑 + 事务;这样,保证 job 里面尽量不要大事务,而是 n 个独立小事务的处理。 | ||
| 362 | - // 3. 校验是否虚拟成团 | 354 | + // 3.校验是否虚拟成团 |
| 363 | List<CombinationRecordDO> virtualGroupHeadRecords = new ArrayList<>(); // 虚拟成团 | 355 | List<CombinationRecordDO> virtualGroupHeadRecords = new ArrayList<>(); // 虚拟成团 |
| 364 | for (Iterator<CombinationRecordDO> iterator = headExpireRecords.iterator(); iterator.hasNext(); ) { | 356 | for (Iterator<CombinationRecordDO> iterator = headExpireRecords.iterator(); iterator.hasNext(); ) { |
| 365 | CombinationRecordDO record = iterator.next(); | 357 | CombinationRecordDO record = iterator.next(); |
| 366 | - // 3.1 不匹配,则直接跳过 | 358 | + // 3.1.不匹配,则直接跳过 |
| 367 | CombinationActivityDO activity = activityMap.get(record.getActivityId()); | 359 | CombinationActivityDO activity = activityMap.get(record.getActivityId()); |
| 368 | if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的 | 360 | if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的 |
| 369 | continue; | 361 | continue; |
| 370 | } | 362 | } |
| 371 | - // 3.2 匹配,则移除,添加到虚拟成团中,并结束寻找 | 363 | + // 3.2.匹配,则移除,添加到虚拟成团中,并结束寻找 |
| 372 | virtualGroupHeadRecords.add(record); | 364 | virtualGroupHeadRecords.add(record); |
| 373 | iterator.remove(); | 365 | iterator.remove(); |
| 374 | break; | 366 | break; |
| @@ -381,8 +373,13 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -381,8 +373,13 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 381 | return new KeyValue<>(headExpireRecords.size(), virtualGroupHeadRecords.size()); | 373 | return new KeyValue<>(headExpireRecords.size(), virtualGroupHeadRecords.size()); |
| 382 | } | 374 | } |
| 383 | 375 | ||
| 384 | - @Async | ||
| 385 | - protected void handleExpireRecord(List<CombinationRecordDO> headExpireRecords) { | 376 | + /** |
| 377 | + * 处理过期拼团 | ||
| 378 | + * | ||
| 379 | + * @param headExpireRecords 过期拼团团长记录列表 | ||
| 380 | + */ | ||
| 381 | + @Transactional(rollbackFor = Exception.class) | ||
| 382 | + public void handleExpireRecord(List<CombinationRecordDO> headExpireRecords) { | ||
| 386 | if (CollUtil.isEmpty(headExpireRecords)) { | 383 | if (CollUtil.isEmpty(headExpireRecords)) { |
| 387 | return; | 384 | return; |
| 388 | } | 385 | } |
| @@ -400,8 +397,13 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -400,8 +397,13 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 400 | }); | 397 | }); |
| 401 | } | 398 | } |
| 402 | 399 | ||
| 403 | - @Async | ||
| 404 | - protected void handleVirtualGroupRecord(List<CombinationRecordDO> virtualGroupHeadRecords) { | 400 | + /** |
| 401 | + * 处理虚拟拼团 | ||
| 402 | + * | ||
| 403 | + * @param virtualGroupHeadRecords 虚拟成团团长记录列表 | ||
| 404 | + */ | ||
| 405 | + @Transactional(rollbackFor = Exception.class) | ||
| 406 | + public void handleVirtualGroupRecord(List<CombinationRecordDO> virtualGroupHeadRecords) { | ||
| 405 | if (CollUtil.isEmpty(virtualGroupHeadRecords)) { | 407 | if (CollUtil.isEmpty(virtualGroupHeadRecords)) { |
| 406 | return; | 408 | return; |
| 407 | } | 409 | } |
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImplTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.article; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | ||
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryExportReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; | ||
| 10 | +import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleCategoryMapper; | ||
| 11 | +import org.junit.jupiter.api.Disabled; | ||
| 12 | +import org.junit.jupiter.api.Test; | ||
| 13 | +import org.springframework.context.annotation.Import; | ||
| 14 | + | ||
| 15 | +import javax.annotation.Resource; | ||
| 16 | +import java.util.List; | ||
| 17 | + | ||
| 18 | +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; | ||
| 19 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | ||
| 20 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | ||
| 21 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | ||
| 22 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | ||
| 23 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | ||
| 24 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS; | ||
| 25 | +import static org.junit.jupiter.api.Assertions.*; | ||
| 26 | + | ||
| 27 | +/** | ||
| 28 | + * {@link ArticleCategoryServiceImpl} 的单元测试类 | ||
| 29 | + * | ||
| 30 | + * @author HUIHUI | ||
| 31 | + */ | ||
| 32 | +@Import(ArticleCategoryServiceImpl.class) | ||
| 33 | +public class ArticleCategoryServiceImplTest extends BaseDbUnitTest { | ||
| 34 | + | ||
| 35 | + @Resource | ||
| 36 | + private ArticleCategoryServiceImpl articleCategoryService; | ||
| 37 | + | ||
| 38 | + @Resource | ||
| 39 | + private ArticleCategoryMapper articleCategoryMapper; | ||
| 40 | + | ||
| 41 | + @Test | ||
| 42 | + public void testCreateArticleCategory_success() { | ||
| 43 | + // 准备参数 | ||
| 44 | + ArticleCategoryCreateReqVO reqVO = randomPojo(ArticleCategoryCreateReqVO.class); | ||
| 45 | + | ||
| 46 | + // 调用 | ||
| 47 | + Long articleCategoryId = articleCategoryService.createArticleCategory(reqVO); | ||
| 48 | + // 断言 | ||
| 49 | + assertNotNull(articleCategoryId); | ||
| 50 | + // 校验记录的属性是否正确 | ||
| 51 | + ArticleCategoryDO articleCategory = articleCategoryMapper.selectById(articleCategoryId); | ||
| 52 | + assertPojoEquals(reqVO, articleCategory); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + @Test | ||
| 56 | + public void testUpdateArticleCategory_success() { | ||
| 57 | + // mock 数据 | ||
| 58 | + ArticleCategoryDO dbArticleCategory = randomPojo(ArticleCategoryDO.class); | ||
| 59 | + articleCategoryMapper.insert(dbArticleCategory);// @Sql: 先插入出一条存在的数据 | ||
| 60 | + // 准备参数 | ||
| 61 | + ArticleCategoryUpdateReqVO reqVO = randomPojo(ArticleCategoryUpdateReqVO.class, o -> { | ||
| 62 | + o.setId(dbArticleCategory.getId()); // 设置更新的 ID | ||
| 63 | + }); | ||
| 64 | + | ||
| 65 | + // 调用 | ||
| 66 | + articleCategoryService.updateArticleCategory(reqVO); | ||
| 67 | + // 校验是否更新正确 | ||
| 68 | + ArticleCategoryDO articleCategory = articleCategoryMapper.selectById(reqVO.getId()); // 获取最新的 | ||
| 69 | + assertPojoEquals(reqVO, articleCategory); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @Test | ||
| 73 | + public void testUpdateArticleCategory_notExists() { | ||
| 74 | + // 准备参数 | ||
| 75 | + ArticleCategoryUpdateReqVO reqVO = randomPojo(ArticleCategoryUpdateReqVO.class); | ||
| 76 | + | ||
| 77 | + // 调用, 并断言异常 | ||
| 78 | + assertServiceException(() -> articleCategoryService.updateArticleCategory(reqVO), ARTICLE_CATEGORY_NOT_EXISTS); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + @Test | ||
| 82 | + public void testDeleteArticleCategory_success() { | ||
| 83 | + // mock 数据 | ||
| 84 | + ArticleCategoryDO dbArticleCategory = randomPojo(ArticleCategoryDO.class); | ||
| 85 | + articleCategoryMapper.insert(dbArticleCategory);// @Sql: 先插入出一条存在的数据 | ||
| 86 | + // 准备参数 | ||
| 87 | + Long id = dbArticleCategory.getId(); | ||
| 88 | + | ||
| 89 | + // 调用 | ||
| 90 | + articleCategoryService.deleteArticleCategory(id); | ||
| 91 | + // 校验数据不存在了 | ||
| 92 | + assertNull(articleCategoryMapper.selectById(id)); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + @Test | ||
| 96 | + public void testDeleteArticleCategory_notExists() { | ||
| 97 | + // 准备参数 | ||
| 98 | + Long id = randomLongId(); | ||
| 99 | + | ||
| 100 | + // 调用, 并断言异常 | ||
| 101 | + assertServiceException(() -> articleCategoryService.deleteArticleCategory(id), ARTICLE_CATEGORY_NOT_EXISTS); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + @Test | ||
| 105 | + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | ||
| 106 | + public void testGetArticleCategoryPage() { | ||
| 107 | + // mock 数据 | ||
| 108 | + ArticleCategoryDO dbArticleCategory = randomPojo(ArticleCategoryDO.class, o -> { // 等会查询到 | ||
| 109 | + o.setName(null); | ||
| 110 | + o.setPicUrl(null); | ||
| 111 | + o.setStatus(null); | ||
| 112 | + o.setSort(null); | ||
| 113 | + o.setCreateTime(null); | ||
| 114 | + }); | ||
| 115 | + articleCategoryMapper.insert(dbArticleCategory); | ||
| 116 | + // 测试 name 不匹配 | ||
| 117 | + articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setName(null))); | ||
| 118 | + // 测试 picUrl 不匹配 | ||
| 119 | + articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setPicUrl(null))); | ||
| 120 | + // 测试 status 不匹配 | ||
| 121 | + articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setStatus(null))); | ||
| 122 | + // 测试 sort 不匹配 | ||
| 123 | + articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setSort(null))); | ||
| 124 | + // 测试 createTime 不匹配 | ||
| 125 | + articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setCreateTime(null))); | ||
| 126 | + // 准备参数 | ||
| 127 | + ArticleCategoryPageReqVO reqVO = new ArticleCategoryPageReqVO(); | ||
| 128 | + reqVO.setName(null); | ||
| 129 | + reqVO.setStatus(null); | ||
| 130 | + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | ||
| 131 | + | ||
| 132 | + // 调用 | ||
| 133 | + PageResult<ArticleCategoryDO> pageResult = articleCategoryService.getArticleCategoryPage(reqVO); | ||
| 134 | + // 断言 | ||
| 135 | + assertEquals(1, pageResult.getTotal()); | ||
| 136 | + assertEquals(1, pageResult.getList().size()); | ||
| 137 | + assertPojoEquals(dbArticleCategory, pageResult.getList().get(0)); | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + @Test | ||
| 141 | + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | ||
| 142 | + public void testGetArticleCategoryList() { | ||
| 143 | + // mock 数据 | ||
| 144 | + ArticleCategoryDO dbArticleCategory = randomPojo(ArticleCategoryDO.class, o -> { // 等会查询到 | ||
| 145 | + o.setName(null); | ||
| 146 | + o.setPicUrl(null); | ||
| 147 | + o.setStatus(null); | ||
| 148 | + o.setSort(null); | ||
| 149 | + o.setCreateTime(null); | ||
| 150 | + }); | ||
| 151 | + articleCategoryMapper.insert(dbArticleCategory); | ||
| 152 | + // 测试 name 不匹配 | ||
| 153 | + articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setName(null))); | ||
| 154 | + // 测试 picUrl 不匹配 | ||
| 155 | + articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setPicUrl(null))); | ||
| 156 | + // 测试 status 不匹配 | ||
| 157 | + articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setStatus(null))); | ||
| 158 | + // 测试 sort 不匹配 | ||
| 159 | + articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setSort(null))); | ||
| 160 | + // 测试 createTime 不匹配 | ||
| 161 | + articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setCreateTime(null))); | ||
| 162 | + // 准备参数 | ||
| 163 | + ArticleCategoryExportReqVO reqVO = new ArticleCategoryExportReqVO(); | ||
| 164 | + reqVO.setName(null); | ||
| 165 | + reqVO.setStatus(null); | ||
| 166 | + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | ||
| 167 | + | ||
| 168 | + // 调用 | ||
| 169 | + List<ArticleCategoryDO> list = articleCategoryService.getArticleCategoryList(reqVO); | ||
| 170 | + // 断言 | ||
| 171 | + assertEquals(1, list.size()); | ||
| 172 | + assertPojoEquals(dbArticleCategory, list.get(0)); | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImplTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.article; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | ||
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; | ||
| 10 | +import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper; | ||
| 11 | +import org.junit.jupiter.api.Disabled; | ||
| 12 | +import org.junit.jupiter.api.Test; | ||
| 13 | +import org.springframework.context.annotation.Import; | ||
| 14 | + | ||
| 15 | +import javax.annotation.Resource; | ||
| 16 | +import java.util.List; | ||
| 17 | + | ||
| 18 | +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; | ||
| 19 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | ||
| 20 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | ||
| 21 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | ||
| 22 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | ||
| 23 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | ||
| 24 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_NOT_EXISTS; | ||
| 25 | +import static org.junit.jupiter.api.Assertions.*; | ||
| 26 | + | ||
| 27 | +/** | ||
| 28 | + * {@link ArticleServiceImpl} 的单元测试类 | ||
| 29 | + * | ||
| 30 | + * @author HUIHUI | ||
| 31 | + */ | ||
| 32 | +@Import(ArticleServiceImpl.class) | ||
| 33 | +public class ArticleServiceImplTest extends BaseDbUnitTest { | ||
| 34 | + | ||
| 35 | + @Resource | ||
| 36 | + private ArticleServiceImpl articleService; | ||
| 37 | + | ||
| 38 | + @Resource | ||
| 39 | + private ArticleMapper articleMapper; | ||
| 40 | + | ||
| 41 | + @Test | ||
| 42 | + public void testCreateArticle_success() { | ||
| 43 | + // 准备参数 | ||
| 44 | + ArticleCreateReqVO reqVO = randomPojo(ArticleCreateReqVO.class); | ||
| 45 | + | ||
| 46 | + // 调用 | ||
| 47 | + Long articleId = articleService.createArticle(reqVO); | ||
| 48 | + // 断言 | ||
| 49 | + assertNotNull(articleId); | ||
| 50 | + // 校验记录的属性是否正确 | ||
| 51 | + ArticleDO article = articleMapper.selectById(articleId); | ||
| 52 | + assertPojoEquals(reqVO, article); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + @Test | ||
| 56 | + public void testUpdateArticle_success() { | ||
| 57 | + // mock 数据 | ||
| 58 | + ArticleDO dbArticle = randomPojo(ArticleDO.class); | ||
| 59 | + articleMapper.insert(dbArticle);// @Sql: 先插入出一条存在的数据 | ||
| 60 | + // 准备参数 | ||
| 61 | + ArticleUpdateReqVO reqVO = randomPojo(ArticleUpdateReqVO.class, o -> { | ||
| 62 | + o.setId(dbArticle.getId()); // 设置更新的 ID | ||
| 63 | + }); | ||
| 64 | + | ||
| 65 | + // 调用 | ||
| 66 | + articleService.updateArticle(reqVO); | ||
| 67 | + // 校验是否更新正确 | ||
| 68 | + ArticleDO article = articleMapper.selectById(reqVO.getId()); // 获取最新的 | ||
| 69 | + assertPojoEquals(reqVO, article); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @Test | ||
| 73 | + public void testUpdateArticle_notExists() { | ||
| 74 | + // 准备参数 | ||
| 75 | + ArticleUpdateReqVO reqVO = randomPojo(ArticleUpdateReqVO.class); | ||
| 76 | + | ||
| 77 | + // 调用, 并断言异常 | ||
| 78 | + assertServiceException(() -> articleService.updateArticle(reqVO), ARTICLE_NOT_EXISTS); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + @Test | ||
| 82 | + public void testDeleteArticle_success() { | ||
| 83 | + // mock 数据 | ||
| 84 | + ArticleDO dbArticle = randomPojo(ArticleDO.class); | ||
| 85 | + articleMapper.insert(dbArticle);// @Sql: 先插入出一条存在的数据 | ||
| 86 | + // 准备参数 | ||
| 87 | + Long id = dbArticle.getId(); | ||
| 88 | + | ||
| 89 | + // 调用 | ||
| 90 | + articleService.deleteArticle(id); | ||
| 91 | + // 校验数据不存在了 | ||
| 92 | + assertNull(articleMapper.selectById(id)); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + @Test | ||
| 96 | + public void testDeleteArticle_notExists() { | ||
| 97 | + // 准备参数 | ||
| 98 | + Long id = randomLongId(); | ||
| 99 | + | ||
| 100 | + // 调用, 并断言异常 | ||
| 101 | + assertServiceException(() -> articleService.deleteArticle(id), ARTICLE_NOT_EXISTS); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + @Test | ||
| 105 | + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | ||
| 106 | + public void testGetArticlePage() { | ||
| 107 | + // mock 数据 | ||
| 108 | + ArticleDO dbArticle = randomPojo(ArticleDO.class, o -> { // 等会查询到 | ||
| 109 | + o.setCategoryId(null); | ||
| 110 | + o.setTitle(null); | ||
| 111 | + o.setAuthor(null); | ||
| 112 | + o.setPicUrl(null); | ||
| 113 | + o.setIntroduction(null); | ||
| 114 | + o.setBrowseCount(null); | ||
| 115 | + o.setSort(null); | ||
| 116 | + o.setStatus(null); | ||
| 117 | + o.setSpuId(null); | ||
| 118 | + o.setRecommendHot(null); | ||
| 119 | + o.setRecommendBanner(null); | ||
| 120 | + o.setContent(null); | ||
| 121 | + o.setCreateTime(null); | ||
| 122 | + }); | ||
| 123 | + articleMapper.insert(dbArticle); | ||
| 124 | + // 测试 categoryId 不匹配 | ||
| 125 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setCategoryId(null))); | ||
| 126 | + // 测试 title 不匹配 | ||
| 127 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setTitle(null))); | ||
| 128 | + // 测试 author 不匹配 | ||
| 129 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setAuthor(null))); | ||
| 130 | + // 测试 picUrl 不匹配 | ||
| 131 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setPicUrl(null))); | ||
| 132 | + // 测试 introduction 不匹配 | ||
| 133 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setIntroduction(null))); | ||
| 134 | + // 测试 browseCount 不匹配 | ||
| 135 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setBrowseCount(null))); | ||
| 136 | + // 测试 sort 不匹配 | ||
| 137 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setSort(null))); | ||
| 138 | + // 测试 status 不匹配 | ||
| 139 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setStatus(null))); | ||
| 140 | + // 测试 spuId 不匹配 | ||
| 141 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setSpuId(null))); | ||
| 142 | + // 测试 recommendHot 不匹配 | ||
| 143 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setRecommendHot(null))); | ||
| 144 | + // 测试 recommendBanner 不匹配 | ||
| 145 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setRecommendBanner(null))); | ||
| 146 | + // 测试 content 不匹配 | ||
| 147 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setContent(null))); | ||
| 148 | + // 测试 createTime 不匹配 | ||
| 149 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setCreateTime(null))); | ||
| 150 | + // 准备参数 | ||
| 151 | + ArticlePageReqVO reqVO = new ArticlePageReqVO(); | ||
| 152 | + reqVO.setCategoryId(null); | ||
| 153 | + reqVO.setTitle(null); | ||
| 154 | + reqVO.setAuthor(null); | ||
| 155 | + reqVO.setStatus(null); | ||
| 156 | + reqVO.setSpuId(null); | ||
| 157 | + reqVO.setRecommendHot(null); | ||
| 158 | + reqVO.setRecommendBanner(null); | ||
| 159 | + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | ||
| 160 | + | ||
| 161 | + // 调用 | ||
| 162 | + PageResult<ArticleDO> pageResult = articleService.getArticlePage(reqVO); | ||
| 163 | + // 断言 | ||
| 164 | + assertEquals(1, pageResult.getTotal()); | ||
| 165 | + assertEquals(1, pageResult.getList().size()); | ||
| 166 | + assertPojoEquals(dbArticle, pageResult.getList().get(0)); | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + @Test | ||
| 170 | + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | ||
| 171 | + public void testGetArticleList() { | ||
| 172 | + // mock 数据 | ||
| 173 | + ArticleDO dbArticle = randomPojo(ArticleDO.class, o -> { // 等会查询到 | ||
| 174 | + o.setCategoryId(null); | ||
| 175 | + o.setTitle(null); | ||
| 176 | + o.setAuthor(null); | ||
| 177 | + o.setPicUrl(null); | ||
| 178 | + o.setIntroduction(null); | ||
| 179 | + o.setBrowseCount(null); | ||
| 180 | + o.setSort(null); | ||
| 181 | + o.setStatus(null); | ||
| 182 | + o.setSpuId(null); | ||
| 183 | + o.setRecommendHot(null); | ||
| 184 | + o.setRecommendBanner(null); | ||
| 185 | + o.setContent(null); | ||
| 186 | + o.setCreateTime(null); | ||
| 187 | + }); | ||
| 188 | + articleMapper.insert(dbArticle); | ||
| 189 | + // 测试 categoryId 不匹配 | ||
| 190 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setCategoryId(null))); | ||
| 191 | + // 测试 title 不匹配 | ||
| 192 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setTitle(null))); | ||
| 193 | + // 测试 author 不匹配 | ||
| 194 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setAuthor(null))); | ||
| 195 | + // 测试 picUrl 不匹配 | ||
| 196 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setPicUrl(null))); | ||
| 197 | + // 测试 introduction 不匹配 | ||
| 198 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setIntroduction(null))); | ||
| 199 | + // 测试 browseCount 不匹配 | ||
| 200 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setBrowseCount(null))); | ||
| 201 | + // 测试 sort 不匹配 | ||
| 202 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setSort(null))); | ||
| 203 | + // 测试 status 不匹配 | ||
| 204 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setStatus(null))); | ||
| 205 | + // 测试 spuId 不匹配 | ||
| 206 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setSpuId(null))); | ||
| 207 | + // 测试 recommendHot 不匹配 | ||
| 208 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setRecommendHot(null))); | ||
| 209 | + // 测试 recommendBanner 不匹配 | ||
| 210 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setRecommendBanner(null))); | ||
| 211 | + // 测试 content 不匹配 | ||
| 212 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setContent(null))); | ||
| 213 | + // 测试 createTime 不匹配 | ||
| 214 | + articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setCreateTime(null))); | ||
| 215 | + // 准备参数 | ||
| 216 | + ArticleExportReqVO reqVO = new ArticleExportReqVO(); | ||
| 217 | + reqVO.setCategoryId(null); | ||
| 218 | + reqVO.setTitle(null); | ||
| 219 | + reqVO.setAuthor(null); | ||
| 220 | + reqVO.setStatus(null); | ||
| 221 | + reqVO.setSpuId(null); | ||
| 222 | + reqVO.setRecommendHot(null); | ||
| 223 | + reqVO.setRecommendBanner(null); | ||
| 224 | + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | ||
| 225 | + | ||
| 226 | + // 调用 | ||
| 227 | + List<ArticleDO> list = articleService.getArticleList(reqVO); | ||
| 228 | + // 断言 | ||
| 229 | + assertEquals(1, list.size()); | ||
| 230 | + assertPojoEquals(dbArticle, list.get(0)); | ||
| 231 | + } | ||
| 232 | + | ||
| 233 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql
| @@ -6,3 +6,7 @@ DELETE FROM "promotion_discount_activity"; | @@ -6,3 +6,7 @@ DELETE FROM "promotion_discount_activity"; | ||
| 6 | DELETE FROM "promotion_discount_product"; | 6 | DELETE FROM "promotion_discount_product"; |
| 7 | DELETE FROM "promotion_seckill_config"; | 7 | DELETE FROM "promotion_seckill_config"; |
| 8 | DELETE FROM "promotion_combination_activity"; | 8 | DELETE FROM "promotion_combination_activity"; |
| 9 | +DELETE | ||
| 10 | +FROM "promotion_article_category"; | ||
| 11 | +DELETE | ||
| 12 | +FROM "promotion_article"; |
yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql
| @@ -180,4 +180,44 @@ CREATE TABLE IF NOT EXISTS "promotion_combination_activity" | @@ -180,4 +180,44 @@ CREATE TABLE IF NOT EXISTS "promotion_combination_activity" | ||
| 180 | "deleted" bit NOT NULL DEFAULT FALSE, | 180 | "deleted" bit NOT NULL DEFAULT FALSE, |
| 181 | "tenant_id" bigint NOT NULL, | 181 | "tenant_id" bigint NOT NULL, |
| 182 | PRIMARY KEY ("id") | 182 | PRIMARY KEY ("id") |
| 183 | -) COMMENT '拼团活动'; | ||
| 184 | \ No newline at end of file | 183 | \ No newline at end of file |
| 184 | +) COMMENT '拼团活动'; | ||
| 185 | + | ||
| 186 | +CREATE TABLE IF NOT EXISTS "promotion_article_category" | ||
| 187 | +( | ||
| 188 | + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | ||
| 189 | + "name" varchar NOT NULL, | ||
| 190 | + "pic_url" varchar, | ||
| 191 | + "status" int NOT NULL, | ||
| 192 | + "sort" int NOT NULL, | ||
| 193 | + "creator" varchar DEFAULT '', | ||
| 194 | + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| 195 | + "updater" varchar DEFAULT '', | ||
| 196 | + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
| 197 | + "deleted" bit NOT NULL DEFAULT FALSE, | ||
| 198 | + "tenant_id" bigint NOT NULL, | ||
| 199 | + PRIMARY KEY ("id") | ||
| 200 | +) COMMENT '文章分类表'; | ||
| 201 | + | ||
| 202 | +CREATE TABLE IF NOT EXISTS "promotion_article" | ||
| 203 | +( | ||
| 204 | + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | ||
| 205 | + "category_id" bigint NOT NULL, | ||
| 206 | + "title" varchar NOT NULL, | ||
| 207 | + "author" varchar, | ||
| 208 | + "pic_url" varchar NOT NULL, | ||
| 209 | + "introduction" varchar, | ||
| 210 | + "browse_count" varchar, | ||
| 211 | + "sort" int NOT NULL, | ||
| 212 | + "status" int NOT NULL, | ||
| 213 | + "spu_id" bigint NOT NULL, | ||
| 214 | + "recommend_hot" bit NOT NULL, | ||
| 215 | + "recommend_banner" bit NOT NULL, | ||
| 216 | + "content" varchar NOT NULL, | ||
| 217 | + "creator" varchar DEFAULT '', | ||
| 218 | + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| 219 | + "updater" varchar DEFAULT '', | ||
| 220 | + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
| 221 | + "deleted" bit NOT NULL DEFAULT FALSE, | ||
| 222 | + "tenant_id" bigint NOT NULL, | ||
| 223 | + PRIMARY KEY ("id") | ||
| 224 | +) COMMENT '文章管理表'; | ||
| 185 | \ No newline at end of file | 225 | \ No newline at end of file |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java
| @@ -93,16 +93,19 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> { | @@ -93,16 +93,19 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> { | ||
| 93 | return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode); | 93 | return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | - // TODO @hui999:是不是只针对 combinationActivityId 的查询呀? | 96 | + /** |
| 97 | + * 只针对 combinationActivityId 的查询 | ||
| 98 | + * | ||
| 99 | + * @param userId 用户编号 | ||
| 100 | + * @param activityId 拼团活动编号 | ||
| 101 | + * @param status 订单状态 | ||
| 102 | + * @return 交易订单 | ||
| 103 | + */ | ||
| 97 | default TradeOrderDO selectByUserIdAndActivityIdAndStatus(Long userId, Long activityId, Integer status) { | 104 | default TradeOrderDO selectByUserIdAndActivityIdAndStatus(Long userId, Long activityId, Integer status) { |
| 98 | return selectOne(new LambdaQueryWrapperX<TradeOrderDO>() | 105 | return selectOne(new LambdaQueryWrapperX<TradeOrderDO>() |
| 99 | - .and(q -> q.eq(TradeOrderDO::getUserId, userId) | ||
| 100 | - .eq(TradeOrderDO::getStatus, status)) | ||
| 101 | - .and(q -> q.eq(TradeOrderDO::getCombinationActivityId, activityId) | ||
| 102 | - .or() | ||
| 103 | - .eq(TradeOrderDO::getSeckillActivityId, activityId) | ||
| 104 | - .or() | ||
| 105 | - .eq(TradeOrderDO::getBargainActivityId, activityId)) | 106 | + .eq(TradeOrderDO::getUserId, userId) |
| 107 | + .eq(TradeOrderDO::getStatus, status) | ||
| 108 | + .eq(TradeOrderDO::getCombinationActivityId, activityId) | ||
| 106 | ); | 109 | ); |
| 107 | } | 110 | } |
| 108 | 111 |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java
| 1 | package cn.iocoder.yudao.module.trade.service.order.handler; | 1 | package cn.iocoder.yudao.module.trade.service.order.handler; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.lang.Assert; | 3 | import cn.hutool.core.lang.Assert; |
| 4 | -import cn.iocoder.yudao.framework.common.core.KeyValue; | ||
| 5 | import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi; | 4 | import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi; |
| 5 | +import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; | ||
| 6 | import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; | 6 | import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; |
| 7 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; | 7 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; |
| 8 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; | 8 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; |
| @@ -49,7 +49,6 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler { | @@ -49,7 +49,6 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler { | ||
| 49 | order.getCombinationHeadId(), item.getSkuId(), item.getCount()); | 49 | order.getCombinationHeadId(), item.getSkuId(), item.getCount()); |
| 50 | 50 | ||
| 51 | // 2. 校验该用户是否存在未支付的拼团活动订单,避免一个拼团可以下多个单子了 | 51 | // 2. 校验该用户是否存在未支付的拼团活动订单,避免一个拼团可以下多个单子了 |
| 52 | - // TODO @puhui999:只校验未支付的拼团订单噢 | ||
| 53 | TradeOrderDO activityOrder = orderQueryService.getActivityOrderByUserIdAndActivityIdAndStatus( | 52 | TradeOrderDO activityOrder = orderQueryService.getActivityOrderByUserIdAndActivityIdAndStatus( |
| 54 | order.getUserId(), order.getCombinationActivityId(), TradeOrderStatusEnum.UNPAID.getStatus()); | 53 | order.getUserId(), order.getCombinationActivityId(), TradeOrderStatusEnum.UNPAID.getStatus()); |
| 55 | if (activityOrder != null) { | 54 | if (activityOrder != null) { |
| @@ -67,13 +66,14 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler { | @@ -67,13 +66,14 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler { | ||
| 67 | 66 | ||
| 68 | // 2. 创建拼团记录 | 67 | // 2. 创建拼团记录 |
| 69 | TradeOrderItemDO item = orderItems.get(0); | 68 | TradeOrderItemDO item = orderItems.get(0); |
| 70 | - KeyValue<Long, Long> recordIdAndHeadId = combinationRecordApi.createCombinationRecord( | 69 | + CombinationRecordCreateRespDTO combinationRecord = combinationRecordApi.createCombinationRecord( |
| 71 | TradeOrderConvert.INSTANCE.convert(order, item)); | 70 | TradeOrderConvert.INSTANCE.convert(order, item)); |
| 72 | 71 | ||
| 73 | // 3. 更新拼团相关信息到订单 | 72 | // 3. 更新拼团相关信息到订单 |
| 74 | - // TODO 芋艿,只需要更新 record | 73 | + // TODO 芋艿,只需要更新 record。 如果创建订单时自己是团长的情况下 combinationHeadId 是为 null 的, |
| 74 | + // 设置团长编号这个操作时在订单是否后创建拼团记录时才设置的,所以支付完创建拼团记录后需要设置一下记录编号和团长编号 | ||
| 75 | orderUpdateService.updateOrderCombinationInfo(order.getId(), order.getCombinationActivityId(), | 75 | orderUpdateService.updateOrderCombinationInfo(order.getId(), order.getCombinationActivityId(), |
| 76 | - recordIdAndHeadId.getKey(), recordIdAndHeadId.getValue()); | 76 | + combinationRecord.getCombinationRecordId(), combinationRecord.getCombinationHeadId()); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | @Override | 79 | @Override |
yudao-server/src/main/resources/application-local.yaml
| @@ -174,8 +174,8 @@ debug: false | @@ -174,8 +174,8 @@ debug: false | ||
| 174 | --- #################### 微信公众号、小程序相关配置 #################### | 174 | --- #################### 微信公众号、小程序相关配置 #################### |
| 175 | wx: | 175 | wx: |
| 176 | mp: # 公众号配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档 | 176 | mp: # 公众号配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档 |
| 177 | -# app-id: wx041349c6f39b268b | ||
| 178 | -# secret: 5abee519483bc9f8cb37ce280e814bd0 | 177 | + # app-id: wx041349c6f39b268b |
| 178 | + # secret: 5abee519483bc9f8cb37ce280e814bd0 | ||
| 179 | app-id: wx5b23ba7a5589ecbb # 测试号 | 179 | app-id: wx5b23ba7a5589ecbb # 测试号 |
| 180 | secret: 2a7b3b20c537e52e74afd395eb85f61f | 180 | secret: 2a7b3b20c537e52e74afd395eb85f61f |
| 181 | # 存储配置,解决 AccessToken 的跨节点的共享 | 181 | # 存储配置,解决 AccessToken 的跨节点的共享 |
| @@ -184,8 +184,8 @@ wx: | @@ -184,8 +184,8 @@ wx: | ||
| 184 | key-prefix: wx # Redis Key 的前缀 | 184 | key-prefix: wx # Redis Key 的前缀 |
| 185 | http-client-type: HttpClient # 采用 HttpClient 请求微信公众号平台 | 185 | http-client-type: HttpClient # 采用 HttpClient 请求微信公众号平台 |
| 186 | miniapp: # 小程序配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-miniapp-spring-boot-starter/README.md 文档 | 186 | miniapp: # 小程序配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-miniapp-spring-boot-starter/README.md 文档 |
| 187 | -# appid: wx62056c0d5e8db250 | ||
| 188 | -# secret: 333ae72f41552af1e998fe1f54e1584a | 187 | + # appid: wx62056c0d5e8db250 |
| 188 | + # secret: 333ae72f41552af1e998fe1f54e1584a | ||
| 189 | appid: wx63c280fe3248a3e7 # wenhualian的接口测试号 | 189 | appid: wx63c280fe3248a3e7 # wenhualian的接口测试号 |
| 190 | secret: 6f270509224a7ae1296bbf1c8cb97aed | 190 | secret: 6f270509224a7ae1296bbf1c8cb97aed |
| 191 | config-storage: | 191 | config-storage: |