MALL:营销文章增加 title 查询,简易解决常见问题、用户协议的编辑

plp
YunaiV 2 years ago
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…
Cancel
Save