package com.zhongzheng.controller.course; import java.util.Collections; import java.util.List; import java.util.Arrays; import java.util.Map; import com.alibaba.fastjson.JSON; import com.zhongzheng.common.core.domain.model.LoginUser; import com.zhongzheng.common.utils.ServletUtils; import com.zhongzheng.common.utils.poi.EasyPoiUtil; import com.zhongzheng.framework.web.service.TokenService; import com.zhongzheng.modules.bank.vo.QuestionImportV2; import com.zhongzheng.modules.course.bo.CourseModuleAddBo; import com.zhongzheng.modules.course.bo.CourseModuleEditBo; import com.zhongzheng.modules.course.bo.CourseModuleQueryBo; import com.zhongzheng.modules.course.bo.CourseSectionBusinessAddBo; import com.zhongzheng.modules.course.domain.CourseChapterBusiness; import com.zhongzheng.modules.course.domain.CourseModuleBusiness; import com.zhongzheng.modules.course.service.ICourseModuleBusinessService; import com.zhongzheng.modules.course.service.ICourseModuleService; import com.zhongzheng.modules.course.service.ICourseSectionService; import com.zhongzheng.modules.course.vo.CourseChapterSectionImport; import com.zhongzheng.modules.course.vo.CourseModuleVo; import com.zhongzheng.modules.course.vo.CourseSectionImport; import com.zhongzheng.modules.goods.bo.GoodsBatchDelBo; import lombok.RequiredArgsConstructor; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.zhongzheng.common.annotation.Log; import com.zhongzheng.common.core.controller.BaseController; import com.zhongzheng.common.core.domain.AjaxResult; import com.zhongzheng.common.enums.BusinessType; import com.zhongzheng.common.utils.poi.ExcelUtil; import com.zhongzheng.common.core.page.TableDataInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.multipart.MultipartFile; /** * 课程模块Controller * * @author hjl * @date 2021-10-09 */ @Api(value = "课程模块控制器", tags = {"课程模块管理"}) @RequiredArgsConstructor(onConstructor_ = @Autowired) @RestController @RequestMapping("/course/module") public class CourseModuleController extends BaseController { private final ICourseModuleService iCourseModuleService; private final ICourseModuleBusinessService iCourseModuleBusinessService; private final TokenService tokenService; private final ICourseSectionService iCourseSectionService; /** * 查询课程模块列表 */ @ApiOperation("查询课程模块列表") @PreAuthorize("@ss.hasPermi('system:module:list')") @GetMapping("/list") public TableDataInfo list(CourseModuleQueryBo bo) { startPage(); List list = iCourseModuleService.selectList(bo); return getDataTable(list); } /** * 模块批量删除 */ @ApiOperation("模块批量删除") @PostMapping("/batch/del") public AjaxResult batchDelModule(@RequestBody GoodsBatchDelBo bo) { return toAjax(iCourseModuleService.batchDelModule(bo) ? 1 : 0); } /** * 导出课程模块列表 */ /* @ApiOperation("导出课程模块列表") @PreAuthorize("@ss.hasPermi('system:module:export')") @Log(title = "课程模块", businessType = BusinessType.EXPORT) @GetMapping("/export") public AjaxResult export(CourseModuleQueryBo bo) { List list = iCourseModuleService.queryList(bo); ExcelUtil util = new ExcelUtil(CourseModuleVo.class); return util.exportExcel(list, "课程模块"); }*/ /** * 获取课程模块详细信息 */ @ApiOperation("获取课程模块详细信息") @PreAuthorize("@ss.hasPermi('system:module:query')") @GetMapping("/{moduleId}") public AjaxResult getInfo(@PathVariable("moduleId" ) Long moduleId) { return AjaxResult.success(iCourseModuleService.queryById(moduleId)); } /** * 新增课程模块 */ @ApiOperation("新增课程模块") @PreAuthorize("@ss.hasPermi('system:module:add')") @Log(title = "课程模块", businessType = BusinessType.INSERT) @PostMapping() public AjaxResult add(@RequestBody CourseModuleAddBo bo) { return toAjax(iCourseModuleService.insertByAddBo(bo) ? 1 : 0); } /** * 修改课程模块 */ @ApiOperation("修改课程模块") @PreAuthorize("@ss.hasPermi('system:module:edit')") @Log(title = "课程模块", businessType = BusinessType.UPDATE) @PostMapping("/edit") public AjaxResult edit(@RequestBody CourseModuleEditBo bo) { return toAjax(iCourseModuleService.updateByEditBo(bo) ? 1 : 0); } /** * 删除课程模块 */ /* @ApiOperation("删除课程模块") @PreAuthorize("@ss.hasPermi('system:module:remove')") @Log(title = "课程模块" , businessType = BusinessType.DELETE) @DeleteMapping("/{moduleIds}") public AjaxResult remove(@PathVariable Long[] moduleIds) { return toAjax(iCourseModuleService.deleteWithValidByIds(Arrays.asList(moduleIds), true) ? 1 : 0); }*/ /** * 获取课程小节业务层次列表 */ @ApiOperation("获取课程模块业务层次列表") @PreAuthorize("@ss.hasPermi('system:section:query')") @GetMapping("/business/{moduleId}") public AjaxResult> getBusinessList(@PathVariable("moduleId" ) Long moduleId) { List list = iCourseModuleBusinessService.getListById(moduleId); return AjaxResult.success(list); } @ApiOperation("导入章节模板") @Log(title = "导入节模板", businessType = BusinessType.IMPORT) @PreAuthorize("@ss.hasPermi('system:section:import')") @PostMapping("/importData") public AjaxResult> importData(MultipartFile file,String businessJson) throws Exception { List businessList = JSON.parseArray(businessJson, CourseSectionBusinessAddBo.class); List sectionList = EasyPoiUtil.importExcel(file,0,2,CourseChapterSectionImport.class); Collections.reverse(sectionList); LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); String operName = loginUser.getUsername(); Map message = iCourseSectionService.importChapterSection(sectionList, businessList, operName); return AjaxResult.success(message); } }