Skip to content

Commit

Permalink
feat: 课程新增或编辑时可以上传多个附件
Browse files Browse the repository at this point in the history
  • Loading branch information
lichong-a committed Sep 21, 2024
1 parent 2d4b383 commit 9d9f219
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;

/**
* @author 李冲
Expand Down Expand Up @@ -46,5 +47,7 @@ public class CourseAddOrEditVo {
private Long courseMediaStorageId;
@Schema(description = "课程简介文件ID")
private Long courseDescriptionStorageId;
@Schema(description = "课程附件ID列表")
private List<Long> courseAttachmentStorageIds;

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.HashSet;
import java.util.List;

/**
* @author 李冲
Expand Down Expand Up @@ -84,6 +88,7 @@ private Course transAddOrEditVoToCourse(CourseAddOrEditVo courseAddOrEditVo) {
Storage mediaStorage = storageRepository.getReferenceById(mediaStorageId);
Storage coverStorage = storageRepository.getReferenceById(courseAddOrEditVo.getCourseCoverStorageId());
Storage descriptionStorage = storageRepository.getReferenceById(courseAddOrEditVo.getCourseDescriptionStorageId());
List<Storage> courseAttachmentStorages = storageRepository.findAllById(courseAddOrEditVo.getCourseAttachmentStorageIds());
return Course.builder()
.id(courseAddOrEditVo.getId())
.title(courseAddOrEditVo.getTitle())
Expand All @@ -92,6 +97,7 @@ private Course transAddOrEditVoToCourse(CourseAddOrEditVo courseAddOrEditVo) {
.courseMediaStorage(mediaStorage)
.courseCoverStorage(coverStorage)
.courseDescriptionStorage(descriptionStorage)
.courseAttachmentStorages(CollectionUtils.isEmpty(courseAttachmentStorages) ? new HashSet<>() : new HashSet<>(courseAttachmentStorages))
.build();
}
}

0 comments on commit 9d9f219

Please sign in to comment.