Browse Source

完成剧本相关功能

shiyi 3 years ago
parent
commit
105f1e4fec
49 changed files with 535 additions and 83 deletions
  1. 7 0
      core/src/main/java/com/sp/director/context/RequestContext.java
  2. 4 0
      core/src/main/java/com/sp/director/ienum/ModifyStateEnum.java
  3. 3 1
      core/src/main/java/com/sp/director/ienum/ScriptOptTypeEnum.java
  4. 3 0
      core/src/main/java/com/sp/director/module/collect/dao/UserCollectDao.java
  5. 10 0
      core/src/main/java/com/sp/director/module/collect/dao/impl/UserCollectDaoImpl.java
  6. 12 0
      core/src/main/java/com/sp/director/module/collect/service/IUserCollectService.java
  7. 13 0
      core/src/main/java/com/sp/director/module/collect/service/impl/UserCollectServiceImpl.java
  8. 4 0
      core/src/main/java/com/sp/director/module/script/dao/ScriptContentPublicDao.java
  9. 10 0
      core/src/main/java/com/sp/director/module/script/dao/ScriptPublicDao.java
  10. 2 0
      core/src/main/java/com/sp/director/module/script/dao/ScriptVerifyDao.java
  11. 26 0
      core/src/main/java/com/sp/director/module/script/dao/impl/ScriptContentPublicDaoImpl.java
  12. 11 4
      core/src/main/java/com/sp/director/module/script/dao/impl/ScriptPublicDaoImpl.java
  13. 11 1
      core/src/main/java/com/sp/director/module/script/dao/impl/ScriptVerifyDaoImpl.java
  14. 3 0
      core/src/main/java/com/sp/director/module/script/dto/ScriptIntroductionDTO.java
  15. 1 2
      core/src/main/java/com/sp/director/module/script/help/AuthorHelp.java
  16. 12 2
      core/src/main/java/com/sp/director/module/script/param/ScriptSummaryParam.java
  17. 1 1
      core/src/main/java/com/sp/director/module/script/param/ShareOrCooperationParam.java
  18. 3 0
      core/src/main/java/com/sp/director/module/script/service/IScriptContentPublicService.java
  19. 2 1
      core/src/main/java/com/sp/director/module/script/service/IScriptDetailService.java
  20. 7 0
      core/src/main/java/com/sp/director/module/script/service/IScriptService.java
  21. 7 0
      core/src/main/java/com/sp/director/module/script/service/IScriptVerifyService.java
  22. 16 1
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptContentPublicServiceImpl.java
  23. 3 1
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptContentServiceImpl.java
  24. 1 1
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptContentVerifyServiceImpl.java
  25. 1 1
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptCooperateDetailServiceImpl.java
  26. 8 2
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptDetailServiceImpl.java
  27. 64 2
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptPublicServiceImpl.java
  28. 1 1
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptPublishSummaryDetailImpl.java
  29. 87 0
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptRecommendServiceImpl.java
  30. 1 0
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptScreenwriterServiceImpl.java
  31. 17 0
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptServiceImpl.java
  32. 1 1
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptShareDaoImpl.java
  33. 1 1
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptShareDetailServiceImpl.java
  34. 5 18
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptShareServiceImpl.java
  35. 10 2
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptSummaryStrategyDispatcher.java
  36. 10 0
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptVerifyServiceImpl.java
  37. 1 1
      core/src/main/java/com/sp/director/module/script/service/impl/UserCollectScriptServiceImpl.java
  38. 5 3
      core/src/main/java/com/sp/director/module/script/vo/CommonScriptVO.java
  39. 5 4
      core/src/main/java/com/sp/director/module/script/vo/ScriptPublishModifyVO.java
  40. 3 0
      core/src/main/java/com/sp/director/module/script/vo/ScriptSummaryVO.java
  41. 1 0
      core/src/main/resources/com/sp/director/module/script/dao/xml/ScriptMapper.xml
  42. 9 10
      core/src/main/resources/com/sp/director/module/script/dao/xml/ScriptPublicMapper.xml
  43. 21 0
      core/src/main/resources/com/sp/director/module/usercollect/dao/xml/UserCollectMapper.xml
  44. 8 0
      logic/pom.xml
  45. 9 16
      logic/src/main/java/com/sp/director/module/script/script/controller/ScriptContentController.java
  46. 12 6
      logic/src/main/java/com/sp/director/module/script/script/controller/ScriptController.java
  47. 6 0
      logic/src/main/java/com/sp/director/module/script/script/controller/ScriptScreenWriterController.java
  48. 67 0
      logic/src/test/java/com/sp/word/ExcelRead.java
  49. 10 0
      logic/src/test/java/com/sp/word/WordData.java

+ 7 - 0
core/src/main/java/com/sp/director/context/RequestContext.java

@@ -1,5 +1,7 @@
 package com.sp.director.context;
 
+import com.sp.director.base.UserLoginInfo;
+import com.sp.director.constant.RequestConstant;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
 
@@ -31,4 +33,9 @@ public class RequestContext {
     public static Object getAttribute(String key){
         return getRequest().getAttribute(key);
     }
+
+
+    public static UserLoginInfo getUserLoginInfo(){
+        return  (UserLoginInfo)RequestContext.getAttribute(RequestConstant.USER_LOGIN_INFO);
+    }
 }

+ 4 - 0
core/src/main/java/com/sp/director/ienum/ModifyStateEnum.java

@@ -32,4 +32,8 @@ public enum ModifyStateEnum implements IEnum {
     public String getName() {
         return name;
     }
+
+    public Boolean isModify(){
+        return this.equals(ModifyStateEnum.MODIFY);
+    }
 }

+ 3 - 1
core/src/main/java/com/sp/director/ienum/ScriptOptTypeEnum.java

@@ -14,7 +14,9 @@ public enum ScriptOptTypeEnum implements IEnum {
     SHARE(1, "share"),
     COLLECT(2, "collect"),
     COLLABORATOR(3, "collaborator"),
-    PUBLISH(4, "publish");
+    PUBLISH(4, "publish"),
+    RECOMMEND(5, "recommend"),
+    PUBLIC_LATEST(6, "latest");
 
 
 

+ 3 - 0
core/src/main/java/com/sp/director/module/collect/dao/UserCollectDao.java

@@ -88,4 +88,7 @@ public interface UserCollectDao extends IBaseDAO<UserCollect> {
      * @return
      */
     List<ScriptMarkDTO> listAllCollectScriptId(Long userId);
+
+    List<UserCollectDTO> queryUserCollect(Long userId, List<Long> scriptIdList);
+
 }

+ 10 - 0
core/src/main/java/com/sp/director/module/collect/dao/impl/UserCollectDaoImpl.java

@@ -10,6 +10,7 @@ import com.sp.director.module.collect.entity.UserCollect;
 import com.sp.director.module.script.dto.ScriptMarkDTO;
 import com.sp.director.mybatis.plus.BaseDAOImpl;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Repository;
@@ -39,6 +40,11 @@ public class UserCollectDaoImpl
     }
 
     @Override
+    public List<UserCollectDTO> queryUserCollect(Long userId, List<Long> scriptIdList) {
+        return userCollectMapper.queryUserCollect(userId, scriptIdList);
+    }
+
+    @Override
     public List<ScriptMarkDTO> listAllCollectScriptId(Long userId) {
         QueryWrapper<UserCollect> qw = new QueryWrapper<>();
         qw.lambda().eq(UserCollect::getLogicDelete, LogicDeleteEnum.NORMAL)
@@ -134,4 +140,8 @@ interface UserCollectMapper extends BaseMapper<UserCollect> {
     List<UserCollectDTO> listCollectScript(Long userId, LocalDateTime lastSortTime, Integer size);
 
     int statisticCollectCount(Long userId);
+
+    List<UserCollectDTO> queryUserCollect(@Param("userId") Long userId, @Param("scriptIdList") List<Long> scriptIdList);
+
+
 }

+ 12 - 0
core/src/main/java/com/sp/director/module/collect/service/IUserCollectService.java

@@ -1,5 +1,8 @@
 package com.sp.director.module.collect.service;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 用户收藏表 服务类
@@ -33,4 +36,13 @@ public interface IUserCollectService {
      * @return
      */
     boolean checkCollect(Long userId, Long id);
+
+    /**
+     *  查询用户收藏状态,使用map封装返回集合
+     * @param userId
+     * @param scriptIdList
+     * @return
+     */
+    Map<Long, Boolean> queryUserCollectForMap(Long userId, List<Long> scriptIdList);
+
 }

+ 13 - 0
core/src/main/java/com/sp/director/module/collect/service/impl/UserCollectServiceImpl.java

@@ -2,13 +2,16 @@ package com.sp.director.module.collect.service.impl;
 
 import com.sp.director.exception.ParamException;
 import com.sp.director.module.collect.dao.UserCollectDao;
+import com.sp.director.module.collect.dto.UserCollectDTO;
 import com.sp.director.module.collect.entity.UserCollect;
 import com.sp.director.module.collect.service.IUserCollectService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 
 /**
@@ -26,6 +29,16 @@ public class UserCollectServiceImpl implements IUserCollectService {
     private UserCollectDao userCollectDao;
 
     @Override
+    public Map<Long, Boolean> queryUserCollectForMap(Long userId, List<Long> scriptIdList) {
+        List<UserCollectDTO> userCollectDTOList = userCollectDao.queryUserCollect(userId, scriptIdList);
+        Map<Long, Boolean> map = new HashMap<>();
+        for (UserCollectDTO dto : userCollectDTOList) {
+            map.put(dto.getScriptId(),true);
+        }
+        return map;
+    }
+
+    @Override
     public boolean checkCollect(Long userId, Long scriptId) {
         return userCollectDao.checkHasCollected(userId, scriptId);
     }

+ 4 - 0
core/src/main/java/com/sp/director/module/script/dao/ScriptContentPublicDao.java

@@ -32,4 +32,8 @@ public interface ScriptContentPublicDao extends IBaseDAO<ScriptContentPublic> {
 
     List<ScriptContentSummaryVO> queryPublicContentList(Long scriptId, List<Long> queryList);
 
+    Integer queryChapterNum(Long scriptId);
+
+    Long querySingleScriptChapterId(Long scriptId);
+
 }

+ 10 - 0
core/src/main/java/com/sp/director/module/script/dao/ScriptPublicDao.java

@@ -44,4 +44,14 @@ public interface ScriptPublicDao extends IBaseDAO<ScriptPublic> {
      */
     List<ScriptIntroductionDTO> listAllScriptInfoByIds(Long userId, List<Long> scriptList, LocalDateTime lastRecordTime);
 
+    /**
+     * 查询所有的推荐剧本
+     *
+     * @param tagName
+     * @param lastRecordTime
+     * @return
+     */
+    List<ScriptIntroductionDTO> listAllRecommendScriptInfo(String tagName, LocalDateTime lastRecordTime);
+
+
 }

+ 2 - 0
core/src/main/java/com/sp/director/module/script/dao/ScriptVerifyDao.java

@@ -65,4 +65,6 @@ public interface ScriptVerifyDao extends IBaseDAO<ScriptVerify> {
     void verifyScript(Long scriptId, BaseReviewIenum refuse);
 
     ScriptVerify getRecordByScriptId(Long scriptId);
+
+    Boolean queryScriptIsPublish(Long scriptId);
 }

+ 26 - 0
core/src/main/java/com/sp/director/module/script/dao/impl/ScriptContentPublicDaoImpl.java

@@ -3,6 +3,7 @@ package com.sp.director.module.script.dao.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sp.director.exception.BusinessException;
 import com.sp.director.ienum.LogicDeleteEnum;
 import com.sp.director.ienum.RecommendState;
 import com.sp.director.ienum.ScriptPrivateStateEnum;
@@ -18,6 +19,7 @@ import org.springframework.stereotype.Repository;
 
 import java.time.LocalDateTime;
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 /**
@@ -45,6 +47,29 @@ public class ScriptContentPublicDaoImpl extends BaseDAOImpl<ScriptContentPublicM
     }
 
     @Override
+    public Long querySingleScriptChapterId(Long scriptId) {
+        QueryWrapper<ScriptContentPublic> qw = new QueryWrapper<>();
+        qw.lambda().eq(ScriptContentPublic::getScriptId,scriptId)
+                .eq(ScriptContentPublic::getLogicDelete,LogicDeleteEnum.NORMAL)
+                .eq(ScriptContentPublic::getPrivateState,ScriptPrivateStateEnum.PUBLIC);
+        ScriptContentPublic content = this.getOne(qw);
+        if(Objects.isNull(content)){
+            log.error("数据异常,审核通过的单集剧本:"+  scriptId.toString() +"不存在审核通过的章节");
+            throw new BusinessException();
+        }
+        return content.getChapterId();
+    }
+
+    @Override
+    public Integer queryChapterNum(Long scriptId) {
+        QueryWrapper<ScriptContentPublic> qw = new QueryWrapper<>();
+        qw.lambda().eq(ScriptContentPublic::getScriptId,scriptId)
+                .eq(ScriptContentPublic::getLogicDelete,LogicDeleteEnum.NORMAL)
+                .eq(ScriptContentPublic::getPrivateState,ScriptPrivateStateEnum.PUBLIC);
+        return this.count(qw);
+    }
+
+    @Override
     public List<ScriptContentSummaryVO> queryPublicContentList(Long scriptId, List<Long> queryList) {
         return scriptContentPublicMapper.queryPublicContentList(scriptId, queryList);
     }
@@ -107,6 +132,7 @@ public class ScriptContentPublicDaoImpl extends BaseDAOImpl<ScriptContentPublicM
         uw.lambda().eq(ScriptContentPublic::getScriptId, scriptId)
                 .eq(ScriptContentPublic::getPrivateState, ScriptPrivateStateEnum.PUBLIC)
                 .eq(ScriptContentPublic::getLogicDelete, LogicDeleteEnum.NORMAL)
+                .set(ScriptContentPublic::getLogicDelete, LogicDeleteEnum.DELETE)
                 .set(ScriptContentPublic::getPrivateState, ScriptPrivateStateEnum.PRIVATE);
         if(chapterId != null){
             uw.lambda().eq(ScriptContentPublic::getChapterId, chapterId);

+ 11 - 4
core/src/main/java/com/sp/director/module/script/dao/impl/ScriptPublicDaoImpl.java

@@ -32,8 +32,13 @@ public class ScriptPublicDaoImpl extends BaseDAOImpl<ScriptPublicMapper, ScriptP
     private ScriptPublicMapper scriptPublicMapper;
 
     @Override
+    public List<ScriptIntroductionDTO> listAllRecommendScriptInfo(String tagName, LocalDateTime lastRecordTime) {
+        return scriptPublicMapper.listAllPublicScript(tagName,lastRecordTime,true);
+    }
+
+    @Override
     public List<ScriptIntroductionDTO> listAllScriptInfoByIds(Long userId, List<Long> scriptList, LocalDateTime lastRecordTime) {
-        return scriptPublicMapper.listAllPublicScript(userId,scriptList,lastRecordTime);
+        return scriptPublicMapper.listAllPublicScript(null,lastRecordTime,false);
     }
 
     @Override
@@ -70,8 +75,10 @@ public class ScriptPublicDaoImpl extends BaseDAOImpl<ScriptPublicMapper, ScriptP
     public void privateScript(Long scriptId) {
         UpdateWrapper<ScriptPublic> uw = new UpdateWrapper<>();
         uw.lambda().eq(ScriptPublic::getScriptId, scriptId)
+                .eq(ScriptPublic::getLogicDelete,LogicDeleteEnum.NORMAL)
                 .eq(ScriptPublic::getPrivateState, ScriptPrivateStateEnum.PUBLIC)
                 .set(ScriptPublic::getPrivateState, ScriptPrivateStateEnum.PRIVATE)
+                .set(ScriptPublic::getLogicDelete, LogicDeleteEnum.DELETE)
                 .set(ScriptPublic::getUpdateTime, LocalDateTime.now());
         this.update(uw);
 
@@ -81,7 +88,7 @@ public class ScriptPublicDaoImpl extends BaseDAOImpl<ScriptPublicMapper, ScriptP
 @Component
 interface ScriptPublicMapper extends BaseMapper<ScriptPublic> {
 
-    List<ScriptIntroductionDTO> listAllPublicScript(@Param("userId") Long userId,
-                                                    @Param("scriptList") List<Long> scriptList,
-            @Param("lastRecordTime") LocalDateTime lastRecordTime);
+    List<ScriptIntroductionDTO> listAllPublicScript(@Param("tagName") String tagName,
+                                                    @Param("lastRecordTime") LocalDateTime lastRecordTime,
+                                                    @Param("isRecommend") Boolean isRecommend);
 }

+ 11 - 1
core/src/main/java/com/sp/director/module/script/dao/impl/ScriptVerifyDaoImpl.java

@@ -32,6 +32,16 @@ public class ScriptVerifyDaoImpl extends BaseDAOImpl<ScriptVerifyMapper, ScriptV
     private ScriptVerifyMapper scriptVerifyMapper;
 
     @Override
+    public Boolean queryScriptIsPublish(Long scriptId) {
+        QueryWrapper<ScriptVerify> qw = new QueryWrapper<>();
+        qw.lambda().eq(ScriptVerify::getScriptId, scriptId)
+                .eq(ScriptVerify::getLogicDelete, LogicDeleteEnum.NORMAL)
+                .eq(ScriptVerify::getVerifyState, BaseReviewIenum.Review);
+        int count = this.count(qw);
+        return count > 0;
+    }
+
+    @Override
     public ScriptVerify getRecordByScriptId(Long scriptId) {
         QueryWrapper<ScriptVerify> qw = new QueryWrapper<>();
         qw.lambda().eq(ScriptVerify::getScriptId, scriptId)
@@ -45,7 +55,7 @@ public class ScriptVerifyDaoImpl extends BaseDAOImpl<ScriptVerifyMapper, ScriptV
         UpdateWrapper<ScriptVerify> uw = new UpdateWrapper<>();
         uw.lambda().eq(ScriptVerify::getLogicDelete,LogicDeleteEnum.NORMAL)
                     .eq(ScriptVerify::getScriptId,scriptId)
-                    .eq(ScriptVerify::getVerifyState,state)
+                    .set(ScriptVerify::getVerifyState,state)
                     .set(ScriptVerify::getUpdateTime,LocalDateTime.now());
         this.update(uw);
     }

+ 3 - 0
core/src/main/java/com/sp/director/module/script/dto/ScriptIntroductionDTO.java

@@ -1,5 +1,6 @@
 package com.sp.director.module.script.dto;
 
+import com.sp.director.ienum.ModifyStateEnum;
 import com.sp.director.ienum.ScriptTypeEnum;
 import lombok.Data;
 
@@ -22,4 +23,6 @@ public class ScriptIntroductionDTO extends ScriptCommonDTO{
 
     private ScriptTypeEnum scriptType;
 
+    private ModifyStateEnum modifyState;
+
 }

+ 1 - 2
core/src/main/java/com/sp/director/module/script/help/AuthorHelp.java

@@ -1,7 +1,6 @@
 package com.sp.director.module.script.help;
 
 import com.sp.director.base.UserLoginInfo;
-import com.sp.director.constant.RequestConstant;
 import com.sp.director.context.RequestContext;
 
 import java.util.Objects;
@@ -20,7 +19,7 @@ public class AuthorHelp {
      * @return
      */
     public static Boolean isAuthor(Long userId){
-        UserLoginInfo userLoginInfo = (UserLoginInfo)RequestContext.getAttribute(RequestConstant.USER_LOGIN_INFO);
+        UserLoginInfo userLoginInfo = RequestContext.getUserLoginInfo();
         if(Objects.isNull(userLoginInfo)){
             return false;
         }else{

+ 12 - 2
core/src/main/java/com/sp/director/module/script/param/ScriptSummaryParam.java

@@ -1,6 +1,7 @@
 package com.sp.director.module.script.param;
 
 import com.sp.director.ienum.ScriptOptTypeEnum;
+import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiParam;
 import lombok.Data;
 
@@ -16,10 +17,12 @@ import java.time.LocalDateTime;
 @Data
 public class ScriptSummaryParam {
 
-    @NotNull(message="userId不能为空")
     @ApiParam(name = "userId",value = "用户id")
     private Long userId;
 
+    @ApiModelProperty(name="tagName",value="标签,可为空")
+    private String tagName;
+
     @ApiParam(name = "lastRecordId",value = "最后一条记录的id")
     private Long lastRecordId;
 
@@ -27,6 +30,13 @@ public class ScriptSummaryParam {
     private LocalDateTime lastRecordTime;
 
     @NotNull(message="type不能为空")
-    @ApiParam(name = "type",value = "操作类型 0:我自己创作的剧本,1,分享给我的剧本,2.我收藏的剧本,3:协作的剧本,4:发布的剧本")
+    @ApiParam(name = "type",value = "操作类型 0:我自己创作的剧本," +
+            "1,分享给我的剧本," +
+            "2.我收藏的剧本," +
+            "3:协作的剧本," +
+            "4:发布的剧本" +
+            "5:推荐的剧本列表" +
+            "6: 最新发布的剧本列表"
+    )
     private ScriptOptTypeEnum type;
 }

+ 1 - 1
core/src/main/java/com/sp/director/module/script/param/ShareOrCooperationParam.java

@@ -31,7 +31,7 @@ public class ShareOrCooperationParam {
 
 
     @NotNull(message="type不能为空")
-    @ApiModelProperty(name="type",value="类型")
+    @ApiModelProperty(name="type",value="类型,0:分享,1:协作")
     private ScriptSearchTypeEnum type ;
 
 

+ 3 - 0
core/src/main/java/com/sp/director/module/script/service/IScriptContentPublicService.java

@@ -46,4 +46,7 @@ public interface IScriptContentPublicService  {
      * @return
      */
     List<ScriptContentSummaryVO> queryPublicContentList(Long scriptId, Long lastRecordId);
+
+    String querySingleScriptChapterId(Long scriptId);
+
 }

+ 2 - 1
core/src/main/java/com/sp/director/module/script/service/IScriptDetailService.java

@@ -17,7 +17,8 @@ public interface IScriptDetailService {
      * 查询用户发布的剧本列表
      * @param userId
      * @param lastRecordId
+     * @param tagName
      * @return
      */
-    List<ScriptSummaryVO> listScriptSummary(Long userId, Long lastRecordId, LocalDateTime lastRecordTime);
+    List<ScriptSummaryVO> listScriptSummary(Long userId,String tagName, Long lastRecordId, LocalDateTime lastRecordTime);
 }

+ 7 - 0
core/src/main/java/com/sp/director/module/script/service/IScriptService.java

@@ -108,4 +108,11 @@ public interface IScriptService {
      * @return
      */
     ModifyStateEnum modifyScriptContentPrivateState(Long scriptId);
+
+    /**
+     * 查询剧本是否发布
+     * @param scriptId
+     * @return
+     */
+    Boolean isPublic(Long scriptId);
 }

+ 7 - 0
core/src/main/java/com/sp/director/module/script/service/IScriptVerifyService.java

@@ -30,4 +30,11 @@ public interface IScriptVerifyService {
      */
     void verifyScriptRecord(Long scriptId, List<Long> chapterList);
 
+    /**
+     * 检查scriptId是否在审核中
+     * @param scriptId
+     * @return
+     */
+    Boolean queryScriptIsPublish(Long scriptId);
+
 }

+ 16 - 1
core/src/main/java/com/sp/director/module/script/service/impl/ScriptContentPublicServiceImpl.java

@@ -10,6 +10,7 @@ import com.sp.director.module.script.vo.ScriptContentSummaryVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.Cacheable;
+import org.springframework.cache.annotation.Caching;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -35,6 +36,15 @@ public class ScriptContentPublicServiceImpl implements IScriptContentPublicServi
     @Autowired
     private ScriptPublicDao scriptPublicDao;
 
+
+
+    @Override
+    @Cacheable(value = "script:chapter:chapterNum:total",key = "#scriptId",condition = "#scriptId != null")
+    public String querySingleScriptChapterId(Long scriptId) {
+        Long chapterId = scriptContentPublicDao.querySingleScriptChapterId(scriptId);
+        return chapterId.toString();
+    }
+
     @Override
     public List<ScriptContentSummaryVO> queryPublicContentList(Long scriptId, Long lastRecordId) {
         List<Long> chapterIdList = scriptContentPublicDao.queryChapterIdListOrderWithChapterId(scriptId);
@@ -55,7 +65,9 @@ public class ScriptContentPublicServiceImpl implements IScriptContentPublicServi
         return resultList;
     }
 
-    @CacheEvict(value = "script:public:chapter:id:list",key = "#scriptId")
+
+    @Caching(evict = {@CacheEvict(value = "script:public:chapter:id:list",key = "#scriptId"),
+            @CacheEvict(value = "script:chapter:chapterNum:total",key = "#scriptId")})
     public void cacheEvictChapterList(Long scriptId){
 
     }
@@ -95,4 +107,7 @@ public class ScriptContentPublicServiceImpl implements IScriptContentPublicServi
             scriptPublicDao.privateScript(scriptContent.getScriptId());
         }
     }
+
+
+
 }

+ 3 - 1
core/src/main/java/com/sp/director/module/script/service/impl/ScriptContentServiceImpl.java

@@ -134,6 +134,7 @@ public class ScriptContentServiceImpl implements IScriptContentService {
     }
 
     @Override
+    @Transactional
     public void modifyScriptContentPrivateStateByChapterId(Long chapterId) {
         LocalDateTime now = LocalDateTime.now();
         ScriptContent scriptContent = scriptContentDao.getById(chapterId);
@@ -171,7 +172,7 @@ public class ScriptContentServiceImpl implements IScriptContentService {
 
             ScriptVerify scriptVerify = scriptVerifyDao.queryScriptRecordByScriptId(scriptContent.getScriptId());
             if (Objects.isNull(scriptVerify)) {
-                Script script = scriptDao.getById(scriptVerify.getScriptId());
+                Script script = scriptDao.getById(scriptContent.getScriptId());
                 // 新增审核记录
                 scriptVerifyDao.addScriptVerifyRecord(script);
             }
@@ -181,6 +182,7 @@ public class ScriptContentServiceImpl implements IScriptContentService {
         }
 
         scriptContent.setModifyState(ModifyStateEnum.INIT);
+        scriptContent.setPrivateState(ScriptPrivateStateEnum.PUBLIC);
         scriptContentDao.updateById(scriptContent);
     }
 

+ 1 - 1
core/src/main/java/com/sp/director/module/script/service/impl/ScriptContentVerifyServiceImpl.java

@@ -45,7 +45,7 @@ public class ScriptContentVerifyServiceImpl  implements IScriptContentVerifyServ
     public void privateChapterRecord(ScriptContent scriptContent) {
         LocalDateTime now = LocalDateTime.now();
         ScriptContentVerify scriptContentVerify = scriptContentVerifyDao.queryScriptContentPublishRecord(scriptContent.getId());
-        if (Objects.isNull(scriptContentVerify)) {
+        if (Objects.nonNull(scriptContentVerify)) {
             scriptContentVerify.setLogicDelete(LogicDeleteEnum.DELETE);
             scriptContentVerify.setUpdateTime(now);
             scriptContentVerifyDao.updateById(scriptContentVerify);

+ 1 - 1
core/src/main/java/com/sp/director/module/script/service/impl/ScriptCooperateDetailServiceImpl.java

@@ -42,7 +42,7 @@ public class ScriptCooperateDetailServiceImpl implements IScriptDetailService {
      * 查询用户协作的剧本列表
      */
     @Override
-    public List<ScriptSummaryVO> listScriptSummary(Long userId, Long lastRecordId, LocalDateTime lastRecordTime) {
+    public List<ScriptSummaryVO> listScriptSummary(Long userId,String tagName, Long lastRecordId, LocalDateTime lastRecordTime) {
         List<ScriptIntroductionDTO> scriptIntroductionDTOList = new ArrayList<>();
         List<Long> scriptIdList = new ArrayList<>();
         int size = 10;

+ 8 - 2
core/src/main/java/com/sp/director/module/script/service/impl/ScriptDetailServiceImpl.java

@@ -44,7 +44,7 @@ public class ScriptDetailServiceImpl implements IScriptDetailService {
      * 查看用户的剧本列表,如果是本人,那么查看所有的剧本列表,
      * 否则查询公开的剧本列表
      */
-    public List<ScriptSummaryVO> listScriptSummary(Long userId, Long lastRecordId, LocalDateTime lastRecordTime) {
+    public List<ScriptSummaryVO> listScriptSummary(Long userId,String tagName, Long lastRecordId, LocalDateTime lastRecordTime) {
         List<ScriptIntroductionDTO> scriptIntroductionDTOList = new ArrayList<>();
         Boolean isAuthor = AuthorHelp.isAuthor(userId);
         List<Long> scriptIdList = new ArrayList<>();
@@ -85,12 +85,18 @@ public class ScriptDetailServiceImpl implements IScriptDetailService {
             vo.setScriptId(dto.getScriptId());
             vo.setUpdateTime(dto.getTime());
             List<String> writers = scriptScreenwriterService.queryRecentWritersByScriptId(dto.getScriptId(), null);
-            Integer chapterNum = scriptContentService.queryChapterNum(dto.getScriptId());
+            Integer chapterNum = 0;
+
             if(dto.getScriptType().equals(ScriptTypeEnum.SINGLE)){
                 // 查询单集的chapterId
                 String scriptContentId = scriptContentService.querySingleScriptChapterId(dto.getScriptId());
                 vo.setChapterId(scriptContentId);
+            }else{
+                chapterNum = scriptContentService.queryChapterNum(dto.getScriptId());
             }
+            vo.setIsModify(dto.getModifyState().isModify());
+            Boolean isPublic = scriptPublicDao.queryScriptIsPublish(dto.getScriptId());
+            vo.setIsPublic(isPublic);
             vo.setCooperationThumbnail(writers);
             vo.setChapterNum(chapterNum);
             list.add(vo);

+ 64 - 2
core/src/main/java/com/sp/director/module/script/service/impl/ScriptPublicServiceImpl.java

@@ -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;
+    }
 }

+ 1 - 1
core/src/main/java/com/sp/director/module/script/service/impl/ScriptPublishSummaryDetailImpl.java

@@ -27,7 +27,7 @@ public class ScriptPublishSummaryDetailImpl implements IScriptDetailService {
 
 
     @Override
-    public List<ScriptSummaryVO> listScriptSummary(Long userId, Long lastRecordId, LocalDateTime lastRecordTime) {
+    public List<ScriptSummaryVO> listScriptSummary(Long userId,String tagName, Long lastRecordId, LocalDateTime lastRecordTime) {
         // 查询发布的剧本
         List<ScriptIntroductionDTO> scriptPublishDTOList = scriptPublicDao.listAllScriptInfoByIds(userId, null,lastRecordTime);
         List<ScriptSummaryVO> sortList = scriptService.wrapAndSort(lastRecordId, scriptPublishDTOList, null);

+ 87 - 0
core/src/main/java/com/sp/director/module/script/service/impl/ScriptRecommendServiceImpl.java

@@ -0,0 +1,87 @@
+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.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.ScriptIntroductionDTO;
+import com.sp.director.module.script.service.IScriptContentPublicService;
+import com.sp.director.module.script.service.IScriptDetailService;
+import com.sp.director.module.script.vo.ScriptSummaryVO;
+import com.sp.director.utils.BeanUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @Descrption
+ * @Author: 十一
+ * @Date: 2021/3/10
+ * @Version V1.0
+ **/
+@Service
+public class ScriptRecommendServiceImpl implements IScriptDetailService {
+
+
+    @Autowired
+    private ScriptContentPublicDao scriptContentPublicDao;
+
+    @Autowired
+    private ScriptPublicDao scriptPublicDao;
+
+    @Autowired
+    private IScriptContentPublicService scriptContentPublicService;
+
+    @Autowired
+    private IUserCollectService userCollectService;
+
+
+    /**
+     * 查询推荐的剧本列表
+     * @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.listAllRecommendScriptInfo(tagName,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.setUpdateTime(dto.getTime());
+            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());
+            }
+            vo.setCooperationThumbnail(Collections.emptyList());
+            vo.setChapterNum(chapterNum);
+            Boolean collect = collectMap.get(dto.getScriptId());
+            vo.setIsCollect(collect == null ? false : collect);
+            list.add(vo);
+        }
+        return list;
+    }
+}

+ 1 - 0
core/src/main/java/com/sp/director/module/script/service/impl/ScriptScreenwriterServiceImpl.java

@@ -52,6 +52,7 @@ public class ScriptScreenwriterServiceImpl implements IScriptScreenwriterService
             for (ScriptScreenwriter record : list) {
                 if(record.getChapterId() == null || record.getChapterId().equals(chapterId)){
                     resultState = true;
+                    break;
                 }
             }
         }

+ 17 - 0
core/src/main/java/com/sp/director/module/script/service/impl/ScriptServiceImpl.java

@@ -55,6 +55,9 @@ public class ScriptServiceImpl implements IScriptService {
     private IScriptContentVerifyService scriptContentVerifyService;
 
     @Autowired
+    private IScriptPublicService scriptPublicService;
+
+    @Autowired
     private ScriptContentVerifyDao scriptContentVerifyDao;
 
     @Autowired
@@ -72,6 +75,9 @@ public class ScriptServiceImpl implements IScriptService {
     @Autowired
     private IScriptScreenwriterService scriptScreenwriterService;
 
+    @Autowired
+    private IScriptVerifyService scriptVerifyService;
+
     @Override
     @Transactional
     public Long addNewScript(Long userId, String scriptName, ScriptTypeEnum scriptType) {
@@ -96,6 +102,7 @@ public class ScriptServiceImpl implements IScriptService {
 
     @Override
     @Transactional
+    @CacheEvict(value = "script:verify:check:publish",key = "#scriptId")
     public ModifyStateEnum modifyScriptContentPrivateState(Long scriptId) {
         /**
          * 1. 将script对应的记录状态设为私有
@@ -122,6 +129,13 @@ public class ScriptServiceImpl implements IScriptService {
         return ModifyStateEnum.INIT;
     }
 
+    @Override
+    public Boolean isPublic(Long scriptId) {
+        Boolean publicIsPublish = scriptPublicService.queryScriptIsPublish(scriptId);
+        Boolean verifyIsPublish = scriptVerifyService.queryScriptIsPublish(scriptId);
+        return publicIsPublish || verifyIsPublish;
+    }
+
     private Script QueryAndVerifyScriptById(Long scriptId) {
         Script script = scriptDao.getById(scriptId);
         if (Objects.isNull(script)) {
@@ -193,6 +207,7 @@ public class ScriptServiceImpl implements IScriptService {
             BeanUtil.copyBean(dto,vo);
             vo.setScriptId(dto.getScriptId());
             vo.setUpdateTime(dto.getTime());
+            vo.setIsModify(dto.getModifyState().isModify());
             List<String> writers = scriptScreenwriterService.queryRecentWritersByScriptId(dto.getScriptId(), null);
             Integer chapterNum = scriptContentService.queryChapterNum(dto.getScriptId());
             if(dto.getScriptType().equals(ScriptTypeEnum.SINGLE)){
@@ -200,6 +215,8 @@ public class ScriptServiceImpl implements IScriptService {
                 String scriptContentId = scriptContentService.querySingleScriptChapterId(dto.getScriptId());
                 vo.setChapterId(scriptContentId);
             }
+            Boolean isPublic = scriptPublicDao.queryScriptIsPublish(dto.getScriptId());
+            vo.setIsPublic(isPublic);
             vo.setCooperationThumbnail(writers);
             vo.setChapterNum(chapterNum);
             list.add(vo);

+ 1 - 1
core/src/main/java/com/sp/director/module/script/service/impl/ScriptShareDaoImpl.java

@@ -93,7 +93,7 @@ public class ScriptShareDaoImpl extends BaseDAOImpl<ScriptShareMapper, ScriptSha
     @Override
     public List<ScriptShare> searchScriptShareByUserId(Long userId, Long scriptId) {
         QueryWrapper<ScriptShare> qw = new QueryWrapper<>();
-        qw.lambda().eq(ScriptShare::getShareUserId,userId)
+        qw.lambda().eq(ScriptShare::getUserId,userId)
                     .eq(ScriptShare::getScriptId,scriptId)
                     .eq(ScriptShare::getLogicDelete, LogicDeleteEnum.NORMAL);
         return this.list(qw);

+ 1 - 1
core/src/main/java/com/sp/director/module/script/service/impl/ScriptShareDetailServiceImpl.java

@@ -39,7 +39,7 @@ public class ScriptShareDetailServiceImpl implements IScriptDetailService {
 
     @Override
     @Transactional
-    public List<ScriptSummaryVO> listScriptSummary(Long userId, Long lastRecordId, LocalDateTime lastRecordTime) {
+    public List<ScriptSummaryVO> listScriptSummary(Long userId,String tagName, Long lastRecordId, LocalDateTime lastRecordTime) {
         List<ScriptIntroductionDTO> scriptIntroductionDTOList = new ArrayList<>();
         List<Long> scriptIdList = new ArrayList<>();
         // 查询收藏的剧本

+ 5 - 18
core/src/main/java/com/sp/director/module/script/service/impl/ScriptShareServiceImpl.java

@@ -109,24 +109,11 @@ public class ScriptShareServiceImpl implements IScriptShareService {
     public Boolean searchScriptShareByUserId(Long userId, Long scriptId, Long chapterId) {
         List<ScriptShare> list = scriptShareDao.searchScriptShareByUserId(userId, scriptId);
         boolean returnStatus = false;
-        if (list.isEmpty()) {
-            returnStatus = false;
-        } else {
-            // 判断收藏的是剧本还是章节,如果收藏的是剧本,那么章节也是被收藏的
-            // 收藏剧本
-            if (Objects.isNull(chapterId)) {
-                for (ScriptShare scriptShare : list) {
-                    if (scriptShare.getChapterId() == null) {
-                        returnStatus = true;
-                        break;
-                    }
-                }
-            }else{
-                for (ScriptShare scriptShare : list) {
-                    if (scriptShare.getChapterId().equals(chapterId) || null == scriptShare.getChapterId()) {
-                        returnStatus = true;
-                        break;
-                    }
+        if (!list.isEmpty()) {
+            for (ScriptShare scriptShare : list) {
+                if (scriptShare.getChapterId() == null || scriptShare.getChapterId().equals(chapterId)) {
+                    returnStatus = true;
+                    break;
                 }
             }
         }

+ 10 - 2
core/src/main/java/com/sp/director/module/script/service/impl/ScriptSummaryStrategyDispatcher.java

@@ -37,6 +37,12 @@ public class ScriptSummaryStrategyDispatcher implements InitializingBean {
     @Autowired
     private IScriptDetailService scriptPublishSummaryDetailImpl;
 
+    @Autowired
+    private IScriptDetailService scriptPublicServiceImpl;
+
+    @Autowired
+    private IScriptDetailService scriptRecommendServiceImpl;
+
     private static Map<ScriptOptTypeEnum,IScriptDetailService> SCRIPT_SERVICE_MAP ;
 
 
@@ -48,6 +54,8 @@ public class ScriptSummaryStrategyDispatcher implements InitializingBean {
         SCRIPT_SERVICE_MAP.put(ScriptOptTypeEnum.SHARE, scriptShareDetailServiceImpl);
         SCRIPT_SERVICE_MAP.put(ScriptOptTypeEnum.COLLECT, userCollectScriptServiceImpl);
         SCRIPT_SERVICE_MAP.put(ScriptOptTypeEnum.PUBLISH, scriptPublishSummaryDetailImpl);
+        SCRIPT_SERVICE_MAP.put(ScriptOptTypeEnum.PUBLIC_LATEST, scriptPublicServiceImpl);
+        SCRIPT_SERVICE_MAP.put(ScriptOptTypeEnum.RECOMMEND, scriptRecommendServiceImpl);
     }
 
     private IScriptDetailService dispatch(ScriptOptTypeEnum type){
@@ -58,9 +66,9 @@ public class ScriptSummaryStrategyDispatcher implements InitializingBean {
         return service;
     }
 
-    public List<ScriptSummaryVO> handle(ScriptOptTypeEnum type, Long userId, Long lastRecordId, LocalDateTime lastRecordTime){
+    public List<ScriptSummaryVO> handle(ScriptOptTypeEnum type, Long userId,String tagName, Long lastRecordId, LocalDateTime lastRecordTime){
         IScriptDetailService service = dispatch(type);
-        return service.listScriptSummary(userId, lastRecordId,lastRecordTime);
+        return service.listScriptSummary(userId, tagName,lastRecordId,lastRecordTime);
     }
 
 }

+ 10 - 0
core/src/main/java/com/sp/director/module/script/service/impl/ScriptVerifyServiceImpl.java

@@ -14,6 +14,8 @@ import com.sp.director.module.script.vo.ScriptVerifyVO;
 import com.sp.director.utils.BeanUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -52,6 +54,7 @@ public class ScriptVerifyServiceImpl implements IScriptVerifyService {
 
     @Override
     @Transactional
+    @CacheEvict(value = "script:verify:check:publish",key = "#scriptId")
     public void verifyScriptRecord(Long scriptId, List<Long> chapterList) {
         // 如果chapterList为空,说明全部审核不通过
         if(chapterList.isEmpty()){
@@ -85,6 +88,13 @@ public class ScriptVerifyServiceImpl implements IScriptVerifyService {
     }
 
     @Override
+    @Cacheable(value = "script:verify:check:publish",key = "#scriptId")
+    public Boolean queryScriptIsPublish(Long scriptId) {
+        Boolean result = scriptVerifyDao.queryScriptIsPublish(scriptId);
+        return result;
+    }
+
+    @Override
     public List<ScriptVerifyVO> queryReviewScriptList(LocalDateTime lastRecordDate, Long lastRecordId,int size) {
         List<ScriptVerifyVO> list = new ArrayList<>();
         List<ScriptVerifyDTO> verifyList = scriptVerifyDao.queryReviewRecordList(lastRecordDate, lastRecordId,size);

+ 1 - 1
core/src/main/java/com/sp/director/module/script/service/impl/UserCollectScriptServiceImpl.java

@@ -39,7 +39,7 @@ public class UserCollectScriptServiceImpl implements IScriptDetailService {
 
     @Override
     @Transactional
-    public List<ScriptSummaryVO> listScriptSummary(Long userId, Long lastRecordId, LocalDateTime lastRecordTime) {
+    public List<ScriptSummaryVO> listScriptSummary(Long userId,String tagName, Long lastRecordId, LocalDateTime lastRecordTime) {
         List<ScriptIntroductionDTO> scriptIntroductionDTOList = new ArrayList<>();
         List<Long> scriptIdList = new ArrayList<>();
         // 查询收藏的剧本

+ 5 - 3
core/src/main/java/com/sp/director/module/script/vo/CommonScriptVO.java

@@ -2,7 +2,6 @@ package com.sp.director.module.script.vo;
 
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.sp.director.config.jackson.LocalDateTimeSerializer;
-import com.sp.director.ienum.ModifyStateEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -40,7 +39,10 @@ public class CommonScriptVO implements Serializable {
     @ApiModelProperty(name="cooperationThumbnail",value="协作的缩略图")
     private List<String> cooperationThumbnail;
 
-    @ApiModelProperty(name="scriptModifyStatus",value="剧本修改状态")
-    private ModifyStateEnum scriptModifyStatus;
+    @ApiModelProperty(name="isPublic",value="是否发布")
+    private Boolean isPublic;
+
+    @ApiModelProperty(name="isModify",value="是否修改")
+    private Boolean isModify;
 
 }

+ 5 - 4
core/src/main/java/com/sp/director/module/script/vo/ScriptPublishModifyVO.java

@@ -16,9 +16,10 @@ import java.io.Serializable;
 @ApiModel("剧本发布修改VO")
 public class ScriptPublishModifyVO implements Serializable {
 
-    @ApiModelProperty(name="isModify",value="修改状态:0:未修改,1:已修改")
-    private Boolean isModify;
 
-    @ApiModelProperty(name="isPublish",value="发布状态")
-    private Boolean isPublish;
+    @ApiModelProperty(name="isPublic",value="是否发布")
+    private Boolean isPublic;
+
+    @ApiModelProperty(name="isModify",value="是否修改")
+    private Boolean isModify;
 }

+ 3 - 0
core/src/main/java/com/sp/director/module/script/vo/ScriptSummaryVO.java

@@ -43,6 +43,9 @@ public class ScriptSummaryVO extends CommonScriptVO {
     @ApiModelProperty(name="chapterId",value="章节id")
     private String chapterId;
 
+    @ApiModelProperty(name="isCollect",value="是否收藏")
+    private Boolean isCollect = false;
+
     public void setScriptId(Long scriptId) {
         this.scriptId = scriptId.toString();
     }

+ 1 - 0
core/src/main/resources/com/sp/director/module/script/dao/xml/ScriptMapper.xml

@@ -80,6 +80,7 @@
                 script_type scriptType,
                 modify_state modifyState,
                 IF(mark_time is null,0,1) markStatus,
+                modify_state modifyState,
                 <include refid="timeCondition"/> sortTime
         from t_script s
         <where>

+ 9 - 10
core/src/main/resources/com/sp/director/module/script/dao/xml/ScriptPublicMapper.xml

@@ -11,23 +11,22 @@
             cover_img coverImg,
             tag_name tagName,
             introduction introduction,
-            script_type scriptType
+            script_type scriptType,
+            modify_state modifyState
         from t_script_public s
         <where>
             s.logic_delete = 0
             and private_state = 0
-            <if test="userId != null">
-              and  s.author_id = #{userId}
-            </if>
-            <if test="scriptList != null">
-                and s.script_id in
-                <foreach collection="scriptList" item="scriptId" open="(" separator="," close=")">
-                    #{scriptId}
-                </foreach>
-            </if>
             <if test="lastRecordTime != null">
                 and s.create_time <![CDATA[<]]> #{lastRecordTime}
             </if>
+            <if test="tagName != null">
+                and s.tag_name = #{tagName}
+            </if>
+            <if test="isRecommend == true">
+                and s.recommend_state = 1
+                and s.private_state = 0
+            </if>
         </where>
         order by
         s.create_time desc

+ 21 - 0
core/src/main/resources/com/sp/director/module/usercollect/dao/xml/UserCollectMapper.xml

@@ -22,6 +22,7 @@
         limit ${size}
     </select>
 
+
     <select id="statisticCollectCount" resultType="java.lang.Integer">
         select count(DISTINCT(script_id)) count
             from t_user_collect uc
@@ -32,4 +33,24 @@
             </if>
         </where>
     </select>
+
+    <select id="queryUserCollect" resultType="com.sp.director.module.collect.dto.UserCollectDTO">
+        select
+                tuc.script_id scriptId,
+                tuc.update_time updateTime
+        from t_user_collect tuc
+        <where>
+            tuc.logic_delete = 0
+            and tuc.chapter_id is null
+            <if test="userId != null">
+              and  tuc.user_id = 10001001
+            </if>
+             <if test="scriptIdList != null and scriptIdList.size > 0">
+                 and tuc.script_id in
+                 <foreach collection="scriptIdList" index="scriptId" open="(" separator="," close=")">
+                     #{scriptId}
+                 </foreach>
+             </if>
+        </where>
+    </select>
 </mapper>

+ 8 - 0
logic/pom.xml

@@ -19,6 +19,14 @@
     </properties>
 
     <dependencies>
+
+        <!-- https://mvnrepository.com/artifact/com.alibaba/easyexcel -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel</artifactId>
+            <version>2.2.7</version>
+        </dependency>
+
         <dependency>
             <groupId>com.sp</groupId>
             <artifactId>core</artifactId>

+ 9 - 16
logic/src/main/java/com/sp/director/module/script/script/controller/ScriptContentController.java

@@ -7,7 +7,6 @@ import com.sp.director.exception.BusinessException;
 import com.sp.director.exception.ParamException;
 import com.sp.director.http.MJson;
 import com.sp.director.ienum.ModifyStateEnum;
-import com.sp.director.ienum.ScriptOptTypeEnum;
 import com.sp.director.ienum.ScriptPrivateStateEnum;
 import com.sp.director.ienum.ScriptTypeEnum;
 import com.sp.director.module.script.dao.ScriptContentDao;
@@ -103,7 +102,7 @@ public class ScriptContentController {
         vo.setChapterId(chapterId.toString());
         vo.setCooperationThumbnail(Collections.emptyList());
         vo.setMarkStatus(false);
-        vo.setScriptModifyStatus(script.getModifyState());
+        vo.setIsModify(script.getModifyState().isModify());
         vo.setTagName("默认");
         vo.setTitle(title);
         vo.setIntroduction(null);
@@ -316,33 +315,27 @@ public class ScriptContentController {
     })
     public MJson<Boolean> publishChapter(@ApiIgnore UserLoginInfo userLoginInfo,
                                       @Valid @NotNull(message="chapterId不能为空") Long chapterId,
-                                         @Valid @NotNull(message="type不能为空") ScriptOptTypeEnum type) {
+                                         @Valid @NotNull(message="type不能为空") ScriptPrivateStateEnum type) {
         ScriptContent scriptContent = scriptContentDao.getById(chapterId);
         Script script = scriptDao.getById(scriptContent.getScriptId());
         if(Objects.isNull(script) || !script.getAuthorId().equals(userLoginInfo.getUserId())){
             throw new ParamException();
         }
         // 发布
-        if(ScriptOptTypeEnum.PUBLISH.equals(type)){
-            if (!ModifyStateEnum.MODIFY.equals(scriptContent.getModifyState()) ||
-                    !ScriptPrivateStateEnum.PRIVATE.equals(scriptContent.getPrivateState())) {
+        if(ScriptPrivateStateEnum.PUBLIC.equals(type)){
+            if (ModifyStateEnum.MODIFY.equals(scriptContent.getModifyState()) ||
+                    ScriptPrivateStateEnum.PRIVATE.equals(scriptContent.getPrivateState())) {
+                scriptContentService.publishScriptContent(scriptContent);
+            }else{
                 throw new BusinessException("当前章节不能被发布");
             }
-            scriptContentService.publishScriptContent(scriptContent);
+
         // 仅自己可见
         }else{
             scriptContentService.modifyScriptContentPrivateStateByChapterId(chapterId);
         }
 
-        if(scriptContent.getPublishTime() == null ){
-            scriptContent.setPublishTime(LocalDateTime.now());
-            scriptContent.setModifyState(ModifyStateEnum.INIT);
-        }else{
-            scriptContent.setPublishTime(null);
-            scriptContent.setModifyState(ModifyStateEnum.INIT);
-        }
-        scriptContentDao.updateById(scriptContent);
-        return MJson.ok(Objects.nonNull(scriptContent.getPublishTime()));
+        return MJson.ok(ScriptPrivateStateEnum.PUBLIC.equals(type));
     }
 
 }

+ 12 - 6
logic/src/main/java/com/sp/director/module/script/script/controller/ScriptController.java

@@ -105,8 +105,11 @@ public class ScriptController {
                 String scriptContentId = scriptContentService.querySingleScriptChapterId(dto.getScriptId());
                 vo.setChapterId(scriptContentId);
             }
+            Boolean isPublic = scriptService.isPublic(dto.getScriptId());
             vo.setCooperationThumbnail(writers);
             vo.setChapterNum(chapterNum);
+            vo.setIsPublic(isPublic);
+            vo.setIsModify(dto.getModifyState().isModify());
             list.add(vo);
         }
         return MJson.ok(list);
@@ -117,11 +120,12 @@ public class ScriptController {
     @ApiOperation(value="全部的剧本列表")
     @GetMapping("list/all")
     @Authentication
-    public MJson<List<ScriptSummaryVO>> allScriptList(@ApiIgnore UserLoginInfo userLoginInfo,
+    public MJson<List<ScriptSummaryVO>> allScriptList(
                                                    @Valid ScriptSummaryParam param) {
         // 我的剧本列表、共享的剧本列表、协作的剧本列表、收藏的剧本列表
         List<ScriptSummaryVO> result = scriptSummaryStrategyDispatcher.handle(param.getType(),
                                             param.getUserId(),
+                                            param.getTagName(),
                                             param.getLastRecordId(),
                                             param.getLastRecordTime());
         return MJson.ok(result);
@@ -160,7 +164,7 @@ public class ScriptController {
         vo.setCoverImg(null);
         vo.setScriptType(scriptType);
         vo.setMarkStatus(false);
-        vo.setScriptModifyStatus(status);
+        vo.setIsModify(status.isModify());
         vo.setTagName("默认");
         vo.setTitle(title);
         return vo;
@@ -180,13 +184,15 @@ public class ScriptController {
         List<String> writers = scriptScreenwriterService.queryRecentWritersByScriptId(param.getScriptId(), null);
         Integer chapterNum = scriptContentService.queryChapterNum(param.getScriptId());
         ScriptSummaryVO vo = wrapperScriptVO(script.getTitle(), script.getScriptType(), script.getId(),ModifyStateEnum.MODIFY);
+        Boolean isPublic = scriptService.isPublic(param.getScriptId());
         // 查询
-        vo.setScriptModifyStatus(script.getModifyState());
+        vo.setIsModify(script.getModifyState().isModify());
         vo.setMarkStatus(Objects.nonNull(script.getMarkTime()));
         vo.setChapterNum(chapterNum);
         vo.setCooperationThumbnail(writers);
         vo.setSortTime(script.getUpdateTime());
         vo.setUpdateTime(script.getUpdateTime());
+        vo.setIsPublic(isPublic);
         vo.setCoverImg(param.getCoverImg());
         vo.setIntroduction(script.getIntroduction());
         return MJson.ok(vo);
@@ -283,9 +289,9 @@ public class ScriptController {
             modifyState = scriptService.modifyScriptContentPrivateState(scriptId);
         }
         // 查询剧本是否有发布
-        Boolean isPublish  = scriptPublicService.queryScriptIsPublish(scriptId);
-        vo.setIsModify(modifyState.equals(ModifyStateEnum.MODIFY));
-        vo.setIsPublish(isPublish);
+        Boolean isPublic  = scriptService.isPublic(scriptId);
+        vo.setIsModify(modifyState.isModify());
+        vo.setIsPublic(isPublic);
         return MJson.ok(vo);
     }
 

+ 6 - 0
logic/src/main/java/com/sp/director/module/script/script/controller/ScriptScreenWriterController.java

@@ -14,6 +14,7 @@ import com.sp.director.module.script.service.IScriptScreenwriterService;
 import com.sp.director.module.script.service.IScriptShareService;
 import com.sp.director.module.script.vo.ScriptCommonUserVO;
 import com.sp.director.module.script.vo.ShareOrCooperationSearchResultVO;
+import com.sp.director.module.user.entity.User;
 import com.sp.director.module.user.service.IUserService;
 import com.sp.director.module.user.service.IUserValidService;
 import com.sp.director.module.user.vo.CommonUserBaseVO;
@@ -177,4 +178,9 @@ public class ScriptScreenWriterController {
         return script;
     }
 
+    public static void main(String[] args) {
+        User user = new User();
+        System.out.println();
+    }
+
 }

+ 67 - 0
logic/src/test/java/com/sp/word/ExcelRead.java

@@ -0,0 +1,67 @@
+package com.sp.word;
+
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.ExcelReader;
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.alibaba.excel.read.metadata.ReadSheet;
+import com.alibaba.fastjson.JSON;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Descrption
+ * @Author: 十一
+ * @Date: 2021/3/10
+ * @Version V1.0
+ **/
+public class ExcelRead {
+    public static List<WordData> list = new ArrayList<WordData>();
+
+
+    public static void main(String[] args) {
+        ExcelReader excelReader = null;
+        ReadSheet readSheet1;
+        String fileName = "/Users/shiyi/Desktop/myWord.xlsx";
+        try {
+            excelReader = EasyExcel.read(fileName,new IndexOrNameDataListener()).build();
+            // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener
+            for (int i = 0; i < 26; i++) {
+                readSheet1 =
+                        EasyExcel.readSheet(i).head(WordData.class).registerReadListener(new IndexOrNameDataListener()).build();
+                excelReader.read(readSheet1);
+            }
+
+        }catch (Exception e){
+            System.out.println(e);
+        }finally {
+            System.out.println(JSON.toJSON(list));
+        }
+    }
+}
+
+class IndexOrNameDataListener extends AnalysisEventListener<WordData> {
+    /**
+     * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收
+     */
+    private static final int BATCH_COUNT = 5;
+//    List<WordData> list = new ArrayList<WordData>();
+
+    @Override
+    public void invoke(WordData data, AnalysisContext context) {
+        ExcelRead.list.add(data);
+    }
+
+    @Override
+    public void doAfterAllAnalysed(AnalysisContext context) {
+//        System.out.println("所有数据解析完成");
+    }
+
+    /**
+     * 加上存储数据库
+     */
+    private void saveData() {
+
+    }
+}

+ 10 - 0
logic/src/test/java/com/sp/word/WordData.java

@@ -0,0 +1,10 @@
+package com.sp.word;
+
+import lombok.Data;
+
+@Data
+public class WordData{
+
+    private String english;
+    private String chinese;
+}