三大視頻網站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;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM