|
@@ -5,9 +5,6 @@ import nju.seec.helper.data.entity.Slide;
|
|
|
import nju.seec.helper.logic.convert.DTOConvertFactory;
|
|
import nju.seec.helper.logic.convert.DTOConvertFactory;
|
|
|
import nju.seec.helper.logic.convert.EntityConvertFactory;
|
|
import nju.seec.helper.logic.convert.EntityConvertFactory;
|
|
|
import nju.seec.helper.logic.service.SlideService;
|
|
import nju.seec.helper.logic.service.SlideService;
|
|
|
-import nju.seec.helper.logic.vo.Page;
|
|
|
|
|
-import nju.seec.helper.logic.vo.PageInfo;
|
|
|
|
|
-import nju.seec.helper.logic.vo.SlideOutlineVO;
|
|
|
|
|
import nju.seec.helper.logic.vo.SlideVO;
|
|
import nju.seec.helper.logic.vo.SlideVO;
|
|
|
import nju.seec.helper.util.enums.SlideState;
|
|
import nju.seec.helper.util.enums.SlideState;
|
|
|
import nju.seec.helper.util.exception.HelperException;
|
|
import nju.seec.helper.util.exception.HelperException;
|
|
@@ -15,6 +12,7 @@ import nju.seec.helper.web.dto.SlideDTO;
|
|
|
import org.springframework.cache.annotation.CacheConfig;
|
|
import org.springframework.cache.annotation.CacheConfig;
|
|
|
import org.springframework.cache.annotation.CachePut;
|
|
import org.springframework.cache.annotation.CachePut;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -34,16 +32,12 @@ public class SlideServiceImpl implements SlideService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public Page<SlideOutlineVO> getSlides(String courseId, int page, int size, String key) {
|
|
|
|
|
- org.springframework.data.domain.Page<Slide> slidePage = slideDAO.findByNameContains(key, PageRequest.of(page - 1, size));
|
|
|
|
|
|
|
+ public List<SlideVO> getSlides(String courseId, int page, int size, String key) {
|
|
|
|
|
+ Page<Slide> slidePage = slideDAO.findByNameContains(key, PageRequest.of(page - 1, size));
|
|
|
|
|
|
|
|
- List<SlideOutlineVO> slideOutlineVOs = slidePage.getContent().stream()
|
|
|
|
|
- .map(slide -> EntityConvertFactory.convert(slide, SlideOutlineVO.class))
|
|
|
|
|
|
|
+ return slidePage.getContent().stream()
|
|
|
|
|
+ .map(slide -> EntityConvertFactory.convert(slide, SlideVO.class))
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
-
|
|
|
|
|
- PageInfo pageInfo = PageInfo.of(slidePage.getNumber() + 1, slidePage.getNumberOfElements());
|
|
|
|
|
-
|
|
|
|
|
- return Page.of(slideOutlineVOs, pageInfo);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Cacheable(key = "#slideId")
|
|
@Cacheable(key = "#slideId")
|
|
@@ -57,6 +51,8 @@ public class SlideServiceImpl implements SlideService {
|
|
|
public SlideVO create(SlideDTO slideDTO) {
|
|
public SlideVO create(SlideDTO slideDTO) {
|
|
|
Slide slide = new Slide();
|
|
Slide slide = new Slide();
|
|
|
slide.setCourseId(slideDTO.getCourseId());
|
|
slide.setCourseId(slideDTO.getCourseId());
|
|
|
|
|
+ slide.setPlaceholder(slideDTO.getPlaceholder());
|
|
|
|
|
+ slide.setFrontendId(slideDTO.getFrontendId());
|
|
|
slide.setName(slideDTO.getName());
|
|
slide.setName(slideDTO.getName());
|
|
|
slide.setState(SlideState.DRAFT);
|
|
slide.setState(SlideState.DRAFT);
|
|
|
slide = slideDAO.save(slide);
|
|
slide = slideDAO.save(slide);
|
|
@@ -68,7 +64,7 @@ public class SlideServiceImpl implements SlideService {
|
|
|
public SlideVO update(SlideDTO slideDTO) {
|
|
public SlideVO update(SlideDTO slideDTO) {
|
|
|
Slide slide = DTOConvertFactory.convert(slideDTO);
|
|
Slide slide = DTOConvertFactory.convert(slideDTO);
|
|
|
slideDAO.save(slide);
|
|
slideDAO.save(slide);
|
|
|
- return getOneSlide(slideDTO.getId());
|
|
|
|
|
|
|
+ return EntityConvertFactory.convert(findSlideById(slideDTO.getId()), SlideVO.class);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private Slide findSlideById(int slideId) {
|
|
private Slide findSlideById(int slideId) {
|