营销活动:完善文章相关 app 端接口

This commit is contained in:
puhui999 2023-10-15 22:41:18 +08:00
parent b009f0b058
commit 0d45acaf20
18 changed files with 124 additions and 121 deletions

View File

@ -4,7 +4,7 @@ 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.controller.admin.article.vo.article.*;
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;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo;
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo;
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo;
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo;
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo;
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo;
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo;
package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@ -1,16 +1,19 @@
package cn.iocoder.yudao.module.promotion.controller.app.article;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.controller.app.article.vo.category.AppArticleCategoryRespVO;
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.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import javax.annotation.Resource;
import java.util.List;
import java.util.Random;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -20,20 +23,15 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Validated
public class AppArticleCategoryController {
@Resource
private ArticleCategoryService articleCategoryService;
@RequestMapping("/list")
@Operation(summary = "获得文章分类列表")
// TODO @芋艿swagger 注解
public CommonResult<List<AppArticleCategoryRespVO>> getArticleCategoryList() {
List<AppArticleCategoryRespVO> appArticleRespVOList = new ArrayList<>();
Random random = new Random();
for (int i = 0; i < 10; i++) {
AppArticleCategoryRespVO appArticleRespVO = new AppArticleCategoryRespVO();
appArticleRespVO.setId((long) (i + 1));
appArticleRespVO.setName("分类 - " + i);
appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png");
appArticleRespVOList.add(appArticleRespVO);
}
return success(appArticleRespVOList);
List<ArticleCategoryDO> categoryList = articleCategoryService.getArticleCategoryListByStatus(
CommonStatusEnum.ENABLE.getStatus());
return success(ArticleCategoryConvert.INSTANCE.convertList04(categoryList));
}
}

View File

@ -4,16 +4,19 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO;
import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO;
import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert;
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.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.util.ArrayList;
import javax.annotation.Resource;
import java.util.List;
import java.util.Random;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -23,68 +26,33 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Validated
public class AppArticleController {
@Resource
private ArticleService articleService;
@RequestMapping("/list")
// TODO @芋艿swagger 注解
public CommonResult<List<AppArticleRespVO>> getArticleList(@RequestParam(value = "recommendHot", required = false) Boolean recommendHot,
@RequestParam(value = "recommendBanner", required = false) Boolean recommendBanner) {
List<AppArticleRespVO> appArticleRespVOList = new ArrayList<>();
Random random = new Random();
for (int i = 0; i < 10; i++) {
AppArticleRespVO appArticleRespVO = new AppArticleRespVO();
appArticleRespVO.setId((long) (i + 1));
appArticleRespVO.setTitle("芋道源码 - " + i + "模块");
appArticleRespVO.setAuthor("芋道源码");
appArticleRespVO.setCategoryId((long) random.nextInt(10000));
appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png");
appArticleRespVO.setIntroduction("我是简介");
appArticleRespVO.setDescription("我是详细");
appArticleRespVO.setCreateTime(LocalDateTime.now());
appArticleRespVO.setBrowseCount(random.nextInt(10000));
appArticleRespVO.setSpuId((long) random.nextInt(10000));
appArticleRespVOList.add(appArticleRespVO);
}
return success(appArticleRespVOList);
@Operation(summary = "获得文章详情列表")
@Parameters({
@Parameter(name = "recommendHot", description = "是否热门", example = "false"), // 场景一查看指定的文章
@Parameter(name = "recommendBanner", description = "是否轮播图", example = "false") // 场景二查看指定的文章
})
public CommonResult<List<AppArticleRespVO>> getArticleList(
@RequestParam(value = "recommendHot", required = false) Boolean recommendHot,
@RequestParam(value = "recommendBanner", required = false) Boolean recommendBanner) {
return success(ArticleConvert.INSTANCE.convertList03(
articleService.getArticleCategoryListByRecommendHotAndRecommendBanner(recommendHot, recommendBanner)));
}
@RequestMapping("/page")
// TODO @芋艿swagger 注解
@Operation(summary = "获得文章详情分页")
public CommonResult<PageResult<AppArticleRespVO>> getArticlePage(AppArticlePageReqVO pageReqVO) {
List<AppArticleRespVO> appArticleRespVOList = new ArrayList<>();
Random random = new Random();
for (int i = 0; i < 10; i++) {
AppArticleRespVO appArticleRespVO = new AppArticleRespVO();
appArticleRespVO.setId((long) (i + 1));
appArticleRespVO.setTitle("芋道源码 - " + i + "模块");
appArticleRespVO.setAuthor("芋道源码");
appArticleRespVO.setCategoryId((long) random.nextInt(10000));
appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png");
appArticleRespVO.setIntroduction("我是简介");
appArticleRespVO.setDescription("我是详细");
appArticleRespVO.setCreateTime(LocalDateTime.now());
appArticleRespVO.setBrowseCount(random.nextInt(10000));
appArticleRespVO.setSpuId((long) random.nextInt(10000));
appArticleRespVOList.add(appArticleRespVO);
}
return success(new PageResult<>(appArticleRespVOList, 10L));
return success(ArticleConvert.INSTANCE.convertPage02(articleService.getArticlePage(pageReqVO)));
}
@RequestMapping("/get")
// TODO @芋艿swagger 注解
@Operation(summary = "获得文章详情")
@Parameter(name = "id", description = "文章编号", example = "1024")
public CommonResult<AppArticleRespVO> getArticlePage(@RequestParam("id") Long id) {
Random random = new Random();
AppArticleRespVO appArticleRespVO = new AppArticleRespVO();
appArticleRespVO.setId((long) (1));
appArticleRespVO.setTitle("芋道源码 - " + 0 + "模块");
appArticleRespVO.setAuthor("芋道源码");
appArticleRespVO.setCategoryId((long) random.nextInt(10000));
appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (0 + 1) + ".png");
appArticleRespVO.setIntroduction("我是简介");
appArticleRespVO.setDescription("我是详细");
appArticleRespVO.setCreateTime(LocalDateTime.now());
appArticleRespVO.setBrowseCount(random.nextInt(10000));
appArticleRespVO.setSpuId((long) random.nextInt(10000));
appArticleRespVO.setSpuId(633L);
return success(appArticleRespVO);
return success(ArticleConvert.INSTANCE.convert01(articleService.getArticle(id)));
}
}

View File

@ -39,11 +39,4 @@ public class AppArticleRespVO {
@Schema(description = "关联的商品 SPU 编号", example = "1024")
private Long spuId;
// TODO 芋艿下面 2 个字段后端要存储前端不用返回
// @Schema(description = "是否热卖推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
// private Boolean recommendHot;
//
// @Schema(description = "是否 Banner 推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
// private Boolean recommendBanner;
}

View File

@ -16,11 +16,4 @@ public class AppArticleCategoryRespVO {
@Schema(description = "分类图标", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png")
private String picUrl;
// TODO 芋艿下面 2 个字段后端要存储前端不用返回
// @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
// private Integer status;
//
// @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
// private Integer sort;
}

View File

@ -2,6 +2,7 @@ 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.controller.app.article.vo.category.AppArticleCategoryRespVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@ -32,4 +33,6 @@ public interface ArticleCategoryConvert {
List<ArticleCategorySimpleRespVO> convertList03(List<ArticleCategoryDO> list);
List<AppArticleCategoryRespVO> convertList04(List<ArticleCategoryDO> categoryList);
}

View File

@ -1,10 +1,11 @@
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.controller.admin.article.vo.article.ArticleCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleExcelVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleRespVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO;
import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@ -33,4 +34,10 @@ public interface ArticleConvert {
List<ArticleExcelVO> convertList02(List<ArticleDO> list);
List<AppArticleRespVO> convertList03(List<ArticleDO> list);
AppArticleRespVO convert01(ArticleDO article);
PageResult<AppArticleRespVO> convertPage02(PageResult<ArticleDO> articlePage);
}

View File

@ -3,8 +3,9 @@ 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.controller.admin.article.vo.article.ArticleExportReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO;
import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
import org.apache.ibatis.annotations.Mapper;
@ -44,4 +45,15 @@ public interface ArticleMapper extends BaseMapperX<ArticleDO> {
.orderByDesc(ArticleDO::getId));
}
default List<ArticleDO> selectList(Boolean recommendHot, Boolean recommendBanner) {
return selectList(new LambdaQueryWrapperX<ArticleDO>()
.eqIfPresent(ArticleDO::getRecommendHot, recommendHot)
.eqIfPresent(ArticleDO::getRecommendBanner, recommendBanner));
}
default PageResult<ArticleDO> selectPage(AppArticlePageReqVO pageReqVO) {
return selectPage(pageReqVO, new LambdaQueryWrapperX<ArticleDO>()
.eqIfPresent(ArticleDO::getCategoryId, pageReqVO.getCategoryId()));
}
}

View File

@ -1,10 +1,11 @@
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.controller.admin.article.vo.article.ArticleCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleExportReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO;
import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
import javax.validation.Valid;
@ -12,14 +13,14 @@ import java.util.Collection;
import java.util.List;
/**
* 文章管理 Service 接口
* 文章详情 Service 接口
*
* @author HUIHUI
*/
public interface ArticleService {
/**
* 创建文章管理
* 创建文章详情
*
* @param createReqVO 创建信息
* @return 编号
@ -27,49 +28,66 @@ public interface ArticleService {
Long createArticle(@Valid ArticleCreateReqVO createReqVO);
/**
* 更新文章管理
* 更新文章详情
*
* @param updateReqVO 更新信息
*/
void updateArticle(@Valid ArticleUpdateReqVO updateReqVO);
/**
* 删除文章管理
* 删除文章详情
*
* @param id 编号
*/
void deleteArticle(Long id);
/**
* 获得文章管理
* 获得文章详情
*
* @param id 编号
* @return 文章管理
* @return 文章详情
*/
ArticleDO getArticle(Long id);
/**
* 获得文章管理列表
* 获得文章详情列表
*
* @param ids 编号
* @return 文章管理列表
* @return 文章详情列表
*/
List<ArticleDO> getArticleList(Collection<Long> ids);
/**
* 获得文章管理分页
* 获得文章详情分页
*
* @param pageReqVO 分页查询
* @return 文章管理分页
* @return 文章详情分页
*/
PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO);
/**
* 获得文章管理列表, 用于 Excel 导出
* 获得文章详情列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 文章管理列表
* @return 文章详情列表
*/
List<ArticleDO> getArticleList(ArticleExportReqVO exportReqVO);
/**
* 获得文章详情列表
*
* @param recommendHot 是否热门
* @param recommendBanner 是否轮播图
* @return 文章详情列表
*/
List<ArticleDO> getArticleCategoryListByRecommendHotAndRecommendBanner(Boolean recommendHot, Boolean recommendBanner);
/**
* 获得文章详情分页
*
* @param pageReqVO 分页查询
* @return 文章详情分页
*/
PageResult<ArticleDO> getArticlePage(AppArticlePageReqVO pageReqVO);
}

View File

@ -3,10 +3,11 @@ 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.controller.admin.article.vo.article.ArticleCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleExportReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO;
import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO;
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;
@ -87,4 +88,14 @@ public class ArticleServiceImpl implements ArticleService {
return articleMapper.selectList(exportReqVO);
}
@Override
public List<ArticleDO> getArticleCategoryListByRecommendHotAndRecommendBanner(Boolean recommendHot, Boolean recommendBanner) {
return articleMapper.selectList(recommendHot, recommendBanner);
}
@Override
public PageResult<ArticleDO> getArticlePage(AppArticlePageReqVO pageReqVO) {
return articleMapper.selectPage(pageReqVO);
}
}

View File

@ -2,10 +2,10 @@ 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.controller.admin.article.vo.article.ArticleCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleExportReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.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;