shiyi 3 年之前
父節點
當前提交
dad2970747
共有 60 個文件被更改,包括 1157 次插入160 次删除
  1. 3 0
      core/src/main/java/com/sp/director/module/focus/dao/UserFocusDao.java
  2. 12 0
      core/src/main/java/com/sp/director/module/focus/dao/impl/UserFocusDaoImpl.java
  3. 11 0
      core/src/main/java/com/sp/director/module/focus/service/IUserFocusService.java
  4. 10 0
      core/src/main/java/com/sp/director/module/focus/service/impl/UserFocusServiceImpl.java
  5. 0 20
      core/src/main/java/com/sp/director/module/report/controller/ReportController.java
  6. 7 0
      core/src/main/java/com/sp/director/module/script/dao/ScriptMarkDao.java
  7. 1 0
      core/src/main/java/com/sp/director/module/script/dao/ScriptPublicDao.java
  8. 16 0
      core/src/main/java/com/sp/director/module/script/dao/ScriptReferenceDao.java
  9. 5 0
      core/src/main/java/com/sp/director/module/script/dao/ScriptShareDao.java
  10. 9 0
      core/src/main/java/com/sp/director/module/script/dao/impl/ScriptMarkDaoImpl.java
  11. 9 0
      core/src/main/java/com/sp/director/module/script/dao/impl/ScriptPublicDaoImpl.java
  12. 25 0
      core/src/main/java/com/sp/director/module/script/dao/impl/ScriptReferenceDaoImpl.java
  13. 1 0
      core/src/main/java/com/sp/director/module/script/dao/impl/ScriptScreenwriterDaoImpl.java
  14. 68 0
      core/src/main/java/com/sp/director/module/script/entity/ScriptReference.java
  15. 5 0
      core/src/main/java/com/sp/director/module/script/entity/ScriptScreenwriter.java
  16. 3 0
      core/src/main/java/com/sp/director/module/script/entity/ScriptShare.java
  17. 18 0
      core/src/main/java/com/sp/director/module/script/service/IScriptContentIntroductionService.java
  18. 0 12
      core/src/main/java/com/sp/director/module/script/service/IScriptContentService.java
  19. 8 0
      core/src/main/java/com/sp/director/module/script/service/IScriptPublicService.java
  20. 38 0
      core/src/main/java/com/sp/director/module/script/service/IScriptReferenceService.java
  21. 47 0
      core/src/main/java/com/sp/director/module/script/service/impl/AbstractScriptContentIntroductionService.java
  22. 34 4
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptContentPublicServiceImpl.java
  23. 2 24
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptContentServiceImpl.java
  24. 0 8
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptCooperateDetailServiceImpl.java
  25. 1 14
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptDetailServiceImpl.java
  26. 49 20
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptMarkServiceImpl.java
  27. 3 3
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptNodeEditServiceImpl.java
  28. 6 1
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptPublicServiceImpl.java
  29. 39 0
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptReferenceServiceImpl.java
  30. 4 2
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptScreenwriterServiceImpl.java
  31. 4 1
      core/src/main/java/com/sp/director/module/script/service/impl/ScriptServiceImpl.java
  32. 4 5
      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/ScriptShareServiceImpl.java
  34. 22 0
      core/src/main/java/com/sp/director/module/video/dao/UserVideoRecommendDao.java
  35. 2 0
      core/src/main/java/com/sp/director/module/video/dao/VideoLikeDao.java
  36. 48 0
      core/src/main/java/com/sp/director/module/video/dao/impl/UserVideoRecommendDaoImpl.java
  37. 9 0
      core/src/main/java/com/sp/director/module/video/dao/impl/VideoLikeDaoImpl.java
  38. 27 0
      core/src/main/java/com/sp/director/module/video/dto/UserVideoRecommendDTO.java
  39. 17 2
      core/src/main/java/com/sp/director/module/video/entity/UserVideo.java
  40. 88 0
      core/src/main/java/com/sp/director/module/video/entity/UserVideoRecommend.java
  41. 7 3
      core/src/main/java/com/sp/director/module/video/param/UserPublishVideoParam.java
  42. 46 0
      core/src/main/java/com/sp/director/module/video/service/IUserVideoRecommendService.java
  43. 1 1
      core/src/main/java/com/sp/director/module/video/service/IUserVideoService.java
  44. 11 0
      core/src/main/java/com/sp/director/module/video/service/IVideoLikeService.java
  45. 102 0
      core/src/main/java/com/sp/director/module/video/service/impl/UserVideoRecommendServiceImpl.java
  46. 11 5
      core/src/main/java/com/sp/director/module/video/service/impl/UserVideoServiceImpl.java
  47. 8 0
      core/src/main/java/com/sp/director/module/video/service/impl/VideoLikeServiceImpl.java
  48. 38 0
      core/src/main/java/com/sp/director/module/video/vo/UserVideoVO.java
  49. 2 2
      core/src/main/java/com/sp/director/utils/CodeGenerator.java
  50. 6 2
      core/src/main/resources/com/sp/director/module/script/dao/xml/ScriptContentMapper.xml
  51. 2 2
      core/src/main/resources/com/sp/director/module/script/dao/xml/ScriptContentPublicMapper.xml
  52. 2 3
      core/src/main/resources/com/sp/director/module/script/dao/xml/ScriptPublicMapper.xml
  53. 6 0
      core/src/main/resources/com/sp/director/module/script/dao/xml/ScriptShareMapper.xml
  54. 27 0
      core/src/main/resources/com/sp/director/module/video/dao/xml/VideoRecommendMapper.xml
  55. 2 13
      logic/src/main/java/com/sp/director/module/script/script/controller/ScriptContentController.java
  56. 19 4
      logic/src/main/java/com/sp/director/module/script/script/controller/ScriptController.java
  57. 6 6
      logic/src/main/java/com/sp/director/module/userindex/controller/UserIndexController.java
  58. 88 0
      logic/src/main/java/com/sp/director/module/video/controller/UserVideoRecommendController.java
  59. 3 2
      logic/src/main/java/com/sp/director/module/video/controller/VideoController.java
  60. 114 0
      logic/src/test/java/com/sp/module/video/VideoTest.java

+ 3 - 0
core/src/main/java/com/sp/director/module/focus/dao/UserFocusDao.java

@@ -3,6 +3,8 @@ package com.sp.director.module.focus.dao;
 import com.sp.director.module.focus.entity.UserFocus;
 import com.sp.director.mybatis.plus.IBaseDAO;
 
+import java.util.List;
+
 /**
  * <p>
  * 用户关注 Mapper 接口
@@ -25,4 +27,5 @@ public interface UserFocusDao extends IBaseDAO<UserFocus> {
 
     UserFocus checkFocus(Long userId, Long focusUserId);
 
+    List<UserFocus> checkUserFocusByFocusUserIdList(Long userId, List<Long> userIdList);
 }

+ 12 - 0
core/src/main/java/com/sp/director/module/focus/dao/impl/UserFocusDaoImpl.java

@@ -13,6 +13,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 /**
  * @Descrption
  * @Author: 十一
@@ -35,9 +37,19 @@ public class UserFocusDaoImpl extends BaseDAOImpl<UserFocusMapper, UserFocus> im
     }
 
     @Override
+    public List<UserFocus> checkUserFocusByFocusUserIdList(Long userId, List<Long> userIdList) {
+        QueryWrapper<UserFocus> qw = new QueryWrapper<>();
+        qw.lambda().eq(UserFocus::getUserId,userId)
+                .eq(UserFocus::getLogicDelete,LogicDeleteEnum.NORMAL)
+                .in(UserFocus::getFocusUserId,userIdList);
+        return this.list(qw);
+    }
+
+    @Override
     public UserFocus checkFocus(Long userId, Long focusUserId) {
         QueryWrapper<UserFocus> qw = new QueryWrapper<>();
         qw.lambda().eq(UserFocus::getUserId,userId)
+                    .eq(UserFocus::getLogicDelete,LogicDeleteEnum.NORMAL)
                     .eq(UserFocus::getFocusUserId,focusUserId);
         UserFocus userFocus = this.getOne(qw);
         return userFocus;

+ 11 - 0
core/src/main/java/com/sp/director/module/focus/service/IUserFocusService.java

@@ -1,5 +1,8 @@
 package com.sp.director.module.focus.service;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 用户关注 服务类
@@ -46,4 +49,12 @@ public interface IUserFocusService {
      * @return
      */
     boolean checkFocus(Long userId, Long focusUserId);
+
+    /**
+     * 批量查询用户关注信息
+     * @param userId
+     * @param userIdList
+     * @return
+     */
+    Map<Long, Long> checkUserFocusByFocusUserIdList(Long userId, List<Long> userIdList);
 }

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

@@ -12,6 +12,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -72,6 +75,13 @@ public class UserFocusServiceImpl implements IUserFocusService {
     }
 
     @Override
+    public Map<Long, Long> checkUserFocusByFocusUserIdList(Long userId, List<Long> userIdList) {
+        List<UserFocus> userFocusList = userFocusDao.checkUserFocusByFocusUserIdList(userId, userIdList);
+        Map<Long, Long> map = userFocusList.stream().collect(Collectors.toMap(UserFocus::getFocusUserId, UserFocus::getFocusUserId));
+        return map;
+    }
+
+    @Override
     public boolean checkFocus(Long userId, Long focusUserId) {
         UserFocus userFocus = userFocusDao.checkFocus(userId, focusUserId);
         if(userFocus == null || userFocus.getLogicDelete().equals(LogicDeleteEnum.DELETE)){

+ 0 - 20
core/src/main/java/com/sp/director/module/report/controller/ReportController.java

@@ -1,20 +0,0 @@
-package com.sp.director.module.report.controller;
-
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.stereotype.Controller;
-
-/**
- * <p>
- * 举报内容表 前端控制器
- * </p>
- *
- * @author 十一
- * @since 2021-03-01
- */
-@Controller
-@RequestMapping("/report")
-public class ReportController {
-
-}

+ 7 - 0
core/src/main/java/com/sp/director/module/script/dao/ScriptMarkDao.java

@@ -54,4 +54,11 @@ public interface ScriptMarkDao extends IBaseDAO<ScriptMark> {
      */
     List<ScriptMarkDTO> queryMarkScriptContentIdByUserIdOrderByUpdateTime(Long userId);
 
+    /**
+     * 查询单集的剧本记录列表
+     * @param userId
+     * @param scriptId
+     * @return
+     */
+    List<ScriptMark> querySingleTypeScriptMarkRecordList(Long userId, Long scriptId);
 }

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

@@ -54,4 +54,5 @@ public interface ScriptPublicDao extends IBaseDAO<ScriptPublic> {
     List<ScriptIntroductionDTO> listAllRecommendScriptInfo(String tagName, LocalDateTime lastRecordTime);
 
 
+    int statisticScriptPublishNum(Long userId);
 }

+ 16 - 0
core/src/main/java/com/sp/director/module/script/dao/ScriptReferenceDao.java

@@ -0,0 +1,16 @@
+package com.sp.director.module.script.dao;
+
+import com.sp.director.module.script.entity.ScriptReference;
+import com.sp.director.mybatis.plus.IBaseDAO;
+
+/**
+ * <p>
+ * 剧本引用 Mapper 接口
+ * </p>
+ *
+ * @author 十一
+ * @since 2021-03-18
+ */
+public interface ScriptReferenceDao extends IBaseDAO<ScriptReference> {
+
+}

+ 5 - 0
core/src/main/java/com/sp/director/module/script/dao/ScriptShareDao.java

@@ -24,6 +24,11 @@ public interface ScriptShareDao extends IBaseDAO<ScriptShare> {
 
     void removeUser(Long userId, Long scriptId);
 
+    /**
+     * 统计分享给我的剧本数量
+     * @param userId
+     * @return
+     */
     int statisticShareCount(Long userId);
 
     /**

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

@@ -34,6 +34,15 @@ public class ScriptMarkDaoImpl extends BaseDAOImpl<ScriptMarkMapper, ScriptMark>
 
 
     @Override
+    public List<ScriptMark> querySingleTypeScriptMarkRecordList(Long userId, Long scriptId) {
+        QueryWrapper<ScriptMark> qw = new QueryWrapper<>();
+        qw.lambda().eq(ScriptMark::getLogicDelete, LogicDeleteEnum.NORMAL)
+                .eq(ScriptMark::getUserId,userId)
+                .eq(ScriptMark::getScriptId,scriptId);
+        return this.list(qw);
+    }
+
+    @Override
     public List<ScriptMarkDTO> queryMarkScriptContentIdByUserIdOrderByUpdateTime(Long userId) {
         QueryWrapper<ScriptMark> qw = new QueryWrapper<>();
         qw.lambda().eq(ScriptMark::getUserId,userId)

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

@@ -32,6 +32,15 @@ public class ScriptPublicDaoImpl extends BaseDAOImpl<ScriptPublicMapper, ScriptP
     private ScriptPublicMapper scriptPublicMapper;
 
     @Override
+    public int statisticScriptPublishNum(Long userId) {
+        QueryWrapper<ScriptPublic> qw = new QueryWrapper<>();
+        qw.lambda().eq(ScriptPublic::getAuthorId,userId)
+                    .eq(ScriptPublic::getLogicDelete,LogicDeleteEnum.NORMAL)
+                    .eq(ScriptPublic::getPrivateState,ScriptPrivateStateEnum.PUBLIC);
+        return this.count(qw);
+    }
+
+    @Override
     public List<ScriptIntroductionDTO> listAllRecommendScriptInfo(String tagName, LocalDateTime lastRecordTime) {
         return scriptPublicMapper.listAllPublicScript(null,tagName, null,lastRecordTime, true);
     }

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

@@ -0,0 +1,25 @@
+package com.sp.director.module.script.dao.impl;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sp.director.module.script.dao.ScriptReferenceDao;
+import com.sp.director.module.script.entity.ScriptReference;
+import com.sp.director.mybatis.plus.BaseDAOImpl;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @Descrption
+ * @Author: 十一
+ * @Date: 2021/3/18
+ * @Version V1.0
+ **/
+@Repository
+public class ScriptReferenceDaoImpl extends BaseDAOImpl<ScriptReferenceMapper, ScriptReference> implements ScriptReferenceDao {
+
+
+}
+@Mapper
+@Component
+interface ScriptReferenceMapper extends BaseMapper<ScriptReference> {
+}

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

@@ -114,6 +114,7 @@ public class ScriptScreenwriterDaoImpl
         QueryWrapper<ScriptScreenwriter> qw = new QueryWrapper<>();
         qw.lambda().eq(ScriptScreenwriter::getLogicDelete, LogicDeleteEnum.NORMAL)
                 .eq(ScriptScreenwriter::getScriptId, scriptId)
+                .eq(ScriptScreenwriter::getCreative,CreativeStatusEnum.COLLABORATOR)
                 .orderByAsc(ScriptScreenwriter::getId);
         List<ScriptScreenwriter> list = this.list(qw);
         List<ShareOrCooperationDTO> resultList = new ArrayList<>();

+ 68 - 0
core/src/main/java/com/sp/director/module/script/entity/ScriptReference.java

@@ -0,0 +1,68 @@
+package com.sp.director.module.script.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.sp.director.ienum.LogicDeleteEnum;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 剧本引用
+ * </p>
+ *
+ * @author 十一
+ * @since 2021-03-18
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("t_script_reference")
+public class ScriptReference extends Model<ScriptReference> {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * id
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 剧本id
+     */
+    private Long scriptId;
+
+    /**
+     * 引用的剧本id
+     */
+    private Long referenceScriptId;
+
+    /**
+     * 用用的章节id
+     */
+    private Long referenceChapterId;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+
+    /**
+     * 逻辑删除
+     */
+    private LogicDeleteEnum logicDelete;
+
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+}

+ 5 - 0
core/src/main/java/com/sp/director/module/script/entity/ScriptScreenwriter.java

@@ -41,6 +41,11 @@ public class ScriptScreenwriter extends Model<ScriptScreenwriter> {
     private Long scriptId;
 
     /**
+     * 作者id
+     */
+    private Long authorId;
+
+    /**
      * 用户id
      */
     private Long userId;

+ 3 - 0
core/src/main/java/com/sp/director/module/script/entity/ScriptShare.java

@@ -1,5 +1,7 @@
 package com.sp.director.module.script.entity;
 
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.sp.director.ienum.LogicDeleteEnum;
@@ -29,6 +31,7 @@ public class ScriptShare extends Model<ScriptShare> {
     /**
      * id
      */
+    @TableId(type = IdType.AUTO)
     private Long id;
 
     /**

+ 18 - 0
core/src/main/java/com/sp/director/module/script/service/IScriptContentIntroductionService.java

@@ -0,0 +1,18 @@
+package com.sp.director.module.script.service;
+
+import com.sp.director.module.script.param.ScriptNode;
+
+import java.util.Map;
+
+/**
+ * @Descrption
+ * @Author: 十一
+ * @Date: 2021/3/18
+ * @Version V1.0
+ **/
+public interface IScriptContentIntroductionService {
+
+    String queryChapterIntroduction(Long scriptContentId);
+
+    Map<String, ScriptNode> getContentByChapterId(Long chapterId);
+}

+ 0 - 12
core/src/main/java/com/sp/director/module/script/service/IScriptContentService.java

@@ -3,14 +3,11 @@ package com.sp.director.module.script.service;
 
 import com.sp.director.ienum.ScriptStatus;
 import com.sp.director.module.script.dto.ScriptContentDTO;
-import com.sp.director.module.script.dto.ScriptContentInfoDTO;
 import com.sp.director.module.script.entity.ScriptContent;
-import com.sp.director.module.script.param.ScriptNode;
 import com.sp.director.module.script.vo.BaseChapterInfoVO;
 import com.sp.director.module.script.vo.ScriptContentSummaryVO;
 
 import java.util.List;
-import java.util.Map;
 
 /**
  * <p>
@@ -22,8 +19,6 @@ import java.util.Map;
  */
 public interface IScriptContentService {
 
-    Map<String, ScriptNode> getContentByChapterId(Long chapterId);
-
     Long createScriptContent(Long userId, String title, Long scriptId);
 
     /**
@@ -42,13 +37,6 @@ public interface IScriptContentService {
     void updateDoc(Long userId,ScriptContentDTO scriptContentDTO);
 
     /**
-     * 根据章节id查询剧本简介
-     * @param chapterId
-     * @return
-     */
-    String queryChapterIntroduction(Long chapterId);
-
-    /**
      * 查询剧本章节的数量
      * @param scriptId
      * @return

+ 8 - 0
core/src/main/java/com/sp/director/module/script/service/IScriptPublicService.java

@@ -45,4 +45,12 @@ public interface IScriptPublicService {
     List<ScriptSummaryVO> queryPublicScript(Long userId, Long lastRecordId,
                                             LocalDateTime lastRecordTime,
                                             List<ScriptMarkDTO> scriptCollectDTOList);
+
+    /**
+     * 统计剧本发布数量
+     * @param userId
+     * @return
+     */
+    int statisticScriptPublishNum(Long userId);
+
 }

+ 38 - 0
core/src/main/java/com/sp/director/module/script/service/IScriptReferenceService.java

@@ -0,0 +1,38 @@
+package com.sp.director.module.script.service;
+
+import com.sp.director.module.script.entity.ScriptReference;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 剧本引用 服务类
+ * </p>
+ *
+ * @author 十一
+ * @since 2021-03-18
+ */
+public interface IScriptReferenceService {
+
+    /**
+     * 新增剧本引用
+     * @param scriptId
+     * @param referenceScriptId
+     * @param referenceChapterId
+     */
+    void addReference(Long scriptId, Long referenceScriptId, Long referenceChapterId);
+
+    /**
+     * 移除单集剧本引用
+     * @param scriptId
+     * @param referenceChapterId
+     */
+    void removeReference(Long scriptId, Long referenceChapterId);
+
+    /**
+     * 查询出所有的剧本引用
+     * @param scriptId
+     * @return
+     */
+    List<ScriptReference> listReferenceByScriptId(Long scriptId);
+}

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

@@ -0,0 +1,47 @@
+package com.sp.director.module.script.service.impl;
+
+import com.sp.director.module.script.param.ScriptNode;
+import com.sp.director.module.script.service.IScriptContentIntroductionService;
+import com.sp.director.support.cache.DefaultCacheManager;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * @Descrption
+ * @Author: 十一
+ * @Date: 2021/3/18
+ * @Version V1.0
+ **/
+public abstract class AbstractScriptContentIntroductionService implements IScriptContentIntroductionService {
+
+//    @Override
+//    public String queryChapterIntroduction(Long scriptContentId) {
+//        throw new BusinessException();
+//    }
+
+    public String getIntroduction(DefaultCacheManager defaultCacheManager,String key,Long chapterId){
+        String introduction = defaultCacheManager.getValue(key);
+        if (Objects.isNull(introduction)) {
+            Map<String, ScriptNode> map = this.getContentByChapterId(chapterId);
+            StringBuffer sb = new StringBuffer();
+            if (Objects.nonNull(map)) {
+                // 截取前70个字符
+                int size = 70;
+                Iterator<ScriptNode> iterator = map.values().iterator();
+                while (iterator.hasNext()) {
+                    ScriptNode node = iterator.next();
+                    sb.append(node.getContent());
+                    if (sb.length() >= size) {
+                        break;
+                    }
+                }
+                introduction = sb.toString();
+                defaultCacheManager.cacheValue(key, introduction);
+            }
+        }
+        return introduction;
+    }
+
+}

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

@@ -1,22 +1,25 @@
 package com.sp.director.module.script.service.impl;
 
+import com.alibaba.fastjson.JSON;
+import com.sp.director.exception.ParamException;
 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.ScriptMarkDTO;
 import com.sp.director.module.script.entity.ScriptContent;
 import com.sp.director.module.script.entity.ScriptContentPublic;
+import com.sp.director.module.script.param.ScriptNode;
 import com.sp.director.module.script.service.IScriptContentPublicService;
 import com.sp.director.module.script.service.IScriptMarkService;
 import com.sp.director.module.script.vo.ScriptContentSummaryVO;
+import com.sp.director.support.cache.DefaultCacheManager;
+import com.sp.director.utils.StringUtil;
 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.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -28,12 +31,15 @@ import java.util.stream.Collectors;
  * @since 2021-03-05
  */
 @Service
-public class ScriptContentPublicServiceImpl implements IScriptContentPublicService {
+public class ScriptContentPublicServiceImpl extends AbstractScriptContentIntroductionService  implements IScriptContentPublicService {
 
     @Autowired
     private ScriptContentPublicDao scriptContentPublicDao;
 
     @Autowired
+    private DefaultCacheManager defaultCacheManager;
+
+    @Autowired
     private ScriptPublicDao scriptPublicDao;
 
     @Autowired
@@ -162,6 +168,30 @@ public class ScriptContentPublicServiceImpl implements IScriptContentPublicServi
         }
     }
 
+    @Override
+    @Cacheable(value = "script:content:public:map", key = "#chapterId", condition = "#chapterId != null")
+    public Map<String, ScriptNode> getContentByChapterId(Long chapterId) {
+        if (Objects.isNull(chapterId)) {
+            throw new ParamException();
+        }
+        List<ScriptNode> scriptNodeList = new ArrayList<>();
+        Map<String, ScriptNode> contentNodeMap = new LinkedHashMap<>();
+        ScriptContentPublic scriptContentPublic = scriptContentPublicDao.getById(Long.valueOf(chapterId));
+        if (scriptContentPublic != null && StringUtil.isNotBlank(scriptContentPublic.getContent())) {
+            String content = scriptContentPublic.getContent();
+            scriptNodeList = JSON.parseArray(content, ScriptNode.class);
+            for (ScriptNode scriptNode : scriptNodeList) {
+                contentNodeMap.put(scriptNode.getLineId(), scriptNode);
+            }
+            return contentNodeMap;
+        }
+        return contentNodeMap;
+    }
 
 
+    @Override
+    public String queryChapterIntroduction(Long scriptContentId) {
+        String prefix = "chapter:introduction:public:";
+        return getIntroduction(defaultCacheManager, prefix, scriptContentId);
+    }
 }

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

@@ -22,7 +22,6 @@ import com.sp.director.support.cache.DefaultCacheManager;
 import com.sp.director.support.cache.SocketCacheManager;
 import com.sp.director.utils.StringUtil;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.aop.framework.AopContext;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.Cacheable;
@@ -44,7 +43,7 @@ import java.util.stream.Collectors;
  */
 @Service
 @Slf4j
-public class ScriptContentServiceImpl implements IScriptContentService {
+public class ScriptContentServiceImpl extends AbstractScriptContentIntroductionService implements IScriptContentService {
 
     @Autowired
     private ScriptContentDao scriptContentDao;
@@ -313,28 +312,7 @@ public class ScriptContentServiceImpl implements IScriptContentService {
     @Override
     public String queryChapterIntroduction(Long chapterId) {
         String prefix = "chapter:introduction:";
-        String key = prefix + chapterId;
-        String introduction = defaultCacheManager.getValue(key);
-        if (Objects.isNull(introduction)) {
-            IScriptContentService service = (IScriptContentService) AopContext.currentProxy();
-            Map<String, ScriptNode> map = service.getContentByChapterId(chapterId);
-            StringBuffer sb = new StringBuffer();
-            if (Objects.nonNull(map)) {
-                // 截取前70个字符
-                int size = 70;
-                Iterator<ScriptNode> iterator = map.values().iterator();
-                while (iterator.hasNext()) {
-                    ScriptNode node = iterator.next();
-                    sb.append(node.getContent());
-                    if (sb.length() >= size) {
-                        break;
-                    }
-                }
-                introduction = sb.toString();
-                defaultCacheManager.cacheValue(key, introduction);
-            }
-        }
-        return introduction;
+        return getIntroduction(defaultCacheManager, prefix, chapterId);
     }
 
     @Override

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

@@ -1,11 +1,9 @@
 package com.sp.director.module.script.service.impl;
 
-import com.sp.director.module.script.dao.ScriptDao;
 import com.sp.director.module.script.dao.ScriptScreenwriterDao;
 import com.sp.director.module.script.dto.ScriptMarkDTO;
 import com.sp.director.module.script.service.IScriptDetailService;
 import com.sp.director.module.script.service.IScriptPublicService;
-import com.sp.director.module.script.service.IScriptService;
 import com.sp.director.module.script.vo.ScriptSummaryVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -27,12 +25,6 @@ public class ScriptCooperateDetailServiceImpl implements IScriptDetailService {
     private ScriptScreenwriterDao scriptScreenwriterDao;
 
     @Autowired
-    private ScriptDao scriptDao;
-
-    @Autowired
-    private IScriptService scriptService;
-
-    @Autowired
     private IScriptPublicService scriptPublicService;
 
 

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

@@ -44,12 +44,11 @@ public class ScriptDetailServiceImpl implements IScriptDetailService {
     @Autowired
     private IScriptMarkService scriptMarkService;
 
-    @Override
     /**
      * 查看用户的剧本列表,如果是本人,那么查看所有的剧本列表,
      * 否则查询公开的剧本列表
-     * TODO 待测试
      */
+    @Override
     public List<ScriptSummaryVO> listScriptSummary(Long userId,String tagName, Long lastRecordId, LocalDateTime lastRecordTime) {
         List<ScriptIntroductionDTO> scriptIntroductionDTOList = new ArrayList<>();
         Boolean isAuthor = AuthorHelp.isAuthor(userId);
@@ -114,18 +113,6 @@ public class ScriptDetailServiceImpl implements IScriptDetailService {
             vo.setChapterNum(chapterNum);
             list.add(vo);
         }
-//        // 如果有条件,那么根据剧本id的顺序排序
-//        if(lastRecordId != null && !list.isEmpty() && isAuthor){
-//            Map<String, ScriptSummaryVO> map = list.stream().collect(Collectors.toMap(ScriptSummaryVO::getScriptId, Function.identity()));
-//            int sortNum = 1;
-//            for (Long scriptId : scriptIdList) {
-//                ScriptSummaryVO vo = map.get(scriptId.toString());
-//                if(vo != null){
-//                    vo.setSortNum(sortNum ++);
-//                }
-//            }
-//            list = list.stream().sorted(Comparator.comparing(ScriptSummaryVO::getSortNum)).collect(Collectors.toList());
-//        }
 
         return list;
     }

+ 49 - 20
core/src/main/java/com/sp/director/module/script/service/impl/ScriptMarkServiceImpl.java

@@ -1,6 +1,8 @@
 package com.sp.director.module.script.service.impl;
 
+import com.sp.director.exception.ParamException;
 import com.sp.director.ienum.LogicDeleteEnum;
+import com.sp.director.ienum.ScriptTypeEnum;
 import com.sp.director.module.script.dao.ScriptDao;
 import com.sp.director.module.script.dao.ScriptMarkDao;
 import com.sp.director.module.script.dto.ScriptMarkDTO;
@@ -54,32 +56,59 @@ public class ScriptMarkServiceImpl implements IScriptMarkService {
             @CacheEvict(value = "script:mark:script:list:userid:self",key = "#userId")})
     public Boolean makeScriptMarkOrCancel(Long userId, Long scriptId, Long chapterId) {
         ScriptMark scriptMark;
-        boolean resultState;
-        if(Objects.isNull(chapterId)){
-            scriptMark = scriptMarkDao.queryScriptMarkRecord(userId, scriptId);
-        }else{
-            scriptMark = scriptMarkDao.queryScriptContentMarkRecord(userId, chapterId);
+        Script script = scriptDao.getById(scriptId);
+        if(Objects.isNull(script)){
+            throw new ParamException();
         }
-        if(Objects.isNull(scriptMark)){
-            Script script = scriptDao.getById(scriptId);
-            scriptMark = new ScriptMark();
-            scriptMark.setScriptId(scriptId);
-            scriptMark.setChapterId(chapterId);
-            scriptMark.setLogicDelete(LogicDeleteEnum.NORMAL);
-            scriptMark.setUpdateTime(LocalDateTime.now());
-            scriptMark.setUserId(userId);
-            scriptMark.setAuthorId(script.getAuthorId());
-            scriptMarkDao.save(scriptMark);
-            resultState = true;
+
+        boolean resultState;
+        // 如果操作的剧本是单集剧本,那么会影响剧本和章节
+        if(ScriptTypeEnum.SINGLE.equals(script.getScriptType())){
+            List<ScriptMark> singleTypeMarkRecordList = scriptMarkDao.querySingleTypeScriptMarkRecordList(userId, scriptId);
+            if(singleTypeMarkRecordList.isEmpty()){
+                saveMarkRecord(userId, scriptId, null, script);
+                saveMarkRecord(userId, scriptId, chapterId, script);
+                resultState = true;
+            }else{
+                for (ScriptMark markRecord : singleTypeMarkRecordList) {
+                    updateRecord(markRecord);
+                }
+                resultState = false;
+            }
         }else{
-            scriptMark.setLogicDelete(LogicDeleteEnum.DELETE);
-            scriptMark.setUpdateTime(LocalDateTime.now());
-            scriptMarkDao.updateById(scriptMark);
-            resultState = false;
+            if(Objects.isNull(chapterId)){
+                scriptMark = scriptMarkDao.queryScriptMarkRecord(userId, scriptId);
+            }else{
+                scriptMark = scriptMarkDao.queryScriptContentMarkRecord(userId, chapterId);
+            }
+            if(Objects.isNull(scriptMark)){
+                saveMarkRecord(userId, scriptId, chapterId, script);
+                resultState = true;
+            }else{
+                updateRecord(scriptMark);
+                resultState = false;
+            }
         }
         return resultState;
     }
 
+    private void updateRecord(ScriptMark scriptMark) {
+        scriptMark.setLogicDelete(LogicDeleteEnum.DELETE);
+        scriptMark.setUpdateTime(LocalDateTime.now());
+        scriptMarkDao.updateById(scriptMark);
+    }
+
+    private void saveMarkRecord(Long userId, Long scriptId, Long chapterId, Script script) {
+        ScriptMark scriptMark = new ScriptMark();
+        scriptMark.setScriptId(scriptId);
+        scriptMark.setChapterId(chapterId);
+        scriptMark.setLogicDelete(LogicDeleteEnum.NORMAL);
+        scriptMark.setUpdateTime(LocalDateTime.now());
+        scriptMark.setUserId(userId);
+        scriptMark.setAuthorId(script.getAuthorId());
+        scriptMarkDao.save(scriptMark);
+    }
+
     @Override
     @Cacheable(value = "script:mark:script:list:userid",key = "#userId")
     public List<ScriptMarkDTO> queryAndCacheMarkScriptId(Long userId) {

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

@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.sp.director.exception.BusinessException;
 import com.sp.director.module.script.lock.ScriptLockKey;
 import com.sp.director.module.script.param.ScriptNode;
-import com.sp.director.module.script.service.IScriptContentService;
+import com.sp.director.module.script.service.IScriptContentIntroductionService;
 import com.sp.director.module.script.service.ScriptNodeEditService;
 import com.sp.director.support.cache.SocketCacheManager;
 import com.sp.director.utils.BeanUtil;
@@ -29,11 +29,11 @@ public class ScriptNodeEditServiceImpl implements ScriptNodeEditService {
     private SocketCacheManager socketCacheManager;
 
     @Autowired
-    private IScriptContentService scriptContentService;
+    private IScriptContentIntroductionService scriptContentServiceImpl;
 
     @Override
     public Boolean nodeChange(ScriptNode scriptNode,String previousId,Long chapterId) {
-        Map<String, ScriptNode> nodeMap = scriptContentService.getContentByChapterId(chapterId);
+        Map<String, ScriptNode> nodeMap = scriptContentServiceImpl.getContentByChapterId(chapterId);
         ScriptNode newScriptNode = null;
         String key = null;
         Boolean lock = true;

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

@@ -75,6 +75,11 @@ public class ScriptPublicServiceImpl  implements IScriptPublicService, IScriptDe
 
 
     @Override
+    public int statisticScriptPublishNum(Long userId) {
+        return scriptPublicDao.statisticScriptPublishNum(userId);
+    }
+
+    @Override
     public List<ScriptSummaryVO> queryPublicScript(Long userId, Long lastRecordId,
                                                    LocalDateTime lastRecordTime,
                                                    List<ScriptMarkDTO> scriptCollectDTOList) {
@@ -114,7 +119,7 @@ public class ScriptPublicServiceImpl  implements IScriptPublicService, IScriptDe
                 markScriptList = markScriptList.stream().limit(size).collect(Collectors.toList());
                 scriptIdList = markScriptList;
                 scriptIntroductionDTOList = scriptPublicDao.listAllScriptInfoByIds(null,null, markScriptList, lastRecordTime);
-                if(scriptIntroductionDTOList.size() < size){
+                if(scriptIntroductionDTOList.size() < size && notMarkScriptList.size() > 0){
                     size = size - scriptIntroductionDTOList.size();
                     notMarkScriptList = notMarkScriptList.stream().limit(size).collect(Collectors.toList());
                     scriptIdList.addAll(notMarkScriptList);

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

@@ -0,0 +1,39 @@
+package com.sp.director.module.script.service.impl;
+
+import com.sp.director.module.script.dao.ScriptReferenceDao;
+import com.sp.director.module.script.entity.ScriptReference;
+import com.sp.director.module.script.service.IScriptReferenceService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 剧本引用 服务实现类
+ * </p>
+ *
+ * @author 十一
+ * @since 2021-03-18
+ */
+@Service
+public class ScriptReferenceServiceImpl implements IScriptReferenceService {
+
+    @Autowired
+    private ScriptReferenceDao scriptReferenceDao;
+
+    @Override
+    public void addReference(Long scriptId, Long referenceScriptId, Long referenceChapterId) {
+
+    }
+
+    @Override
+    public void removeReference(Long scriptId, Long referenceChapterId) {
+
+    }
+
+    @Override
+    public List<ScriptReference> listReferenceByScriptId(Long scriptId) {
+        return null;
+    }
+}

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

@@ -1,12 +1,12 @@
 package com.sp.director.module.script.service.impl;
 
-import com.sp.director.exception.ParamException;
+import com.sp.director.base.UserLoginInfo;
+import com.sp.director.context.RequestContext;
 import com.sp.director.ienum.CreativeStatusEnum;
 import com.sp.director.ienum.LogicDeleteEnum;
 import com.sp.director.module.script.dao.ScriptScreenwriterDao;
 import com.sp.director.module.script.dto.ShareOrCooperationDTO;
 import com.sp.director.module.script.entity.ScriptScreenwriter;
-import com.sp.director.module.script.entity.ScriptShare;
 import com.sp.director.module.script.service.IScriptScreenwriterService;
 import com.sp.director.module.script.service.IScriptService;
 import com.sp.director.module.user.service.IUserService;
@@ -114,6 +114,8 @@ public class ScriptScreenwriterServiceImpl implements IScriptScreenwriterService
             writer.setScriptId(scriptId);
             writer.setCreateTime(now);
             writer.setUserId(userId);
+            UserLoginInfo userLoginInfo = RequestContext.getUserLoginInfo();
+            writer.setAuthorId(userLoginInfo.getUserId());
             writer.setChapterId(chapterId);
             writer.setLogicDelete(LogicDeleteEnum.NORMAL);
             scriptScreenwriterDao.save(writer);

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

@@ -257,6 +257,7 @@ public class ScriptServiceImpl implements IScriptService {
     }
 
     @Override
+    @CacheEvict(value = "script:chapter:chapterNum:total",key = "#scriptId")
     public void deleteScript(Long scriptId) {
         scriptDao.logicDelete(scriptId);
     }
@@ -323,7 +324,9 @@ public class ScriptServiceImpl implements IScriptService {
         }
         script.setUpdateTime(LocalDateTime.now());
         script.setTitle(param.getTitle());
-        script.setCoverImg(param.getCoverImg());
+        if(Objects.nonNull(param.getCoverImg())){
+            script.setCoverImg(param.getCoverImg());
+        }
         script.setIntroduction(param.getIntroduction());
         script.setTagName(param.getTagName());
         script.setModifyState(ModifyStateEnum.MODIFY);

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

@@ -64,17 +64,14 @@ public class ScriptShareDaoImpl extends BaseDAOImpl<ScriptShareMapper, ScriptSha
 
     @Override
     public int statisticShareCount(Long userId) {
-        QueryWrapper<ScriptShare> qw = new QueryWrapper<>();
-        qw.lambda().eq(ScriptShare::getShareUserId,userId)
-                    .eq(ScriptShare::getLogicDelete,LogicDeleteEnum.NORMAL);
-        return this.count(qw);
+        return scriptShareMapper.statisticShareCount(userId);
     }
 
     @Override
     public void removeUser(Long userId, Long scriptId) {
         UpdateWrapper<ScriptShare> uw = new UpdateWrapper<>();
         uw.lambda().eq(ScriptShare::getScriptId,scriptId)
-                    .eq(ScriptShare::getShareUserId,userId)
+                    .eq(ScriptShare::getUserId,userId)
                     .set(ScriptShare::getLogicDelete,LogicDeleteEnum.DELETE);
         this.update(uw);
     }
@@ -112,4 +109,6 @@ public class ScriptShareDaoImpl extends BaseDAOImpl<ScriptShareMapper, ScriptSha
 interface ScriptShareMapper extends BaseMapper<ScriptShare> {
 
     List<Long> queryShareScriptList(Long userId);
+
+    int statisticShareCount(Long userId);
 }

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

@@ -67,7 +67,7 @@ public class ScriptShareServiceImpl implements IScriptShareService {
         LocalDateTime now = LocalDateTime.now();
         if (Objects.isNull(scriptShare)) {
             scriptShare = new ScriptShare();
-            scriptShare.setChapterId(0L);
+            scriptShare.setChapterId(null);
             scriptShare.setCreateTime(now);
             scriptShare.setLogicDelete(LogicDeleteEnum.NORMAL);
             scriptShare.setShareUserId(shareUserId);

+ 22 - 0
core/src/main/java/com/sp/director/module/video/dao/UserVideoRecommendDao.java

@@ -0,0 +1,22 @@
+package com.sp.director.module.video.dao;
+
+import com.sp.director.module.video.dto.UserVideoRecommendDTO;
+import com.sp.director.module.video.entity.UserVideoRecommend;
+import com.sp.director.mybatis.plus.IBaseDAO;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 十一
+ * @since 2021-03-18
+ */
+public interface UserVideoRecommendDao extends IBaseDAO<UserVideoRecommend> {
+
+    UserVideoRecommend queryByVideoId(Long videoId);
+
+    List<UserVideoRecommendDTO> queryRecommendVideoList(Long lastRecordId);
+}

+ 2 - 0
core/src/main/java/com/sp/director/module/video/dao/VideoLikeDao.java

@@ -28,4 +28,6 @@ public interface VideoLikeDao extends IBaseDAO<VideoLike> {
     List<VideoLikeDTO> listLikeVideoId(Long userId, LocalDateTime lastSortTime);
 
     int countLikeVideoNunByUserId(Long userId);
+
+    List<VideoLike> checkUserLikeByVideoList(Long userId, List<Long> videoIdList);
 }

+ 48 - 0
core/src/main/java/com/sp/director/module/video/dao/impl/UserVideoRecommendDaoImpl.java

@@ -0,0 +1,48 @@
+package com.sp.director.module.video.dao.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sp.director.ienum.LogicDeleteEnum;
+import com.sp.director.module.video.dao.UserVideoRecommendDao;
+import com.sp.director.module.video.dto.UserVideoRecommendDTO;
+import com.sp.director.module.video.entity.UserVideoRecommend;
+import com.sp.director.mybatis.plus.BaseDAOImpl;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * @Descrption
+ * @Author: 十一
+ * @Date: 2021/3/18
+ * @Version V1.0
+ **/
+@Repository
+public class UserVideoRecommendDaoImpl extends BaseDAOImpl<UserVideoRecommendMapper, UserVideoRecommend> implements UserVideoRecommendDao {
+
+    @Autowired
+    private UserVideoRecommendMapper userVideoRecommendMapper;
+
+
+    @Override
+   public UserVideoRecommend queryByVideoId(Long videoId) {
+        QueryWrapper<UserVideoRecommend> qw = new QueryWrapper<>();
+        qw.lambda().eq(UserVideoRecommend::getVideoId, videoId)
+                .eq(UserVideoRecommend::getLogicDelete, LogicDeleteEnum.NORMAL);
+        return this.getOne(qw);
+    }
+
+    @Override
+    public List<UserVideoRecommendDTO> queryRecommendVideoList(Long lastRecordId) {
+        return userVideoRecommendMapper.queryRecommendVideoList(lastRecordId);
+    }
+}
+@Mapper
+@Component
+interface UserVideoRecommendMapper extends BaseMapper<UserVideoRecommend> {
+
+    List<UserVideoRecommendDTO> queryRecommendVideoList(Long lastRecordId);
+}

+ 9 - 0
core/src/main/java/com/sp/director/module/video/dao/impl/VideoLikeDaoImpl.java

@@ -29,6 +29,15 @@ public class VideoLikeDaoImpl extends BaseDAOImpl<VideoLikeMapper, VideoLike> im
     private VideoLikeMapper videoLikeMapper;
 
     @Override
+    public List<VideoLike> checkUserLikeByVideoList(Long userId, List<Long> videoIdList) {
+        QueryWrapper<VideoLike> qw = new QueryWrapper<>();
+        qw.lambda().eq(VideoLike::getLogicDelete,LogicDeleteEnum.NORMAL)
+                .in(VideoLike::getVideoId,videoIdList)
+                .eq(VideoLike::getUserId,userId);
+        return this.list(qw);
+    }
+
+    @Override
     public int countLikeVideoNunByUserId(Long userId) {
         QueryWrapper<VideoLike> qw = new QueryWrapper<>();
         qw.lambda().eq(VideoLike::getLogicDelete,LogicDeleteEnum.NORMAL)

+ 27 - 0
core/src/main/java/com/sp/director/module/video/dto/UserVideoRecommendDTO.java

@@ -0,0 +1,27 @@
+package com.sp.director.module.video.dto;
+
+import lombok.Data;
+
+/**
+ * @Descrption
+ * @Author: 十一
+ * @Date: 2021/3/18
+ * @Version V1.0
+ **/
+@Data
+public class UserVideoRecommendDTO {
+
+    private Long videoId;
+
+    private String videoCover;
+
+    private String videoUrl;
+
+    private String content;
+
+    private Integer width;
+
+    private Integer height;
+
+    private Long userId;
+}

+ 17 - 2
core/src/main/java/com/sp/director/module/video/entity/UserVideo.java

@@ -66,9 +66,24 @@ public class UserVideo extends Model<UserVideo> {
     private String videoUrl;
 
     /**
-     * 是否撑满屏幕
+     * 审核时间
      */
-    private Boolean isFill;
+    private LocalDateTime verifyTime;
+
+    /**
+     * 宽度
+     */
+    private Integer width;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 高度
+     */
+    private Integer height;
 
     /**
      * 逻辑删除

+ 88 - 0
core/src/main/java/com/sp/director/module/video/entity/UserVideoRecommend.java

@@ -0,0 +1,88 @@
+package com.sp.director.module.video.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.sp.director.ienum.LogicDeleteEnum;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 十一
+ * @since 2021-03-18
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("t_user_video_recommend")
+public class UserVideoRecommend extends Model<UserVideoRecommend> {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 视频id
+     */
+    private Long videoId;
+
+    /**
+     * 用户id
+     */
+    private Long userId;
+
+    /**
+     * 文案
+     */
+    private String content;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 视频封面
+     */
+    private String videoCover;
+
+    /**
+     * 视频地址
+     */
+    private String videoUrl;
+
+    /**
+     * 宽度
+     */
+    private Integer width;
+
+    /**
+     * 高度
+     */
+    private Integer height;
+
+    /**
+     * 逻辑删除
+     */
+    private LogicDeleteEnum logicDelete;
+
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+}

+ 7 - 3
core/src/main/java/com/sp/director/module/video/param/UserPublishVideoParam.java

@@ -26,9 +26,13 @@ public class UserPublishVideoParam {
     @ApiParam(name = "videoUrl",value = "视频路径")
     private String videoUrl;
 
-    @ApiParam(name = "isFull",value = "是否撑满全屏")
-    @NotNull(message="isFull不能为空")
-    private Boolean isFull;
+    @ApiParam(name = "width",value = "宽度")
+    @NotNull(message="width不能为空")
+    private Integer width;
+
+    @ApiParam(name = "height",value = "高度")
+    @NotNull(message="height不能为空")
+    private Integer height;
 
 
 }

+ 46 - 0
core/src/main/java/com/sp/director/module/video/service/IUserVideoRecommendService.java

@@ -0,0 +1,46 @@
+package com.sp.director.module.video.service;
+
+import com.sp.director.ienum.BaseReviewIenum;
+import com.sp.director.module.video.dto.UserVideoRecommendDTO;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 十一
+ * @since 2021-03-18
+ */
+public interface IUserVideoRecommendService {
+
+    /**
+     * 审核视频
+     * @param videoId
+     * @param state
+     * @param remark
+     */
+    void verifyUserVideo(Long videoId, BaseReviewIenum state, String remark);
+
+    /**
+     * 推荐视频(将com.sp.director.module.video.entity.UserVideo的记录复制到
+     * com.sp.director.module.video.entity.UserVideoRecommend中)
+     * @param videoId
+     */
+    void recommendVideo(Long videoId);
+
+    /**
+     * 下架视频(从推荐表中将记录设为逻辑删除)
+     * @param videoId
+     */
+    void obObtainedVideo(Long videoId);
+
+    /**
+     * 推荐的视频列表
+     * @param lastRecordId
+     * @return
+     */
+    List<UserVideoRecommendDTO> queryRecommendVideoList(Long lastRecordId);
+
+}

+ 1 - 1
core/src/main/java/com/sp/director/module/video/service/IUserVideoService.java

@@ -12,5 +12,5 @@ import com.sp.director.module.video.param.UserPublishVideoParam;
  */
 public interface IUserVideoService extends IVideoSummaryService {
 
-    Boolean publishVideo(Long userId, UserPublishVideoParam param);
+    Long publishVideo(Long userId, UserPublishVideoParam param);
 }

+ 11 - 0
core/src/main/java/com/sp/director/module/video/service/IVideoLikeService.java

@@ -2,6 +2,9 @@ package com.sp.director.module.video.service;
 
 import com.sp.director.ienum.LogicDeleteEnum;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 视频点赞 服务类
@@ -22,4 +25,12 @@ public interface IVideoLikeService extends IVideoSummaryService{
     void addLikeVideo(Long userId, Long videoId);
 
     void changeVideoLikeState(Long userId, Long videoId, LogicDeleteEnum state);
+
+    /**
+     * 批量查询用户是否点赞视频
+     * @param userId
+     * @param videoIdList
+     * @return
+     */
+    Map<Long, Long> checkUserLikeByVideoList(Long userId, List<Long> videoIdList);
 }

+ 102 - 0
core/src/main/java/com/sp/director/module/video/service/impl/UserVideoRecommendServiceImpl.java

@@ -0,0 +1,102 @@
+package com.sp.director.module.video.service.impl;
+
+import com.sp.director.exception.BusinessException;
+import com.sp.director.exception.ParamException;
+import com.sp.director.ienum.BaseReviewIenum;
+import com.sp.director.ienum.LogicDeleteEnum;
+import com.sp.director.module.video.dao.UserVideoDao;
+import com.sp.director.module.video.dao.UserVideoRecommendDao;
+import com.sp.director.module.video.dto.UserVideoRecommendDTO;
+import com.sp.director.module.video.entity.UserVideo;
+import com.sp.director.module.video.entity.UserVideoRecommend;
+import com.sp.director.module.video.service.IUserVideoRecommendService;
+import com.sp.director.module.video.vo.UserVideoVO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 十一
+ * @since 2021-03-18
+ */
+@Service
+@Slf4j
+public class UserVideoRecommendServiceImpl implements IUserVideoRecommendService {
+
+    @Autowired
+    private UserVideoDao userVideoDao;
+
+    @Autowired
+    private UserVideoRecommendDao userVideoRecommendDao;
+
+    @Override
+    public void verifyUserVideo(Long videoId, BaseReviewIenum state, String remark) {
+        UserVideo userVideo = queryAndVerifyVideoByVideoId(videoId);
+        userVideo.setStatus(state);
+        userVideo.setRemark(remark);
+        userVideo.setVerifyTime(LocalDateTime.now());
+        userVideoDao.updateById(userVideo);
+    }
+
+    @Override
+    public void recommendVideo(Long videoId) {
+        UserVideo userVideo = queryAndVerifyVideoByVideoId(videoId);
+        // 判断是否是否已经被推荐
+        UserVideoRecommend userVideoRecommend = userVideoRecommendDao.queryByVideoId(videoId);
+        if(Objects.nonNull(userVideoRecommend)){
+            log.error("推荐用户视频异常,该视频:{}已经被推荐", videoId);
+            throw new BusinessException();
+        }
+        userVideoRecommend = this.wrapUserVideoRecommend(userVideo);
+        userVideoRecommendDao.save(userVideoRecommend);
+    }
+
+    private UserVideoRecommend wrapUserVideoRecommend(UserVideo userVideo) {
+        UserVideoRecommend userVideoRecommend = new UserVideoRecommend();
+        userVideoRecommend.setVideoId(userVideo.getId());
+        userVideoRecommend.setUserId(userVideo.getUserId());
+        userVideoRecommend.setVideoCover(userVideo.getVideoCover());
+        userVideoRecommend.setVideoUrl(userVideo.getVideoUrl());
+        userVideoRecommend.setLogicDelete(LogicDeleteEnum.NORMAL);
+        userVideoRecommend.setContent(userVideo.getContent());
+        userVideoRecommend.setCreateTime(LocalDateTime.now());
+        userVideoRecommend.setHeight(userVideo.getHeight());
+        userVideoRecommend.setWidth(userVideo.getWidth());
+        return userVideoRecommend;
+    }
+
+    @Override
+    public void obObtainedVideo(Long videoId) {
+        UserVideoRecommend userVideoRecommend = userVideoRecommendDao.queryByVideoId(videoId);
+        if(Objects.isNull(userVideoRecommend)){
+            throw new ParamException();
+        }
+        userVideoRecommend.setLogicDelete(LogicDeleteEnum.DELETE);
+        userVideoRecommendDao.updateById(userVideoRecommend);
+    }
+
+    @Override
+    @Transactional(readOnly = true)
+    // 每次查询20条
+    public List<UserVideoRecommendDTO> queryRecommendVideoList(Long lastRecordId) {
+        List<UserVideoRecommendDTO> userVideoRecommendList = userVideoRecommendDao.queryRecommendVideoList(lastRecordId);
+        return userVideoRecommendList;
+    }
+
+    public UserVideo queryAndVerifyVideoByVideoId(Long videoId){
+        UserVideo userVideo = userVideoDao.getById(videoId);
+        if(Objects.isNull(userVideo)){
+            throw new ParamException();
+        }
+        return userVideo;
+    }
+}

+ 11 - 5
core/src/main/java/com/sp/director/module/video/service/impl/UserVideoServiceImpl.java

@@ -1,7 +1,6 @@
 package com.sp.director.module.video.service.impl;
 
 import com.sp.director.base.UserLoginInfo;
-import com.sp.director.constant.RequestConstant;
 import com.sp.director.context.RequestContext;
 import com.sp.director.ienum.BaseReviewIenum;
 import com.sp.director.ienum.LogicDeleteEnum;
@@ -34,7 +33,7 @@ public class UserVideoServiceImpl implements IUserVideoService {
     private UserVideoDao userVideoDao;
 
     @Override
-    public Boolean publishVideo(Long userId, UserPublishVideoParam param) {
+    public Long publishVideo(Long userId, UserPublishVideoParam param) {
         UserVideo userVideo = new UserVideo();
         userVideo.setUserId(userId);
         userVideo.setCreateTime(LocalDateTime.now());
@@ -43,14 +42,21 @@ public class UserVideoServiceImpl implements IUserVideoService {
         userVideo.setLogicDelete(LogicDeleteEnum.NORMAL);
         userVideo.setStatus(BaseReviewIenum.Review);
         userVideo.setVideoCover(param.getVideoCover());
-        userVideo.setIsFill(param.getIsFull());
+        userVideo.setWidth(param.getWidth());
+        userVideo.setHeight(param.getHeight());
         userVideoDao.save(userVideo);
-        return true;
+        return userVideo.getId();
     }
 
+    /**
+     * 查看用户的视频列表
+     * @param userId
+     * @param lastSortTime
+     * @return
+     */
     @Override
     public List<VideoSummaryVO> videoList(Long userId, LocalDateTime lastSortTime) {
-        UserLoginInfo userInfo = (UserLoginInfo) RequestContext.getAttribute(RequestConstant.USER_LOGIN_INFO);
+        UserLoginInfo userInfo = RequestContext.getUserLoginInfo();
         // 判断是否是作者本人,如果是本人,可以看到所有的视频,否则只能看到审核通过的视频
         boolean isAuthor = false;
         if(userInfo.getUserId().equals(userId)){

+ 8 - 0
core/src/main/java/com/sp/director/module/video/service/impl/VideoLikeServiceImpl.java

@@ -5,6 +5,7 @@ import com.sp.director.module.video.dao.UserVideoDao;
 import com.sp.director.module.video.dao.VideoLikeDao;
 import com.sp.director.module.video.dto.VideoLikeDTO;
 import com.sp.director.module.video.dto.VideoSummaryDTO;
+import com.sp.director.module.video.entity.VideoLike;
 import com.sp.director.module.video.service.IVideoLikeService;
 import com.sp.director.module.video.vo.VideoSummaryVO;
 import com.sp.director.utils.BeanUtil;
@@ -73,6 +74,13 @@ public class VideoLikeServiceImpl  implements IVideoLikeService {
     }
 
     @Override
+    public Map<Long, Long> checkUserLikeByVideoList(Long userId, List<Long> videoIdList) {
+        List<VideoLike> videoLikeList = videoLikeDao.checkUserLikeByVideoList(userId, videoIdList);
+        Map<Long, Long> map = videoLikeList.stream().collect(Collectors.toMap(VideoLike::getVideoId, VideoLike::getVideoId));
+        return map;
+    }
+
+    @Override
     @CacheEvict(value="video:like:count:by:userId",key="#userId",condition = "#userId != null")
     public void changeVideoLikeState(Long userId, Long videoId, LogicDeleteEnum state) {
         videoLikeDao.changeVideoLikeState(userId, videoId, state);

+ 38 - 0
core/src/main/java/com/sp/director/module/video/vo/UserVideoVO.java

@@ -0,0 +1,38 @@
+package com.sp.director.module.video.vo;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiParam;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @Descrption
+ * @Author: 十一
+ * @Date: 2021/3/18
+ * @Version V1.0
+ **/
+@Data
+@JsonIgnoreProperties("sortTime")
+public class UserVideoVO extends VideoSummaryVO implements Serializable {
+
+    @ApiModelProperty(name="content",value="文案")
+    private String content;
+
+    @ApiParam(name = "focus", value = "是否关注")
+    private Boolean focus = false;
+
+    @ApiParam(name = "like", value = "是否点赞")
+    private Boolean like = false;
+
+    @ApiModelProperty(name="width",value="宽度")
+    private Integer width;
+
+    @ApiModelProperty(name="height",value="高度")
+    private Integer height;
+
+    @ApiModelProperty(name="userId",value="用户id")
+    private Integer userId;
+
+}

+ 2 - 2
core/src/main/java/com/sp/director/utils/CodeGenerator.java

@@ -30,7 +30,7 @@ public class CodeGenerator {
         gc.setAuthor("十一");
         //自动生成代码的输出路径
         gc.setOutputDir("/Users/shiyi/IdeaWorkSpace/director/core/src/main/java");
-        String entityName = "ScriptMark";
+        String entityName = "ScriptReference";
         // 是否覆盖同名文件,默认是false
         gc.setFileOverride(false);
         // 不需要ActiveRecord特性的请改为false
@@ -76,7 +76,7 @@ public class CodeGenerator {
         StrategyConfig strategy = new StrategyConfig();
         // 使用驼峰命名规则
         strategy.setNaming(NamingStrategy.underline_to_camel);
-        strategy.setInclude("t_script_mark");
+        strategy.setInclude("t_script_reference");
         // 需要生成的表
 //        strategy.setInclude(new String[]{"app_sign"});
         // 使用lombok方式生成getter和setter

+ 6 - 2
core/src/main/resources/com/sp/director/module/script/dao/xml/ScriptContentMapper.xml

@@ -17,8 +17,10 @@
             resultType="com.sp.director.module.script.vo.ScriptContentSummaryVO">
         select
             id chapterId,
-            update_time time,
+            update_time updateTime,
             title,
+            1 markStatus,
+            modify_state isModify,
             "默认" tagName
         from t_script_content sc
         <where>
@@ -40,8 +42,10 @@
     <select id="queryScriptContentNotInMarkChapterId" resultType="com.sp.director.module.script.vo.ScriptContentSummaryVO">
         select
         id chapterId,
-        update_time time,
+        update_time updateTime,
         title,
+        0 markStatus,
+        modify_state isModify,
         "默认" tagName
         from t_script_content sc
         <where>

+ 2 - 2
core/src/main/resources/com/sp/director/module/script/dao/xml/ScriptContentPublicMapper.xml

@@ -38,7 +38,7 @@
         p.title title,
         p.introduction,
         p.tag_name tagName,
-        0 scriptModifyStatus,
+        modify_state scriptModifyStatus,
         1 markStatus
         from t_script_content_public p
         <where>
@@ -66,7 +66,7 @@
         p.chapter_id chapterId,
         p.update_time updateTime,
         p.title title,
-        0 scriptModifyStatus,
+        modify_state scriptModifyStatus,
         0 markStatus
         from t_script_content_public p
         <where>

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

@@ -26,7 +26,7 @@
             <if test="tagName != null">
                 and s.tag_name = #{tagName}
             </if>
-            <if test="scriptList != null">
+            <if test="scriptList != null and scriptList.size > 0">
                 and s.script_id in
                 <foreach collection="scriptList" item="scriptId" open="(" separator="," close=")">
                     #{scriptId}
@@ -37,8 +37,7 @@
                 and s.private_state = 0
             </if>
         </where>
-        order by
-        s.create_time desc
+        order by s.create_time desc
         limit 10
     </select>
 </mapper>

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

@@ -11,4 +11,10 @@
               share_user_id = #{userId}
                 and logic_delete = 0
     </select>
+    <select id="statisticShareCount" resultType="java.lang.Integer" parameterType="java.lang.Long">
+        select count(*) from (
+             select  DISTINCT script_id
+             from t_script_share
+             where user_id = #{userId} and logic_delete = 0 )t
+    </select>
 </mapper>

+ 27 - 0
core/src/main/resources/com/sp/director/module/video/dao/xml/VideoRecommendMapper.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sp.director.module.video.dao.impl.UserVideoRecommendMapper">
+
+
+    <select id="queryRecommendVideoList" resultType="com.sp.director.module.video.dto.UserVideoRecommendDTO"
+            parameterType="java.time.LocalDateTime">
+        select
+            id recordId,
+            video_id videoId,
+            user_id userId,
+            content,
+            create_time createTime,
+            video_cover videoCover,
+            video_url videoUrl,
+            width,
+            height
+        from t_user_video_recommend uvr
+        <where>
+            <if test="lastRecordId != null">
+                and uvr.id <![CDATA[<]]> #{lastRecordId}
+            </if>
+        </where>
+        order by id desc
+        limit 20
+    </select>
+</mapper>

+ 2 - 13
logic/src/main/java/com/sp/director/module/script/script/controller/ScriptContentController.java

@@ -11,7 +11,6 @@ import com.sp.director.ienum.ScriptPrivateStateEnum;
 import com.sp.director.ienum.ScriptTypeEnum;
 import com.sp.director.module.script.dao.ScriptContentDao;
 import com.sp.director.module.script.dao.ScriptDao;
-import com.sp.director.module.script.dao.ScriptPublicDao;
 import com.sp.director.module.script.dto.ScriptContentDTO;
 import com.sp.director.module.script.entity.Script;
 import com.sp.director.module.script.entity.ScriptContent;
@@ -54,9 +53,6 @@ public class ScriptContentController {
     private IScriptService scriptService;
 
     @Autowired
-    private IScriptMarkService scriptMarkService;
-
-    @Autowired
     private ScriptDao scriptDao;
 
     @Autowired
@@ -66,12 +62,6 @@ public class ScriptContentController {
     private IScriptScreenwriterService scriptScreenwriterService;
 
     @Autowired
-    private IScriptPublicService scriptPublicService;
-
-    @Autowired
-    private ScriptPublicDao scriptPublicDao;
-
-    @Autowired
     private IScriptContentPublicService scriptContentPublicService;
 
     @ApiOperation(value = "新增剧本作品")
@@ -100,8 +90,6 @@ public class ScriptContentController {
         if (!roleUsers.contains(userLoginInfo.getUserId())) {
             throw new ParamException();
         }
-        script.setModifyState(ModifyStateEnum.MODIFY);
-        scriptDao.updateById(script);
         Long chapterId = scriptContentService.createScriptContent(userLoginInfo.getUserId(), title, scriptId);
         ScriptContentSummaryVO vo = new ScriptContentSummaryVO();
         vo.setUpdateTime(LocalDateTime.now());
@@ -161,7 +149,7 @@ public class ScriptContentController {
     public MJson<List<ScriptContentSummaryVO>> chapterList(@ApiIgnore UserLoginInfo userLoginInfo,
                                                            @Valid @NotNull(message = "scriptId不能为空") Long scriptId,
                                                            @RequestParam(required = false) Long lastRecordId) {
-        List<ScriptContentSummaryVO> list = new ArrayList<>();
+        List<ScriptContentSummaryVO> list;
         boolean onlyViewPublicSource = scriptScreenwriterService.isOnlyViewPublicSource(userLoginInfo.getUserId(), scriptId);
         // 如果用户不是作者本人或者不是协作者,只能看公开的数据
         if (onlyViewPublicSource) {
@@ -174,6 +162,7 @@ public class ScriptContentController {
             boolean isPublic = publicChapterList.contains(vo.getChapterId());
             vo.setIsPublic(isPublic);
             vo.setUpdateTime(vo.getUpdateTime());
+
             // 查询协作者
             List<String> cooperationList =
                     scriptScreenwriterService.queryRecentWritersByScriptId(scriptId, Long.valueOf(vo.getChapterId()));

+ 19 - 4
logic/src/main/java/com/sp/director/module/script/script/controller/ScriptController.java

@@ -132,6 +132,21 @@ public class ScriptController {
     }
 
 
+//
+//    @ApiOperation(value="查询出当前剧本没有合并的单集剧本列表")
+//    @GetMapping("unreference/singleType/list")
+//    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);
+//    }
+
+
     @ApiOperation(value="新增剧本")
     @PostMapping("newScript")
     @ApiImplicitParams({
@@ -149,11 +164,11 @@ public class ScriptController {
         if (ScriptTypeEnum.SINGLE.equals(scriptType)) {
             scriptContentService.createScriptContent(userLoginInfo.getUserId(), title, scriptId);
         }
-        ScriptSummaryVO vo = wrapperScriptVO(title, scriptType, scriptId, ModifyStateEnum.MODIFY);
+        ScriptSummaryVO vo = wrapperScriptVO(title,null, scriptType, scriptId, ModifyStateEnum.MODIFY);
         return MJson.ok(vo);
     }
 
-    private ScriptSummaryVO wrapperScriptVO(String title,ScriptTypeEnum scriptType, Long scriptId,ModifyStateEnum status) {
+    private ScriptSummaryVO wrapperScriptVO(String title,String tagName,ScriptTypeEnum scriptType, Long scriptId,ModifyStateEnum status) {
         ScriptSummaryVO vo = new ScriptSummaryVO();
         LocalDateTime now = LocalDateTime.now();
         vo.setSortTime(now);
@@ -165,7 +180,7 @@ public class ScriptController {
         vo.setScriptType(scriptType);
         vo.setMarkStatus(false);
         vo.setIsModify(status.isModify());
-        vo.setTagName("默认");
+        vo.setTagName(tagName == null ? "默认" : tagName);
         vo.setTitle(title);
         return vo;
     }
@@ -183,7 +198,7 @@ public class ScriptController {
         Script script = scriptService.editScript(userLoginInfo.getUserId(), param);
         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);
+        ScriptSummaryVO vo = wrapperScriptVO(script.getTitle(),script.getTagName(), script.getScriptType(), script.getId(),ModifyStateEnum.MODIFY);
         Boolean isPublic = scriptService.isPublic(param.getScriptId());
         // 查询
         vo.setIsModify(script.getModifyState().isModify());

+ 6 - 6
logic/src/main/java/com/sp/director/module/userindex/controller/UserIndexController.java

@@ -5,9 +5,9 @@ import com.sp.director.base.UserLoginInfo;
 import com.sp.director.http.MJson;
 import com.sp.director.module.collect.dao.UserCollectDao;
 import com.sp.director.module.focus.service.IUserFocusService;
-import com.sp.director.module.script.dao.ScriptDao;
 import com.sp.director.module.script.dao.ScriptScreenwriterDao;
 import com.sp.director.module.script.dao.ScriptShareDao;
+import com.sp.director.module.script.service.IScriptPublicService;
 import com.sp.director.module.user.service.IUserService;
 import com.sp.director.module.userinfo.vo.UserHomeVO;
 import com.sp.director.module.userinfo.vo.UserIndexVO;
@@ -39,6 +39,9 @@ import javax.validation.constraints.NotNull;
 public class UserIndexController {
 
     @Autowired
+    private IScriptPublicService scriptPublicService;
+
+    @Autowired
     private ScriptShareDao scriptShareDao;
 
     @Autowired
@@ -56,9 +59,6 @@ public class UserIndexController {
     @Autowired
     private IUserService userService;
 
-    @Autowired
-    private ScriptDao scriptDao;
-
     @ApiOperation(value = "用户首页信息")
     @GetMapping("home")
     @Authentication
@@ -70,7 +70,7 @@ public class UserIndexController {
         // 统计收藏
         int collectNum = userCollectDao.statisticCollectCount(userLoginInfo.getUserId());
         // 统计剧本发布数量
-        int publishNum = scriptDao.statisticScriptPublishNum(userLoginInfo.getUserId());
+        int publishNum = scriptPublicService.statisticScriptPublishNum(userLoginInfo.getUserId());
         UserHomeVO vo = UserHomeVO
                 .builder()
                 .cooperatorNum(cooperatorNum)
@@ -94,8 +94,8 @@ public class UserIndexController {
         UserIndexVO vo = new UserIndexVO();
         boolean focus = false;
         if(!userLoginInfo.getUserId().equals(userId)){
-            userLoginInfo = userService.getUserLoginInfoByUserId(userId);
             focus = userFocusService.checkFocus(userLoginInfo.getUserId(), userId);
+            userLoginInfo = userService.getUserLoginInfoByUserId(userId);
         }
         // 统计点赞数量
         int likeNum = videoLikeService.countLikeVideoNunByUserId(userId);

+ 88 - 0
logic/src/main/java/com/sp/director/module/video/controller/UserVideoRecommendController.java

@@ -0,0 +1,88 @@
+package com.sp.director.module.video.controller;
+
+import com.sp.director.annotation.Authentication;
+import com.sp.director.base.UserLoginInfo;
+import com.sp.director.http.MJson;
+import com.sp.director.module.focus.service.IUserFocusService;
+import com.sp.director.module.video.dto.UserVideoRecommendDTO;
+import com.sp.director.module.video.service.IUserVideoRecommendService;
+import com.sp.director.module.video.service.IVideoLikeService;
+import com.sp.director.module.video.vo.UserVideoVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import springfox.documentation.annotations.ApiIgnore;
+
+import javax.validation.Valid;
+import java.util.*;
+
+/**
+ * @Descrption
+ * @Author: 十一
+ * @Date: 2021/3/18
+ * @Version V1.0
+ **/
+@RestController
+@RequestMapping("userVideoRecommend")
+@Api(tags = "视频推荐域")
+@Validated
+public class UserVideoRecommendController {
+
+    @Autowired
+    private IUserFocusService userFocusService;
+
+    @Autowired
+    private IVideoLikeService videoLikeService;
+
+    @Autowired
+    private IUserVideoRecommendService userVideoRecommendService;
+
+    @ApiOperation(value="推荐的视频列表")
+    @GetMapping("list")
+    @Authentication
+    @ApiImplicitParams({
+                @ApiImplicitParam(name = "lastRecordId", value = "最后一条记录的id",
+                paramType = "query",required = true, dataType = "long")
+    })
+    public MJson<List<UserVideoVO>> videoList(@ApiIgnore UserLoginInfo userLoginInfo,
+                                              @Valid Long lastRecordId) {
+        List<UserVideoVO> resultList = new ArrayList<>();
+        List<Long> userIdList = new ArrayList<>();
+        List<Long> videoIdList = new ArrayList<>();
+        Map<Long,Long> userFocusMap = new HashMap<>();
+        Map<Long, Long> userVideoLikeMap = new HashMap<>();;
+        List<UserVideoRecommendDTO> videoList = userVideoRecommendService.queryRecommendVideoList(lastRecordId);
+        if(!videoList.isEmpty() ){
+            videoList.stream().forEach(v ->{
+                userIdList.add(v.getUserId());
+                videoIdList.add(v.getVideoId());
+            });
+        }
+        if( Objects.nonNull(userLoginInfo) && !userIdList.isEmpty() ){
+            userFocusMap = userFocusService.checkUserFocusByFocusUserIdList(userLoginInfo.getUserId(), userIdList);
+            userVideoLikeMap = videoLikeService.checkUserLikeByVideoList(userLoginInfo.getUserId(), videoIdList);
+        }
+        for (UserVideoRecommendDTO dto : videoList) {
+            UserVideoVO vo = new UserVideoVO();
+            BeanUtils.copyProperties(dto,vo);
+            vo.setVideoId(dto.getVideoId().toString());
+            if( null != userFocusMap ){
+                Long focusUser = userFocusMap.get(vo.getUserId());
+                vo.setFocus(focusUser == null ? false : true);
+            }
+            if( null != userVideoLikeMap ){
+                Long videoLike = userVideoLikeMap.get(vo.getVideoId());
+                vo.setFocus(videoLike == null ? false : true);
+            }
+            resultList.add(vo);
+        }
+        return MJson.ok(resultList);
+    }
+}

+ 3 - 2
logic/src/main/java/com/sp/director/module/video/controller/VideoController.java

@@ -20,6 +20,7 @@ import springfox.documentation.annotations.ApiIgnore;
 
 import javax.validation.Valid;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * @Descrption
@@ -44,8 +45,8 @@ public class VideoController {
     @Authentication
     public MJson<Boolean> publishVideo(@ApiIgnore UserLoginInfo userLoginInfo,
                                       @Valid UserPublishVideoParam param) {
-        Boolean result = userVideoService.publishVideo(userLoginInfo.getUserId(), param);
-        if(result){
+        Long videoId = userVideoService.publishVideo(userLoginInfo.getUserId(), param);
+        if(Objects.nonNull(videoId)){
             return MJson.ok(true);
         }
         return MJson.fail();

+ 114 - 0
logic/src/test/java/com/sp/module/video/VideoTest.java

@@ -0,0 +1,114 @@
+package com.sp.module.video;
+
+import com.alibaba.fastjson.JSON;
+import com.sp.director.base.UserLoginInfo;
+import com.sp.director.ienum.BaseReviewIenum;
+import com.sp.director.module.focus.service.IUserFocusService;
+import com.sp.director.module.video.dto.UserVideoRecommendDTO;
+import com.sp.director.module.video.param.UserPublishVideoParam;
+import com.sp.director.module.video.service.IUserVideoRecommendService;
+import com.sp.director.module.video.service.IUserVideoService;
+import com.sp.director.module.video.service.IVideoLikeService;
+import com.sp.director.module.video.vo.UserVideoVO;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.Rollback;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.*;
+
+/**
+ * @Descrption
+ * @Author: 十一
+ * @Date: 2021/3/18
+ * @Version V1.0
+ **/
+@RunWith(SpringRunner.class)
+@SpringBootTest
+@Slf4j
+@Rollback(value = false)
+public class VideoTest {
+
+    @Autowired
+    private IUserVideoRecommendService userVideoRecommendService;
+
+    @Autowired
+    private IUserVideoService userVideoService;
+
+    @Autowired
+    private IUserFocusService userFocusService;
+
+    @Autowired
+    private IVideoLikeService videoLikeService;
+
+    private Long videoId;
+
+    @Test
+    public void publishVideo(){
+        UserPublishVideoParam param = new UserPublishVideoParam();
+        param.setVideoCover("https://directorout.oss-cn-shenzhen.aliyuncs.com/defaultHeadImg/avatar_1.png");
+        param.setVideoUrl("https://media.w3.org/2010/05/sintel/trailer.mp4");
+        param.setContent("my video");
+        param.setHeight(1980);
+        param.setWidth(789);
+        videoId = userVideoService.publishVideo(10001001L, param);
+        log.error("发布视频成功{}",videoId);
+        verifyVideo();
+        recommendVideo();
+        videoRecommendList();
+    }
+
+    @Test
+    public void verifyVideo(){
+        userVideoRecommendService.verifyUserVideo(videoId, BaseReviewIenum.Pass,null);
+        log.error("审核视频:{}",videoId);
+    }
+
+    @Test
+    public void recommendVideo(){
+        userVideoRecommendService.recommendVideo(videoId);
+        log.error("推荐视频:{}",videoId);
+    }
+
+    @Test
+    public void videoRecommendList(){
+        UserLoginInfo userLoginInfo = new UserLoginInfo();
+        userLoginInfo.setUserId(10001001L);
+        List<UserVideoVO> resultList = new ArrayList<>();
+        List<Long> userIdList = new ArrayList<>();
+        List<Long> videoIdList = new ArrayList<>();
+        Map<Long,Long> userFocusMap = new HashMap<>();
+        Map<Long, Long> userVideoLikeMap = new HashMap<>();;
+        List<UserVideoRecommendDTO> videoList = userVideoRecommendService.queryRecommendVideoList(null);
+        if(!videoList.isEmpty() ){
+            videoList.stream().forEach(v ->{
+                userIdList.add(v.getUserId());
+                videoIdList.add(v.getVideoId());
+            });
+        }
+        if( Objects.nonNull(userLoginInfo) && !userIdList.isEmpty() ){
+            userFocusMap = userFocusService.checkUserFocusByFocusUserIdList(userLoginInfo.getUserId(), userIdList);
+            userVideoLikeMap = videoLikeService.checkUserLikeByVideoList(userLoginInfo.getUserId(), videoIdList);
+        }
+        for (UserVideoRecommendDTO dto : videoList) {
+            UserVideoVO vo = new UserVideoVO();
+            BeanUtils.copyProperties(dto,vo);
+            vo.setVideoId(dto.getVideoId().toString());
+            if( null != userFocusMap ){
+                Long focusUser = userFocusMap.get(vo.getUserId());
+                vo.setFocus(focusUser == null ? false : true);
+            }
+            if( null != userVideoLikeMap ){
+                Long videoLike = userVideoLikeMap.get(vo.getVideoId());
+                vo.setFocus(videoLike == null ? false : true);
+            }
+            resultList.add(vo);
+        }
+        log.error("推荐的视频列表");
+        log.error(JSON.toJSONString(resultList));
+    }
+}