refactor(service): 重构服务接口和实现类结构
将服务接口从service包移动到service.imp包 修复ArticleRepository中viewCount的COALESCE处理 添加getPublishedArticles方法获取已发布文章 优化incrementViewCount方法使用仓库直接更新 修正HelpController中README_API.md路径
This commit is contained in:
@@ -3,7 +3,8 @@ package com.qf.myafterprojecy.controller;
|
||||
import com.qf.myafterprojecy.pojo.Article;
|
||||
import com.qf.myafterprojecy.pojo.ResponseMessage;
|
||||
import com.qf.myafterprojecy.pojo.dto.ArticleDto;
|
||||
import com.qf.myafterprojecy.service.IArticleService;
|
||||
import com.qf.myafterprojecy.service.imp.IArticleService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -33,7 +34,14 @@ public class ArticleController {
|
||||
public ResponseMessage<Article> getArticle(@PathVariable String id) {
|
||||
return articleService.getArticleById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已发布的文章列表
|
||||
* @return 返回包含已发布文章列表的ResponseMessage对象
|
||||
*/
|
||||
@GetMapping("/published")
|
||||
public ResponseMessage<List<Article>> getPublishedArticles() {
|
||||
return articleService.getPublishedArticles();
|
||||
}
|
||||
/**
|
||||
* 获取所有文章列表
|
||||
* @return 返回包含文章列表的ResponseMessage对象
|
||||
@@ -61,17 +69,8 @@ public class ArticleController {
|
||||
public ResponseMessage<List<Article>> getArticlesByAttribute(@PathVariable Integer attributeId) {
|
||||
return articleService.getArticlesByAttribute(attributeId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据分类ID获取该分类下的所有文章(兼容旧接口)
|
||||
* @param categoryId 分类ID
|
||||
* @return 返回包含文章列表的ResponseMessage对象
|
||||
*/
|
||||
@GetMapping("/category/{categoryId}")
|
||||
public ResponseMessage<List<Article>> getArticlesByCategory(@PathVariable Integer categoryId) {
|
||||
return articleService.getArticlesByCategory(categoryId);
|
||||
}
|
||||
/**
|
||||
* 根据属性ID获取最新文章(按创建时间降序)
|
||||
* @param attributeId 属性ID
|
||||
@@ -81,14 +80,7 @@ public class ArticleController {
|
||||
public ResponseMessage<List<Article>> getLatestArticlesByAttribute(@PathVariable Integer attributeId) {
|
||||
return articleService.getLatestArticlesByAttribute(attributeId);
|
||||
}
|
||||
/**
|
||||
* 获取浏览量最高的文章列表
|
||||
* @return 返回包含热门文章列表的ResponseMessage对象
|
||||
*/
|
||||
@GetMapping("/popular")
|
||||
public ResponseMessage<List<Article>> getMostViewedArticles() {
|
||||
return articleService.getMostViewedArticles();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建新文章
|
||||
* 仅限AUTHOR角色用户访问
|
||||
|
||||
Reference in New Issue
Block a user