|
|
|
@ -7,9 +7,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
|
|
|
|
|
import com.teaching.backend.mapper.records.LearningRecordsMapper; |
|
|
|
|
import com.teaching.backend.mapper.resource.CourseResourcesMapper; |
|
|
|
|
import com.teaching.backend.model.entity.CourseResources; |
|
|
|
|
import com.teaching.backend.model.entity.ResourceRelationship; |
|
|
|
|
import com.teaching.backend.model.entity.records.LearningRecords; |
|
|
|
|
import com.teaching.backend.service.impl.records.LearningRecordsServiceImpl; |
|
|
|
|
import com.teaching.backend.service.resource.CourseResourcesService; |
|
|
|
|
import com.teaching.backend.service.resource.ResourcesRelationshipService; |
|
|
|
|
import org.apache.commons.io.FileUtils; |
|
|
|
@ -21,7 +24,9 @@ import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.InputStream; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.function.Consumer; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* ClassName: FileTableImpl |
|
|
|
@ -39,6 +44,8 @@ public class CourseResourcesServiceImpl extends ServiceImpl<CourseResourcesMappe |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private CourseResourcesMapper courseResourcesMapper; |
|
|
|
|
@Autowired |
|
|
|
|
private LearningRecordsMapper learningRecordsMapper; |
|
|
|
|
@Override |
|
|
|
|
public void updateFile(Integer type, String fileName, String filePath) { |
|
|
|
|
|
|
|
|
@ -132,12 +139,20 @@ public class CourseResourcesServiceImpl extends ServiceImpl<CourseResourcesMappe |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void removeCourseResources(List<Long> ids) { |
|
|
|
|
LambdaQueryWrapper<CourseResources> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
lambdaQueryWrapper.in(CourseResources::getId, ids); |
|
|
|
|
List<CourseResources> list = this.list(lambdaQueryWrapper); |
|
|
|
|
courseResourcesMapper.deleteBatchIds(list); |
|
|
|
|
// System.out.println(this.updateBatchById(list));
|
|
|
|
|
// this.remove(lambdaQueryWrapper);
|
|
|
|
|
//删除资源在记录表里对应的记录
|
|
|
|
|
List<LearningRecords> list = new ArrayList<>(); |
|
|
|
|
for (Long id: ids) { |
|
|
|
|
LambdaQueryWrapper<LearningRecords> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
//System.out.println("id:"+id);
|
|
|
|
|
lambdaQueryWrapper.eq(LearningRecords::getCoursesId, id).eq(LearningRecords::getType, 4); |
|
|
|
|
//System.out.println("资源对应的记录:"+learningRecordsMapper.selectList(lambdaQueryWrapper));
|
|
|
|
|
list.addAll(learningRecordsMapper.selectList(lambdaQueryWrapper)); |
|
|
|
|
//System.out.println("添加完后的集合:"+list);
|
|
|
|
|
} |
|
|
|
|
learningRecordsMapper.deleteBatchIds(list); |
|
|
|
|
//System.out.println(list);
|
|
|
|
|
//删除课程资源
|
|
|
|
|
courseResourcesMapper.deleteBatchIds(ids); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -148,8 +163,8 @@ public class CourseResourcesServiceImpl extends ServiceImpl<CourseResourcesMappe |
|
|
|
|
switch (courseResources.getType()){ |
|
|
|
|
case 1 : courseResources.setImg("src\\assets\\icons\\ppt (2).png");//ppt的默认图片
|
|
|
|
|
break; |
|
|
|
|
// case 2 : courseResources.setImg(""); //图片
|
|
|
|
|
// break;
|
|
|
|
|
case 2 : courseResources.setImg(courseResources.getImg()); //图片
|
|
|
|
|
break; |
|
|
|
|
case 3 : courseResources.setImg("src\\assets\\images\\video.png"); //视频
|
|
|
|
|
break; |
|
|
|
|
case 4 : courseResources.setImg("src\\assets\\images\\PDF .png"); //pdf
|
|
|
|
@ -160,14 +175,14 @@ public class CourseResourcesServiceImpl extends ServiceImpl<CourseResourcesMappe |
|
|
|
|
break; |
|
|
|
|
default: courseResources.setImg(""); //暂无默认图片
|
|
|
|
|
} |
|
|
|
|
this.save(courseResources); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public CourseResources editCourseResource(String resourceId) { |
|
|
|
|
//根据id查数据
|
|
|
|
|
CourseResources courseResources = this.getById(resourceId); |
|
|
|
|
|
|
|
|
|
return courseResources; |
|
|
|
|
return this.getById(resourceId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|