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