فهرست منبع

活动回顾添加视频播放功能

wangjiang988 5 سال پیش
والد
کامیت
dbc57afa66

+ 0 - 1
src/main/java/platform/modules/government/dao/AttachmentDao.java

@@ -19,7 +19,6 @@ public interface AttachmentDao extends BaseMapper<Attachment> {
 
     Integer  deleteByBusiness(@Param("business_type") String business_type, @Param("business_id") Integer business_id);
 
-
     void  updateAttachment(@Param("business_type") String business_type, @Param("business_id") Integer business_id, @Param("id")Integer id);
 
     Integer  deleteByIdAndBusinessId(@Param("business_type") String business_type, @Param("business_id") Integer business_id, @Param("id")Integer id);

+ 0 - 1
src/main/java/platform/modules/government/entity/ProjectMattersDeclaration.java

@@ -1,6 +1,5 @@
 package platform.modules.government.entity;
 
-import com.sun.org.apache.xpath.internal.operations.Bool;
 import lombok.Data;
 import platform.common.base.model.BaseEntity;
 

+ 5 - 2
src/main/java/platform/modules/government/web/ActivityReviewController.java

@@ -9,6 +9,7 @@ import platform.common.Constant;
 import platform.common.base.controller.BaseController;
 import platform.common.base.model.DictionaryItem;
 import platform.common.base.service.DictionaryItemService;
+import platform.common.util.CommonUtils;
 import platform.common.util.DateUtil;
 import platform.common.util.ShiroUtils;
 import platform.modules.government.dto.BatchDto;
@@ -134,12 +135,14 @@ public class ActivityReviewController extends BaseController{
         // ###**************
         // ### 保存视频 wangjiang
         Boolean hasVideo = review.getVideoDown() != null;
-        review.setHas_video(hasVideo );
+        review.setHas_video(hasVideo);
         if (hasVideo) {
             review.setVideo_attachment_id(review.getVideoDown().getFile_id());
             Attachment att = attachmentService.findById(review.getVideoDown().getFile_id());
             review.setVideo_url(att.getFile_url());
-
+        } else {
+            review.setVideo_url("");
+            review.setVideo_attachment_id(null);
         }
         // todo 删除原文件
         // ###**************

+ 20 - 8
src/main/java/platform/modules/sys/service/ActivityReviewService.java

@@ -3,6 +3,7 @@ package platform.modules.sys.service;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import platform.common.Constant;
@@ -35,6 +36,9 @@ public class ActivityReviewService extends BaseService<ActivityReview> {
     @Autowired
     private AttachmentService attachmentService;
 
+    @Value("${fileUrl}")
+    private String fileUrl;
+
     /**
      * 获取活动回顾列表
      *
@@ -69,10 +73,11 @@ public class ActivityReviewService extends BaseService<ActivityReview> {
         // ###**************
         // ### 保存视频 wangjiang
         Boolean hasVideo = review.getVideoDown() != null;
-        review.setHas_video(hasVideo );
+        review.setHas_video(hasVideo);
         if (hasVideo) {
-            review.setVideo_url(review.getVideoDown().getFile_url());
             review.setVideo_attachment_id(review.getVideoDown().getFile_id());
+            Attachment att = attachmentService.findById(review.getVideoDown().getFile_id());
+            review.setVideo_url(att.getFile_url());
         }
         // ###**************
 
@@ -109,12 +114,19 @@ public class ActivityReviewService extends BaseService<ActivityReview> {
             }
             // ###***************
             // ### 获取 video
-//            if(review.getVideo_attachment_id() != null) {
-//                Attachment attachment1 = attachmentService.findById(review.getVideo_attachment_id());
-//                if (attachment1 != null) {
-//
-//                }
-//            }
+            if(review.getVideo_attachment_id() != null) {
+                Attachment attachment1 = attachmentService.findById(review.getVideo_attachment_id());
+                if (attachment1 != null) {
+                    FileDown videoDown = new FileDown();
+                    videoDown.setFile_id(attachment1.getId());
+                    videoDown.setFile_name(attachment1.getFile_name());
+                    videoDown.setFile_url(attachment1.getFile_url());
+                    review.setVideoDown(videoDown);
+                    String file_url = attachment1.getFile_url();
+                    file_url = fileUrl + file_url;
+                    review.setVideo_url(file_url);
+                }
+            }
             // ###**************
             review.setBrowse_count(review.getBrowse_count()+1);
             this.updateSelective(review);

+ 19 - 0
src/main/resources/templates/admin/government/activity_review/add.html

@@ -53,6 +53,13 @@
             </div>
         </div>
         <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>是否有视频:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <label style="margin-right: 10px;"><input name="has_video" checked type="radio" value="0">否</label>
+                <label><input name="has_video"  type="radio" value="1"> 是</label>
+            </div>
+        </div>
+        <div class="row cl" id="videoArea">
             <label class="form-label col-xs-4 col-sm-2">视频:</label>
             <div class="formControls col-xs-8 col-sm-9">
                 <div class="uploader-thum-container">
@@ -124,6 +131,7 @@
     var webUploadPicture = new $WebUploadPicture(options);
     webUploadPicture.init();
 
+    // 初始视频上传
     // 初始视频上传
     var options2 = {
         auto: false,
@@ -168,6 +176,17 @@
             $("#activity_endtimeIE").remove();
             $("#activity_deadlineIE").remove();
         }
+        // 视频区域设置
+        $('input[type=radio][name=has_video]').change(function() {
+            if (this.value == '1') {
+                $("#videoArea").show()
+            } else {
+                $("#videoArea").hide()
+            }
+        });
+        setTimeout(function () {
+            $("#videoArea").hide()
+        }, 300)
     });
     
     function findActivity() {

+ 35 - 12
src/main/resources/templates/admin/government/activity_review/edit.html

@@ -38,7 +38,7 @@
         <div class="row cl">
             <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>是否置顶:</label>
             <div class="formControls col-xs-8 col-sm-9">
-                <label style="margin-right: 10px;"><input name="is_top" type="radio" value="0"> 不置顶</label>
+                <label style="margin-right: 10px;"><input name="is_top"  type="radio" value="0"> 不置顶</label>
                 <label><input name="is_top" type="radio" value="1"> 置顶</label>
             </div>
         </div>
@@ -55,6 +55,13 @@
             </div>
         </div>
         <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>是否有视频:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <label style="margin-right: 10px;"><input name="has_video" th:checked="${review.has_video==false }" type="radio" value="0">否</label>
+                <label><input name="has_video" th:checked="${review.has_video==true }" type="radio" value="1"> 是</label>
+            </div>
+        </div>
+        <div class="row cl" id="videoArea">
             <label class="form-label col-xs-4 col-sm-2">视频:</label>
             <div class="formControls col-xs-8 col-sm-9">
                 <div class="uploader-thum-container">
@@ -62,7 +69,8 @@
                     <div id="videoPicker" class="margin-right-10">选择视频</div>
                     <input type="hidden" th:value="${review.video_url}" th:id="video_url" th:name="video_url"/>
                     <div id="videoListPre">
-                        <video id="videoElement" class="centeredVideo" controls autoplay width="450" height="400">Your browser is too old which doesn't support HTML5 video.</video>
+                        <a th:href="@{ '' + ${review.videoDown.file_url}}">[[${review.videoDown.file_name}]]</a>
+<!--                        <video id="videoElement" class="centeredVideo" controls autoplay width="450" height="400">Your browser is too old which doesn't support HTML5 video.</video>-->
                     </div>
                 </div>
             </div>
@@ -88,16 +96,16 @@
 <script type="text/javascript" th:src="@{/h-ui/lib/webuploader/0.1.5/webuploader.min.js}"></script>
 <script th:inline="javascript">
 
-    var player = document.getElementById('videoElement');
-    var video_url = $('#video_url').val();
-    if (flvjs.isSupported()) {
-        var flvPlayer = flvjs.createPlayer({
-            type: 'flv',
-            url: video_url
-        });
-        flvPlayer.attachMediaElement(videoElement);
-        flvPlayer.load(); //加载
-    }
+    // var player = document.getElementById('videoElement');
+    // var video_url = $('#video_url').val();
+    // if (flvjs.isSupported() && video_url !=null) {
+    //     var flvPlayer = flvjs.createPlayer({
+    //         type: 'flv',
+    //         url: video_url
+    //     });
+    //     flvPlayer.attachMediaElement(videoElement);
+    //     flvPlayer.load(); //加载
+    // }
 
     //富文本kindeditor初始化
     var editor;
@@ -193,6 +201,21 @@
         else {
             $("input:radio[name='is_top'][value= '0']").prop("checked", true);
         }
+        var hasVideo = [[${review.has_video}]];
+
+        if (hasVideo) {
+            $("#videoArea").show()
+        } else {
+            $("#videoArea").hide()
+        }
+
+        $('input[type=radio][name=has_video]').change(function() {
+            if (this.value == '1') {
+                $("#videoArea").show()
+            } else {
+                $("#videoArea").hide()
+            }
+        });
 
     });