Authored by 张帅

后台发布文章

... ... @@ -11,11 +11,13 @@ import com.yohobuy.platform.dal.grass.model.GrassArticleImage;
import com.yohobuy.platform.dal.grass.model.GrassArticleSkn;
import com.yohobuy.platform.grass.service.IGrassArticleService;
import com.yohobuy.platform.model.grass.request.GrassArticleReq;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
/**
... ... @@ -53,10 +55,10 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
try{
List<GrassArticleImage> imageList = Lists.newArrayList();
for (String img: req.getArticleImages()) {
String[] urls = req.getArticleImages().split(",");
for (String img: urls) {
GrassArticleImage image = new GrassArticleImage();
image.setArticleId(article.getGuangArticleId());
image.setArticleId(article.getId());
image.setImgSrc(img);
image.setCreateTime(DateUtil.getCurrentTimeSeconds());
imageList.add(image);
... ... @@ -69,9 +71,10 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
try{
List<GrassArticleSkn> sknList = Lists.newArrayList();
for (String skn: req.getArticleSkns()) {
String[] skns = req.getArticleSkns().split(",");
for (String skn: skns) {
GrassArticleSkn grassArticleSkn = new GrassArticleSkn();
grassArticleSkn.setArticleId(article.getGuangArticleId());
grassArticleSkn.setArticleId(article.getId());
grassArticleSkn.setProductSkn(Integer.valueOf(skn));
grassArticleSkn.setCreateTime(DateUtil.getCurrentTimeSeconds());
sknList.add(grassArticleSkn);
... ... @@ -90,11 +93,11 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
logger.info("publishCheck uid is null");
throw new PlatformException("publish uid is null", 403);
}
if(req.getArticleImages() ==null || req.getArticleImages().size()< 1){
if(StringUtils.isEmpty(req.getArticleImages())){
logger.info("publishCheck images is null");
throw new PlatformException("publish images is null", 403);
}
if(req.getArticleSkns() ==null || req.getArticleSkns().size()< 1){
if(StringUtils.isEmpty(req.getArticleSkns())){
logger.info("publishCheck skn is null");
throw new PlatformException("publish skn is null", 403);
}
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Yoho!Buy运营平台</title>
<script src="/pfcms/js/include.js"></script>
<script src="/pfcms/js/ajaxfileupload.js"></script>
<style>
.btn-long {
width: 120px;
height: 37px;
line-height: 37px;
font-size: 15px;
color: white;
border-radius: 5px;
display: inline-block;
cursor: pointer;
text-align: center;
}
.btn-long:hover {
opacity: 0.9;
}
</style>
</head>
<body class="easyui-layout" >
<div region="north" style="height: 100px;">
<script>
document.write(addHead('运营管理', '种草内容发布'));
</script>
</div>
<div region="center" id="labelGroupList" style="margin-left: 20px">
<div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll">
<form name="publishArticleForm" id="publishArticleForm" method="post" >
<div style="margin-top: 20px;margin-left: 30px">
<table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab">
<tr style="height: 60px">
<td >
<span style="color:red">*</span><label>选择用户</label> <br>
<input id="articleUid" name="articleUid" class="easyui-textbox" style="width: 380px;"/>
</td>
</tr>
<tr style="height: 60px">
<td>
<span style="color:red">*</span><label>文字内容</label> <br>
<input id="content" name="content" class="easyui-textbox" style="width: 380px;"/>
</td>
</tr>
<tr style="height: 60px">
<td>
<span style="color:red">*</span><label>选择话题</label> <br>
<input id="topic" name="topicId" class="easyui-combobox" style="width: 380px;"/>
</td>
</tr>
<tr style="height: 20px">
<td >
<span style="color:red">*</span><label>选择图片</label>
<a id="addImage" class="btn-default" >选择图片+</a>
<input id="imgs" name="articleImages" hidden="hidden"/>
</td>
</tr>
<tr style="height: 60px">
<td id="imgTd">
<div id="imageUpload">
</div>
</td>
</tr>
<tr style="height: 60px">
<td>
<span style="color:red">*</span><label>关联商品</label> <br>
<a id="addSkn" class="btn-default" >新增商品+</a>
<input id="skns" name="articleSkns" hidden="hidden"/>
</td>
<td>
<img id="good1" src="" hidden>
<img id="good2" src="" hidden>
</td>
</tr>
<tr>
<td height="50" valign="bottom">
<input class="btn-primary" type="button" onclick="submit()" value="保存"/>
</td>
</tr>
</table>
</div>
</form>
</div>
</div>
</body>
<script>
var count = 1;
$(function () {
$("#articleUid").textbox({
required: true,
missingMessage: "发布用户不能为空",
prompt: "请输入发布用户"
});
$("#content").textbox({
required: true,
missingMessage: "发布内容不能为空",
prompt: "请输入发布内容"
});
$("#topic").combobox({
prompt: "请选择话题"
});
$("#imageUpload").imageUpload({
width: 171,
height: 120,
realInputName: "url",
url: contextPath + '/fileupload/uploadFile',
queryParams: {
bucket: "activity"
},
onBeforeSubmit: function () {
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后...",
interval: 500,
text: ""
});
},
filterFileName: function (data) {
debugger;
if (!data || data.code != 200) {
$.messager.progress("close");
$.messager.alert("错误",data.message);
return "";
}
return data.data.url;
},
onLoadSuccess: function (data) {
$.messager.progress("close");
$("#imageUpload").after('<div id="imageUpload1">\n' +
' </div>');
oo(1);
return false;
}
});
function oo(num){
if(count >8){
return
}
$("#imageUpload"+num).imageUpload({
width: 171,
height: 120,
realInputName: "url",
url: contextPath + '/fileupload/uploadFile',
queryParams: {
bucket: "activity"
},
onBeforeSubmit: function () {
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后...",
interval: 500,
text: ""
});
},
filterFileName: function (data) {
debugger;
if (!data || data.code != 200) {
$.messager.progress("close");
$.messager.alert("错误",data.message);
return "";
}
return data.data.url;
},
onLoadSuccess: function (data) {
$.messager.progress("close");
var nnum = num+1;
$("#imageUpload"+num).after('<div id="imageUpload'+nnum+'"> </div>');
count = count+1;
oo(nnum);
return false;
}
});
}
});
function submit(){
$("#publishArticleForm").form("submit",{
url : "http://localhost:8088/platform/grassArticle/publishArticle",
onSubmit : function(param) {
if (!$("#publishArticleForm").form("validate")) {
return false;
}
var imgs = '';
$("input[name='url']").each(function(j,item){
var url = item.val();
if(imgs == ''){
imgs = url;
}else{
imgs = imgs + ","+url;
}
});
$("#imgs").val(imgs);
return true;
},
success : function(data) {
if (data) {
data = $.parseJSON(data);
if (data.code == 200) {
$.messager.alert("保存成功");
} else {
$.messager.alert("保存失败", data.message, "error");
}
} else {
$.messager.alert("保存失败", data.message, "error");
}
}
});
}
function submit1(){
debugger
var imgs = '';
$("input[name='url']").each(function(j,item){
var url = item.value;
if(imgs == ''){
imgs = url;
}else{
imgs = imgs + ","+url;
}
});
$("#imgs").val(imgs);
$("#publishArticleForm").action="http://localhost:8088/platform/grassArticle/publishArticle";
$("#publishArticleForm").submit();
}
</script>
</html>
\ No newline at end of file
... ...