Authored by mlge

Merge branch 'test6.9.6' of http://git.yoho.cn/platform/platform-cms into test6.9.6

... ... @@ -521,9 +521,112 @@ public class GrassArticleServiceImpl implements IGrassArticleService {
//推荐和置顶操作,清前台缓存
clearArticleListCache(req.getArticleId());
}
//编辑文章 没地方用到
//编辑文章
if (type == 1) {
publishCheck(req);
//修改文章内容
Integer articleId = req.getArticleId();
if (articleId == null) {
throw new PlatformException("articleId is null", 402);
}
List<Integer> labels = Lists.newArrayList();
String[] urls = req.getArticleImages().split(",");
String[] skns = null;
if (StringUtils.isNotEmpty(req.getArticleSkns())) {
skns = req.getArticleSkns().split(",");
if (skns.length > 10) {
logger.info("updateArticleDraft , article products more than most publish number");
throw new PlatformException("publish products most number is 10 ", 405);
}
}
if (urls.length > 9) {
logger.info("updateArticleDraft , article images more than most publish number");
throw new PlatformException("publish images most number is 9 ", 405);
}
if (StringUtils.isNotEmpty(req.getLabelIds())) {
labels = Arrays.stream(req.getLabelIds().split(",")).map(Integer::valueOf).collect(Collectors.toList());
if (labels.size() > 5) {
logger.info("updateArticleDraft , article labels more than most publish number");
throw new PlatformException("publish labels most number is 5 ", 405);
}
}
//修改文章主体内容
long time = 0L;
Integer sort = Optional.ofNullable(req.getSort()).orElse(1);
GrassArticle grassArticle = new GrassArticle();
grassArticle.setId(articleId);
grassArticle.setAuthorUid(req.getAuthorUid());
grassArticle.setUpdateTime(System.currentTimeMillis());
grassArticle.setArticleTitle(req.getTitle());
grassArticle.setArticleSubtitle(req.getSubtitle());
grassArticle.setSort(sort);
grassArticle.setCopyright(req.getCopyright());
grassArticleDao.updateByPrimaryKeySelective(grassArticle);
//文章内容
grassArticleBlockDao.deleteByArticleId(articleId);
//新增
List<GrassArticleBlock> addList = buildArticleBlock(urls, articleId, req);
if (CollectionUtils.isNotEmpty(addList)) {
grassArticleBlockDao.insertArticleContents(addList);
updateArticleImageSize(articleId);
}
//商品
grassArticleProductDao.deleteByArticleId(articleId);
//新增
List<GrassArticleProduct> addSknList = Lists.newArrayList();
int orderBy = 0;
if (CollectionUtils.isNotEmpty(req.getProducts())) {
for (GrassArticleProductBo skn : req.getProducts()) {
GrassArticleProduct grassArticleSkn = new GrassArticleProduct();
grassArticleSkn.setArticleId(articleId);
grassArticleSkn.setProductSkn(skn.getProductSkn());
grassArticleSkn.setCreateTime(System.currentTimeMillis());
grassArticleSkn.setOrderBy(orderBy);
grassArticleSkn.setProductSource(skn.getProductType());
orderBy++;
addSknList.add(grassArticleSkn);
}
}
if (CollectionUtils.isNotEmpty(addSknList)) {
grassArticleProductDao.insertArticleSkns(addSknList);
}
//构建lables 数据
grassArticleLabelDao.deleteByArticleId(articleId);
List<GrassArticleLabel> grassArticleLabels = buildArticleLabels(articleId, labels, req.getAuthStatus());
try {
if (CollectionUtils.isNotEmpty(grassArticleLabels) && 3 != req.getSort()) {
grassArticleLabelDao.insertArticleLabels(grassArticleLabels);
}
} catch (Exception e) {
logger.warn("updateArticle grassArticleLableDao insertArticleLables error, uid is {}, e is {}", req.getAuthorUid(), e);
}
grassArticleTopicDao.deleteByArticleId(articleId);
try {
Integer topicId = req.getTopicId();
if (null != topicId && 3 != sort) {
GrassArticleTopic grassArticleTopic = new GrassArticleTopic();
grassArticleTopic.setTopicId(topicId);
grassArticleTopic.setArticleId(articleId);
grassArticleTopic.setCreateTime(time);
grassArticleTopicDao.insertArticleTopic(grassArticleTopic);
//后期增加(清理话题缓存)
GrassCacheReq cacheReq = new GrassCacheReq();
cacheReq.setClearCode(1005);
cacheReq.setTopicId(topicId);
logger.info("updateArticle clear topicCache topicId={}", topicId);
grassRefreshCacheService.refreshGrassCache(cacheReq);
}
} catch (Exception e) {
logger.warn("publishArticle ,grassArticleTopicDao insertArticleTopic error, uid is {}, e is {}", req.getAuthorUid(), e);
}
}
//审核 通过--不通过
... ... @@ -796,7 +899,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService {
@Database(ForceMaster = true)
public void updateArticleDraft(GrassArticleReq req) throws PlatformException {
publishCheck(req);
// 操作类型,1 编辑后保存草稿箱 2 编辑后直接发布 3 编辑后定时发布
// 操作类型,1 编辑后保存草稿箱 2 编辑后直接发布 3 编辑后定时发布 4 文章已发布二次编辑再次发布
Integer type = req.getDraftType();
//修改文章内容
... ...
... ... @@ -357,6 +357,8 @@
str += optStr;
}
str += "<a role='preview' class='btn-info' dataId='" + rowData.previewUrl + "' index='"+ rowIndex + "' style='margin-left:10px'>预览</a>";
return str;
}
... ... @@ -408,6 +410,15 @@
}
});
//预览
$(this).datagrid("getPanel").find("a[role='preview']").linkbutton({
iconCls : "icon-save",
onClick: function () {
var previewUrl = $(this).attr("dataId");
articlePreview(previewUrl);
}
});
// 查看详情
$(this).datagrid("getPanel").find("a[role='showDetail']").linkbutton({
iconCls : "icon-edit",
... ... @@ -464,6 +475,29 @@
}, "json");
}
// 预览
function articlePreview(previewUrl){
var articleEditer = $("<div id='articleEditer' style = 'width:25%;height:80%;overflow:scroll;'>").appendTo($(document.body));
var content = '<iframe src="' + previewUrl + '" width="95%" height="95%" frameborder="0"></iframe>';
$(articleEditer).myDialog({
content: content,
noheader: true,
border: true,
resizable: false,//定义对话框是否可调整尺寸。
maximized: false,//默认最大化,可调整为false,改成弹出框模式。
modal: false,
buttons:[
{
text: "关闭",
iconCls: "icon-cancel",
handler: function () {
$(articleEditer).dialog("close");
}
}
],
});
}
function switchTimer(id, status,publishTime) {
debugger
var operateType = status == 1 ? 3 : 4;
... ...
... ... @@ -41,6 +41,7 @@
<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" >
<input id="operateType" name="operateType" hidden="hidden"/>
<input id="draftType" name="draftType" hidden="hidden"/>
<input id="draftArticleId" name="articleId" hidden="hidden"/>
<div style="margin-top: 20px;margin-left: 30px">
... ... @@ -158,9 +159,12 @@
var data = paramObject.mkData;
var editFlag = data.editFlag ;
var subottonUrl = serverContextPath+"/grassArticle/updateArticleDraft";
if(editFlag == 1){
$("#draftBotton").hide();
$("#timerBotton").hide();
$("#operateType").val(1);
subottonUrl = serverContextPath+"/grassArticle/updateArticle";
}
$("#content").emojioneArea({
... ... @@ -431,7 +435,7 @@
width:200,
onClick: function () {
$("#publishArticleForm").form("submit",{
url : serverContextPath+"/grassArticle/updateArticleDraft",
url : subottonUrl,
onSubmit : function(param) {
debugger;
if (!$("#publishArticleForm").form("validate")) {
... ...
... ... @@ -508,7 +508,7 @@
str += "<a role='showDetail' class='btn-info' dataId='"+rowData.articleId+ "' index='"+ rowIndex + "' status='1' style='margin-left:10px'>评论</a>";
}
str += "<a role='preview' class='btn-info' dataId='" + rowData.previewUrl + "' index='"+ rowIndex + "' style='margin-left:10px'>预览</a>";
//str += "<a role='preview' class='btn-info' dataId='" + rowData.previewUrl + "' index='"+ rowIndex + "' style='margin-left:10px'>预览</a>";
return str;
}
... ...
... ... @@ -39,6 +39,7 @@
<div region="center" id="labelGroupList" style="margin-left: 20px;width: 100%">
<div id="tt" class="easyui-layout" style="overflow-y: scroll;overflow-x: auto;">
<form name="publishArticleForm" id="publishArticleForm" method="post" >
<input id="operateType" name="operateType" hidden="hidden"/>
<input id="sort" name="sort" value="2" hidden>
<input id="draftArticleId" name="articleId" hidden="hidden"/>
<input id="draftType" name="draftType" hidden="hidden"/>
... ... @@ -189,6 +190,7 @@
//对于内容发布页面进来的编辑,只保留立即发布功能
var data = paramObject.mkData;
var editFlag = data.editFlag ;
var subottonUrl = serverContextPath+"/grassArticle/updateArticleDraft";
if(editFlag == 1){
var sort = data.sort;
$("#draftBotton").hide();
... ... @@ -198,6 +200,9 @@
}else if(sort == 3){ //H5跳转链接 隐藏正文
$("#contentTR").hide();
}
$("#operateType").val(1);
subottonUrl = serverContextPath+"/grassArticle/updateArticle";
}
UE.delEditor("content");
... ... @@ -496,7 +501,7 @@
width:200,
onClick: function () {
$("#publishArticleForm").form("submit",{
url : serverContextPath+"/grassArticle/updateArticleDraft",
url : subottonUrl,
onSubmit : function(param) {
debugger;
if (!$("#publishArticleForm").form("validate")) {
... ...