帮助中心

This commit is contained in:
SjS 2025-03-28 17:26:01 +08:00
parent 929d16c25b
commit dd03652a01
4 changed files with 27 additions and 50 deletions

View File

@ -61,5 +61,5 @@ public interface ArticleService
*/
public int deleteArticleById(Long id);
public ArticleVO selectChildrenByCategoryId(Long id);
ArticleVO selectChildrenByCategoryId(Long id);
}

View File

@ -89,6 +89,16 @@ public class ArticleServiceImpl implements ArticleService
@Override
public int updateArticle(Article article)
{
//分类必须存在
if(articleCategoryService.selectArticleCategoryById(article.getCategoryId()) ==null){
throw new ServiceException("当前分类不存在");
}
//所属区域必须存在
if (areaService.selectAreaById(article.getAreaId()) == null){
throw new ServiceException("所属区域不存在");
}
article.setUpdateTime(DateUtils.getNowDate());
return articleMapper.updateArticle(article);
}

View File

@ -1,36 +0,0 @@
package com.ruoyi.web.app;
import com.ruoyi.bst.areaSub.domain.AreaSubQuery;
import com.ruoyi.bst.areaSub.domain.enums.AreaSubStatus;
import com.ruoyi.bst.article.domain.ArticleQuery;
import com.ruoyi.bst.article.service.ArticleService;
import com.ruoyi.bst.articleCategory.domain.ArticleCategoryQuery;
import com.ruoyi.bst.articleCategory.domain.enums.ArticleCategoryStatus;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/app/article")
public class AppArticleController extends BaseController {
@Autowired
private ArticleService articleService;
@ApiOperation("查看文章")
@GetMapping
@Anonymous
public AjaxResult getCategoryList(ArticleQuery query) {
if(query.getId() == null){
return error("文章id不能为空");
}
return AjaxResult.success(articleService.selectArticleList(query));
}
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.web.app;
import com.ruoyi.bst.article.domain.ArticleQuery;
import com.ruoyi.bst.article.domain.ArticleVO;
import com.ruoyi.bst.article.service.ArticleService;
import com.ruoyi.bst.articleCategory.domain.ArticleCategoryQuery;
@ -30,23 +31,25 @@ public class AppAtricleCategoryController extends BaseController {
@Autowired
private ArticleService articleService;
@ApiOperation("帮助中心")
@GetMapping
@ApiOperation("查询所有文章分类信息")
@GetMapping("/list")
@Anonymous
public TableDataInfo getCategoryList(ArticleCategoryQuery query) {
public TableDataInfo getArticleCategory(ArticleCategoryQuery articleCategoryQuery) {
startPage();
query.setCategoryStatus(ArticleCategoryStatus.ENABLED.getCode());
articleCategoryQuery.setCategoryStatus(ArticleCategoryStatus.ENABLED.getCode());
return getDataTable(articleCategoryService.selectArticleCategoryList(articleCategoryQuery));
}
@ApiOperation("查询分类下的文章")
@GetMapping("/article")
@Anonymous
public TableDataInfo getArticle(ArticleCategoryQuery articleCategoryQuery) {
startPage();
//查询分类的文章
List<ArticleCategoryVO> list = articleCategoryService.selectArticleCategoryList(query);
list.forEach(articleCategoryVO -> {
ArticleVO children = articleService.selectChildrenByCategoryId(articleCategoryVO.getId());
List<ArticleVO> childrenList = new ArrayList<>();
if (children != null) {
childrenList.add(children);
}
articleCategoryVO.setChildren(childrenList);
});
ArticleQuery articleQuery = new ArticleQuery();
articleQuery.setCategoryId(articleCategoryQuery.getId());
List<ArticleVO> list = articleService.selectArticleList(articleQuery);
return getDataTable(list);
}
}