|
@@ -0,0 +1,63 @@
|
|
|
+package com.smcic.api.conference.service.impl;
|
|
|
+
|
|
|
+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.smcic.api.conference.dto.BatchPhoto;
|
|
|
+import com.smcic.api.conference.entity.ConferenceLivePhoto;
|
|
|
+import com.smcic.api.conference.mapper.ConferenceLivePhotoMapper;
|
|
|
+import com.smcic.api.conference.service.IConferenceLivePhotoService;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.concurrent.ThreadPoolExecutor;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author syj
|
|
|
+ * @since 2024-03-28
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class ConferenceLivePhotoServiceImpl extends ServiceImpl<ConferenceLivePhotoMapper, ConferenceLivePhoto> implements IConferenceLivePhotoService {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ThreadPoolExecutor threadPoolExecutor;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private SSEService sseService;
|
|
|
+
|
|
|
+ public Page<ConferenceLivePhoto> photoPage(Long cid, Integer page, Integer pageSize) {
|
|
|
+ Page<ConferenceLivePhoto> page1 = new Page<>(page, pageSize);
|
|
|
+
|
|
|
+ LambdaQueryWrapper<ConferenceLivePhoto> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ return this.baseMapper.selectPage(page1, wrapper.eq(ConferenceLivePhoto::getConferenceId, cid)
|
|
|
+ .orderByDesc(ConferenceLivePhoto::getIsTop)
|
|
|
+ .orderByDesc(ConferenceLivePhoto::getId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void batchCreate(BatchPhoto batchPhoto){
|
|
|
+ List<ConferenceLivePhoto> photos = new ArrayList<>();
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ for(String url : batchPhoto.getPhoto()){
|
|
|
+ ConferenceLivePhoto conferenceLivePhoto = new ConferenceLivePhoto();
|
|
|
+
|
|
|
+ conferenceLivePhoto.setConferenceId(batchPhoto.getConferenceId());
|
|
|
+ conferenceLivePhoto.setAgendaId(batchPhoto.getAgendaId());
|
|
|
+ conferenceLivePhoto.setTitle(batchPhoto.getTitle());
|
|
|
+ conferenceLivePhoto.setPhoto(url);
|
|
|
+ conferenceLivePhoto.setCreateTime(now);
|
|
|
+ photos.add(conferenceLivePhoto);
|
|
|
+ }
|
|
|
+ saveBatch(photos);
|
|
|
+
|
|
|
+ threadPoolExecutor.execute(()-> sseService.sendData(batchPhoto.getConferenceId(), photos));
|
|
|
+ }
|
|
|
+}
|