|
|
@@ -30,20 +30,20 @@ public class KnowledgeController extends BaseController {
|
|
|
public AjaxResult list(Integer page, Integer pageSize, String category)
|
|
|
{
|
|
|
startPage();
|
|
|
-
|
|
|
+
|
|
|
KnowledgeContent knowledgeContent = new KnowledgeContent();
|
|
|
if (category != null) {
|
|
|
knowledgeContent.setContentCategory(category);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
List<KnowledgeContent> list = knowledgeContentService.selectKnowledgeContentList(knowledgeContent);
|
|
|
TableDataInfo dataTable = getDataTable(list);
|
|
|
-
|
|
|
+
|
|
|
// 构造与前端一致的数据格式
|
|
|
Map<String, Object> data = new HashMap<>();
|
|
|
data.put("list", dataTable.getRows());
|
|
|
data.put("total", dataTable.getTotal());
|
|
|
-
|
|
|
+
|
|
|
return AjaxResult.success(data);
|
|
|
}
|
|
|
|
|
|
@@ -55,7 +55,7 @@ public class KnowledgeController extends BaseController {
|
|
|
{
|
|
|
return AjaxResult.success(knowledgeContentService.selectKnowledgeContentById(id));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 更新阅读量
|
|
|
*/
|
|
|
@@ -66,11 +66,11 @@ public class KnowledgeController extends BaseController {
|
|
|
if (id == null) {
|
|
|
return AjaxResult.error("参数错误");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
knowledgeContentService.incrementViewCount(id);
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 点赞内容
|
|
|
*/
|
|
|
@@ -81,11 +81,11 @@ public class KnowledgeController extends BaseController {
|
|
|
if (id == null) {
|
|
|
return AjaxResult.error("参数错误");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 实际业务中可能需要记录用户的点赞状态
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 取消点赞
|
|
|
*/
|
|
|
@@ -96,11 +96,11 @@ public class KnowledgeController extends BaseController {
|
|
|
if (id == null) {
|
|
|
return AjaxResult.error("参数错误");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 实际业务中可能需要删除用户的点赞记录
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 收藏内容
|
|
|
*/
|
|
|
@@ -111,11 +111,11 @@ public class KnowledgeController extends BaseController {
|
|
|
if (id == null) {
|
|
|
return AjaxResult.error("参数错误");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 实际业务中可能需要记录用户的收藏状态
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 取消收藏
|
|
|
*/
|
|
|
@@ -126,7 +126,6 @@ public class KnowledgeController extends BaseController {
|
|
|
if (id == null) {
|
|
|
return AjaxResult.error("参数错误");
|
|
|
}
|
|
|
-
|
|
|
// 实际业务中可能需要删除用户的收藏记录
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
@@ -163,4 +162,15 @@ public class KnowledgeController extends BaseController {
|
|
|
{
|
|
|
return toAjax(knowledgeContentService.deleteKnowledgeContentByIds(ids));
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据浏览量查询
|
|
|
+ */
|
|
|
+ @GetMapping("/top-articles")
|
|
|
+ public List<KnowledgeContent> topArticles(
|
|
|
+ @RequestParam(defaultValue = "4") int limit,
|
|
|
+ @RequestParam(required = false) String category) {
|
|
|
+ return knowledgeContentService.getTopArticles(limit, category);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|