mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
✨ MALL:营销文章增加 title 查询,简易解决常见问题、用户协议的编辑
This commit is contained in:
parent
c019136f07
commit
1f3f3d789b
@ -2,9 +2,11 @@ package cn.iocoder.yudao.module.promotion.controller.app.article;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
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.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;
|
||||
@ -51,9 +53,15 @@ public class AppArticleController {
|
||||
|
||||
@RequestMapping("/get")
|
||||
@Operation(summary = "获得文章详情")
|
||||
@Parameter(name = "id", description = "文章编号", example = "1024")
|
||||
public CommonResult<AppArticleRespVO> getArticlePage(@RequestParam("id") Long id) {
|
||||
return success(ArticleConvert.INSTANCE.convert01(articleService.getArticle(id)));
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "文章编号", example = "1024"),
|
||||
@Parameter(name = "title", description = "文章标题", example = "1024"),
|
||||
})
|
||||
public CommonResult<AppArticleRespVO> getArticle(@RequestParam(value = "id", required = false) Long id,
|
||||
@RequestParam(value = "title", required = false) String title) {
|
||||
ArticleDO article = id != null ? articleService.getArticle(id)
|
||||
: articleService.getLastArticleByTitle(title);
|
||||
return success(BeanUtils.toBean(article, AppArticleRespVO.class));
|
||||
}
|
||||
|
||||
@PutMapping("/add-browse-count")
|
||||
@ -64,4 +72,4 @@ public class AppArticleController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ public class AppArticleRespVO {
|
||||
private String introduction;
|
||||
|
||||
@Schema(description = "文章内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是详细")
|
||||
private String description;
|
||||
private String content;
|
||||
|
||||
@Schema(description = "发布时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
@ -38,6 +38,10 @@ public interface ArticleMapper extends BaseMapperX<ArticleDO> {
|
||||
.eqIfPresent(ArticleDO::getRecommendBanner, recommendBanner));
|
||||
}
|
||||
|
||||
default List<ArticleDO> selectListByTitle(String title) {
|
||||
return selectList(ArticleDO::getTitle, title);
|
||||
}
|
||||
|
||||
default PageResult<ArticleDO> selectPage(AppArticlePageReqVO pageReqVO) {
|
||||
return selectPage(pageReqVO, new LambdaQueryWrapperX<ArticleDO>()
|
||||
.eqIfPresent(ArticleDO::getCategoryId, pageReqVO.getCategoryId()));
|
||||
|
@ -11,14 +11,14 @@ import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文章详情 Service 接口
|
||||
* 文章 Service 接口
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
public interface ArticleService {
|
||||
|
||||
/**
|
||||
* 创建文章详情
|
||||
* 创建文章
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
@ -26,60 +26,62 @@ 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 title 标题
|
||||
* @return 文章
|
||||
*/
|
||||
ArticleDO getLastArticleByTitle(String title);
|
||||
|
||||
/**
|
||||
* 获得文章分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 文章详情分页
|
||||
* @return 文章分页
|
||||
*/
|
||||
PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得文章详情列表
|
||||
* 获得文章列表
|
||||
*
|
||||
* @param recommendHot 是否热门
|
||||
* @param recommendBanner 是否轮播图
|
||||
* @return 文章详情列表
|
||||
* @return 文章列表
|
||||
*/
|
||||
List<ArticleDO> getArticleCategoryListByRecommend(Boolean recommendHot, Boolean recommendBanner);
|
||||
|
||||
/**
|
||||
* 获得文章详情分页
|
||||
* 获得文章分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 文章详情分页
|
||||
* @return 文章分页
|
||||
*/
|
||||
PageResult<ArticleDO> getArticlePage(AppArticlePageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得指定分类的文章列表
|
||||
*
|
||||
* @param categoryId 文章分类编号
|
||||
* @return 文章列表
|
||||
*/
|
||||
List<ArticleDO> getArticleByCategoryId(Long categoryId);
|
||||
|
||||
/**
|
||||
* 获得指定分类的文章数量
|
||||
*
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.promotion.service.article;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO;
|
||||
@ -85,6 +86,12 @@ public class ArticleServiceImpl implements ArticleService {
|
||||
return articleMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArticleDO getLastArticleByTitle(String title) {
|
||||
List<ArticleDO> articles = articleMapper.selectListByTitle(title);
|
||||
return CollUtil.getLast(articles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO) {
|
||||
return articleMapper.selectPage(pageReqVO);
|
||||
@ -100,11 +107,6 @@ public class ArticleServiceImpl implements ArticleService {
|
||||
return articleMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArticleDO> getArticleByCategoryId(Long categoryId) {
|
||||
return articleMapper.selectList(ArticleDO::getCategoryId, categoryId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getArticleCountByCategoryId(Long categoryId) {
|
||||
return articleMapper.selectCount(ArticleDO::getCategoryId, categoryId);
|
||||
|
Loading…
Reference in New Issue
Block a user