|
@@ -1,20 +1,30 @@
|
|
|
package com.sp.director.module.script.service.impl;
|
|
|
|
|
|
+import com.sp.director.base.UserLoginInfo;
|
|
|
+import com.sp.director.context.RequestContext;
|
|
|
import com.sp.director.ienum.LogicDeleteEnum;
|
|
|
import com.sp.director.ienum.RecommendState;
|
|
|
import com.sp.director.ienum.ScriptPrivateStateEnum;
|
|
|
+import com.sp.director.ienum.ScriptTypeEnum;
|
|
|
+import com.sp.director.module.collect.service.IUserCollectService;
|
|
|
import com.sp.director.module.script.dao.ScriptContentPublicDao;
|
|
|
import com.sp.director.module.script.dao.ScriptPublicDao;
|
|
|
-import com.sp.director.module.script.dto.ScriptContentDTO;
|
|
|
+import com.sp.director.module.script.dto.ScriptIntroductionDTO;
|
|
|
import com.sp.director.module.script.entity.ScriptPublic;
|
|
|
import com.sp.director.module.script.entity.ScriptVerify;
|
|
|
+import com.sp.director.module.script.service.IScriptContentPublicService;
|
|
|
+import com.sp.director.module.script.service.IScriptDetailService;
|
|
|
import com.sp.director.module.script.service.IScriptPublicService;
|
|
|
+import com.sp.director.module.script.vo.ScriptSummaryVO;
|
|
|
+import com.sp.director.utils.BeanUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -25,7 +35,7 @@ import java.time.LocalDateTime;
|
|
|
* @since 2021-03-05
|
|
|
*/
|
|
|
@Service
|
|
|
-public class ScriptPublicServiceImpl implements IScriptPublicService {
|
|
|
+public class ScriptPublicServiceImpl implements IScriptPublicService, IScriptDetailService {
|
|
|
|
|
|
@Autowired
|
|
|
private ScriptPublicDao scriptPublicDao;
|
|
@@ -33,6 +43,12 @@ public class ScriptPublicServiceImpl implements IScriptPublicService {
|
|
|
@Autowired
|
|
|
private ScriptContentPublicDao scriptContentPublicDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IScriptContentPublicService scriptContentPublicService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserCollectService userCollectService;
|
|
|
+
|
|
|
@Override
|
|
|
public void addPublicRecord(ScriptVerify scriptVerify) {
|
|
|
ScriptPublic scriptPublic = new ScriptPublic();
|
|
@@ -75,5 +91,51 @@ public class ScriptPublicServiceImpl implements IScriptPublicService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询最新审核公开的剧本列表
|
|
|
+ * @param userId
|
|
|
+ * @param lastRecordId
|
|
|
+ * @param lastRecordTime
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ScriptSummaryVO> listScriptSummary(Long userId,
|
|
|
+ String tagName,
|
|
|
+ Long lastRecordId,
|
|
|
+ LocalDateTime lastRecordTime) {
|
|
|
+ Map<Long, Boolean> collectMap = new HashMap<>();
|
|
|
+ UserLoginInfo userLoginInfo = RequestContext.getUserLoginInfo();
|
|
|
+ List<ScriptIntroductionDTO> scriptIntroductionDTOList = scriptPublicDao.listAllScriptInfoByIds(userId, null,lastRecordTime);
|
|
|
+ List<Long> scriptIdList = scriptIntroductionDTOList.stream().map(ScriptIntroductionDTO::getScriptId).collect(Collectors.toList());
|
|
|
+ if(userLoginInfo != null && !scriptIdList.isEmpty()){
|
|
|
+ // 查询收藏状态
|
|
|
+ collectMap = userCollectService.queryUserCollectForMap(userLoginInfo.getUserId(), scriptIdList);
|
|
|
+ }
|
|
|
|
|
|
+ List<ScriptSummaryVO> list = new ArrayList<>();
|
|
|
+ for (ScriptIntroductionDTO dto : scriptIntroductionDTOList) {
|
|
|
+ ScriptSummaryVO vo = new ScriptSummaryVO();
|
|
|
+ BeanUtil.copyBean(dto,vo);
|
|
|
+ vo.setScriptId(dto.getScriptId());
|
|
|
+ vo.setIsModify(dto.getModifyState().isModify());
|
|
|
+ vo.setUpdateTime(dto.getTime());
|
|
|
+ vo.setIsModify(dto.getModifyState().isModify());
|
|
|
+ Integer chapterNum = 1;
|
|
|
+ if(dto.getScriptType().equals(ScriptTypeEnum.SINGLE)){
|
|
|
+ // 查询单集的chapterId
|
|
|
+ String scriptContentId = scriptContentPublicService.querySingleScriptChapterId(dto.getScriptId());
|
|
|
+ vo.setChapterId(scriptContentId);
|
|
|
+ }else{
|
|
|
+ chapterNum = scriptContentPublicDao.queryChapterNum(dto.getScriptId());
|
|
|
+ }
|
|
|
+ Boolean isPublic = scriptPublicDao.queryScriptIsPublish(dto.getScriptId());
|
|
|
+ vo.setIsPublic(isPublic);
|
|
|
+ vo.setCooperationThumbnail(Collections.emptyList());
|
|
|
+ vo.setChapterNum(chapterNum);
|
|
|
+ Boolean collect = collectMap.get(dto.getScriptId());
|
|
|
+ vo.setIsCollect(collect == null ? false : collect);
|
|
|
+ list.add(vo);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|