CourseChapterSectionController.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package com.zhongzheng.controller.course;
  2. import java.util.HashMap;
  3. import java.util.List;
  4. import java.util.Arrays;
  5. import java.util.Map;
  6. import cn.hutool.http.HttpStatus;
  7. import com.github.pagehelper.PageInfo;
  8. import com.zhongzheng.modules.course.bo.CourseChapterSectionAddBo;
  9. import com.zhongzheng.modules.course.bo.CourseChapterSectionEditBo;
  10. import com.zhongzheng.modules.course.bo.CourseChapterSectionQueryBo;
  11. import com.zhongzheng.modules.course.service.ICourseChapterSectionService;
  12. import com.zhongzheng.modules.course.vo.CourseChapterSectionVo;
  13. import lombok.RequiredArgsConstructor;
  14. import org.springframework.security.access.prepost.PreAuthorize;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.web.bind.annotation.GetMapping;
  17. import org.springframework.web.bind.annotation.PostMapping;
  18. import org.springframework.web.bind.annotation.PutMapping;
  19. import org.springframework.web.bind.annotation.DeleteMapping;
  20. import org.springframework.web.bind.annotation.PathVariable;
  21. import org.springframework.web.bind.annotation.RequestBody;
  22. import org.springframework.web.bind.annotation.RequestMapping;
  23. import org.springframework.web.bind.annotation.RestController;
  24. import com.zhongzheng.common.annotation.Log;
  25. import com.zhongzheng.common.core.controller.BaseController;
  26. import com.zhongzheng.common.core.domain.AjaxResult;
  27. import com.zhongzheng.common.enums.BusinessType;
  28. import com.zhongzheng.common.utils.poi.ExcelUtil;
  29. import com.zhongzheng.common.core.page.TableDataInfo;
  30. import io.swagger.annotations.Api;
  31. import io.swagger.annotations.ApiOperation;
  32. /**
  33. * 章与节关系Controller
  34. *
  35. * @author hjl
  36. * @date 2021-10-12
  37. */
  38. @Api(value = "章与节关系控制器", tags = {"章与节关系管理"})
  39. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  40. @RestController
  41. @RequestMapping("/course/chapter/section")
  42. public class CourseChapterSectionController extends BaseController {
  43. private final ICourseChapterSectionService iCourseChapterSectionService;
  44. /**
  45. * 查询章与节关系列表
  46. */
  47. @ApiOperation("查询章与节关系列表")
  48. @PreAuthorize("@ss.hasPermi('system:section:list')")
  49. @GetMapping("/list/{id}")
  50. public AjaxResult list(@PathVariable("id" ) Long id) {
  51. startPage();
  52. List<CourseChapterSectionVo> list = iCourseChapterSectionService.getListById(id);
  53. Map<String, Object> result = new HashMap<>();
  54. result.put("total",new PageInfo(list).getTotal());
  55. result.put("code", HttpStatus.HTTP_OK);
  56. result.put("list",list);
  57. result.put("msg","查询成功");
  58. result.put("sectionTotal",new PageInfo(list).getTotal());
  59. return AjaxResult.success(result);
  60. }
  61. /**
  62. * 导出章与节关系列表
  63. */
  64. /* @ApiOperation("导出章与节关系列表")
  65. @PreAuthorize("@ss.hasPermi('system:section:export')")
  66. @Log(title = "章与节关系", businessType = BusinessType.EXPORT)
  67. @GetMapping("/export")
  68. public AjaxResult<CourseChapterSectionVo> export(CourseChapterSectionQueryBo bo) {
  69. List<CourseChapterSectionVo> list = iCourseChapterSectionService.queryList(bo);
  70. ExcelUtil<CourseChapterSectionVo> util = new ExcelUtil<CourseChapterSectionVo>(CourseChapterSectionVo.class);
  71. return util.exportExcel(list, "章与节关系");
  72. }*/
  73. /**
  74. * 获取章与节关系详细信息
  75. */
  76. /* @ApiOperation("获取章与节关系详细信息")
  77. @PreAuthorize("@ss.hasPermi('system:section:query')")
  78. @GetMapping("/{id}")
  79. public AjaxResult<CourseChapterSectionVo> getInfo(@PathVariable("id" ) Long id) {
  80. return AjaxResult.success(iCourseChapterSectionService.queryById(id));
  81. }*/
  82. /**
  83. * 新增章与节关系
  84. */
  85. @ApiOperation("新增章与节关系")
  86. @PreAuthorize("@ss.hasPermi('system:section:add')")
  87. @Log(title = "章与节关系", businessType = BusinessType.INSERT)
  88. @PostMapping()
  89. public AjaxResult<Void> add(@RequestBody CourseChapterSectionAddBo bo) {
  90. return toAjax(iCourseChapterSectionService.insertByAddBo(bo) ? 1 : 0);
  91. }
  92. /**
  93. * 修改章与节关系
  94. */
  95. @ApiOperation("修改章与节关系")
  96. @PreAuthorize("@ss.hasPermi('system:section:edit')")
  97. @Log(title = "章与节关系", businessType = BusinessType.UPDATE)
  98. @PostMapping("/edit")
  99. public AjaxResult<Void> edit(@RequestBody CourseChapterSectionEditBo bo) {
  100. return toAjax(iCourseChapterSectionService.updateByEditBo(bo) ? 1 : 0);
  101. }
  102. /**
  103. * 删除章与节关系
  104. */
  105. @ApiOperation("删除章与节关系")
  106. @PreAuthorize("@ss.hasPermi('system:section:remove')")
  107. @Log(title = "章与节关系" , businessType = BusinessType.DELETE)
  108. @PostMapping("/del/{ids}")
  109. public AjaxResult<Void> remove(@PathVariable Long[] ids) {
  110. return toAjax(iCourseChapterSectionService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
  111. }
  112. }