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.ui.Model;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 课程管理
|
* @author zhibing.pu
|
* @Date 2023/7/27 15:54
|
*/
|
@Controller
|
@RequestMapping("/course")
|
public class TCourseController extends BaseController {
|
|
private String PREFIX = "/system/course/";
|
|
@Autowired
|
private ICourseService courseService;
|
|
|
|
|
/**
|
* 跳转到列表页
|
* @return
|
*/
|
@GetMapping("/showCourseList")
|
public String showCourseList(){
|
return PREFIX + "course.html";
|
}
|
|
|
/**
|
* 跳转到添加页
|
* @return
|
*/
|
@GetMapping("/showAddCourse")
|
public String showAddCourse(){
|
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);
|
}
|
}
|