From e8dc76ef821a7d70fd4326d8301d6a502b45cc4e Mon Sep 17 00:00:00 2001 From: MichaelWin Date: Thu, 30 Oct 2025 09:36:39 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=98=BE=E7=A4=BA=E6=95=99=E7=A8=8B=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app}/TutorialController.java | 28 +++++++++++++++---- .../templates/app/tutorial/viewDetail.html | 10 +++++++ 2 files changed, 32 insertions(+), 6 deletions(-) rename src/main/java/com/corewing/app/{controller => modules/app}/TutorialController.java (82%) create mode 100644 src/main/resources/templates/app/tutorial/viewDetail.html diff --git a/src/main/java/com/corewing/app/controller/TutorialController.java b/src/main/java/com/corewing/app/modules/app/TutorialController.java similarity index 82% rename from src/main/java/com/corewing/app/controller/TutorialController.java rename to src/main/java/com/corewing/app/modules/app/TutorialController.java index 6e11875..ebd16ab 100644 --- a/src/main/java/com/corewing/app/controller/TutorialController.java +++ b/src/main/java/com/corewing/app/modules/app/TutorialController.java @@ -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.metadata.IPage; @@ -10,10 +10,9 @@ import com.corewing.app.service.TutorialCategoryService; import com.corewing.app.service.TutorialService; import com.corewing.app.util.I18nUtil; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -21,7 +20,7 @@ import java.util.List; * 教程接口 */ @RequestMapping("/tutorial") -@RestController +@Controller @Slf4j public class TutorialController { @@ -33,12 +32,27 @@ public class TutorialController { 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 * @return */ @GetMapping("/addViewCount") + @ResponseBody public Result addViewCount(@RequestParam Long tutorialId) { Tutorial tutorial = tutorialService.getById(tutorialId); if(tutorial == null) { @@ -56,6 +70,7 @@ public class TutorialController { * */ @GetMapping("/category") + @ResponseBody public Result> category( @RequestParam(required = false, defaultValue = "0") Integer firstStatus ) { @@ -77,6 +92,7 @@ public class TutorialController { * */ @GetMapping("/page") + @ResponseBody public Result> getPageList( @RequestParam(defaultValue = "1") Long current, @RequestParam(defaultValue = "10") Long size, diff --git a/src/main/resources/templates/app/tutorial/viewDetail.html b/src/main/resources/templates/app/tutorial/viewDetail.html new file mode 100644 index 0000000..b19d9b6 --- /dev/null +++ b/src/main/resources/templates/app/tutorial/viewDetail.html @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file