123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- 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<CourseModuleVo> list(CourseModuleQueryBo bo) {
- startPage();
- List<CourseModuleVo> list = iCourseModuleService.selectList(bo);
- return getDataTable(list);
- }
- /**
- * 模块批量删除
- */
- @ApiOperation("模块批量删除")
- @PostMapping("/batch/del")
- public AjaxResult<Void> 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<CourseModuleVo> export(CourseModuleQueryBo bo) {
- List<CourseModuleVo> list = iCourseModuleService.queryList(bo);
- ExcelUtil<CourseModuleVo> util = new ExcelUtil<CourseModuleVo>(CourseModuleVo.class);
- return util.exportExcel(list, "课程模块");
- }*/
- /**
- * 获取课程模块详细信息
- */
- @ApiOperation("获取课程模块详细信息")
- @PreAuthorize("@ss.hasPermi('system:module:query')")
- @GetMapping("/{moduleId}")
- public AjaxResult<CourseModuleVo> 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<Void> 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<Void> 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<Void> 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<List<CourseModuleBusiness>> getBusinessList(@PathVariable("moduleId" ) Long moduleId) {
- List<CourseModuleBusiness> list = iCourseModuleBusinessService.getListById(moduleId);
- return AjaxResult.success(list);
- }
- @ApiOperation("导入章节模板")
- @Log(title = "导入节模板", businessType = BusinessType.IMPORT)
- @PreAuthorize("@ss.hasPermi('system:section:import')")
- @PostMapping("/importData")
- public AjaxResult<Map<String,Object>> importData(MultipartFile file,String businessJson) throws Exception
- {
- List<CourseSectionBusinessAddBo> businessList = JSON.parseArray(businessJson, CourseSectionBusinessAddBo.class);
- List<CourseChapterSectionImport> sectionList = EasyPoiUtil.importExcel(file,0,2,CourseChapterSectionImport.class);
- Collections.reverse(sectionList);
- LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
- String operName = loginUser.getUsername();
- Map<String,Object> message = iCourseSectionService.importChapterSection(sectionList, businessList, operName);
- return AjaxResult.success(message);
- }
- }
|