|
|
@@ -12,30 +12,37 @@
|
|
|
*/
|
|
|
package vip.xiaonuo.disk.controller;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollStreamUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
+import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
|
|
|
import vip.xiaonuo.common.annotation.CommonLog;
|
|
|
import vip.xiaonuo.common.pojo.CommonResult;
|
|
|
import vip.xiaonuo.common.pojo.CommonValidList;
|
|
|
-import vip.xiaonuo.disk.domain.CourseNotes;
|
|
|
-import vip.xiaonuo.disk.domain.CourseNotesVo;
|
|
|
+import vip.xiaonuo.disk.domain.*;
|
|
|
import vip.xiaonuo.disk.param.CourseNotesAddParam;
|
|
|
import vip.xiaonuo.disk.param.CourseNotesEditParam;
|
|
|
import vip.xiaonuo.disk.param.CourseNotesIdParam;
|
|
|
import vip.xiaonuo.disk.param.CourseNotesPageParam;
|
|
|
-import vip.xiaonuo.disk.service.CourseNotesService;
|
|
|
+import vip.xiaonuo.disk.service.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.validation.Valid;
|
|
|
import javax.validation.constraints.NotEmpty;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 课程笔记表控制器
|
|
|
@@ -51,18 +58,33 @@ public class CourseNotesController {
|
|
|
|
|
|
@Resource
|
|
|
private CourseNotesService courseNotesService;
|
|
|
+ @Resource
|
|
|
+ private CourseInfoService courseInfoService;
|
|
|
+ @Resource
|
|
|
+ private ChapterService chapterService;
|
|
|
+ @Resource
|
|
|
+ private ClassHourService classHourService;
|
|
|
+ @Resource
|
|
|
+ private CourseNotebooksService courseNotebooksService;
|
|
|
+ @Resource
|
|
|
+ private CourseRelateService courseRelateService;
|
|
|
|
|
|
/**
|
|
|
- * 获取课程笔记表分页
|
|
|
+ * 课程笔记-分页列表
|
|
|
*
|
|
|
* @author 金吉龙
|
|
|
* @date 2025/07/01 18:56
|
|
|
*/
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
- @ApiOperation("获取课程笔记表分页")
|
|
|
+ @ApiOperation("课程笔记-分页列表")
|
|
|
@GetMapping("/disk/courseNotes/page")
|
|
|
- public CommonResult<Page<CourseNotesVo>> page(CourseNotesPageParam courseNotesPageParam) {
|
|
|
- return CommonResult.data(courseNotesService.page(courseNotesPageParam));
|
|
|
+ public CommonResult<Page<Map<String,Object>>> page(CourseNotesPageParam courseNotesPageParam, HttpServletRequest req) {
|
|
|
+ Map param =new HashMap();
|
|
|
+ param.put("courseId", req.getParameter("courseId"));
|
|
|
+ param.put("hourId", req.getParameter("hourId"));
|
|
|
+ param.put("userId", StpLoginUserUtil.getLoginUser().getId());
|
|
|
+ Page<Map<String,Object>> page=courseNotesService.queryList(param);
|
|
|
+ return CommonResult.data(page);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -76,7 +98,42 @@ public class CourseNotesController {
|
|
|
@CommonLog("添加课程笔记表")
|
|
|
@PostMapping("/disk/courseNotes/add")
|
|
|
public CommonResult<String> add(@RequestBody @Valid CourseNotesAddParam courseNotesAddParam) {
|
|
|
- courseNotesService.add(courseNotesAddParam);
|
|
|
+ Map param=new HashMap<>();
|
|
|
+ //1.先校验这个课时是不是第一次创建笔记,如果是第一次创建,则创建课程笔记本
|
|
|
+ String courseId = courseNotesAddParam.getCourseId();
|
|
|
+ if(StringUtils.isEmpty(courseId))
|
|
|
+ {
|
|
|
+ if(StringUtils.isEmpty(courseNotesAddParam.getHourId()))return CommonResult.error("课时id不能为空");
|
|
|
+ ClassHour classHour=classHourService.queryEntity(courseNotesAddParam.getHourId());
|
|
|
+ Chapter chapter = chapterService.queryEntity(classHour.getChapterId());
|
|
|
+ courseId=chapter.getCourseId();
|
|
|
+ }
|
|
|
+ param.put("courseId", courseId);
|
|
|
+ param.put("userId", StpLoginUserUtil.getLoginUser().getId() );
|
|
|
+ List<CourseNotebooks> courseNotebooksList=courseNotebooksService.wrapperList(param);
|
|
|
+ CourseNotebooks courseNotebooks=new CourseNotebooks();
|
|
|
+ if(courseNotebooksList.size()==0)
|
|
|
+ {
|
|
|
+ courseNotebooks.setCourseId(courseId);
|
|
|
+ courseNotebooks.setUserId(StpLoginUserUtil.getLoginUser().getId());
|
|
|
+ courseNotebooksService.addOne(courseNotebooks);
|
|
|
+ }
|
|
|
+
|
|
|
+ //2.存储笔记本体信息
|
|
|
+ CourseNotes courseNotes = BeanUtil.toBean(courseNotesAddParam, CourseNotes.class);
|
|
|
+ courseNotes.setUserId(StpLoginUserUtil.getLoginUser().getId());
|
|
|
+ courseNotes.setCourseId(courseId);
|
|
|
+ courseNotesService.addOne(courseNotes);
|
|
|
+ //3.添加进课程关联信息
|
|
|
+ CourseRelate courseRelate=new CourseRelate();
|
|
|
+ courseRelate.setMainId(courseNotesAddParam.getHourId());
|
|
|
+ courseRelate.setRelateId(courseNotes.getNoteId());
|
|
|
+ //功能类型,1视频资源,2讲义,3字幕,4作业,5测验,6笔记,7问答
|
|
|
+ courseRelate.setFuncType("6");
|
|
|
+ courseRelate.setChapterhourType("1");
|
|
|
+ courseRelate.setInfoType("1");
|
|
|
+ courseRelateService.addOne(courseRelate);
|
|
|
+
|
|
|
return CommonResult.ok();
|
|
|
}
|
|
|
|
|
|
@@ -91,7 +148,8 @@ public class CourseNotesController {
|
|
|
@CommonLog("编辑课程笔记表")
|
|
|
@PostMapping("/disk/courseNotes/edit")
|
|
|
public CommonResult<String> edit(@RequestBody @Valid CourseNotesEditParam courseNotesEditParam) {
|
|
|
- courseNotesService.edit(courseNotesEditParam);
|
|
|
+ CourseNotes courseNotes = BeanUtil.toBean(courseNotesEditParam, CourseNotes.class);
|
|
|
+ courseNotesService.editOne(courseNotes);
|
|
|
return CommonResult.ok();
|
|
|
}
|
|
|
|
|
|
@@ -107,7 +165,15 @@ public class CourseNotesController {
|
|
|
@PostMapping("/disk/courseNotes/delete")
|
|
|
public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
|
|
|
CommonValidList<CourseNotesIdParam> courseNotesIdParamList) {
|
|
|
+ //删除笔记基本信息
|
|
|
courseNotesService.delete(courseNotesIdParamList);
|
|
|
+ //删除课程关联笔记信息
|
|
|
+ List<String> deleteNoteIdList=CollStreamUtil.toList(courseNotesIdParamList, CourseNotesIdParam::getNoteId);
|
|
|
+ Map param=new HashMap<>();
|
|
|
+ param.put("relateIdList", deleteNoteIdList);
|
|
|
+ List<CourseRelate> courseRelateList=courseRelateService.wrapperList(param);
|
|
|
+ List<String> deleteRelateIdList=CollStreamUtil.toList(courseRelateList, CourseRelate::getId);
|
|
|
+ courseRelateService.deleteByIds(deleteRelateIdList);
|
|
|
return CommonResult.ok();
|
|
|
}
|
|
|
|