| | |
| | | package com.dsh.guns.modular.system.controller.code; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dsh.guns.core.base.controller.BaseController; |
| | | import com.dsh.guns.core.common.constant.factory.PageFactory; |
| | | import com.dsh.guns.modular.system.model.TCourse; |
| | | import com.dsh.guns.modular.system.service.ICourseService; |
| | | import com.dsh.guns.modular.system.util.ResultUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 课程管理 |
| | |
| | | */ |
| | | @Controller |
| | | @RequestMapping("/course") |
| | | public class TCourseController { |
| | | public class TCourseController extends BaseController { |
| | | |
| | | private String PREFIX = "/system/course/"; |
| | | |
| | | @Autowired |
| | | private ICourseService courseService; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | return PREFIX + "course_add.html"; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 跳转到编辑页 |
| | | * @param id |
| | | * @param model |
| | | * @return |
| | | */ |
| | | @GetMapping("/showEditCourse") |
| | | public String showEditCourse(Integer id, Model model){ |
| | | TCourse tCourse = courseService.queryCourseById(id); |
| | | model.addAttribute("item", tCourse); |
| | | return PREFIX + "course_edit.html"; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 跳转到详情页 |
| | | * @param id |
| | | * @param model |
| | | * @return |
| | | */ |
| | | @GetMapping("/showCourseDetails") |
| | | public String showCourseDetails(Integer id, Model model){ |
| | | TCourse tCourse = courseService.queryCourseById(id); |
| | | model.addAttribute("item", tCourse); |
| | | return PREFIX + "course_info.html"; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取列表数据 |
| | | * @param name |
| | | * @param courseType |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/queryCourseList") |
| | | public Object queryCourseList(String name, Integer courseType){ |
| | | Page<Map<String, Object>> mapPage = courseService.queryCourseList(name, courseType); |
| | | return super.packForBT(mapPage); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加课程 |
| | | * @param course |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/addCourse") |
| | | public ResultUtil addCourse(TCourse course){ |
| | | courseService.addCourse(course); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 编辑数据 |
| | | * @param course |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/editCourse") |
| | | public ResultUtil editCourse(TCourse course){ |
| | | courseService.editCourse(course); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除数据 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/delCourse") |
| | | public ResultUtil delCourse(Integer id){ |
| | | courseService.delCourse(id); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 编辑数据状态 |
| | | * @param id |
| | | * @param state |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/editCourseState") |
| | | public ResultUtil editCourseState(Integer id, Integer state){ |
| | | courseService.editCourseState(id, state); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据类型获取数据 |
| | | * @param type |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/queryCourseByType") |
| | | public List<TCourse> queryCourseByType(Integer type){ |
| | | return courseService.queryCourseByType(type); |
| | | } |
| | | } |