|
|
@@ -1,7 +1,9 @@
|
|
|
package com.fs.course.controller;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.fs.common.annotation.Log;
|
|
|
import com.fs.common.core.controller.BaseController;
|
|
|
import com.fs.common.core.domain.AjaxResult;
|
|
|
@@ -12,12 +14,15 @@ import com.fs.common.enums.BusinessType;
|
|
|
import com.fs.common.utils.ServletUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
import com.fs.course.config.CourseConfig;
|
|
|
+import com.fs.course.domain.FsDepVideoShow;
|
|
|
import com.fs.course.domain.FsUserCourse;
|
|
|
import com.fs.course.domain.FsUserCourseVideo;
|
|
|
+import com.fs.course.mapper.FsDepVideoShowMapper;
|
|
|
import com.fs.course.mapper.FsUserCourseVideoMapper;
|
|
|
import com.fs.course.param.BatchRedUpdate;
|
|
|
import com.fs.course.param.BatchVideoSvae;
|
|
|
import com.fs.course.param.CourseVideoUpdates;
|
|
|
+import com.fs.course.param.FsUserCourseVideoAddAndUpdateParam;
|
|
|
import com.fs.course.service.IFsUserCourseService;
|
|
|
import com.fs.course.service.IFsUserCourseVideoService;
|
|
|
import com.fs.course.vo.FsUserCourseVideoChooseVO;
|
|
|
@@ -58,6 +63,9 @@ public class FsUserCourseVideoController extends BaseController
|
|
|
@Autowired
|
|
|
private ISysConfigService configService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FsDepVideoShowMapper fsDepVideoShowMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询课堂视频列表
|
|
|
*/
|
|
|
@@ -120,9 +128,9 @@ public class FsUserCourseVideoController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('course:userCourseVideo:add')")
|
|
|
@Log(title = "课堂视频", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
- public AjaxResult add(@RequestBody FsUserCourseVideo fsUserCourseVideo)
|
|
|
+ public AjaxResult add(@RequestBody FsUserCourseVideoAddAndUpdateParam param)
|
|
|
{
|
|
|
- Long count = fsUserCourseVideoMapper.selectFsUserCourseVideoByCourseSort(fsUserCourseVideo.getCourseId(),fsUserCourseVideo.getCourseSort());
|
|
|
+ Long count = fsUserCourseVideoMapper.selectFsUserCourseVideoByCourseSort(param.getCourseId(),param.getCourseSort());
|
|
|
if (count>0){
|
|
|
return AjaxResult.error("课程排序重复");
|
|
|
}
|
|
|
@@ -131,11 +139,29 @@ public class FsUserCourseVideoController extends BaseController
|
|
|
String json = configService.selectConfigByKey("course.config");
|
|
|
CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
if (ObjectUtil.isNotEmpty(config.getIsBound())&&config.getIsBound()){
|
|
|
- fsUserCourseVideo.setUserId(userId);
|
|
|
+ param.setUserId(userId);
|
|
|
}
|
|
|
// 设置项目ID
|
|
|
- FsUserCourse fsUserCourse = fsUserCourseService.selectFsUserCourseByCourseId(fsUserCourseVideo.getCourseId());
|
|
|
- fsUserCourseVideo.setProjectId(fsUserCourse.getProject());
|
|
|
+ FsUserCourse fsUserCourse = fsUserCourseService.selectFsUserCourseByCourseId(param.getCourseId());
|
|
|
+ param.setProjectId(fsUserCourse.getProject());
|
|
|
+ Integer showTreatment = param.getShowTreatment();
|
|
|
+ if (showTreatment != null){
|
|
|
+ // 先检查是否存在相同记录
|
|
|
+ QueryWrapper<FsDepVideoShow> queryWrapper = new QueryWrapper<>();
|
|
|
+ Long videoId = param.getVideoId();
|
|
|
+ queryWrapper.eq("video_id", videoId);
|
|
|
+ FsDepVideoShow fsDepVideoShow = fsDepVideoShowMapper.selectOne(queryWrapper);
|
|
|
+ int result;
|
|
|
+ if (fsDepVideoShow != null) {
|
|
|
+ // 更新现有记录
|
|
|
+ fsDepVideoShow.setIsShow(showTreatment.toString());
|
|
|
+ fsDepVideoShowMapper.updateByVideoId(fsDepVideoShow);
|
|
|
+ } else {
|
|
|
+ // 插入新记录
|
|
|
+ fsDepVideoShowMapper.insertFsDepVideoShowByVideoId(fsDepVideoShow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ FsUserCourseVideo fsUserCourseVideo = BeanUtil.copyProperties(param, FsUserCourseVideo.class);
|
|
|
return toAjax(fsUserCourseVideoService.insertFsUserCourseVideo(fsUserCourseVideo));
|
|
|
}
|
|
|
|
|
|
@@ -145,8 +171,29 @@ public class FsUserCourseVideoController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('course:userCourseVideo:edit')")
|
|
|
@Log(title = "课堂视频", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
- public AjaxResult edit(@RequestBody FsUserCourseVideo fsUserCourseVideo)
|
|
|
+ public AjaxResult edit(@RequestBody FsUserCourseVideoAddAndUpdateParam param)
|
|
|
{
|
|
|
+ Integer showTreatment = param.getShowTreatment();
|
|
|
+ if (showTreatment != null){
|
|
|
+ // 先检查是否存在相同记录
|
|
|
+ QueryWrapper<FsDepVideoShow> queryWrapper = new QueryWrapper<>();
|
|
|
+ Long videoId = param.getVideoId();
|
|
|
+ queryWrapper.eq("video_id", videoId);
|
|
|
+ FsDepVideoShow fsDepVideoShow = fsDepVideoShowMapper.selectOne(queryWrapper);
|
|
|
+ int result;
|
|
|
+ if (fsDepVideoShow != null) {
|
|
|
+ // 更新现有记录
|
|
|
+ fsDepVideoShow.setIsShow(showTreatment.toString());
|
|
|
+ fsDepVideoShowMapper.updateByVideoId(fsDepVideoShow);
|
|
|
+ } else {
|
|
|
+ // 插入新记录
|
|
|
+ fsDepVideoShow = new FsDepVideoShow();
|
|
|
+ fsDepVideoShow.setIsShow(showTreatment.toString());
|
|
|
+ fsDepVideoShow.setVideoId(videoId);
|
|
|
+ fsDepVideoShowMapper.insertFsDepVideoShowByVideoId(fsDepVideoShow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ FsUserCourseVideo fsUserCourseVideo = BeanUtil.copyProperties(param, FsUserCourseVideo.class);
|
|
|
return toAjax(fsUserCourseVideoService.updateFsUserCourseVideo(fsUserCourseVideo));
|
|
|
}
|
|
|
|