Commit 7345933d6bae2ea42e72a9e9d881e795074a83ac
1 parent
69268b52
code review:文章管理
Showing
21 changed files
with
35 additions
and
388 deletions
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleCategoryController.java
| @@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.promotion.controller.admin.article; | @@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.promotion.controller.admin.article; | ||
| 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 7 | -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 8 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.*; | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.*; |
| 9 | import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; | 7 | import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; |
| 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; |
| @@ -17,15 +15,11 @@ import org.springframework.validation.annotation.Validated; | @@ -17,15 +15,11 @@ import org.springframework.validation.annotation.Validated; | ||
| 17 | import org.springframework.web.bind.annotation.*; | 15 | import org.springframework.web.bind.annotation.*; |
| 18 | 16 | ||
| 19 | import javax.annotation.Resource; | 17 | import javax.annotation.Resource; |
| 20 | -import javax.servlet.http.HttpServletResponse; | ||
| 21 | import javax.validation.Valid; | 18 | import javax.validation.Valid; |
| 22 | -import java.io.IOException; | ||
| 23 | -import java.util.Collection; | ||
| 24 | import java.util.Comparator; | 19 | import java.util.Comparator; |
| 25 | import java.util.List; | 20 | import java.util.List; |
| 26 | 21 | ||
| 27 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 28 | -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | ||
| 29 | 23 | ||
| 30 | @Tag(name = "管理后台 - 文章分类") | 24 | @Tag(name = "管理后台 - 文章分类") |
| 31 | @RestController | 25 | @RestController |
| @@ -65,23 +59,14 @@ public class ArticleCategoryController { | @@ -65,23 +59,14 @@ public class ArticleCategoryController { | ||
| 65 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 59 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 66 | @PreAuthorize("@ss.hasPermission('promotion:article-category:query')") | 60 | @PreAuthorize("@ss.hasPermission('promotion:article-category:query')") |
| 67 | public CommonResult<ArticleCategoryRespVO> getArticleCategory(@RequestParam("id") Long id) { | 61 | public CommonResult<ArticleCategoryRespVO> getArticleCategory(@RequestParam("id") Long id) { |
| 68 | - ArticleCategoryDO articleCategory = articleCategoryService.getArticleCategory(id); | ||
| 69 | - return success(ArticleCategoryConvert.INSTANCE.convert(articleCategory)); | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - @GetMapping("/list") | ||
| 73 | - @Operation(summary = "获得文章分类列表") | ||
| 74 | - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") | ||
| 75 | - @PreAuthorize("@ss.hasPermission('promotion:article-category:query')") | ||
| 76 | - public CommonResult<List<ArticleCategoryRespVO>> getArticleCategoryList(@RequestParam("ids") Collection<Long> ids) { | ||
| 77 | - List<ArticleCategoryDO> list = articleCategoryService.getArticleCategoryList(ids); | ||
| 78 | - return success(ArticleCategoryConvert.INSTANCE.convertList(list)); | 62 | + ArticleCategoryDO category = articleCategoryService.getArticleCategory(id); |
| 63 | + return success(ArticleCategoryConvert.INSTANCE.convert(category)); | ||
| 79 | } | 64 | } |
| 80 | 65 | ||
| 81 | @GetMapping("/list-all-simple") | 66 | @GetMapping("/list-all-simple") |
| 82 | @Operation(summary = "获取文章分类精简信息列表", description = "只包含被开启的文章分类,主要用于前端的下拉选项") | 67 | @Operation(summary = "获取文章分类精简信息列表", description = "只包含被开启的文章分类,主要用于前端的下拉选项") |
| 83 | public CommonResult<List<ArticleCategorySimpleRespVO>> getSimpleDeptList() { | 68 | public CommonResult<List<ArticleCategorySimpleRespVO>> getSimpleDeptList() { |
| 84 | - // 获得部门列表,只要开启状态的 | 69 | + // 获得分类列表,只要开启状态的 |
| 85 | List<ArticleCategoryDO> list = articleCategoryService.getArticleCategoryListByStatus(CommonStatusEnum.ENABLE.getStatus()); | 70 | List<ArticleCategoryDO> list = articleCategoryService.getArticleCategoryListByStatus(CommonStatusEnum.ENABLE.getStatus()); |
| 86 | // 降序排序后,返回给前端 | 71 | // 降序排序后,返回给前端 |
| 87 | list.sort(Comparator.comparing(ArticleCategoryDO::getSort).reversed()); | 72 | list.sort(Comparator.comparing(ArticleCategoryDO::getSort).reversed()); |
| @@ -96,16 +81,4 @@ public class ArticleCategoryController { | @@ -96,16 +81,4 @@ public class ArticleCategoryController { | ||
| 96 | return success(ArticleCategoryConvert.INSTANCE.convertPage(pageResult)); | 81 | return success(ArticleCategoryConvert.INSTANCE.convertPage(pageResult)); |
| 97 | } | 82 | } |
| 98 | 83 | ||
| 99 | - @GetMapping("/export-excel") | ||
| 100 | - @Operation(summary = "导出文章分类 Excel") | ||
| 101 | - @PreAuthorize("@ss.hasPermission('promotion:article-category:export')") | ||
| 102 | - @OperateLog(type = EXPORT) | ||
| 103 | - public void exportArticleCategoryExcel(@Valid ArticleCategoryExportReqVO exportReqVO, | ||
| 104 | - HttpServletResponse response) throws IOException { | ||
| 105 | - List<ArticleCategoryDO> list = articleCategoryService.getArticleCategoryList(exportReqVO); | ||
| 106 | - // 导出 Excel | ||
| 107 | - List<ArticleCategoryExcelVO> datas = ArticleCategoryConvert.INSTANCE.convertList02(list); | ||
| 108 | - ExcelUtils.write(response, "文章分类.xls", "数据", ArticleCategoryExcelVO.class, datas); | ||
| 109 | - } | ||
| 110 | - | ||
| 111 | } | 84 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleController.java
| @@ -2,9 +2,10 @@ package cn.iocoder.yudao.module.promotion.controller.admin.article; | @@ -2,9 +2,10 @@ package cn.iocoder.yudao.module.promotion.controller.admin.article; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 6 | -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.*; | 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleRespVO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; | ||
| 8 | import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; | 9 | import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; |
| 9 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; | 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; |
| 10 | import cn.iocoder.yudao.module.promotion.service.article.ArticleService; | 11 | import cn.iocoder.yudao.module.promotion.service.article.ArticleService; |
| @@ -16,14 +17,9 @@ import org.springframework.validation.annotation.Validated; | @@ -16,14 +17,9 @@ import org.springframework.validation.annotation.Validated; | ||
| 16 | import org.springframework.web.bind.annotation.*; | 17 | import org.springframework.web.bind.annotation.*; |
| 17 | 18 | ||
| 18 | import javax.annotation.Resource; | 19 | import javax.annotation.Resource; |
| 19 | -import javax.servlet.http.HttpServletResponse; | ||
| 20 | import javax.validation.Valid; | 20 | import javax.validation.Valid; |
| 21 | -import java.io.IOException; | ||
| 22 | -import java.util.Collection; | ||
| 23 | -import java.util.List; | ||
| 24 | 21 | ||
| 25 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 26 | -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | ||
| 27 | 23 | ||
| 28 | @Tag(name = "管理后台 - 文章管理") | 24 | @Tag(name = "管理后台 - 文章管理") |
| 29 | @RestController | 25 | @RestController |
| @@ -67,15 +63,6 @@ public class ArticleController { | @@ -67,15 +63,6 @@ public class ArticleController { | ||
| 67 | return success(ArticleConvert.INSTANCE.convert(article)); | 63 | return success(ArticleConvert.INSTANCE.convert(article)); |
| 68 | } | 64 | } |
| 69 | 65 | ||
| 70 | - @GetMapping("/list") | ||
| 71 | - @Operation(summary = "获得文章管理列表") | ||
| 72 | - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") | ||
| 73 | - @PreAuthorize("@ss.hasPermission('promotion:article:query')") | ||
| 74 | - public CommonResult<List<ArticleRespVO>> getArticleList(@RequestParam("ids") Collection<Long> ids) { | ||
| 75 | - List<ArticleDO> list = articleService.getArticleList(ids); | ||
| 76 | - return success(ArticleConvert.INSTANCE.convertList(list)); | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | @GetMapping("/page") | 66 | @GetMapping("/page") |
| 80 | @Operation(summary = "获得文章管理分页") | 67 | @Operation(summary = "获得文章管理分页") |
| 81 | @PreAuthorize("@ss.hasPermission('promotion:article:query')") | 68 | @PreAuthorize("@ss.hasPermission('promotion:article:query')") |
| @@ -84,16 +71,4 @@ public class ArticleController { | @@ -84,16 +71,4 @@ public class ArticleController { | ||
| 84 | return success(ArticleConvert.INSTANCE.convertPage(pageResult)); | 71 | return success(ArticleConvert.INSTANCE.convertPage(pageResult)); |
| 85 | } | 72 | } |
| 86 | 73 | ||
| 87 | - @GetMapping("/export-excel") | ||
| 88 | - @Operation(summary = "导出文章管理 Excel") | ||
| 89 | - @PreAuthorize("@ss.hasPermission('promotion:article:export')") | ||
| 90 | - @OperateLog(type = EXPORT) | ||
| 91 | - public void exportArticleExcel(@Valid ArticleExportReqVO exportReqVO, | ||
| 92 | - HttpServletResponse response) throws IOException { | ||
| 93 | - List<ArticleDO> list = articleService.getArticleList(exportReqVO); | ||
| 94 | - // 导出 Excel | ||
| 95 | - List<ArticleExcelVO> datas = ArticleConvert.INSTANCE.convertList02(list); | ||
| 96 | - ExcelUtils.write(response, "文章管理.xls", "数据", ArticleExcelVO.class, datas); | ||
| 97 | - } | ||
| 98 | - | ||
| 99 | } | 74 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleExcelVO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | ||
| 4 | -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | ||
| 5 | -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; | ||
| 6 | -import com.alibaba.excel.annotation.ExcelProperty; | ||
| 7 | -import lombok.Data; | ||
| 8 | - | ||
| 9 | -import java.time.LocalDateTime; | ||
| 10 | - | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | - * 文章管理 Excel VO | ||
| 14 | - * | ||
| 15 | - * @author HUIHUI | ||
| 16 | - */ | ||
| 17 | -@Data | ||
| 18 | -public class ArticleExcelVO { | ||
| 19 | - | ||
| 20 | - @ExcelProperty("文章编号") | ||
| 21 | - private Long id; | ||
| 22 | - | ||
| 23 | - @ExcelProperty("文章分类编号") | ||
| 24 | - private Long categoryId; | ||
| 25 | - | ||
| 26 | - @ExcelProperty("关联商品编号") | ||
| 27 | - private Long spuId; | ||
| 28 | - | ||
| 29 | - @ExcelProperty("文章标题") | ||
| 30 | - private String title; | ||
| 31 | - | ||
| 32 | - @ExcelProperty("文章作者") | ||
| 33 | - private String author; | ||
| 34 | - | ||
| 35 | - @ExcelProperty("文章封面图片地址") | ||
| 36 | - private String picUrl; | ||
| 37 | - | ||
| 38 | - @ExcelProperty("文章简介") | ||
| 39 | - private String introduction; | ||
| 40 | - | ||
| 41 | - @ExcelProperty("浏览次数") | ||
| 42 | - private String browseCount; | ||
| 43 | - | ||
| 44 | - @ExcelProperty("排序") | ||
| 45 | - private Integer sort; | ||
| 46 | - | ||
| 47 | - @ExcelProperty(value = "状态", converter = DictConvert.class) | ||
| 48 | - @DictFormat(DictTypeConstants.COMMON_STATUS) | ||
| 49 | - private Integer status; | ||
| 50 | - | ||
| 51 | - @ExcelProperty("是否热门(小程序)") | ||
| 52 | - private Boolean recommendHot; | ||
| 53 | - | ||
| 54 | - @ExcelProperty("是否轮播图(小程序)") | ||
| 55 | - private Boolean recommendBanner; | ||
| 56 | - | ||
| 57 | - @ExcelProperty("文章内容") | ||
| 58 | - private String content; | ||
| 59 | - | ||
| 60 | - @ExcelProperty("创建时间") | ||
| 61 | - private LocalDateTime createTime; | ||
| 62 | - | ||
| 63 | -} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleExportReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 6 | - | ||
| 7 | -import java.time.LocalDateTime; | ||
| 8 | - | ||
| 9 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 10 | - | ||
| 11 | -@Schema(description = "管理后台 - 文章管理 Excel 导出 Request VO,参数和 ArticlePageReqVO 是一致的") | ||
| 12 | -@Data | ||
| 13 | -public class ArticleExportReqVO { | ||
| 14 | - | ||
| 15 | - @Schema(description = "文章分类编号", example = "15458") | ||
| 16 | - private Long categoryId; | ||
| 17 | - | ||
| 18 | - @Schema(description = "关联商品编号", example = "22378") | ||
| 19 | - private Long spuId; | ||
| 20 | - | ||
| 21 | - @Schema(description = "文章标题") | ||
| 22 | - private String title; | ||
| 23 | - | ||
| 24 | - @Schema(description = "文章作者") | ||
| 25 | - private String author; | ||
| 26 | - | ||
| 27 | - @Schema(description = "状态", example = "2") | ||
| 28 | - private Integer status; | ||
| 29 | - | ||
| 30 | - @Schema(description = "是否热门(小程序)") | ||
| 31 | - private Boolean recommendHot; | ||
| 32 | - | ||
| 33 | - @Schema(description = "是否轮播图(小程序)") | ||
| 34 | - private Boolean recommendBanner; | ||
| 35 | - | ||
| 36 | - @Schema(description = "创建时间") | ||
| 37 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 38 | - private LocalDateTime[] createTime; | ||
| 39 | - | ||
| 40 | -} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleBaseVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleBaseVO.java
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; | 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| @@ -34,6 +34,7 @@ public class ArticleBaseVO { | @@ -34,6 +34,7 @@ public class ArticleBaseVO { | ||
| 34 | @Schema(description = "文章简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是一个简介") | 34 | @Schema(description = "文章简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是一个简介") |
| 35 | private String introduction; | 35 | private String introduction; |
| 36 | 36 | ||
| 37 | + // TODO @puhui999:浏览量的字段,应该不是后端新增设置的哈; | ||
| 37 | @Schema(description = "浏览次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") | 38 | @Schema(description = "浏览次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") |
| 38 | private String browseCount; | 39 | private String browseCount; |
| 39 | 40 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleCreateReqVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleCreateReqVO.java
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; | 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.Data; | 4 | import lombok.Data; |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticlePageReqVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticlePageReqVO.java
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; | 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | import io.swagger.v3.oas.annotations.media.Schema; | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleRespVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleRespVO.java
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; | 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.Data; | 4 | import lombok.Data; |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleUpdateReqVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleUpdateReqVO.java
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; | 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.Data; | 4 | import lombok.Data; |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryExcelVO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | ||
| 4 | -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | ||
| 5 | -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; | ||
| 6 | -import com.alibaba.excel.annotation.ExcelProperty; | ||
| 7 | -import lombok.Data; | ||
| 8 | - | ||
| 9 | -import java.time.LocalDateTime; | ||
| 10 | - | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | - * 文章分类 Excel VO | ||
| 14 | - * | ||
| 15 | - * @author HUIHUI | ||
| 16 | - */ | ||
| 17 | -@Data | ||
| 18 | -public class ArticleCategoryExcelVO { | ||
| 19 | - | ||
| 20 | - @ExcelProperty("文章分类编号") | ||
| 21 | - private Long id; | ||
| 22 | - | ||
| 23 | - @ExcelProperty("文章分类名称") | ||
| 24 | - private String name; | ||
| 25 | - | ||
| 26 | - @ExcelProperty("图标地址") | ||
| 27 | - private String picUrl; | ||
| 28 | - | ||
| 29 | - @ExcelProperty(value = "状态", converter = DictConvert.class) | ||
| 30 | - @DictFormat(DictTypeConstants.COMMON_STATUS) | ||
| 31 | - private Integer status; | ||
| 32 | - | ||
| 33 | - @ExcelProperty("排序") | ||
| 34 | - private Integer sort; | ||
| 35 | - | ||
| 36 | - @ExcelProperty("创建时间") | ||
| 37 | - private LocalDateTime createTime; | ||
| 38 | - | ||
| 39 | -} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryExportReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 6 | - | ||
| 7 | -import java.time.LocalDateTime; | ||
| 8 | - | ||
| 9 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 10 | - | ||
| 11 | -@Schema(description = "管理后台 - 文章分类 Excel 导出 Request VO,参数和 ArticleCategoryPageReqVO 是一致的") | ||
| 12 | -@Data | ||
| 13 | -public class ArticleCategoryExportReqVO { | ||
| 14 | - | ||
| 15 | - @Schema(description = "文章分类名称", example = "秒杀") | ||
| 16 | - private String name; | ||
| 17 | - | ||
| 18 | - @Schema(description = "状态", example = "1") | ||
| 19 | - private Integer status; | ||
| 20 | - | ||
| 21 | - @Schema(description = "创建时间") | ||
| 22 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 23 | - private LocalDateTime[] createTime; | ||
| 24 | - | ||
| 25 | -} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleCategoryConvert.java
| @@ -28,8 +28,6 @@ public interface ArticleCategoryConvert { | @@ -28,8 +28,6 @@ public interface ArticleCategoryConvert { | ||
| 28 | 28 | ||
| 29 | PageResult<ArticleCategoryRespVO> convertPage(PageResult<ArticleCategoryDO> page); | 29 | PageResult<ArticleCategoryRespVO> convertPage(PageResult<ArticleCategoryDO> page); |
| 30 | 30 | ||
| 31 | - List<ArticleCategoryExcelVO> convertList02(List<ArticleCategoryDO> list); | ||
| 32 | - | ||
| 33 | List<ArticleCategorySimpleRespVO> convertList03(List<ArticleCategoryDO> list); | 31 | List<ArticleCategorySimpleRespVO> convertList03(List<ArticleCategoryDO> list); |
| 34 | 32 | ||
| 35 | } | 33 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java
| 1 | package cn.iocoder.yudao.module.promotion.convert.article; | 1 | package cn.iocoder.yudao.module.promotion.convert.article; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExcelVO; | ||
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleRespVO; | ||
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO; | 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleRespVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; | ||
| 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; |
| 9 | import org.mapstruct.Mapper; | 8 | import org.mapstruct.Mapper; |
| 10 | import org.mapstruct.factory.Mappers; | 9 | import org.mapstruct.factory.Mappers; |
| @@ -31,6 +30,4 @@ public interface ArticleConvert { | @@ -31,6 +30,4 @@ public interface ArticleConvert { | ||
| 31 | 30 | ||
| 32 | PageResult<ArticleRespVO> convertPage(PageResult<ArticleDO> page); | 31 | PageResult<ArticleRespVO> convertPage(PageResult<ArticleDO> page); |
| 33 | 32 | ||
| 34 | - List<ArticleExcelVO> convertList02(List<ArticleDO> list); | ||
| 35 | - | ||
| 36 | } | 33 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleCategoryMapper.java
| @@ -3,13 +3,10 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.article; | @@ -3,13 +3,10 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.article; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryExportReqVO; | ||
| 7 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; |
| 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; |
| 9 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 10 | 9 | ||
| 11 | -import java.util.List; | ||
| 12 | - | ||
| 13 | /** | 10 | /** |
| 14 | * 文章分类 Mapper | 11 | * 文章分类 Mapper |
| 15 | * | 12 | * |
| @@ -26,12 +23,4 @@ public interface ArticleCategoryMapper extends BaseMapperX<ArticleCategoryDO> { | @@ -26,12 +23,4 @@ public interface ArticleCategoryMapper extends BaseMapperX<ArticleCategoryDO> { | ||
| 26 | .orderByDesc(ArticleCategoryDO::getSort)); | 23 | .orderByDesc(ArticleCategoryDO::getSort)); |
| 27 | } | 24 | } |
| 28 | 25 | ||
| 29 | - default List<ArticleCategoryDO> selectList(ArticleCategoryExportReqVO reqVO) { | ||
| 30 | - return selectList(new LambdaQueryWrapperX<ArticleCategoryDO>() | ||
| 31 | - .likeIfPresent(ArticleCategoryDO::getName, reqVO.getName()) | ||
| 32 | - .eqIfPresent(ArticleCategoryDO::getStatus, reqVO.getStatus()) | ||
| 33 | - .betweenIfPresent(ArticleCategoryDO::getCreateTime, reqVO.getCreateTime()) | ||
| 34 | - .orderByDesc(ArticleCategoryDO::getSort)); | ||
| 35 | - } | ||
| 36 | - | ||
| 37 | } | 26 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java
| @@ -3,13 +3,10 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.article; | @@ -3,13 +3,10 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.article; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO; | 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; |
| 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; |
| 9 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 10 | 9 | ||
| 11 | -import java.util.List; | ||
| 12 | - | ||
| 13 | /** | 10 | /** |
| 14 | * 文章管理 Mapper | 11 | * 文章管理 Mapper |
| 15 | * | 12 | * |
| @@ -31,17 +28,4 @@ public interface ArticleMapper extends BaseMapperX<ArticleDO> { | @@ -31,17 +28,4 @@ public interface ArticleMapper extends BaseMapperX<ArticleDO> { | ||
| 31 | .orderByDesc(ArticleDO::getId)); | 28 | .orderByDesc(ArticleDO::getId)); |
| 32 | } | 29 | } |
| 33 | 30 | ||
| 34 | - default List<ArticleDO> selectList(ArticleExportReqVO reqVO) { | ||
| 35 | - return selectList(new LambdaQueryWrapperX<ArticleDO>() | ||
| 36 | - .eqIfPresent(ArticleDO::getCategoryId, reqVO.getCategoryId()) | ||
| 37 | - .eqIfPresent(ArticleDO::getTitle, reqVO.getTitle()) | ||
| 38 | - .eqIfPresent(ArticleDO::getAuthor, reqVO.getAuthor()) | ||
| 39 | - .eqIfPresent(ArticleDO::getStatus, reqVO.getStatus()) | ||
| 40 | - .eqIfPresent(ArticleDO::getSpuId, reqVO.getSpuId()) | ||
| 41 | - .eqIfPresent(ArticleDO::getRecommendHot, reqVO.getRecommendHot()) | ||
| 42 | - .eqIfPresent(ArticleDO::getRecommendBanner, reqVO.getRecommendBanner()) | ||
| 43 | - .betweenIfPresent(ArticleDO::getCreateTime, reqVO.getCreateTime()) | ||
| 44 | - .orderByDesc(ArticleDO::getId)); | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | } | 31 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryService.java
| @@ -2,13 +2,11 @@ package cn.iocoder.yudao.module.promotion.service.article; | @@ -2,13 +2,11 @@ package cn.iocoder.yudao.module.promotion.service.article; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; | 4 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; |
| 5 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryExportReqVO; | ||
| 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; |
| 7 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; |
| 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; |
| 9 | 8 | ||
| 10 | import javax.validation.Valid; | 9 | import javax.validation.Valid; |
| 11 | -import java.util.Collection; | ||
| 12 | import java.util.List; | 10 | import java.util.List; |
| 13 | 11 | ||
| 14 | /** | 12 | /** |
| @@ -49,14 +47,6 @@ public interface ArticleCategoryService { | @@ -49,14 +47,6 @@ public interface ArticleCategoryService { | ||
| 49 | ArticleCategoryDO getArticleCategory(Long id); | 47 | ArticleCategoryDO getArticleCategory(Long id); |
| 50 | 48 | ||
| 51 | /** | 49 | /** |
| 52 | - * 获得文章分类列表 | ||
| 53 | - * | ||
| 54 | - * @param ids 编号 | ||
| 55 | - * @return 文章分类列表 | ||
| 56 | - */ | ||
| 57 | - List<ArticleCategoryDO> getArticleCategoryList(Collection<Long> ids); | ||
| 58 | - | ||
| 59 | - /** | ||
| 60 | * 获得文章分类分页 | 50 | * 获得文章分类分页 |
| 61 | * | 51 | * |
| 62 | * @param pageReqVO 分页查询 | 52 | * @param pageReqVO 分页查询 |
| @@ -65,14 +55,6 @@ public interface ArticleCategoryService { | @@ -65,14 +55,6 @@ public interface ArticleCategoryService { | ||
| 65 | PageResult<ArticleCategoryDO> getArticleCategoryPage(ArticleCategoryPageReqVO pageReqVO); | 55 | PageResult<ArticleCategoryDO> getArticleCategoryPage(ArticleCategoryPageReqVO pageReqVO); |
| 66 | 56 | ||
| 67 | /** | 57 | /** |
| 68 | - * 获得文章分类列表, 用于 Excel 导出 | ||
| 69 | - * | ||
| 70 | - * @param exportReqVO 查询条件 | ||
| 71 | - * @return 文章分类列表 | ||
| 72 | - */ | ||
| 73 | - List<ArticleCategoryDO> getArticleCategoryList(ArticleCategoryExportReqVO exportReqVO); | ||
| 74 | - | ||
| 75 | - /** | ||
| 76 | * 获得指定状态的文章分类列表 | 58 | * 获得指定状态的文章分类列表 |
| 77 | * | 59 | * |
| 78 | * @param status 状态 | 60 | * @param status 状态 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImpl.java
| 1 | package cn.iocoder.yudao.module.promotion.service.article; | 1 | package cn.iocoder.yudao.module.promotion.service.article; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.collection.CollUtil; | ||
| 4 | -import cn.hutool.core.collection.ListUtil; | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; | 4 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; |
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryExportReqVO; | ||
| 8 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; |
| 9 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; |
| 10 | import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; | 7 | import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; |
| @@ -14,7 +11,6 @@ import org.springframework.stereotype.Service; | @@ -14,7 +11,6 @@ import org.springframework.stereotype.Service; | ||
| 14 | import org.springframework.validation.annotation.Validated; | 11 | import org.springframework.validation.annotation.Validated; |
| 15 | 12 | ||
| 16 | import javax.annotation.Resource; | 13 | import javax.annotation.Resource; |
| 17 | -import java.util.Collection; | ||
| 18 | import java.util.List; | 14 | import java.util.List; |
| 19 | 15 | ||
| 20 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 16 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| @@ -35,10 +31,10 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { | @@ -35,10 +31,10 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { | ||
| 35 | @Override | 31 | @Override |
| 36 | public Long createArticleCategory(ArticleCategoryCreateReqVO createReqVO) { | 32 | public Long createArticleCategory(ArticleCategoryCreateReqVO createReqVO) { |
| 37 | // 插入 | 33 | // 插入 |
| 38 | - ArticleCategoryDO articleCategory = ArticleCategoryConvert.INSTANCE.convert(createReqVO); | ||
| 39 | - articleCategoryMapper.insert(articleCategory); | 34 | + ArticleCategoryDO category = ArticleCategoryConvert.INSTANCE.convert(createReqVO); |
| 35 | + articleCategoryMapper.insert(category); | ||
| 40 | // 返回 | 36 | // 返回 |
| 41 | - return articleCategory.getId(); | 37 | + return category.getId(); |
| 42 | } | 38 | } |
| 43 | 39 | ||
| 44 | @Override | 40 | @Override |
| @@ -54,6 +50,8 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { | @@ -54,6 +50,8 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { | ||
| 54 | public void deleteArticleCategory(Long id) { | 50 | public void deleteArticleCategory(Long id) { |
| 55 | // 校验存在 | 51 | // 校验存在 |
| 56 | validateArticleCategoryExists(id); | 52 | validateArticleCategoryExists(id); |
| 53 | + // TODO @puhui999:需要校验下,是不是存在文章 | ||
| 54 | + | ||
| 57 | // 删除 | 55 | // 删除 |
| 58 | articleCategoryMapper.deleteById(id); | 56 | articleCategoryMapper.deleteById(id); |
| 59 | } | 57 | } |
| @@ -70,24 +68,11 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { | @@ -70,24 +68,11 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { | ||
| 70 | } | 68 | } |
| 71 | 69 | ||
| 72 | @Override | 70 | @Override |
| 73 | - public List<ArticleCategoryDO> getArticleCategoryList(Collection<Long> ids) { | ||
| 74 | - if (CollUtil.isEmpty(ids)) { | ||
| 75 | - return ListUtil.empty(); | ||
| 76 | - } | ||
| 77 | - return articleCategoryMapper.selectBatchIds(ids); | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - @Override | ||
| 81 | public PageResult<ArticleCategoryDO> getArticleCategoryPage(ArticleCategoryPageReqVO pageReqVO) { | 71 | public PageResult<ArticleCategoryDO> getArticleCategoryPage(ArticleCategoryPageReqVO pageReqVO) { |
| 82 | return articleCategoryMapper.selectPage(pageReqVO); | 72 | return articleCategoryMapper.selectPage(pageReqVO); |
| 83 | } | 73 | } |
| 84 | 74 | ||
| 85 | @Override | 75 | @Override |
| 86 | - public List<ArticleCategoryDO> getArticleCategoryList(ArticleCategoryExportReqVO exportReqVO) { | ||
| 87 | - return articleCategoryMapper.selectList(exportReqVO); | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | - @Override | ||
| 91 | public List<ArticleCategoryDO> getArticleCategoryListByStatus(Integer status) { | 76 | public List<ArticleCategoryDO> getArticleCategoryListByStatus(Integer status) { |
| 92 | return articleCategoryMapper.selectList(ArticleCategoryDO::getStatus, status); | 77 | return articleCategoryMapper.selectList(ArticleCategoryDO::getStatus, status); |
| 93 | } | 78 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java
| 1 | package cn.iocoder.yudao.module.promotion.service.article; | 1 | package cn.iocoder.yudao.module.promotion.service.article; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; | ||
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO; | 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; | ||
| 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; |
| 9 | 8 | ||
| 10 | import javax.validation.Valid; | 9 | import javax.validation.Valid; |
| 11 | -import java.util.Collection; | ||
| 12 | -import java.util.List; | ||
| 13 | 10 | ||
| 14 | /** | 11 | /** |
| 15 | * 文章管理 Service 接口 | 12 | * 文章管理 Service 接口 |
| @@ -49,14 +46,6 @@ public interface ArticleService { | @@ -49,14 +46,6 @@ public interface ArticleService { | ||
| 49 | ArticleDO getArticle(Long id); | 46 | ArticleDO getArticle(Long id); |
| 50 | 47 | ||
| 51 | /** | 48 | /** |
| 52 | - * 获得文章管理列表 | ||
| 53 | - * | ||
| 54 | - * @param ids 编号 | ||
| 55 | - * @return 文章管理列表 | ||
| 56 | - */ | ||
| 57 | - List<ArticleDO> getArticleList(Collection<Long> ids); | ||
| 58 | - | ||
| 59 | - /** | ||
| 60 | * 获得文章管理分页 | 49 | * 获得文章管理分页 |
| 61 | * | 50 | * |
| 62 | * @param pageReqVO 分页查询 | 51 | * @param pageReqVO 分页查询 |
| @@ -64,12 +53,4 @@ public interface ArticleService { | @@ -64,12 +53,4 @@ public interface ArticleService { | ||
| 64 | */ | 53 | */ |
| 65 | PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO); | 54 | PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO); |
| 66 | 55 | ||
| 67 | - /** | ||
| 68 | - * 获得文章管理列表, 用于 Excel 导出 | ||
| 69 | - * | ||
| 70 | - * @param exportReqVO 查询条件 | ||
| 71 | - * @return 文章管理列表 | ||
| 72 | - */ | ||
| 73 | - List<ArticleDO> getArticleList(ArticleExportReqVO exportReqVO); | ||
| 74 | - | ||
| 75 | } | 56 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java
| 1 | package cn.iocoder.yudao.module.promotion.service.article; | 1 | package cn.iocoder.yudao.module.promotion.service.article; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.collection.CollUtil; | ||
| 4 | -import cn.hutool.core.collection.ListUtil; | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; | ||
| 8 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO; | ||
| 9 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO; | 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; | ||
| 10 | import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; | 7 | import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; |
| 11 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; |
| 12 | import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper; | 9 | import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper; |
| @@ -14,8 +11,6 @@ import org.springframework.stereotype.Service; | @@ -14,8 +11,6 @@ import org.springframework.stereotype.Service; | ||
| 14 | import org.springframework.validation.annotation.Validated; | 11 | import org.springframework.validation.annotation.Validated; |
| 15 | 12 | ||
| 16 | import javax.annotation.Resource; | 13 | import javax.annotation.Resource; |
| 17 | -import java.util.Collection; | ||
| 18 | -import java.util.List; | ||
| 19 | 14 | ||
| 20 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 15 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 21 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_NOT_EXISTS; | 16 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_NOT_EXISTS; |
| @@ -34,6 +29,7 @@ public class ArticleServiceImpl implements ArticleService { | @@ -34,6 +29,7 @@ public class ArticleServiceImpl implements ArticleService { | ||
| 34 | 29 | ||
| 35 | @Override | 30 | @Override |
| 36 | public Long createArticle(ArticleCreateReqVO createReqVO) { | 31 | public Long createArticle(ArticleCreateReqVO createReqVO) { |
| 32 | + // TODO @puhui999:需要校验分类存在 | ||
| 37 | // 插入 | 33 | // 插入 |
| 38 | ArticleDO article = ArticleConvert.INSTANCE.convert(createReqVO); | 34 | ArticleDO article = ArticleConvert.INSTANCE.convert(createReqVO); |
| 39 | articleMapper.insert(article); | 35 | articleMapper.insert(article); |
| @@ -45,6 +41,8 @@ public class ArticleServiceImpl implements ArticleService { | @@ -45,6 +41,8 @@ public class ArticleServiceImpl implements ArticleService { | ||
| 45 | public void updateArticle(ArticleUpdateReqVO updateReqVO) { | 41 | public void updateArticle(ArticleUpdateReqVO updateReqVO) { |
| 46 | // 校验存在 | 42 | // 校验存在 |
| 47 | validateArticleExists(updateReqVO.getId()); | 43 | validateArticleExists(updateReqVO.getId()); |
| 44 | + // TODO @puhui999:需要校验分类存在 | ||
| 45 | + | ||
| 48 | // 更新 | 46 | // 更新 |
| 49 | ArticleDO updateObj = ArticleConvert.INSTANCE.convert(updateReqVO); | 47 | ArticleDO updateObj = ArticleConvert.INSTANCE.convert(updateReqVO); |
| 50 | articleMapper.updateById(updateObj); | 48 | articleMapper.updateById(updateObj); |
| @@ -70,21 +68,8 @@ public class ArticleServiceImpl implements ArticleService { | @@ -70,21 +68,8 @@ public class ArticleServiceImpl implements ArticleService { | ||
| 70 | } | 68 | } |
| 71 | 69 | ||
| 72 | @Override | 70 | @Override |
| 73 | - public List<ArticleDO> getArticleList(Collection<Long> ids) { | ||
| 74 | - if (CollUtil.isEmpty(ids)) { | ||
| 75 | - return ListUtil.empty(); | ||
| 76 | - } | ||
| 77 | - return articleMapper.selectBatchIds(ids); | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - @Override | ||
| 81 | public PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO) { | 71 | public PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO) { |
| 82 | return articleMapper.selectPage(pageReqVO); | 72 | return articleMapper.selectPage(pageReqVO); |
| 83 | } | 73 | } |
| 84 | 74 | ||
| 85 | - @Override | ||
| 86 | - public List<ArticleDO> getArticleList(ArticleExportReqVO exportReqVO) { | ||
| 87 | - return articleMapper.selectList(exportReqVO); | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | } | 75 | } |
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImplTest.java
| @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.promotion.service.article; | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.promotion.service.article; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 5 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; |
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryExportReqVO; | ||
| 7 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; |
| 8 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; | 7 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; |
| 9 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; |
| @@ -13,7 +12,6 @@ import org.junit.jupiter.api.Test; | @@ -13,7 +12,6 @@ import org.junit.jupiter.api.Test; | ||
| 13 | import org.springframework.context.annotation.Import; | 12 | import org.springframework.context.annotation.Import; |
| 14 | 13 | ||
| 15 | import javax.annotation.Resource; | 14 | import javax.annotation.Resource; |
| 16 | -import java.util.List; | ||
| 17 | 15 | ||
| 18 | import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; | 16 | import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; |
| 19 | import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | 17 | import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; |
| @@ -24,6 +22,7 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | @@ -24,6 +22,7 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | ||
| 24 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS; | 22 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS; |
| 25 | import static org.junit.jupiter.api.Assertions.*; | 23 | import static org.junit.jupiter.api.Assertions.*; |
| 26 | 24 | ||
| 25 | +// TODO 芋艿:review 单测 | ||
| 27 | /** | 26 | /** |
| 28 | * {@link ArticleCategoryServiceImpl} 的单元测试类 | 27 | * {@link ArticleCategoryServiceImpl} 的单元测试类 |
| 29 | * | 28 | * |
| @@ -137,39 +136,4 @@ public class ArticleCategoryServiceImplTest extends BaseDbUnitTest { | @@ -137,39 +136,4 @@ public class ArticleCategoryServiceImplTest extends BaseDbUnitTest { | ||
| 137 | assertPojoEquals(dbArticleCategory, pageResult.getList().get(0)); | 136 | assertPojoEquals(dbArticleCategory, pageResult.getList().get(0)); |
| 138 | } | 137 | } |
| 139 | 138 | ||
| 140 | - @Test | ||
| 141 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | ||
| 142 | - public void testGetArticleCategoryList() { | ||
| 143 | - // mock 数据 | ||
| 144 | - ArticleCategoryDO dbArticleCategory = randomPojo(ArticleCategoryDO.class, o -> { // 等会查询到 | ||
| 145 | - o.setName(null); | ||
| 146 | - o.setPicUrl(null); | ||
| 147 | - o.setStatus(null); | ||
| 148 | - o.setSort(null); | ||
| 149 | - o.setCreateTime(null); | ||
| 150 | - }); | ||
| 151 | - articleCategoryMapper.insert(dbArticleCategory); | ||
| 152 | - // 测试 name 不匹配 | ||
| 153 | - articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setName(null))); | ||
| 154 | - // 测试 picUrl 不匹配 | ||
| 155 | - articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setPicUrl(null))); | ||
| 156 | - // 测试 status 不匹配 | ||
| 157 | - articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setStatus(null))); | ||
| 158 | - // 测试 sort 不匹配 | ||
| 159 | - articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setSort(null))); | ||
| 160 | - // 测试 createTime 不匹配 | ||
| 161 | - articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setCreateTime(null))); | ||
| 162 | - // 准备参数 | ||
| 163 | - ArticleCategoryExportReqVO reqVO = new ArticleCategoryExportReqVO(); | ||
| 164 | - reqVO.setName(null); | ||
| 165 | - reqVO.setStatus(null); | ||
| 166 | - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | ||
| 167 | - | ||
| 168 | - // 调用 | ||
| 169 | - List<ArticleCategoryDO> list = articleCategoryService.getArticleCategoryList(reqVO); | ||
| 170 | - // 断言 | ||
| 171 | - assertEquals(1, list.size()); | ||
| 172 | - assertPojoEquals(dbArticleCategory, list.get(0)); | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | } | 139 | } |
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImplTest.java
| @@ -2,10 +2,10 @@ package cn.iocoder.yudao.module.promotion.service.article; | @@ -2,10 +2,10 @@ package cn.iocoder.yudao.module.promotion.service.article; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 5 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO; | 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; |
| 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; |
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO; | ||
| 8 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO; | 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; |
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; | ||
| 9 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; | 9 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; |
| 10 | import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper; | 10 | import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper; |
| 11 | import org.junit.jupiter.api.Disabled; | 11 | import org.junit.jupiter.api.Disabled; |