【新增】新增显示教程详情
Some checks failed
CI Build and Test / build (pull_request) Has been cancelled

This commit is contained in:
2025-10-30 09:36:39 +08:00
parent 8aa6fc0abf
commit e8dc76ef82
2 changed files with 32 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
package com.corewing.app.controller; package com.corewing.app.modules.app;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -10,10 +10,9 @@ import com.corewing.app.service.TutorialCategoryService;
import com.corewing.app.service.TutorialService; import com.corewing.app.service.TutorialService;
import com.corewing.app.util.I18nUtil; import com.corewing.app.util.I18nUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@@ -21,7 +20,7 @@ import java.util.List;
* 教程接口 * 教程接口
*/ */
@RequestMapping("/tutorial") @RequestMapping("/tutorial")
@RestController @Controller
@Slf4j @Slf4j
public class TutorialController { public class TutorialController {
@@ -33,12 +32,27 @@ public class TutorialController {
this.tutorialCategoryService = tutorialCategoryService; this.tutorialCategoryService = tutorialCategoryService;
} }
/**
* 跳转到界面查看教程详情
* @param tutorialId 教程id
* @param model 数据模型
* @return 详情页
*/
@GetMapping("/viewDetail/{tutorialId}")
public String viewDetail(@PathVariable Long tutorialId, ModelMap model) {
Tutorial tutorial = tutorialService.getById(tutorialId);
model.put("tutorial", tutorial);
return "/app/tutorial/viewDetail";
}
/** /**
* 添加查看次数 * 添加查看次数
* @param tutorialId 教程id * @param tutorialId 教程id
* @return * @return
*/ */
@GetMapping("/addViewCount") @GetMapping("/addViewCount")
@ResponseBody
public Result<String> addViewCount(@RequestParam Long tutorialId) { public Result<String> addViewCount(@RequestParam Long tutorialId) {
Tutorial tutorial = tutorialService.getById(tutorialId); Tutorial tutorial = tutorialService.getById(tutorialId);
if(tutorial == null) { if(tutorial == null) {
@@ -56,6 +70,7 @@ public class TutorialController {
* *
*/ */
@GetMapping("/category") @GetMapping("/category")
@ResponseBody
public Result<List<TutorialCategory>> category( public Result<List<TutorialCategory>> category(
@RequestParam(required = false, defaultValue = "0") Integer firstStatus @RequestParam(required = false, defaultValue = "0") Integer firstStatus
) { ) {
@@ -77,6 +92,7 @@ public class TutorialController {
* *
*/ */
@GetMapping("/page") @GetMapping("/page")
@ResponseBody
public Result<IPage<Tutorial>> getPageList( public Result<IPage<Tutorial>> getPageList(
@RequestParam(defaultValue = "1") Long current, @RequestParam(defaultValue = "1") Long current,
@RequestParam(defaultValue = "10") Long size, @RequestParam(defaultValue = "10") Long size,

View File

@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title th:text="${tutorial?.tutorialTitle}"></title>
</head>
<body>
</body>
</html>