!666 营销活动:新增文章管理,文章分类管理
Merge pull request !666 from puhui999/feature/mall_product
This commit is contained in:
commit
7bc3b7b2ff
|
@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*;
|
|||
import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
|
||||
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
|
||||
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
@ -22,6 +23,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -88,11 +90,13 @@ public class ProductSpuController {
|
|||
return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus));
|
||||
}
|
||||
|
||||
@GetMapping("/get-simple-list")
|
||||
@GetMapping("/list-all-simple")
|
||||
@Operation(summary = "获得商品 SPU 精简列表")
|
||||
@PreAuthorize("@ss.hasPermission('product:spu:query')")
|
||||
public CommonResult<List<ProductSpuSimpleRespVO>> getSpuSimpleList() {
|
||||
List<ProductSpuDO> list = productSpuService.getSpuList();
|
||||
List<ProductSpuDO> list = productSpuService.getSpuListByStatus(ProductSpuStatusEnum.ENABLE.getStatus());
|
||||
// 降序排序后,返回给前端
|
||||
list.sort(Comparator.comparing(ProductSpuDO::getSort).reversed());
|
||||
return success(ProductSpuConvert.INSTANCE.convertList02(list));
|
||||
}
|
||||
|
||||
|
|
|
@ -68,11 +68,12 @@ public interface ProductSpuService {
|
|||
}
|
||||
|
||||
/**
|
||||
* 获得所有商品 SPU 列表
|
||||
* 获得指定状态的商品 SPU 列表
|
||||
*
|
||||
* @param status 状态
|
||||
* @return 商品 SPU 列表
|
||||
*/
|
||||
List<ProductSpuDO> getSpuList();
|
||||
List<ProductSpuDO> getSpuListByStatus(Integer status);
|
||||
|
||||
/**
|
||||
* 获得所有商品 SPU 列表
|
||||
|
@ -146,4 +147,5 @@ public interface ProductSpuService {
|
|||
* @return 商品 SPU 列表
|
||||
*/
|
||||
List<ProductSpuDO> validateSpuList(Collection<Long> ids);
|
||||
|
||||
}
|
||||
|
|
|
@ -196,8 +196,8 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ProductSpuDO> getSpuList() {
|
||||
return productSpuMapper.selectList();
|
||||
public List<ProductSpuDO> getSpuListByStatus(Integer status) {
|
||||
return productSpuMapper.selectList(ProductSpuDO::getStatus, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package cn.iocoder.yudao.module.promotion.api.combination;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
@ -28,9 +28,9 @@ public interface CombinationRecordApi {
|
|||
* 创建开团记录
|
||||
*
|
||||
* @param reqDTO 请求 DTO
|
||||
* @return key 开团记录编号、value 团长编号
|
||||
* @return 团信息
|
||||
*/
|
||||
KeyValue<Long, Long> createCombinationRecord(@Valid CombinationRecordCreateReqDTO reqDTO);
|
||||
CombinationRecordCreateRespDTO createCombinationRecord(@Valid CombinationRecordCreateReqDTO reqDTO);
|
||||
|
||||
/**
|
||||
* 查询拼团记录是否成功
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package cn.iocoder.yudao.module.promotion.api.combination.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 拼团记录的创建 Response DTO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Data
|
||||
public class CombinationRecordCreateRespDTO {
|
||||
|
||||
/**
|
||||
* 拼团活动编号
|
||||
*
|
||||
* 关联 CombinationActivityDO 的 id 字段
|
||||
*/
|
||||
private Long combinationActivityId;
|
||||
/**
|
||||
* 拼团团长编号
|
||||
*
|
||||
* 关联 CombinationRecordDO 的 headId 字段
|
||||
*/
|
||||
private Long combinationHeadId;
|
||||
/**
|
||||
* 拼团记录编号
|
||||
*
|
||||
* 关联 CombinationRecordDO 的 id 字段
|
||||
*/
|
||||
private Long combinationRecordId;
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package cn.iocoder.yudao.module.promotion.enums;
|
||||
|
||||
/**
|
||||
* promotion 字典类型的枚举类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
public class DictTypeConstants {
|
||||
|
||||
}
|
|
@ -110,4 +110,10 @@ public interface ErrorCodeConstants {
|
|||
ErrorCode BARGAIN_HELP_CREATE_FAIL_CONFLICT = new ErrorCode(1_013_014_003, "助力失败,请重试");
|
||||
ErrorCode BARGAIN_HELP_CREATE_FAIL_HELP_EXISTS = new ErrorCode(1_013_014_004, "助力失败,您已经助力过了");
|
||||
|
||||
// ========== 文章分类 1-013-015-000 ==========
|
||||
ErrorCode ARTICLE_CATEGORY_NOT_EXISTS = new ErrorCode(1_013_015_000, "分类不存在");
|
||||
|
||||
// ========== 文章管理 1-013-016-000 ==========
|
||||
ErrorCode ARTICLE_NOT_EXISTS = new ErrorCode(1_013_016_000, "文章管理不存在");
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package cn.iocoder.yudao.module.promotion.api.combination;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
||||
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
|
||||
import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService;
|
||||
|
@ -29,10 +30,9 @@ public class CombinationRecordApiImpl implements CombinationRecordApi {
|
|||
recordService.validateCombinationRecord(userId, activityId, headId, skuId, count);
|
||||
}
|
||||
|
||||
// TODO @puhui999:搞个创建的 RespDTO 哈;
|
||||
@Override
|
||||
public KeyValue<Long, Long> createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
|
||||
return recordService.createCombinationRecord(reqDTO);
|
||||
public CombinationRecordCreateRespDTO createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
|
||||
return CombinationActivityConvert.INSTANCE.convert4(recordService.createCombinationRecord(reqDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.article;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.*;
|
||||
import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO;
|
||||
import cn.iocoder.yudao.module.promotion.service.article.ArticleCategoryService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Tag(name = "管理后台 - 文章分类")
|
||||
@RestController
|
||||
@RequestMapping("/promotion/article-category")
|
||||
@Validated
|
||||
public class ArticleCategoryController {
|
||||
|
||||
@Resource
|
||||
private ArticleCategoryService articleCategoryService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建文章分类")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:article-category:create')")
|
||||
public CommonResult<Long> createArticleCategory(@Valid @RequestBody ArticleCategoryCreateReqVO createReqVO) {
|
||||
return success(articleCategoryService.createArticleCategory(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新文章分类")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:article-category:update')")
|
||||
public CommonResult<Boolean> updateArticleCategory(@Valid @RequestBody ArticleCategoryUpdateReqVO updateReqVO) {
|
||||
articleCategoryService.updateArticleCategory(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除文章分类")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('promotion:article-category:delete')")
|
||||
public CommonResult<Boolean> deleteArticleCategory(@RequestParam("id") Long id) {
|
||||
articleCategoryService.deleteArticleCategory(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得文章分类")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:article-category:query')")
|
||||
public CommonResult<ArticleCategoryRespVO> getArticleCategory(@RequestParam("id") Long id) {
|
||||
ArticleCategoryDO articleCategory = articleCategoryService.getArticleCategory(id);
|
||||
return success(ArticleCategoryConvert.INSTANCE.convert(articleCategory));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得文章分类列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:article-category:query')")
|
||||
public CommonResult<List<ArticleCategoryRespVO>> getArticleCategoryList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<ArticleCategoryDO> list = articleCategoryService.getArticleCategoryList(ids);
|
||||
return success(ArticleCategoryConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/list-all-simple")
|
||||
@Operation(summary = "获取文章分类精简信息列表", description = "只包含被开启的文章分类,主要用于前端的下拉选项")
|
||||
public CommonResult<List<ArticleCategorySimpleRespVO>> getSimpleDeptList() {
|
||||
// 获得部门列表,只要开启状态的
|
||||
List<ArticleCategoryDO> list = articleCategoryService.getArticleCategoryListByStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
// 降序排序后,返回给前端
|
||||
list.sort(Comparator.comparing(ArticleCategoryDO::getSort).reversed());
|
||||
return success(ArticleCategoryConvert.INSTANCE.convertList03(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得文章分类分页")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:article-category:query')")
|
||||
public CommonResult<PageResult<ArticleCategoryRespVO>> getArticleCategoryPage(@Valid ArticleCategoryPageReqVO pageVO) {
|
||||
PageResult<ArticleCategoryDO> pageResult = articleCategoryService.getArticleCategoryPage(pageVO);
|
||||
return success(ArticleCategoryConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出文章分类 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:article-category:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportArticleCategoryExcel(@Valid ArticleCategoryExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<ArticleCategoryDO> list = articleCategoryService.getArticleCategoryList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<ArticleCategoryExcelVO> datas = ArticleCategoryConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "文章分类.xls", "数据", ArticleCategoryExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.article;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.*;
|
||||
import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
|
||||
import cn.iocoder.yudao.module.promotion.service.article.ArticleService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Tag(name = "管理后台 - 文章管理")
|
||||
@RestController
|
||||
@RequestMapping("/promotion/article")
|
||||
@Validated
|
||||
public class ArticleController {
|
||||
|
||||
@Resource
|
||||
private ArticleService articleService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建文章管理")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:article:create')")
|
||||
public CommonResult<Long> createArticle(@Valid @RequestBody ArticleCreateReqVO createReqVO) {
|
||||
return success(articleService.createArticle(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新文章管理")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:article:update')")
|
||||
public CommonResult<Boolean> updateArticle(@Valid @RequestBody ArticleUpdateReqVO updateReqVO) {
|
||||
articleService.updateArticle(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除文章管理")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('promotion:article:delete')")
|
||||
public CommonResult<Boolean> deleteArticle(@RequestParam("id") Long id) {
|
||||
articleService.deleteArticle(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得文章管理")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:article:query')")
|
||||
public CommonResult<ArticleRespVO> getArticle(@RequestParam("id") Long id) {
|
||||
ArticleDO article = articleService.getArticle(id);
|
||||
return success(ArticleConvert.INSTANCE.convert(article));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得文章管理列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:article:query')")
|
||||
public CommonResult<List<ArticleRespVO>> getArticleList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<ArticleDO> list = articleService.getArticleList(ids);
|
||||
return success(ArticleConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得文章管理分页")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:article:query')")
|
||||
public CommonResult<PageResult<ArticleRespVO>> getArticlePage(@Valid ArticlePageReqVO pageVO) {
|
||||
PageResult<ArticleDO> pageResult = articleService.getArticlePage(pageVO);
|
||||
return success(ArticleConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出文章管理 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:article:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportArticleExcel(@Valid ArticleExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<ArticleDO> list = articleService.getArticleList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<ArticleExcelVO> datas = ArticleConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "文章管理.xls", "数据", ArticleExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 文章管理 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class ArticleBaseVO {
|
||||
|
||||
@Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15458")
|
||||
@NotNull(message = "文章分类编号不能为空")
|
||||
private Long categoryId;
|
||||
|
||||
@Schema(description = "关联商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22378")
|
||||
@NotNull(message = "关联商品不能为空")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "文章标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是一个标题")
|
||||
@NotNull(message = "文章标题不能为空")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "文章作者", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
private String author;
|
||||
|
||||
@Schema(description = "文章封面图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
|
||||
@NotNull(message = "文章封面图片地址不能为空")
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = "文章简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是一个简介")
|
||||
private String introduction;
|
||||
|
||||
@Schema(description = "浏览次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "111")
|
||||
private String browseCount;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否热门(小程序)", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@NotNull(message = "是否热门(小程序)不能为空")
|
||||
private Boolean recommendHot;
|
||||
|
||||
@Schema(description = "是否轮播图(小程序)", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@NotNull(message = "是否轮播图(小程序)不能为空")
|
||||
private Boolean recommendBanner;
|
||||
|
||||
@Schema(description = "文章内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是文章内容")
|
||||
@NotNull(message = "文章内容不能为空")
|
||||
private String content;
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 文章管理创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ArticleCreateReqVO extends ArticleBaseVO {
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
/**
|
||||
* 文章管理 Excel VO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Data
|
||||
public class ArticleExcelVO {
|
||||
|
||||
@ExcelProperty("文章编号")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("文章分类编号")
|
||||
private Long categoryId;
|
||||
|
||||
@ExcelProperty("关联商品编号")
|
||||
private Long spuId;
|
||||
|
||||
@ExcelProperty("文章标题")
|
||||
private String title;
|
||||
|
||||
@ExcelProperty("文章作者")
|
||||
private String author;
|
||||
|
||||
@ExcelProperty("文章封面图片地址")
|
||||
private String picUrl;
|
||||
|
||||
@ExcelProperty("文章简介")
|
||||
private String introduction;
|
||||
|
||||
@ExcelProperty("浏览次数")
|
||||
private String browseCount;
|
||||
|
||||
@ExcelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("是否热门(小程序)")
|
||||
private Boolean recommendHot;
|
||||
|
||||
@ExcelProperty("是否轮播图(小程序)")
|
||||
private Boolean recommendBanner;
|
||||
|
||||
@ExcelProperty("文章内容")
|
||||
private String content;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 文章管理 Excel 导出 Request VO,参数和 ArticlePageReqVO 是一致的")
|
||||
@Data
|
||||
public class ArticleExportReqVO {
|
||||
|
||||
@Schema(description = "文章分类编号", example = "15458")
|
||||
private Long categoryId;
|
||||
|
||||
@Schema(description = "关联商品编号", example = "22378")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "文章标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "文章作者")
|
||||
private String author;
|
||||
|
||||
@Schema(description = "状态", example = "2")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否热门(小程序)")
|
||||
private Boolean recommendHot;
|
||||
|
||||
@Schema(description = "是否轮播图(小程序)")
|
||||
private Boolean recommendBanner;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 文章管理分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ArticlePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "文章分类编号", example = "15458")
|
||||
private Long categoryId;
|
||||
|
||||
@Schema(description = "关联商品编号", example = "22378")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "文章标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "文章作者")
|
||||
private String author;
|
||||
|
||||
@Schema(description = "状态", example = "2")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否热门(小程序)")
|
||||
private Boolean recommendHot;
|
||||
|
||||
@Schema(description = "是否轮播图(小程序)")
|
||||
private Boolean recommendBanner;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 文章管理 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ArticleRespVO extends ArticleBaseVO {
|
||||
|
||||
@Schema(description = "文章编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8606")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 文章管理更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ArticleUpdateReqVO extends ArticleBaseVO {
|
||||
|
||||
@Schema(description = "文章编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8606")
|
||||
@NotNull(message = "文章编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 文章分类 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class ArticleCategoryBaseVO {
|
||||
|
||||
@Schema(description = "文章分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "秒杀")
|
||||
@NotNull(message = "文章分类名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "图标地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 文章分类创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ArticleCategoryCreateReqVO extends ArticleCategoryBaseVO {
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
/**
|
||||
* 文章分类 Excel VO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Data
|
||||
public class ArticleCategoryExcelVO {
|
||||
|
||||
@ExcelProperty("文章分类编号")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("文章分类名称")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("图标地址")
|
||||
private String picUrl;
|
||||
|
||||
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 文章分类 Excel 导出 Request VO,参数和 ArticleCategoryPageReqVO 是一致的")
|
||||
@Data
|
||||
public class ArticleCategoryExportReqVO {
|
||||
|
||||
@Schema(description = "文章分类名称", example = "秒杀")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "状态", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 文章分类分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ArticleCategoryPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "文章分类名称", example = "秒杀")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "状态", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 文章分类 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ArticleCategoryRespVO extends ArticleCategoryBaseVO {
|
||||
|
||||
@Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19490")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 文章分类精简信息 Response VO")
|
||||
@Data
|
||||
public class ArticleCategorySimpleRespVO {
|
||||
|
||||
@Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19490")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "文章分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "秒杀")
|
||||
private String name;
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 文章分类更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ArticleCategoryUpdateReqVO extends ArticleCategoryBaseVO {
|
||||
|
||||
@Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19490")
|
||||
@NotNull(message = "文章分类编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
|
@ -3,11 +3,11 @@ package cn.iocoder.yudao.module.promotion.controller.admin.combination;
|
|||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordPageItemRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPage2VO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordSummaryVO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
||||
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
|
||||
import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService;
|
||||
|
@ -40,7 +40,6 @@ public class CombinationRecordController {
|
|||
@Lazy
|
||||
private CombinationRecordService combinationRecordService;
|
||||
|
||||
// TODO @puhui999:getBargainRecordPage 和 getBargainRecordPage 是不是可以合并;然后 CombinationRecordReqPageVO 加一个 headId;
|
||||
// 然后如果 headId 非空,并且第一页,单独多查询一条 head ;放到第 0 个位置;相当于说,第一页特殊一点;
|
||||
|
||||
@GetMapping("/page")
|
||||
|
@ -48,21 +47,12 @@ public class CombinationRecordController {
|
|||
@PreAuthorize("@ss.hasPermission('promotion:combination-record:query')")
|
||||
public CommonResult<PageResult<CombinationRecordPageItemRespVO>> getBargainRecordPage(@Valid CombinationRecordReqPageVO pageVO) {
|
||||
PageResult<CombinationRecordDO> recordPage = combinationRecordService.getCombinationRecordPage(pageVO);
|
||||
// 拼接数据
|
||||
List<CombinationActivityDO> activities = combinationActivityService.getCombinationActivityListByIds(
|
||||
convertSet(recordPage.getList(), CombinationRecordDO::getActivityId));
|
||||
// TODO @puhui999:商品没读取
|
||||
return success(CombinationActivityConvert.INSTANCE.convert(recordPage, activities));
|
||||
}
|
||||
|
||||
@GetMapping("/page-by-headId")
|
||||
@Operation(summary = "获得拼团记录分页")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:combination-record:query')")
|
||||
public CommonResult<PageResult<CombinationRecordPageItemRespVO>> getBargainRecordPage(@Valid CombinationRecordReqPage2VO pageVO) {
|
||||
// 包含团长和团员的分页记录
|
||||
PageResult<CombinationRecordDO> recordPage = combinationRecordService.getCombinationRecordPage2(pageVO);
|
||||
List<CombinationActivityDO> activities = combinationActivityService.getCombinationActivityListByIds(
|
||||
List<CombinationProductDO> products = combinationActivityService.getCombinationProductListByActivityIds(
|
||||
convertSet(recordPage.getList(), CombinationRecordDO::getActivityId));
|
||||
return success(CombinationActivityConvert.INSTANCE.convert(recordPage, activities));
|
||||
return success(CombinationActivityConvert.INSTANCE.convert(recordPage, activities, products));
|
||||
}
|
||||
|
||||
@GetMapping("/get-summary")
|
||||
|
@ -70,7 +60,7 @@ public class CombinationRecordController {
|
|||
@PreAuthorize("@ss.hasPermission('promotion:combination-record:query')")
|
||||
public CommonResult<CombinationRecordSummaryVO> getCombinationRecordSummary() {
|
||||
CombinationRecordSummaryVO summaryVO = new CombinationRecordSummaryVO();
|
||||
summaryVO.setUserCount(combinationRecordService.getCombinationRecordCount(null, null, null)); // 获取拼团用户参与数量
|
||||
summaryVO.setUserCount(combinationRecordService.getCombinationUserCount()); // 获取拼团用户参与数量
|
||||
summaryVO.setSuccessCount(combinationRecordService.getCombinationRecordCount( // 获取成团记录
|
||||
CombinationRecordStatusEnum.SUCCESS.getStatus(), null, CombinationRecordDO.HEAD_ID_GROUP));
|
||||
summaryVO.setVirtualGroupCount(combinationRecordService.getCombinationRecordCount(// 获取虚拟成团记录
|
||||
|
|
|
@ -23,6 +23,9 @@ public class CombinationRecordReqPageVO extends PageParam {
|
|||
@InEnum(BargainRecordStatusEnum.class)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "团长编号", example = "1024")
|
||||
private Long headId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
|
|
@ -47,7 +47,7 @@ public class AppCombinationRecordController {
|
|||
public CommonResult<AppCombinationRecordSummaryRespVO> getCombinationRecordSummary() {
|
||||
AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO();
|
||||
// 1. 获得拼团参与用户数量
|
||||
Long count = combinationRecordService.getCombinationRecordCount(null, null, null);
|
||||
Long count = combinationRecordService.getCombinationUserCount();
|
||||
if (count == 0) {
|
||||
summary.setAvatars(Collections.emptyList());
|
||||
summary.setUserCount(count);
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package cn.iocoder.yudao.module.promotion.convert.article;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.*;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文章分类 Convert
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Mapper
|
||||
public interface ArticleCategoryConvert {
|
||||
|
||||
ArticleCategoryConvert INSTANCE = Mappers.getMapper(ArticleCategoryConvert.class);
|
||||
|
||||
ArticleCategoryDO convert(ArticleCategoryCreateReqVO bean);
|
||||
|
||||
ArticleCategoryDO convert(ArticleCategoryUpdateReqVO bean);
|
||||
|
||||
ArticleCategoryRespVO convert(ArticleCategoryDO bean);
|
||||
|
||||
List<ArticleCategoryRespVO> convertList(List<ArticleCategoryDO> list);
|
||||
|
||||
PageResult<ArticleCategoryRespVO> convertPage(PageResult<ArticleCategoryDO> page);
|
||||
|
||||
List<ArticleCategoryExcelVO> convertList02(List<ArticleCategoryDO> list);
|
||||
|
||||
List<ArticleCategorySimpleRespVO> convertList03(List<ArticleCategoryDO> list);
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package cn.iocoder.yudao.module.promotion.convert.article;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExcelVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文章管理 Convert
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Mapper
|
||||
public interface ArticleConvert {
|
||||
|
||||
ArticleConvert INSTANCE = Mappers.getMapper(ArticleConvert.class);
|
||||
|
||||
ArticleDO convert(ArticleCreateReqVO bean);
|
||||
|
||||
ArticleDO convert(ArticleUpdateReqVO bean);
|
||||
|
||||
ArticleRespVO convert(ArticleDO bean);
|
||||
|
||||
List<ArticleRespVO> convertList(List<ArticleDO> list);
|
||||
|
||||
PageResult<ArticleRespVO> convertPage(PageResult<ArticleDO> page);
|
||||
|
||||
List<ArticleExcelVO> convertList02(List<ArticleDO> list);
|
||||
|
||||
}
|
|
@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
|||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageItemRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityRespVO;
|
||||
|
@ -109,6 +110,11 @@ public interface CombinationActivityConvert {
|
|||
|
||||
CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO);
|
||||
|
||||
default CombinationRecordCreateRespDTO convert4(CombinationRecordDO combinationRecord) {
|
||||
return new CombinationRecordCreateRespDTO().setCombinationActivityId(combinationRecord.getActivityId())
|
||||
.setCombinationRecordId(combinationRecord.getId()).setCombinationHeadId(combinationRecord.getHeadId());
|
||||
}
|
||||
|
||||
default CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO,
|
||||
CombinationActivityDO activity, MemberUserRespDTO user,
|
||||
ProductSpuRespDTO spu, ProductSkuRespDTO sku) {
|
||||
|
@ -172,12 +178,14 @@ public interface CombinationActivityConvert {
|
|||
|
||||
PageResult<CombinationRecordPageItemRespVO> convert(PageResult<CombinationRecordDO> result);
|
||||
|
||||
default PageResult<CombinationRecordPageItemRespVO> convert(PageResult<CombinationRecordDO> recordPage, List<CombinationActivityDO> activities) {
|
||||
default PageResult<CombinationRecordPageItemRespVO> convert(PageResult<CombinationRecordDO> recordPage, List<CombinationActivityDO> activities, List<CombinationProductDO> products) {
|
||||
PageResult<CombinationRecordPageItemRespVO> result = convert(recordPage);
|
||||
// 拼接关联属性
|
||||
Map<Long, CombinationActivityDO> activityMap = convertMap(activities, CombinationActivityDO::getId);
|
||||
Map<Long, List<CombinationProductDO>> productsMap = convertMultiMap(products, CombinationProductDO::getActivityId);
|
||||
result.setList(CollectionUtils.convertList(result.getList(), item -> {
|
||||
findAndThen(activityMap, item.getActivityId(), activity -> {
|
||||
item.setActivity(convert(activity));
|
||||
item.setActivity(convert(activity).setProducts(convertList2(productsMap.get(item.getActivityId()))));
|
||||
});
|
||||
return item;
|
||||
}));
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package cn.iocoder.yudao.module.promotion.dal.dataobject.article;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 文章分类 DO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@TableName("promotion_article_category")
|
||||
@KeySequence("promotion_article_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ArticleCategoryDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 文章分类编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 文章分类名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 图标地址
|
||||
*/
|
||||
private String picUrl;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 枚举 {@link CommonStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package cn.iocoder.yudao.module.promotion.dal.dataobject.article;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 文章管理 DO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@TableName("promotion_article")
|
||||
@KeySequence("promotion_article_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ArticleDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 文章管理编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 分类编号 ArticleCategoryDO#id
|
||||
*/
|
||||
private Long categoryId;
|
||||
/**
|
||||
* 关联商品编号 ProductSpuDO#id
|
||||
*/
|
||||
private Long spuId;
|
||||
/**
|
||||
* 文章标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 文章作者
|
||||
*/
|
||||
private String author;
|
||||
/**
|
||||
* 文章封面图片地址
|
||||
*/
|
||||
private String picUrl;
|
||||
/**
|
||||
* 文章简介
|
||||
*/
|
||||
private String introduction;
|
||||
/**
|
||||
* 浏览次数
|
||||
*/
|
||||
private String browseCount;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 枚举 {@link CommonStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 是否热门(小程序)
|
||||
*/
|
||||
private Boolean recommendHot;
|
||||
/**
|
||||
* 是否轮播图(小程序)
|
||||
*/
|
||||
private Boolean recommendBanner;
|
||||
/**
|
||||
* 文章内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package cn.iocoder.yudao.module.promotion.dal.mysql.article;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryExportReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文章分类 Mapper
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Mapper
|
||||
public interface ArticleCategoryMapper extends BaseMapperX<ArticleCategoryDO> {
|
||||
|
||||
default PageResult<ArticleCategoryDO> selectPage(ArticleCategoryPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ArticleCategoryDO>()
|
||||
.likeIfPresent(ArticleCategoryDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ArticleCategoryDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(ArticleCategoryDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ArticleCategoryDO::getSort));
|
||||
}
|
||||
|
||||
default List<ArticleCategoryDO> selectList(ArticleCategoryExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<ArticleCategoryDO>()
|
||||
.likeIfPresent(ArticleCategoryDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ArticleCategoryDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(ArticleCategoryDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ArticleCategoryDO::getSort));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package cn.iocoder.yudao.module.promotion.dal.mysql.article;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文章管理 Mapper
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Mapper
|
||||
public interface ArticleMapper extends BaseMapperX<ArticleDO> {
|
||||
|
||||
default PageResult<ArticleDO> selectPage(ArticlePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ArticleDO>()
|
||||
.eqIfPresent(ArticleDO::getCategoryId, reqVO.getCategoryId())
|
||||
.eqIfPresent(ArticleDO::getTitle, reqVO.getTitle())
|
||||
.eqIfPresent(ArticleDO::getAuthor, reqVO.getAuthor())
|
||||
.eqIfPresent(ArticleDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(ArticleDO::getSpuId, reqVO.getSpuId())
|
||||
.eqIfPresent(ArticleDO::getRecommendHot, reqVO.getRecommendHot())
|
||||
.eqIfPresent(ArticleDO::getRecommendBanner, reqVO.getRecommendBanner())
|
||||
.betweenIfPresent(ArticleDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ArticleDO::getId));
|
||||
}
|
||||
|
||||
default List<ArticleDO> selectList(ArticleExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<ArticleDO>()
|
||||
.eqIfPresent(ArticleDO::getCategoryId, reqVO.getCategoryId())
|
||||
.eqIfPresent(ArticleDO::getTitle, reqVO.getTitle())
|
||||
.eqIfPresent(ArticleDO::getAuthor, reqVO.getAuthor())
|
||||
.eqIfPresent(ArticleDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(ArticleDO::getSpuId, reqVO.getSpuId())
|
||||
.eqIfPresent(ArticleDO::getRecommendHot, reqVO.getRecommendHot())
|
||||
.eqIfPresent(ArticleDO::getRecommendBanner, reqVO.getRecommendBanner())
|
||||
.betweenIfPresent(ArticleDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ArticleDO::getId));
|
||||
}
|
||||
|
||||
}
|
|
@ -86,7 +86,7 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> {
|
|||
.last("LIMIT " + count));
|
||||
}
|
||||
|
||||
// TODO @puhui999:是不是返回 BargainActivityDO 更干净哈?
|
||||
// TODO @puhui999:是不是返回 BargainActivityDO 更干净哈?分组后返回 DO 的话需要联表查询
|
||||
/**
|
||||
* 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号
|
||||
*
|
||||
|
|
|
@ -6,7 +6,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPage2VO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
@ -97,21 +96,19 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO
|
|||
}
|
||||
|
||||
default PageResult<CombinationRecordDO> selectPage(CombinationRecordReqPageVO pageVO) {
|
||||
return selectPage(pageVO, new LambdaQueryWrapperX<CombinationRecordDO>()
|
||||
LambdaQueryWrapperX<CombinationRecordDO> queryWrapper = new LambdaQueryWrapperX<CombinationRecordDO>()
|
||||
.eqIfPresent(CombinationRecordDO::getStatus, pageVO.getStatus())
|
||||
.betweenIfPresent(CombinationRecordDO::getCreateTime, pageVO.getCreateTime()));
|
||||
}
|
||||
|
||||
default PageResult<CombinationRecordDO> selectPage(CombinationRecordReqPage2VO pageVO) {
|
||||
return selectPage(pageVO, new LambdaQueryWrapperX<CombinationRecordDO>()
|
||||
.eq(CombinationRecordDO::getId, pageVO.getHeadId())
|
||||
.betweenIfPresent(CombinationRecordDO::getCreateTime, pageVO.getCreateTime());
|
||||
if (pageVO.getHeadId() != null) {
|
||||
queryWrapper.eq(CombinationRecordDO::getId, pageVO.getHeadId())
|
||||
.or()
|
||||
.eq(CombinationRecordDO::getHeadId, pageVO.getHeadId()));
|
||||
.eq(CombinationRecordDO::getHeadId, pageVO.getHeadId());
|
||||
}
|
||||
return selectPage(pageVO, queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定条件的记录数
|
||||
* 如果参数都为 null 时则查询用户拼团记录(DISTINCT 去重),也就是说查询会员表中的用户有多少人参与过拼团活动每个人只统计一次
|
||||
*
|
||||
* @param status 状态,可为 null
|
||||
* @param virtualGroup 是否虚拟成团,可为 null
|
||||
|
@ -119,12 +116,20 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO
|
|||
* @return 记录数
|
||||
*/
|
||||
default Long selectCountByHeadAndStatusAndVirtualGroup(Integer status, Boolean virtualGroup, Long headId) {
|
||||
return selectCount(new LambdaQueryWrapperX<CombinationRecordDO>()
|
||||
.eqIfPresent(CombinationRecordDO::getStatus, status)
|
||||
.eqIfPresent(CombinationRecordDO::getVirtualGroup, virtualGroup)
|
||||
.eqIfPresent(CombinationRecordDO::getHeadId, headId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户拼团记录(DISTINCT 去重),也就是说查询会员表中的用户有多少人参与过拼团活动每个人只统计一次
|
||||
*
|
||||
* @return 参加过拼团的用户数
|
||||
*/
|
||||
default Long selectUserDistinctCount() {
|
||||
return selectCount(new QueryWrapper<CombinationRecordDO>()
|
||||
// TODO @puhui999:这种偏逻辑性的,不要给 mapper 哈;可以考虑拆成 2 个 mapper,上层也是 2 个 service;
|
||||
.select(status == null && virtualGroup == null && headId == null, "DISTINCT (user_id)")
|
||||
.eq(status != null, "status", status)
|
||||
.eq(virtualGroup != null, "virtual_group", virtualGroup)
|
||||
.eq(headId != null, "head_id", headId)
|
||||
.select("DISTINCT (user_id)")
|
||||
.groupBy("user_id"));
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
package cn.iocoder.yudao.module.promotion.service.article;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryExportReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文章分类 Service 接口
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
public interface ArticleCategoryService {
|
||||
|
||||
/**
|
||||
* 创建文章分类
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createArticleCategory(@Valid ArticleCategoryCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新文章分类
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateArticleCategory(@Valid ArticleCategoryUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除文章分类
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteArticleCategory(Long id);
|
||||
|
||||
/**
|
||||
* 获得文章分类
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 文章分类
|
||||
*/
|
||||
ArticleCategoryDO getArticleCategory(Long id);
|
||||
|
||||
/**
|
||||
* 获得文章分类列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 文章分类列表
|
||||
*/
|
||||
List<ArticleCategoryDO> getArticleCategoryList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得文章分类分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 文章分类分页
|
||||
*/
|
||||
PageResult<ArticleCategoryDO> getArticleCategoryPage(ArticleCategoryPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得文章分类列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 文章分类列表
|
||||
*/
|
||||
List<ArticleCategoryDO> getArticleCategoryList(ArticleCategoryExportReqVO exportReqVO);
|
||||
|
||||
/**
|
||||
* 获得指定状态的文章分类列表
|
||||
*
|
||||
* @param status 状态
|
||||
* @return 文章分类列表
|
||||
*/
|
||||
List<ArticleCategoryDO> getArticleCategoryListByStatus(Integer status);
|
||||
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package cn.iocoder.yudao.module.promotion.service.article;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryExportReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleCategoryMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 文章分类 Service 实现类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ArticleCategoryServiceImpl implements ArticleCategoryService {
|
||||
|
||||
@Resource
|
||||
private ArticleCategoryMapper articleCategoryMapper;
|
||||
|
||||
@Override
|
||||
public Long createArticleCategory(ArticleCategoryCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
ArticleCategoryDO articleCategory = ArticleCategoryConvert.INSTANCE.convert(createReqVO);
|
||||
articleCategoryMapper.insert(articleCategory);
|
||||
// 返回
|
||||
return articleCategory.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateArticleCategory(ArticleCategoryUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateArticleCategoryExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ArticleCategoryDO updateObj = ArticleCategoryConvert.INSTANCE.convert(updateReqVO);
|
||||
articleCategoryMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteArticleCategory(Long id) {
|
||||
// 校验存在
|
||||
validateArticleCategoryExists(id);
|
||||
// 删除
|
||||
articleCategoryMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateArticleCategoryExists(Long id) {
|
||||
if (articleCategoryMapper.selectById(id) == null) {
|
||||
throw exception(ARTICLE_CATEGORY_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArticleCategoryDO getArticleCategory(Long id) {
|
||||
return articleCategoryMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArticleCategoryDO> getArticleCategoryList(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return ListUtil.empty();
|
||||
}
|
||||
return articleCategoryMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ArticleCategoryDO> getArticleCategoryPage(ArticleCategoryPageReqVO pageReqVO) {
|
||||
return articleCategoryMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArticleCategoryDO> getArticleCategoryList(ArticleCategoryExportReqVO exportReqVO) {
|
||||
return articleCategoryMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArticleCategoryDO> getArticleCategoryListByStatus(Integer status) {
|
||||
return articleCategoryMapper.selectList(ArticleCategoryDO::getStatus, status);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package cn.iocoder.yudao.module.promotion.service.article;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文章管理 Service 接口
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
public interface ArticleService {
|
||||
|
||||
/**
|
||||
* 创建文章管理
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createArticle(@Valid ArticleCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新文章管理
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateArticle(@Valid ArticleUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除文章管理
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteArticle(Long id);
|
||||
|
||||
/**
|
||||
* 获得文章管理
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 文章管理
|
||||
*/
|
||||
ArticleDO getArticle(Long id);
|
||||
|
||||
/**
|
||||
* 获得文章管理列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 文章管理列表
|
||||
*/
|
||||
List<ArticleDO> getArticleList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得文章管理分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 文章管理分页
|
||||
*/
|
||||
PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得文章管理列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 文章管理列表
|
||||
*/
|
||||
List<ArticleDO> getArticleList(ArticleExportReqVO exportReqVO);
|
||||
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package cn.iocoder.yudao.module.promotion.service.article;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 文章管理 Service 实现类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ArticleServiceImpl implements ArticleService {
|
||||
|
||||
@Resource
|
||||
private ArticleMapper articleMapper;
|
||||
|
||||
@Override
|
||||
public Long createArticle(ArticleCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
ArticleDO article = ArticleConvert.INSTANCE.convert(createReqVO);
|
||||
articleMapper.insert(article);
|
||||
// 返回
|
||||
return article.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateArticle(ArticleUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateArticleExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ArticleDO updateObj = ArticleConvert.INSTANCE.convert(updateReqVO);
|
||||
articleMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteArticle(Long id) {
|
||||
// 校验存在
|
||||
validateArticleExists(id);
|
||||
// 删除
|
||||
articleMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateArticleExists(Long id) {
|
||||
if (articleMapper.selectById(id) == null) {
|
||||
throw exception(ARTICLE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArticleDO getArticle(Long id) {
|
||||
return articleMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArticleDO> getArticleList(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return ListUtil.empty();
|
||||
}
|
||||
return articleMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO) {
|
||||
return articleMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArticleDO> getArticleList(ArticleExportReqVO exportReqVO) {
|
||||
return articleMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
|
@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.common.core.KeyValue;
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPage2VO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO;
|
||||
|
@ -50,9 +49,9 @@ public interface CombinationRecordService {
|
|||
* 创建拼团记录
|
||||
*
|
||||
* @param reqDTO 创建信息
|
||||
* @return key 开团记录编号 value 团长编号
|
||||
* @return 团信息
|
||||
*/
|
||||
KeyValue<Long, Long> createCombinationRecord(CombinationRecordCreateReqDTO reqDTO);
|
||||
CombinationRecordDO createCombinationRecord(CombinationRecordCreateReqDTO reqDTO);
|
||||
|
||||
/**
|
||||
* 获得拼团记录
|
||||
|
@ -94,7 +93,14 @@ public interface CombinationRecordService {
|
|||
* @param headId 团长编号,允许空。目的 headId 设置为 {@link CombinationRecordDO#HEAD_ID_GROUP} 时,可以设置
|
||||
* @return 记录数
|
||||
*/
|
||||
Long getCombinationRecordCount(@Nullable Integer status, @Nullable Boolean virtualGroup, @Nullable Long headId);
|
||||
Long getCombinationRecordCount(@Nullable Integer status, @Nullable Boolean virtualGroup, Long headId);
|
||||
|
||||
/**
|
||||
* 查询用户拼团记录(DISTINCT 去重),也就是说查询会员表中的用户有多少人参与过拼团活动每个人只统计一次
|
||||
*
|
||||
* @return 参加过拼团的用户数
|
||||
*/
|
||||
Long getCombinationUserCount();
|
||||
|
||||
/**
|
||||
* 获取最近的 count 条拼团记录
|
||||
|
@ -138,14 +144,6 @@ public interface CombinationRecordService {
|
|||
*/
|
||||
PageResult<CombinationRecordDO> getCombinationRecordPage(CombinationRecordReqPageVO pageVO);
|
||||
|
||||
/**
|
||||
* 获取拼团记录分页数据(通过团长查询)
|
||||
*
|
||||
* @param pageVO 分页请求
|
||||
* @return 拼团记录分页数据(包括团长的)
|
||||
*/
|
||||
PageResult<CombinationRecordDO> getCombinationRecordPage2(CombinationRecordReqPage2VO pageVO);
|
||||
|
||||
/**
|
||||
* 【拼团活动】获得拼团记录数量 Map
|
||||
*
|
||||
|
|
|
@ -14,7 +14,6 @@ import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
|||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPage2VO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
||||
|
@ -23,7 +22,6 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationR
|
|||
import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationRecordMapper;
|
||||
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
|
||||
import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
@ -72,9 +70,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||
CombinationRecordDO record = validateCombinationRecord(userId, orderId);
|
||||
|
||||
// 更新状态
|
||||
// TODO @puhui999:不要整个更新,new 一个出来;why?例如说,两个线程都去更新,这样存在相互覆盖的问题
|
||||
record.setStatus(status);
|
||||
combinationRecordMapper.updateById(record);
|
||||
combinationRecordMapper.updateById(new CombinationRecordDO().setId(record.getId()).setStatus(status));
|
||||
}
|
||||
|
||||
private CombinationRecordDO validateCombinationRecord(Long userId, Long orderId) {
|
||||
|
@ -164,7 +160,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public KeyValue<Long, Long> createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
|
||||
public CombinationRecordDO createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
|
||||
// 1. 校验拼团活动
|
||||
KeyValue<CombinationActivityDO, CombinationProductDO> keyValue = validateCombinationRecord(reqDTO.getUserId(),
|
||||
reqDTO.getActivityId(), reqDTO.getHeadId(), reqDTO.getSkuId(), reqDTO.getCount());
|
||||
|
@ -191,7 +187,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||
if (ObjUtil.notEqual(CombinationRecordDO.HEAD_ID_GROUP, record.getHeadId())) {
|
||||
updateCombinationRecordWhenCreate(reqDTO.getHeadId(), keyValue.getKey());
|
||||
}
|
||||
return new KeyValue<>(record.getId(), record.getHeadId());
|
||||
return record;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -249,6 +245,11 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||
return combinationRecordMapper.selectCountByHeadAndStatusAndVirtualGroup(status, virtualGroup, headId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getCombinationUserCount() {
|
||||
return combinationRecordMapper.selectUserDistinctCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CombinationRecordDO> getLatestCombinationRecordList(int count) {
|
||||
return combinationRecordMapper.selectLatestList(count);
|
||||
|
@ -275,11 +276,6 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||
return combinationRecordMapper.selectPage(pageVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<CombinationRecordDO> getCombinationRecordPage2(CombinationRecordReqPage2VO pageVO) {
|
||||
return combinationRecordMapper.selectPage(pageVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, Integer> getCombinationRecordCountMapByActivity(Collection<Long> activityIds,
|
||||
@Nullable Integer status, @Nullable Long headId) {
|
||||
|
@ -343,8 +339,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||
|
||||
@Override
|
||||
public KeyValue<Integer, Integer> expireCombinationRecord() {
|
||||
// TODO @puhui999:数字一般是 1. 2. 这种格式哈
|
||||
// 1。获取所有正在进行中的过期的父拼团
|
||||
// 1.获取所有正在进行中的过期的父拼团
|
||||
List<CombinationRecordDO> headExpireRecords = combinationRecordMapper.selectListByHeadIdAndStatusAndExpireTimeLt(
|
||||
CombinationRecordDO.HEAD_ID_GROUP, CombinationRecordStatusEnum.IN_PROGRESS.getStatus(), LocalDateTime.now());
|
||||
if (CollUtil.isEmpty(headExpireRecords)) {
|
||||
|
@ -352,23 +347,20 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||
}
|
||||
|
||||
// 2.获取拼团活动
|
||||
// TODO @puhui999:在自己模块里,变量可以简略点;例如说 activityList
|
||||
List<CombinationActivityDO> combinationActivities = combinationActivityService.getCombinationActivityListByIds(
|
||||
List<CombinationActivityDO> activities = combinationActivityService.getCombinationActivityListByIds(
|
||||
convertSet(headExpireRecords, CombinationRecordDO::getActivityId));
|
||||
Map<Long, CombinationActivityDO> activityMap = convertMap(combinationActivities, CombinationActivityDO::getId);
|
||||
Map<Long, CombinationActivityDO> activityMap = convertMap(activities, CombinationActivityDO::getId);
|
||||
|
||||
// TODO @puhui999:job 一般不建议异步跑;因为可能下次跑,结果上次还没跑完;
|
||||
// TODO 这里,我们可以每个 record 处理下;然后按照是否需要虚拟拼团,各搞一个方法逻辑 + 事务;这样,保证 job 里面尽量不要大事务,而是 n 个独立小事务的处理。
|
||||
// 3.校验是否虚拟成团
|
||||
List<CombinationRecordDO> virtualGroupHeadRecords = new ArrayList<>(); // 虚拟成团
|
||||
for (Iterator<CombinationRecordDO> iterator = headExpireRecords.iterator(); iterator.hasNext(); ) {
|
||||
CombinationRecordDO record = iterator.next();
|
||||
// 3.1 不匹配,则直接跳过
|
||||
// 3.1.不匹配,则直接跳过
|
||||
CombinationActivityDO activity = activityMap.get(record.getActivityId());
|
||||
if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的
|
||||
continue;
|
||||
}
|
||||
// 3.2 匹配,则移除,添加到虚拟成团中,并结束寻找
|
||||
// 3.2.匹配,则移除,添加到虚拟成团中,并结束寻找
|
||||
virtualGroupHeadRecords.add(record);
|
||||
iterator.remove();
|
||||
break;
|
||||
|
@ -381,8 +373,13 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||
return new KeyValue<>(headExpireRecords.size(), virtualGroupHeadRecords.size());
|
||||
}
|
||||
|
||||
@Async
|
||||
protected void handleExpireRecord(List<CombinationRecordDO> headExpireRecords) {
|
||||
/**
|
||||
* 处理过期拼团
|
||||
*
|
||||
* @param headExpireRecords 过期拼团团长记录列表
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void handleExpireRecord(List<CombinationRecordDO> headExpireRecords) {
|
||||
if (CollUtil.isEmpty(headExpireRecords)) {
|
||||
return;
|
||||
}
|
||||
|
@ -400,8 +397,13 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||
});
|
||||
}
|
||||
|
||||
@Async
|
||||
protected void handleVirtualGroupRecord(List<CombinationRecordDO> virtualGroupHeadRecords) {
|
||||
/**
|
||||
* 处理虚拟拼团
|
||||
*
|
||||
* @param virtualGroupHeadRecords 虚拟成团团长记录列表
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void handleVirtualGroupRecord(List<CombinationRecordDO> virtualGroupHeadRecords) {
|
||||
if (CollUtil.isEmpty(virtualGroupHeadRecords)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,175 @@
|
|||
package cn.iocoder.yudao.module.promotion.service.article;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryExportReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleCategoryMapper;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* {@link ArticleCategoryServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Import(ArticleCategoryServiceImpl.class)
|
||||
public class ArticleCategoryServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private ArticleCategoryServiceImpl articleCategoryService;
|
||||
|
||||
@Resource
|
||||
private ArticleCategoryMapper articleCategoryMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateArticleCategory_success() {
|
||||
// 准备参数
|
||||
ArticleCategoryCreateReqVO reqVO = randomPojo(ArticleCategoryCreateReqVO.class);
|
||||
|
||||
// 调用
|
||||
Long articleCategoryId = articleCategoryService.createArticleCategory(reqVO);
|
||||
// 断言
|
||||
assertNotNull(articleCategoryId);
|
||||
// 校验记录的属性是否正确
|
||||
ArticleCategoryDO articleCategory = articleCategoryMapper.selectById(articleCategoryId);
|
||||
assertPojoEquals(reqVO, articleCategory);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateArticleCategory_success() {
|
||||
// mock 数据
|
||||
ArticleCategoryDO dbArticleCategory = randomPojo(ArticleCategoryDO.class);
|
||||
articleCategoryMapper.insert(dbArticleCategory);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
ArticleCategoryUpdateReqVO reqVO = randomPojo(ArticleCategoryUpdateReqVO.class, o -> {
|
||||
o.setId(dbArticleCategory.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
articleCategoryService.updateArticleCategory(reqVO);
|
||||
// 校验是否更新正确
|
||||
ArticleCategoryDO articleCategory = articleCategoryMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, articleCategory);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateArticleCategory_notExists() {
|
||||
// 准备参数
|
||||
ArticleCategoryUpdateReqVO reqVO = randomPojo(ArticleCategoryUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> articleCategoryService.updateArticleCategory(reqVO), ARTICLE_CATEGORY_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteArticleCategory_success() {
|
||||
// mock 数据
|
||||
ArticleCategoryDO dbArticleCategory = randomPojo(ArticleCategoryDO.class);
|
||||
articleCategoryMapper.insert(dbArticleCategory);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbArticleCategory.getId();
|
||||
|
||||
// 调用
|
||||
articleCategoryService.deleteArticleCategory(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(articleCategoryMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteArticleCategory_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> articleCategoryService.deleteArticleCategory(id), ARTICLE_CATEGORY_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetArticleCategoryPage() {
|
||||
// mock 数据
|
||||
ArticleCategoryDO dbArticleCategory = randomPojo(ArticleCategoryDO.class, o -> { // 等会查询到
|
||||
o.setName(null);
|
||||
o.setPicUrl(null);
|
||||
o.setStatus(null);
|
||||
o.setSort(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
articleCategoryMapper.insert(dbArticleCategory);
|
||||
// 测试 name 不匹配
|
||||
articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setName(null)));
|
||||
// 测试 picUrl 不匹配
|
||||
articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setPicUrl(null)));
|
||||
// 测试 status 不匹配
|
||||
articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setStatus(null)));
|
||||
// 测试 sort 不匹配
|
||||
articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setSort(null)));
|
||||
// 测试 createTime 不匹配
|
||||
articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
ArticleCategoryPageReqVO reqVO = new ArticleCategoryPageReqVO();
|
||||
reqVO.setName(null);
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
PageResult<ArticleCategoryDO> pageResult = articleCategoryService.getArticleCategoryPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbArticleCategory, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetArticleCategoryList() {
|
||||
// mock 数据
|
||||
ArticleCategoryDO dbArticleCategory = randomPojo(ArticleCategoryDO.class, o -> { // 等会查询到
|
||||
o.setName(null);
|
||||
o.setPicUrl(null);
|
||||
o.setStatus(null);
|
||||
o.setSort(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
articleCategoryMapper.insert(dbArticleCategory);
|
||||
// 测试 name 不匹配
|
||||
articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setName(null)));
|
||||
// 测试 picUrl 不匹配
|
||||
articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setPicUrl(null)));
|
||||
// 测试 status 不匹配
|
||||
articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setStatus(null)));
|
||||
// 测试 sort 不匹配
|
||||
articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setSort(null)));
|
||||
// 测试 createTime 不匹配
|
||||
articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
ArticleCategoryExportReqVO reqVO = new ArticleCategoryExportReqVO();
|
||||
reqVO.setName(null);
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
List<ArticleCategoryDO> list = articleCategoryService.getArticleCategoryList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbArticleCategory, list.get(0));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,233 @@
|
|||
package cn.iocoder.yudao.module.promotion.service.article;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_NOT_EXISTS;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* {@link ArticleServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Import(ArticleServiceImpl.class)
|
||||
public class ArticleServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private ArticleServiceImpl articleService;
|
||||
|
||||
@Resource
|
||||
private ArticleMapper articleMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateArticle_success() {
|
||||
// 准备参数
|
||||
ArticleCreateReqVO reqVO = randomPojo(ArticleCreateReqVO.class);
|
||||
|
||||
// 调用
|
||||
Long articleId = articleService.createArticle(reqVO);
|
||||
// 断言
|
||||
assertNotNull(articleId);
|
||||
// 校验记录的属性是否正确
|
||||
ArticleDO article = articleMapper.selectById(articleId);
|
||||
assertPojoEquals(reqVO, article);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateArticle_success() {
|
||||
// mock 数据
|
||||
ArticleDO dbArticle = randomPojo(ArticleDO.class);
|
||||
articleMapper.insert(dbArticle);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
ArticleUpdateReqVO reqVO = randomPojo(ArticleUpdateReqVO.class, o -> {
|
||||
o.setId(dbArticle.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
articleService.updateArticle(reqVO);
|
||||
// 校验是否更新正确
|
||||
ArticleDO article = articleMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, article);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateArticle_notExists() {
|
||||
// 准备参数
|
||||
ArticleUpdateReqVO reqVO = randomPojo(ArticleUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> articleService.updateArticle(reqVO), ARTICLE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteArticle_success() {
|
||||
// mock 数据
|
||||
ArticleDO dbArticle = randomPojo(ArticleDO.class);
|
||||
articleMapper.insert(dbArticle);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbArticle.getId();
|
||||
|
||||
// 调用
|
||||
articleService.deleteArticle(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(articleMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteArticle_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> articleService.deleteArticle(id), ARTICLE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetArticlePage() {
|
||||
// mock 数据
|
||||
ArticleDO dbArticle = randomPojo(ArticleDO.class, o -> { // 等会查询到
|
||||
o.setCategoryId(null);
|
||||
o.setTitle(null);
|
||||
o.setAuthor(null);
|
||||
o.setPicUrl(null);
|
||||
o.setIntroduction(null);
|
||||
o.setBrowseCount(null);
|
||||
o.setSort(null);
|
||||
o.setStatus(null);
|
||||
o.setSpuId(null);
|
||||
o.setRecommendHot(null);
|
||||
o.setRecommendBanner(null);
|
||||
o.setContent(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
articleMapper.insert(dbArticle);
|
||||
// 测试 categoryId 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setCategoryId(null)));
|
||||
// 测试 title 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setTitle(null)));
|
||||
// 测试 author 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setAuthor(null)));
|
||||
// 测试 picUrl 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setPicUrl(null)));
|
||||
// 测试 introduction 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setIntroduction(null)));
|
||||
// 测试 browseCount 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setBrowseCount(null)));
|
||||
// 测试 sort 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setSort(null)));
|
||||
// 测试 status 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setStatus(null)));
|
||||
// 测试 spuId 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setSpuId(null)));
|
||||
// 测试 recommendHot 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setRecommendHot(null)));
|
||||
// 测试 recommendBanner 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setRecommendBanner(null)));
|
||||
// 测试 content 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setContent(null)));
|
||||
// 测试 createTime 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
ArticlePageReqVO reqVO = new ArticlePageReqVO();
|
||||
reqVO.setCategoryId(null);
|
||||
reqVO.setTitle(null);
|
||||
reqVO.setAuthor(null);
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setSpuId(null);
|
||||
reqVO.setRecommendHot(null);
|
||||
reqVO.setRecommendBanner(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
PageResult<ArticleDO> pageResult = articleService.getArticlePage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbArticle, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetArticleList() {
|
||||
// mock 数据
|
||||
ArticleDO dbArticle = randomPojo(ArticleDO.class, o -> { // 等会查询到
|
||||
o.setCategoryId(null);
|
||||
o.setTitle(null);
|
||||
o.setAuthor(null);
|
||||
o.setPicUrl(null);
|
||||
o.setIntroduction(null);
|
||||
o.setBrowseCount(null);
|
||||
o.setSort(null);
|
||||
o.setStatus(null);
|
||||
o.setSpuId(null);
|
||||
o.setRecommendHot(null);
|
||||
o.setRecommendBanner(null);
|
||||
o.setContent(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
articleMapper.insert(dbArticle);
|
||||
// 测试 categoryId 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setCategoryId(null)));
|
||||
// 测试 title 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setTitle(null)));
|
||||
// 测试 author 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setAuthor(null)));
|
||||
// 测试 picUrl 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setPicUrl(null)));
|
||||
// 测试 introduction 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setIntroduction(null)));
|
||||
// 测试 browseCount 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setBrowseCount(null)));
|
||||
// 测试 sort 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setSort(null)));
|
||||
// 测试 status 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setStatus(null)));
|
||||
// 测试 spuId 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setSpuId(null)));
|
||||
// 测试 recommendHot 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setRecommendHot(null)));
|
||||
// 测试 recommendBanner 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setRecommendBanner(null)));
|
||||
// 测试 content 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setContent(null)));
|
||||
// 测试 createTime 不匹配
|
||||
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
ArticleExportReqVO reqVO = new ArticleExportReqVO();
|
||||
reqVO.setCategoryId(null);
|
||||
reqVO.setTitle(null);
|
||||
reqVO.setAuthor(null);
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setSpuId(null);
|
||||
reqVO.setRecommendHot(null);
|
||||
reqVO.setRecommendBanner(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
List<ArticleDO> list = articleService.getArticleList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbArticle, list.get(0));
|
||||
}
|
||||
|
||||
}
|
|
@ -6,3 +6,7 @@ DELETE FROM "promotion_discount_activity";
|
|||
DELETE FROM "promotion_discount_product";
|
||||
DELETE FROM "promotion_seckill_config";
|
||||
DELETE FROM "promotion_combination_activity";
|
||||
DELETE
|
||||
FROM "promotion_article_category";
|
||||
DELETE
|
||||
FROM "promotion_article";
|
||||
|
|
|
@ -181,3 +181,43 @@ CREATE TABLE IF NOT EXISTS "promotion_combination_activity"
|
|||
"tenant_id" bigint NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
) COMMENT '拼团活动';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "promotion_article_category"
|
||||
(
|
||||
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"name" varchar NOT NULL,
|
||||
"pic_url" varchar,
|
||||
"status" int NOT NULL,
|
||||
"sort" int NOT NULL,
|
||||
"creator" varchar DEFAULT '',
|
||||
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updater" varchar DEFAULT '',
|
||||
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
"deleted" bit NOT NULL DEFAULT FALSE,
|
||||
"tenant_id" bigint NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
) COMMENT '文章分类表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "promotion_article"
|
||||
(
|
||||
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"category_id" bigint NOT NULL,
|
||||
"title" varchar NOT NULL,
|
||||
"author" varchar,
|
||||
"pic_url" varchar NOT NULL,
|
||||
"introduction" varchar,
|
||||
"browse_count" varchar,
|
||||
"sort" int NOT NULL,
|
||||
"status" int NOT NULL,
|
||||
"spu_id" bigint NOT NULL,
|
||||
"recommend_hot" bit NOT NULL,
|
||||
"recommend_banner" bit NOT NULL,
|
||||
"content" varchar NOT NULL,
|
||||
"creator" varchar DEFAULT '',
|
||||
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updater" varchar DEFAULT '',
|
||||
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
"deleted" bit NOT NULL DEFAULT FALSE,
|
||||
"tenant_id" bigint NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
) COMMENT '文章管理表';
|
|
@ -93,16 +93,19 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {
|
|||
return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode);
|
||||
}
|
||||
|
||||
// TODO @hui999:是不是只针对 combinationActivityId 的查询呀?
|
||||
/**
|
||||
* 只针对 combinationActivityId 的查询
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param activityId 拼团活动编号
|
||||
* @param status 订单状态
|
||||
* @return 交易订单
|
||||
*/
|
||||
default TradeOrderDO selectByUserIdAndActivityIdAndStatus(Long userId, Long activityId, Integer status) {
|
||||
return selectOne(new LambdaQueryWrapperX<TradeOrderDO>()
|
||||
.and(q -> q.eq(TradeOrderDO::getUserId, userId)
|
||||
.eq(TradeOrderDO::getStatus, status))
|
||||
.and(q -> q.eq(TradeOrderDO::getCombinationActivityId, activityId)
|
||||
.or()
|
||||
.eq(TradeOrderDO::getSeckillActivityId, activityId)
|
||||
.or()
|
||||
.eq(TradeOrderDO::getBargainActivityId, activityId))
|
||||
.eq(TradeOrderDO::getUserId, userId)
|
||||
.eq(TradeOrderDO::getStatus, status)
|
||||
.eq(TradeOrderDO::getCombinationActivityId, activityId)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package cn.iocoder.yudao.module.trade.service.order.handler;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;
|
||||
|
@ -49,7 +49,6 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler {
|
|||
order.getCombinationHeadId(), item.getSkuId(), item.getCount());
|
||||
|
||||
// 2. 校验该用户是否存在未支付的拼团活动订单,避免一个拼团可以下多个单子了
|
||||
// TODO @puhui999:只校验未支付的拼团订单噢
|
||||
TradeOrderDO activityOrder = orderQueryService.getActivityOrderByUserIdAndActivityIdAndStatus(
|
||||
order.getUserId(), order.getCombinationActivityId(), TradeOrderStatusEnum.UNPAID.getStatus());
|
||||
if (activityOrder != null) {
|
||||
|
@ -67,13 +66,14 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler {
|
|||
|
||||
// 2. 创建拼团记录
|
||||
TradeOrderItemDO item = orderItems.get(0);
|
||||
KeyValue<Long, Long> recordIdAndHeadId = combinationRecordApi.createCombinationRecord(
|
||||
CombinationRecordCreateRespDTO combinationRecord = combinationRecordApi.createCombinationRecord(
|
||||
TradeOrderConvert.INSTANCE.convert(order, item));
|
||||
|
||||
// 3. 更新拼团相关信息到订单
|
||||
// TODO 芋艿,只需要更新 record
|
||||
// TODO 芋艿,只需要更新 record。 如果创建订单时自己是团长的情况下 combinationHeadId 是为 null 的,
|
||||
// 设置团长编号这个操作时在订单是否后创建拼团记录时才设置的,所以支付完创建拼团记录后需要设置一下记录编号和团长编号
|
||||
orderUpdateService.updateOrderCombinationInfo(order.getId(), order.getCombinationActivityId(),
|
||||
recordIdAndHeadId.getKey(), recordIdAndHeadId.getValue());
|
||||
combinationRecord.getCombinationRecordId(), combinationRecord.getCombinationHeadId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue