|
@@ -128,41 +128,44 @@ public class FsUserCourseVideoController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('course:userCourseVideo:add')")
|
|
@PreAuthorize("@ss.hasPermi('course:userCourseVideo:add')")
|
|
|
@Log(title = "课堂视频", businessType = BusinessType.INSERT)
|
|
@Log(title = "课堂视频", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
@PostMapping
|
|
|
- public AjaxResult add(@RequestBody FsUserCourseVideoAddAndUpdateParam param)
|
|
|
|
|
- {
|
|
|
|
|
- Long count = fsUserCourseVideoMapper.selectFsUserCourseVideoByCourseSort(param.getCourseId(),param.getCourseSort());
|
|
|
|
|
- if (count>0){
|
|
|
|
|
|
|
+ public AjaxResult add(@RequestBody FsUserCourseVideoAddAndUpdateParam param) {
|
|
|
|
|
+ Long count = fsUserCourseVideoMapper.selectFsUserCourseVideoByCourseSort(param.getCourseId(), param.getCourseSort());
|
|
|
|
|
+ if (count > 0) {
|
|
|
return AjaxResult.error("课程排序重复");
|
|
return AjaxResult.error("课程排序重复");
|
|
|
}
|
|
}
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
Long userId = loginUser.getUser().getUserId();
|
|
Long userId = loginUser.getUser().getUserId();
|
|
|
String json = configService.selectConfigByKey("course.config");
|
|
String json = configService.selectConfigByKey("course.config");
|
|
|
CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
- if (ObjectUtil.isNotEmpty(config.getIsBound())&&config.getIsBound()){
|
|
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(config.getIsBound()) && config.getIsBound()) {
|
|
|
param.setUserId(userId);
|
|
param.setUserId(userId);
|
|
|
}
|
|
}
|
|
|
// 设置项目ID
|
|
// 设置项目ID
|
|
|
FsUserCourse fsUserCourse = fsUserCourseService.selectFsUserCourseByCourseId(param.getCourseId());
|
|
FsUserCourse fsUserCourse = fsUserCourseService.selectFsUserCourseByCourseId(param.getCourseId());
|
|
|
param.setProjectId(fsUserCourse.getProject());
|
|
param.setProjectId(fsUserCourse.getProject());
|
|
|
Integer showTreatment = param.getShowTreatment();
|
|
Integer showTreatment = param.getShowTreatment();
|
|
|
- if (showTreatment != null){
|
|
|
|
|
|
|
+ FsUserCourseVideo fsUserCourseVideo = BeanUtil.copyProperties(param, FsUserCourseVideo.class);
|
|
|
|
|
+ int result = fsUserCourseVideoService.insertFsUserCourseVideo(fsUserCourseVideo);
|
|
|
|
|
+ if (showTreatment != null && result > 0) {
|
|
|
// 先检查是否存在相同记录
|
|
// 先检查是否存在相同记录
|
|
|
QueryWrapper<FsDepVideoShow> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<FsDepVideoShow> queryWrapper = new QueryWrapper<>();
|
|
|
- Long videoId = param.getVideoId();
|
|
|
|
|
|
|
+ Long videoId = fsUserCourseVideo.getVideoId();
|
|
|
queryWrapper.eq("video_id", videoId);
|
|
queryWrapper.eq("video_id", videoId);
|
|
|
FsDepVideoShow fsDepVideoShow = fsDepVideoShowMapper.selectOne(queryWrapper);
|
|
FsDepVideoShow fsDepVideoShow = fsDepVideoShowMapper.selectOne(queryWrapper);
|
|
|
- int result;
|
|
|
|
|
|
|
+
|
|
|
if (fsDepVideoShow != null) {
|
|
if (fsDepVideoShow != null) {
|
|
|
// 更新现有记录
|
|
// 更新现有记录
|
|
|
fsDepVideoShow.setIsShow(showTreatment.toString());
|
|
fsDepVideoShow.setIsShow(showTreatment.toString());
|
|
|
fsDepVideoShowMapper.updateByVideoId(fsDepVideoShow);
|
|
fsDepVideoShowMapper.updateByVideoId(fsDepVideoShow);
|
|
|
} else {
|
|
} else {
|
|
|
// 插入新记录
|
|
// 插入新记录
|
|
|
|
|
+ fsDepVideoShow = new FsDepVideoShow();
|
|
|
|
|
+ fsDepVideoShow.setIsShow(showTreatment.toString());
|
|
|
|
|
+ fsDepVideoShow.setVideoId(videoId);
|
|
|
fsDepVideoShowMapper.insertFsDepVideoShowByVideoId(fsDepVideoShow);
|
|
fsDepVideoShowMapper.insertFsDepVideoShowByVideoId(fsDepVideoShow);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- FsUserCourseVideo fsUserCourseVideo = BeanUtil.copyProperties(param, FsUserCourseVideo.class);
|
|
|
|
|
- return toAjax(fsUserCourseVideoService.insertFsUserCourseVideo(fsUserCourseVideo));
|
|
|
|
|
|
|
+ return toAjax(result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|