package com.ruoyi.hezhi.controller; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.hezhi.domain.TbCourseChapter; import com.ruoyi.hezhi.service.ITbCourseChapterService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.util.List; /** * 课程章节Controller * * @author ruoyi * @date 2024-09-14 */ @RestController @RequestMapping("/hezhi/courseChapter") public class TbCourseChapterController extends BaseController { @Autowired private ITbCourseChapterService tbCourseChapterService; /** * 查询课程章节列表 */ @PreAuthorize("@ss.hasPermi('hezhi:courseChapter:list')") @GetMapping("/list") public AjaxResult list(TbCourseChapter tbCourseChapter) { List list = tbCourseChapterService.selectTbCourseChapterList(tbCourseChapter); return success(list); } /** * 导出课程章节列表 */ @PreAuthorize("@ss.hasPermi('hezhi:courseChapter:export')") @Log(title = "课程章节", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, TbCourseChapter tbCourseChapter) { List list = tbCourseChapterService.selectTbCourseChapterList(tbCourseChapter); ExcelUtil util = new ExcelUtil(TbCourseChapter.class); util.exportExcel(response, list, "课程章节数据"); } /** * 获取课程章节详细信息 */ @PreAuthorize("@ss.hasPermi('hezhi:courseChapter:query')") @GetMapping(value = "/{chapterId}") public AjaxResult getInfo(@PathVariable("chapterId") Long chapterId) { return success(tbCourseChapterService.selectTbCourseChapterByChapterId(chapterId)); } /** * 新增课程章节 */ @PreAuthorize("@ss.hasPermi('hezhi:courseChapter:add')") @Log(title = "课程章节", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody TbCourseChapter tbCourseChapter) { if (tbCourseChapter.getPid() == 0) { tbCourseChapter.setType(1); } else { tbCourseChapter.setType(2); tbCourseChapter.setLevel(1); tbCourseChapter.setIsVideo(1); } return toAjax(tbCourseChapterService.insertTbCourseChapter(tbCourseChapter)); } /** * 修改课程章节 */ @PreAuthorize("@ss.hasPermi('hezhi:courseChapter:edit')") @Log(title = "课程章节", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody TbCourseChapter tbCourseChapter) { return toAjax(tbCourseChapterService.updateTbCourseChapter(tbCourseChapter)); } /** * 删除课程章节 */ @PreAuthorize("@ss.hasPermi('hezhi:courseChapter:remove')") @Log(title = "课程章节", businessType = BusinessType.DELETE) @DeleteMapping("/{chapterIds}") public AjaxResult remove(@PathVariable Long[] chapterIds) { return toAjax(tbCourseChapterService.deleteTbCourseChapterByChapterIds(chapterIds)); } }