CourseModuleController.java 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. package com.zhongzheng.controller.course;
  2. import java.util.Collections;
  3. import java.util.List;
  4. import java.util.Arrays;
  5. import java.util.Map;
  6. import com.alibaba.fastjson.JSON;
  7. import com.zhongzheng.common.core.domain.model.LoginUser;
  8. import com.zhongzheng.common.utils.ServletUtils;
  9. import com.zhongzheng.common.utils.poi.EasyPoiUtil;
  10. import com.zhongzheng.framework.web.service.TokenService;
  11. import com.zhongzheng.modules.bank.vo.QuestionImportV2;
  12. import com.zhongzheng.modules.course.bo.CourseModuleAddBo;
  13. import com.zhongzheng.modules.course.bo.CourseModuleEditBo;
  14. import com.zhongzheng.modules.course.bo.CourseModuleQueryBo;
  15. import com.zhongzheng.modules.course.bo.CourseSectionBusinessAddBo;
  16. import com.zhongzheng.modules.course.domain.CourseChapterBusiness;
  17. import com.zhongzheng.modules.course.domain.CourseModuleBusiness;
  18. import com.zhongzheng.modules.course.service.ICourseModuleBusinessService;
  19. import com.zhongzheng.modules.course.service.ICourseModuleService;
  20. import com.zhongzheng.modules.course.service.ICourseSectionService;
  21. import com.zhongzheng.modules.course.vo.CourseChapterSectionImport;
  22. import com.zhongzheng.modules.course.vo.CourseModuleVo;
  23. import com.zhongzheng.modules.course.vo.CourseSectionImport;
  24. import com.zhongzheng.modules.goods.bo.GoodsBatchDelBo;
  25. import lombok.RequiredArgsConstructor;
  26. import org.springframework.security.access.prepost.PreAuthorize;
  27. import org.springframework.beans.factory.annotation.Autowired;
  28. import org.springframework.web.bind.annotation.GetMapping;
  29. import org.springframework.web.bind.annotation.PostMapping;
  30. import org.springframework.web.bind.annotation.PutMapping;
  31. import org.springframework.web.bind.annotation.DeleteMapping;
  32. import org.springframework.web.bind.annotation.PathVariable;
  33. import org.springframework.web.bind.annotation.RequestBody;
  34. import org.springframework.web.bind.annotation.RequestMapping;
  35. import org.springframework.web.bind.annotation.RestController;
  36. import com.zhongzheng.common.annotation.Log;
  37. import com.zhongzheng.common.core.controller.BaseController;
  38. import com.zhongzheng.common.core.domain.AjaxResult;
  39. import com.zhongzheng.common.enums.BusinessType;
  40. import com.zhongzheng.common.utils.poi.ExcelUtil;
  41. import com.zhongzheng.common.core.page.TableDataInfo;
  42. import io.swagger.annotations.Api;
  43. import io.swagger.annotations.ApiOperation;
  44. import org.springframework.web.multipart.MultipartFile;
  45. /**
  46. * 课程模块Controller
  47. *
  48. * @author hjl
  49. * @date 2021-10-09
  50. */
  51. @Api(value = "课程模块控制器", tags = {"课程模块管理"})
  52. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  53. @RestController
  54. @RequestMapping("/course/module")
  55. public class CourseModuleController extends BaseController {
  56. private final ICourseModuleService iCourseModuleService;
  57. private final ICourseModuleBusinessService iCourseModuleBusinessService;
  58. private final TokenService tokenService;
  59. private final ICourseSectionService iCourseSectionService;
  60. /**
  61. * 查询课程模块列表
  62. */
  63. @ApiOperation("查询课程模块列表")
  64. @PreAuthorize("@ss.hasPermi('system:module:list')")
  65. @GetMapping("/list")
  66. public TableDataInfo<CourseModuleVo> list(CourseModuleQueryBo bo) {
  67. startPage();
  68. List<CourseModuleVo> list = iCourseModuleService.selectList(bo);
  69. return getDataTable(list);
  70. }
  71. /**
  72. * 模块批量删除
  73. */
  74. @ApiOperation("模块批量删除")
  75. @PostMapping("/batch/del")
  76. public AjaxResult<Void> batchDelModule(@RequestBody GoodsBatchDelBo bo) {
  77. return toAjax(iCourseModuleService.batchDelModule(bo) ? 1 : 0);
  78. }
  79. /**
  80. * 导出课程模块列表
  81. */
  82. /* @ApiOperation("导出课程模块列表")
  83. @PreAuthorize("@ss.hasPermi('system:module:export')")
  84. @Log(title = "课程模块", businessType = BusinessType.EXPORT)
  85. @GetMapping("/export")
  86. public AjaxResult<CourseModuleVo> export(CourseModuleQueryBo bo) {
  87. List<CourseModuleVo> list = iCourseModuleService.queryList(bo);
  88. ExcelUtil<CourseModuleVo> util = new ExcelUtil<CourseModuleVo>(CourseModuleVo.class);
  89. return util.exportExcel(list, "课程模块");
  90. }*/
  91. /**
  92. * 获取课程模块详细信息
  93. */
  94. @ApiOperation("获取课程模块详细信息")
  95. @PreAuthorize("@ss.hasPermi('system:module:query')")
  96. @GetMapping("/{moduleId}")
  97. public AjaxResult<CourseModuleVo> getInfo(@PathVariable("moduleId" ) Long moduleId) {
  98. return AjaxResult.success(iCourseModuleService.queryById(moduleId));
  99. }
  100. /**
  101. * 新增课程模块
  102. */
  103. @ApiOperation("新增课程模块")
  104. @PreAuthorize("@ss.hasPermi('system:module:add')")
  105. @Log(title = "课程模块", businessType = BusinessType.INSERT)
  106. @PostMapping()
  107. public AjaxResult<Void> add(@RequestBody CourseModuleAddBo bo) {
  108. return toAjax(iCourseModuleService.insertByAddBo(bo) ? 1 : 0);
  109. }
  110. /**
  111. * 修改课程模块
  112. */
  113. @ApiOperation("修改课程模块")
  114. @PreAuthorize("@ss.hasPermi('system:module:edit')")
  115. @Log(title = "课程模块", businessType = BusinessType.UPDATE)
  116. @PostMapping("/edit")
  117. public AjaxResult<Void> edit(@RequestBody CourseModuleEditBo bo) {
  118. return toAjax(iCourseModuleService.updateByEditBo(bo) ? 1 : 0);
  119. }
  120. /**
  121. * 删除课程模块
  122. */
  123. /* @ApiOperation("删除课程模块")
  124. @PreAuthorize("@ss.hasPermi('system:module:remove')")
  125. @Log(title = "课程模块" , businessType = BusinessType.DELETE)
  126. @DeleteMapping("/{moduleIds}")
  127. public AjaxResult<Void> remove(@PathVariable Long[] moduleIds) {
  128. return toAjax(iCourseModuleService.deleteWithValidByIds(Arrays.asList(moduleIds), true) ? 1 : 0);
  129. }*/
  130. /**
  131. * 获取课程小节业务层次列表
  132. */
  133. @ApiOperation("获取课程模块业务层次列表")
  134. @PreAuthorize("@ss.hasPermi('system:section:query')")
  135. @GetMapping("/business/{moduleId}")
  136. public AjaxResult<List<CourseModuleBusiness>> getBusinessList(@PathVariable("moduleId" ) Long moduleId) {
  137. List<CourseModuleBusiness> list = iCourseModuleBusinessService.getListById(moduleId);
  138. return AjaxResult.success(list);
  139. }
  140. @ApiOperation("导入章节模板")
  141. @Log(title = "导入节模板", businessType = BusinessType.IMPORT)
  142. @PreAuthorize("@ss.hasPermi('system:section:import')")
  143. @PostMapping("/importData")
  144. public AjaxResult<Map<String,Object>> importData(MultipartFile file,String businessJson) throws Exception
  145. {
  146. List<CourseSectionBusinessAddBo> businessList = JSON.parseArray(businessJson, CourseSectionBusinessAddBo.class);
  147. List<CourseChapterSectionImport> sectionList = EasyPoiUtil.importExcel(file,0,2,CourseChapterSectionImport.class);
  148. Collections.reverse(sectionList);
  149. LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
  150. String operName = loginUser.getUsername();
  151. Map<String,Object> message = iCourseSectionService.importChapterSection(sectionList, businessList, operName);
  152. return AjaxResult.success(message);
  153. }
  154. }