mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-10 20:04:06 +08:00
课程附件列表查询--增加ext参数
This commit is contained in:
parent
db4c92e23e
commit
b7c4410028
@ -40,6 +40,7 @@ import xyz.playedu.api.types.paginate.PaginationResult;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@ -236,14 +237,18 @@ public class CourseController {
|
||||
List<CourseAttachment> attachments =
|
||||
attachmentService.getAttachmentsByCourseId(course.getId());
|
||||
if (null != attachments && attachments.size() > 0) {
|
||||
Map<Integer, String> resourceMap =
|
||||
Map<Integer, Resource> resourceMap =
|
||||
resourceService
|
||||
.chunks(attachments.stream().map(CourseAttachment::getRid).toList())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(Resource::getId, Resource::getUrl));
|
||||
.collect(Collectors.toMap(Resource::getId, Function.identity()));
|
||||
attachments.forEach(
|
||||
courseAttachment -> {
|
||||
courseAttachment.setUrl(resourceMap.get(courseAttachment.getRid()));
|
||||
Resource resource = resourceMap.get(courseAttachment.getRid());
|
||||
if(null != resource){
|
||||
courseAttachment.setUrl(resource.getUrl());
|
||||
courseAttachment.setExt(resource.getExtension());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class CourseAttachment implements Serializable {
|
||||
/** 附件名 */
|
||||
private String title;
|
||||
|
||||
/** 附件类型 */
|
||||
/** 类型 */
|
||||
private String type;
|
||||
|
||||
/** 资源id */
|
||||
@ -57,6 +57,10 @@ public class CourseAttachment implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private String url;
|
||||
|
||||
/** 资源类型 */
|
||||
@TableField(exist = false)
|
||||
private String ext;
|
||||
|
||||
/** */
|
||||
@JsonIgnore private Date createdAt;
|
||||
|
||||
@ -85,6 +89,9 @@ public class CourseAttachment implements Serializable {
|
||||
&& (this.getTitle() == null
|
||||
? other.getTitle() == null
|
||||
: this.getTitle().equals(other.getTitle()))
|
||||
&& (this.getExt() == null
|
||||
? other.getExt() == null
|
||||
: this.getExt().equals(other.getExt()))
|
||||
&& (this.getType() == null
|
||||
? other.getType() == null
|
||||
: this.getType().equals(other.getType()))
|
||||
@ -107,6 +114,7 @@ public class CourseAttachment implements Serializable {
|
||||
result = prime * result + ((getCourseId() == null) ? 0 : getCourseId().hashCode());
|
||||
result = prime * result + ((getSort() == null) ? 0 : getSort().hashCode());
|
||||
result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode());
|
||||
result = prime * result + ((getExt() == null) ? 0 : getExt().hashCode());
|
||||
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
|
||||
result = prime * result + ((getRid() == null) ? 0 : getRid().hashCode());
|
||||
result = prime * result + ((getUrl() == null) ? 0 : getUrl().hashCode());
|
||||
@ -124,6 +132,7 @@ public class CourseAttachment implements Serializable {
|
||||
sb.append(", courseId=").append(courseId);
|
||||
sb.append(", sort=").append(sort);
|
||||
sb.append(", title=").append(title);
|
||||
sb.append(", ext=").append(ext);
|
||||
sb.append(", type=").append(type);
|
||||
sb.append(", rid=").append(rid);
|
||||
sb.append(", url=").append(url);
|
||||
|
Loading…
x
Reference in New Issue
Block a user