|
@@ -1,12 +1,14 @@
|
|
|
package com.zhongzheng.modules.course.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
|
import com.zhongzheng.modules.course.bo.*;
|
|
|
+import com.zhongzheng.modules.course.domain.Course;
|
|
|
import com.zhongzheng.modules.course.domain.CourseSectionBusiness;
|
|
|
import com.zhongzheng.modules.course.domain.CourseStreaming;
|
|
|
import com.zhongzheng.modules.course.domain.CourseStreamingBusiness;
|
|
@@ -141,6 +143,9 @@ public class CourseStreamingServiceImpl extends ServiceImpl<CourseStreamingMappe
|
|
|
*/
|
|
|
private void validEntityBeforeSave(CourseStreaming entity){
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
+ if(checkNameUnique(entity)){
|
|
|
+ throw new CustomException("名称重复");
|
|
|
+ }
|
|
|
if(StringUtils.isNotBlank(entity.getRecordingVideoId())){
|
|
|
try{
|
|
|
PolyvVideoQuerVo polyvVideo = iPolyvVideoService.queryById(entity.getRecordingVideoId());
|
|
@@ -162,4 +167,19 @@ public class CourseStreamingServiceImpl extends ServiceImpl<CourseStreamingMappe
|
|
|
}
|
|
|
return this.removeByIds(ids);
|
|
|
}
|
|
|
+
|
|
|
+ private boolean checkNameUnique(CourseStreaming entity) {
|
|
|
+ CourseStreaming info = getOne(new LambdaQueryWrapper<CourseStreaming>()
|
|
|
+ .eq(CourseStreaming::getStreamingName,entity.getStreamingName()).last("limit 1"));
|
|
|
+ if (Validator.isNotNull(info)) {
|
|
|
+ if(Validator.isNotEmpty(entity.getId())){
|
|
|
+ if(entity.getId() != info.getId()){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|