瀏覽代碼

添加回顾视频功能

wangjiang988 5 年之前
父節點
當前提交
f5d69eebb9

+ 7 - 0
sql/20200424.sql

@@ -0,0 +1,7 @@
+-- 活动详情 视频字段
+ALTER TABLE `ac_activity_review`
+ADD COLUMN `has_video` tinyint(1) NULL DEFAULT 0 COMMENT '是否有视频' AFTER `is_draft`,
+ADD COLUMN `video_url` varchar(600) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '视频地址' AFTER `has_video`,
+ADD COLUMN `video_attachment_id` int(11)  DEFAULT NULL COMMENT '视频附件uuid' AFTER `video_url`,
+DROP PRIMARY KEY,
+ADD PRIMARY KEY (`id`) USING BTREE;

+ 14 - 1
src/main/java/platform/modules/government/web/ActivityReviewController.java

@@ -114,7 +114,7 @@ public class ActivityReviewController extends BaseController{
      * @return
      */
     @GetMapping("/edit/{id}")
-    public String toEdit(@PathVariable Integer id, ModelMap modelMap){
+    public String toEdit(@PathVariable Integer id, ModelMap modelMap) {
         ActivityReview review = activityReviewService.findReviewById(id);
         modelMap.put("review", review);
         modelMap.put("fileUrl", setFileUrl());
@@ -130,6 +130,19 @@ public class ActivityReviewController extends BaseController{
     @PostMapping("/update")
     @ResponseBody
     public Object updateReview(ActivityReview review){
+        review.setHas_video(review.getVideoDown() != null );
+        // ###**************
+        // ### 保存视频 wangjiang
+        Boolean hasVideo = review.getVideoDown() != null;
+        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());
+
+        }
+        // todo 删除原文件
+        // ###**************
         activityReviewService.updateSelective(review);
         if (review.getFileDown() != null){
             Attachment attachment = attachmentService.findById(review.getFileDown().getFile_id());

+ 9 - 0
src/main/java/platform/modules/sys/entity/ActivityReview.java

@@ -31,6 +31,12 @@ public class ActivityReview extends BaseEntity {
 
     private Integer browse_count;   //浏览次数
 
+    private Boolean has_video; // 是否有视频 true 有 false 无
+
+    private String video_url; // 视频地址
+    private Integer video_attachment_id; // 视频文件id
+
+
     @Transient
     private String activity_title;
     @Transient
@@ -39,4 +45,7 @@ public class ActivityReview extends BaseEntity {
     private String publisher;
     @Transient
     private FileDown fileDown;
+
+    @Transient
+    private FileDown videoDown;
 }

+ 19 - 0
src/main/java/platform/modules/sys/service/ActivityReviewService.java

@@ -66,6 +66,16 @@ public class ActivityReviewService extends BaseService<ActivityReview> {
      */
     public void insert(ActivityReview review) {
         review.setBrowse_count(0);
+        // ###**************
+        // ### 保存视频 wangjiang
+        Boolean hasVideo = review.getVideoDown() != null;
+        review.setHas_video(hasVideo );
+        if (hasVideo) {
+            review.setVideo_url(review.getVideoDown().getFile_url());
+            review.setVideo_attachment_id(review.getVideoDown().getFile_id());
+        }
+        // ###**************
+
         int reviewId = this.insertAndGetId(review);
         //保存图片
         if (review.getFileDown() != null){
@@ -97,6 +107,15 @@ public class ActivityReviewService extends BaseService<ActivityReview> {
                 FileDown fileDown = new FileDown(null, null, "", null);
                 review.setFileDown(fileDown);
             }
+            // ###***************
+            // ### 获取 video
+//            if(review.getVideo_attachment_id() != null) {
+//                Attachment attachment1 = attachmentService.findById(review.getVideo_attachment_id());
+//                if (attachment1 != null) {
+//
+//                }
+//            }
+            // ###**************
             review.setBrowse_count(review.getBrowse_count()+1);
             this.updateSelective(review);
         }

+ 1 - 1
src/main/java/platform/modules/sys/web/FileUploadController.java

@@ -53,7 +53,7 @@ public class FileUploadController extends BaseController {
     // 允许上传图片的格式
     private static final String[] IMAGE_TYPE = new String[]{".gif", ".jpeg", ".bmp", ".jpg", ".png"};
     // 允许上传文件的格式
-    private static final String[] DOC_TYPE = new String[]{".doc", ".docx", ".ppt", ".pptx", ".pdf", ".xls", ".xlsx", ".gif", ".jpeg", ".bmp", ".jpg", ".png", ".txt", ".rar", ".zip", ".7z"};
+    private static final String[] DOC_TYPE = new String[]{".doc", ".docx", ".ppt", ".pptx", ".pdf", ".xls", ".xlsx", ".gif", ".jpeg", ".bmp", ".jpg", ".png", ".txt", ".rar", ".zip", ".7z", ".flv"};
 
     //private static final String FILE_SERVER_URL = "http://172.18.1.101:8080/file/upload/";
 

File diff suppressed because it is too large
+ 0 - 0
src/main/resources/static/js/common/flv.min.js


+ 2 - 3
src/main/resources/templates/admin/common/common.html

@@ -32,9 +32,7 @@
 	<link rel="stylesheet" th:href="@{/home/font/iconfont.css}">
     <link rel="stylesheet" th:href="@{/home/font2/iconfont.css}">
     <link rel="stylesheet" type="text/css" th:href="@{/home/css/cover.css}" />
-
-
-
+    <link rel="stylesheet" type="text/css" th:href="@{/home/css/cover.css}" />
 
 
     <!--<script type="text/javascript" th:src="@{/js/lib/jquery-1.11.0.min.js}"></script>-->
@@ -54,6 +52,7 @@
 
     <script type="text/javascript" th:src="@{/js/common/layerUtil.js}"></script>
     <script type="text/javascript" th:src="@{/js/common/common.js}"></script>
+    <script type="text/javascript" th:src="@{/js/common/flv.min.js}"></script>
     <script type="text/javascript" th:src="@{/js/common/webUploadUtil.js}"></script>
 
     <script type="text/javascript" charset="utf-8" th:src="@{/h-ui/lib/kindeditor-4.1.7/kindeditor-min.js}"></script>

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

@@ -51,6 +51,18 @@
                     <div id="fileListPre"></div>
                 </div>
             </div>
+        </div>
+        <div class="row cl">
+            <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">
+                    <div id="videoList" class="uploader-list"></div>
+                    <div id="videoPicker" class="margin-right-10">选择视频</div>
+                    <input type="hidden" value="11" th:id="video_url" th:name="video_url"/>
+                    <div id="videoListPre"></div>
+                </div>
+            </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">
@@ -108,8 +120,32 @@
         fileSingleSizeLimit: 100 * 1024 * 1024
 //		fileNumLimit: 1
     };
+
     var webUploadPicture = new $WebUploadPicture(options);
     webUploadPicture.init();
+
+    // 初始视频上传
+    var options2 = {
+        auto: false,
+        uploadBtnId: '#videoPicker',
+        docPreId: 'videoListPre',
+        //serverUrl: '/government/slides/uploadImg',
+        hiddenDocUrl: 'videoDown.file_id',
+        hiddenPictureName: 'videoName',
+        accept: {
+            title: 'video',
+            extensions: 'flv',
+            mimeTypes: 'flv-application/octet-stream'
+        },
+        width: 81,
+        height: 81,
+        fileSizeLimit: 300 * 1024 * 1024,
+        fileSingleSizeLimit: 300 * 1024 * 1024
+//		fileNumLimit: 1
+    };
+    var webUploadPicture2 = new $WebUploadDoc(options2);
+    webUploadPicture2.init();
+
     $("#is_quota").change(function () {
         if ($('#is_quota option:selected').val() == "1") {
             $("#quota").show()

+ 47 - 1
src/main/resources/templates/admin/government/activity_review/edit.html

@@ -3,7 +3,7 @@
       xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
       layout:decorate="~{admin/common/common}">
 <head>
-    <title>活动管理新增</title>
+    <title>活动管理编辑</title>
     <style>
         .push-names span {
             display: inline-block;
@@ -54,6 +54,19 @@
                 </div>
             </div>
         </div>
+        <div class="row cl">
+            <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">
+                    <div id="videoList" class="uploader-list"></div>
+                    <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>
+                    </div>
+                </div>
+            </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">
@@ -75,6 +88,17 @@
 <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(); //加载
+    }
+
     //富文本kindeditor初始化
     var editor;
     KindEditor.ready(function (K) {
@@ -113,6 +137,28 @@
     };
     var webUploadPicture = new $WebUploadPicture(options);
     webUploadPicture.init();
+
+    // 初始视频上传
+    var options2 = {
+        auto: false,
+        uploadBtnId: '#videoPicker',
+        docPreId: 'videoListPre',
+        //serverUrl: '/government/slides/uploadImg',
+        hiddenDocUrl: 'videoDown.file_id',
+        hiddenPictureName: 'videoName',
+        accept: {
+            title: 'video',
+            extensions: 'flv',
+            mimeTypes: 'flv-application/octet-stream'
+        },
+        width: 81,
+        height: 81,
+        fileSizeLimit: 300 * 1024 * 1024,
+        fileSingleSizeLimit: 300 * 1024 * 1024
+//		fileNumLimit: 1
+    };
+    var webUploadPicture2 = new $WebUploadDoc(options2);
+    webUploadPicture2.init();
     $("#is_quota").change(function () {
         if ($('#is_quota option:selected').val() == "1") {
             $("#quota").show()

Some files were not shown because too many files changed in this diff