zoukankan      html  css  js  c++  java
  • 三大视频网站Url的处理保存(视频和图片二选一操作)

    前台Js

    // 视频处理
    var textVideoLink=$("input[name='textVideoLink']").val();
    // 去除所有有的引号和空格
    var vk=textVideoLink.replace(/"/g, "");
    // 地址的处理
    var reg = RegExp(/allowfullscreen/);
    var youku = RegExp(/youku/);
    var youkuPostfix = RegExp(/frameborder=0/);
    // 编辑时的处理
    var vklPrefix="http";
    var vklStr=textVideoLink.substr(0,4);

    if(textVideoLink!=null && textVideoLink != ""){

    if(vk.match(reg) && !vk.match(youku)){
    // 爱奇艺和腾讯走以下截取
    var textVideoLink=vk.substring(vk.indexOf("http"), vk.lastIndexOf("allowfullscreen"));

    }else if(vk.match(youku) && vk.match(youkuPostfix)){
    // 优酷视频地址走一下截取
    var textVideoLink=vk.substring(vk.indexOf("http"), vk.lastIndexOf("frameborder=0"));

    }else if(vklPrefix==vklStr){
    // 编辑回显状态时输入框的url
    var textVideoLink=textVideoLink.replace(/"/g, "");
    }else{
    bootbox.alert({
    size: "small",
    title: "错误",
    message: "输入的视频地址格式有误"
    });
    return;
    }
    }else{
    // 发生在变更时 将视频转图片的情况下
    alert("测试");
    }



    // 视频和主图的添加的判断
    var textPicture = $('input[name=textPicture]').val().trim();

    if (textVideoLink == null || textVideoLink == "") {
    if (textPicture != "") {
    // 添加图片
    data.textPicture = textPicture;
    } else {
    bootbox.alert({
    size: "small",
    title: "错误",
    message: "请至少上传一张图片或一个视频地址"
    });
    return;
    }
    } else if ((textVideoLink != "" || textVideoLink != null) && textPicture != "") {

    bootbox.alert({
    size: "small",
    title: "错误",
    message: "图片和视频只能二选一"
    });
    return;

    }else if(textVideoLink != "" && vklStr==vklPrefix && textPicture=="") {
    // 编辑时 会显的是 http开头的地址
    data.textVideoLink=textVideoLink;

    }else if(textVideoLink != "" && (textPicture != "" || textPicture != null)){
    // 新增时 视频url 添加
    data.textVideoLink=textVideoLink;
    }

    后台Java代码的保存

    / 新增微信推荐文章信息
    @Override
    @Transactional
    public BaseOutDTO addWxText( WxDiscoverText wxDiscoverText) {
    BaseOutDTO baseOutDTO = new BaseOutDTO();
    int i;
    Date date = new Date();
    if (wxDiscoverText.getTextId()==null){
    if(wxDiscoverText.getTextVideoLink()!=null && wxDiscoverText.getTextVideoLink()!=""){
    String vk = wxDiscoverText.getTextVideoLink();
    wxDiscoverText.setTextVideoLink(vk);
    }
    // 删除状态默认未删除
    wxDiscoverText.setIsDelete((byte) 0);
    // 创建时文章浏览量默认为0
    wxDiscoverText.setReadCount(0L);
    // 默认排序为0
    wxDiscoverText.setSort(0);
    wxDiscoverText.setTextCreateTime(date);
    i = wxDiscoverTextMapper.insertSelect(wxDiscoverText);
    } else if(wxDiscoverText.getTextId()!=null && wxDiscoverText.getTextVideoLink()!=null ){
    String vk = wxDiscoverText.getTextVideoLink();
    wxDiscoverText.setTextVideoLink(vk);
    wxDiscoverText.setTextUpdateTime(date);
    wxDiscoverText.setIsShow((byte)1);
    i = wxDiscoverTextMapper.updateTextByPrimaryKeyService(wxDiscoverText);
    }else if(wxDiscoverText.getTextId()!=null && wxDiscoverText.getTextVideoLink()==null && wxDiscoverText.getTextPicture()!=null){
    wxDiscoverText.setTextVideoLink("");
    wxDiscoverText.setTextUpdateTime(date);
    wxDiscoverText.setIsShow((byte)1);
    i = wxDiscoverTextMapper.updateTextByPrimaryKeyService(wxDiscoverText);
    }else {
    wxDiscoverText.setTextUpdateTime(date);
    wxDiscoverText.setIsShow((byte)1);
    i = wxDiscoverTextMapper.updateTextByPrimaryKeyService(wxDiscoverText);
    }

    if (i==1){
    baseOutDTO.setErrorCode(Rescode.SUCCESS);
    }else {
    baseOutDTO.setErrorCode(Rescode.FAIL);
    }
    return baseOutDTO;
    }
  • 相关阅读:
    C++ Primer Plus 6 第二章
    C++ Primer Plus 6 第一章
    log4j不同级别的日志打印到不同的目录
    清理(删除)pika中的数据
    大数据技术发展回顾
    Flink RedisRichSinkFunction
    Flink FlinkEnvBuilder
    Flink maven project build config
    RedisRichSinkFunction
    kafka Consumer2Local
  • 原文地址:https://www.cnblogs.com/jabez1992/p/9376538.html
Copyright © 2011-2022 走看看