Merge branch 'test6.9.6' of http://git.yoho.cn/platform/platform-cms into test6.9.6
Showing
5 changed files
with
151 additions
and
5 deletions
@@ -521,9 +521,112 @@ public class GrassArticleServiceImpl implements IGrassArticleService { | @@ -521,9 +521,112 @@ public class GrassArticleServiceImpl implements IGrassArticleService { | ||
521 | //推荐和置顶操作,清前台缓存 | 521 | //推荐和置顶操作,清前台缓存 |
522 | clearArticleListCache(req.getArticleId()); | 522 | clearArticleListCache(req.getArticleId()); |
523 | } | 523 | } |
524 | - //编辑文章 没地方用到 | 524 | + //编辑文章 |
525 | if (type == 1) { | 525 | if (type == 1) { |
526 | + publishCheck(req); | ||
526 | 527 | ||
528 | + //修改文章内容 | ||
529 | + Integer articleId = req.getArticleId(); | ||
530 | + if (articleId == null) { | ||
531 | + throw new PlatformException("articleId is null", 402); | ||
532 | + } | ||
533 | + | ||
534 | + List<Integer> labels = Lists.newArrayList(); | ||
535 | + String[] urls = req.getArticleImages().split(","); | ||
536 | + String[] skns = null; | ||
537 | + if (StringUtils.isNotEmpty(req.getArticleSkns())) { | ||
538 | + skns = req.getArticleSkns().split(","); | ||
539 | + if (skns.length > 10) { | ||
540 | + logger.info("updateArticleDraft , article products more than most publish number"); | ||
541 | + throw new PlatformException("publish products most number is 10 ", 405); | ||
542 | + } | ||
543 | + } | ||
544 | + if (urls.length > 9) { | ||
545 | + logger.info("updateArticleDraft , article images more than most publish number"); | ||
546 | + throw new PlatformException("publish images most number is 9 ", 405); | ||
547 | + } | ||
548 | + if (StringUtils.isNotEmpty(req.getLabelIds())) { | ||
549 | + labels = Arrays.stream(req.getLabelIds().split(",")).map(Integer::valueOf).collect(Collectors.toList()); | ||
550 | + if (labels.size() > 5) { | ||
551 | + logger.info("updateArticleDraft , article labels more than most publish number"); | ||
552 | + throw new PlatformException("publish labels most number is 5 ", 405); | ||
553 | + } | ||
554 | + } | ||
555 | + | ||
556 | + //修改文章主体内容 | ||
557 | + long time = 0L; | ||
558 | + Integer sort = Optional.ofNullable(req.getSort()).orElse(1); | ||
559 | + GrassArticle grassArticle = new GrassArticle(); | ||
560 | + grassArticle.setId(articleId); | ||
561 | + grassArticle.setAuthorUid(req.getAuthorUid()); | ||
562 | + grassArticle.setUpdateTime(System.currentTimeMillis()); | ||
563 | + grassArticle.setArticleTitle(req.getTitle()); | ||
564 | + grassArticle.setArticleSubtitle(req.getSubtitle()); | ||
565 | + grassArticle.setSort(sort); | ||
566 | + grassArticle.setCopyright(req.getCopyright()); | ||
567 | + grassArticleDao.updateByPrimaryKeySelective(grassArticle); | ||
568 | + | ||
569 | + //文章内容 | ||
570 | + grassArticleBlockDao.deleteByArticleId(articleId); | ||
571 | + | ||
572 | + //新增 | ||
573 | + List<GrassArticleBlock> addList = buildArticleBlock(urls, articleId, req); | ||
574 | + if (CollectionUtils.isNotEmpty(addList)) { | ||
575 | + grassArticleBlockDao.insertArticleContents(addList); | ||
576 | + updateArticleImageSize(articleId); | ||
577 | + } | ||
578 | + | ||
579 | + //商品 | ||
580 | + grassArticleProductDao.deleteByArticleId(articleId); | ||
581 | + //新增 | ||
582 | + List<GrassArticleProduct> addSknList = Lists.newArrayList(); | ||
583 | + int orderBy = 0; | ||
584 | + if (CollectionUtils.isNotEmpty(req.getProducts())) { | ||
585 | + for (GrassArticleProductBo skn : req.getProducts()) { | ||
586 | + GrassArticleProduct grassArticleSkn = new GrassArticleProduct(); | ||
587 | + grassArticleSkn.setArticleId(articleId); | ||
588 | + grassArticleSkn.setProductSkn(skn.getProductSkn()); | ||
589 | + grassArticleSkn.setCreateTime(System.currentTimeMillis()); | ||
590 | + grassArticleSkn.setOrderBy(orderBy); | ||
591 | + grassArticleSkn.setProductSource(skn.getProductType()); | ||
592 | + orderBy++; | ||
593 | + addSknList.add(grassArticleSkn); | ||
594 | + } | ||
595 | + } | ||
596 | + if (CollectionUtils.isNotEmpty(addSknList)) { | ||
597 | + grassArticleProductDao.insertArticleSkns(addSknList); | ||
598 | + } | ||
599 | + | ||
600 | + //构建lables 数据 | ||
601 | + grassArticleLabelDao.deleteByArticleId(articleId); | ||
602 | + List<GrassArticleLabel> grassArticleLabels = buildArticleLabels(articleId, labels, req.getAuthStatus()); | ||
603 | + try { | ||
604 | + if (CollectionUtils.isNotEmpty(grassArticleLabels) && 3 != req.getSort()) { | ||
605 | + grassArticleLabelDao.insertArticleLabels(grassArticleLabels); | ||
606 | + } | ||
607 | + } catch (Exception e) { | ||
608 | + logger.warn("updateArticle grassArticleLableDao insertArticleLables error, uid is {}, e is {}", req.getAuthorUid(), e); | ||
609 | + } | ||
610 | + | ||
611 | + grassArticleTopicDao.deleteByArticleId(articleId); | ||
612 | + try { | ||
613 | + Integer topicId = req.getTopicId(); | ||
614 | + if (null != topicId && 3 != sort) { | ||
615 | + GrassArticleTopic grassArticleTopic = new GrassArticleTopic(); | ||
616 | + grassArticleTopic.setTopicId(topicId); | ||
617 | + grassArticleTopic.setArticleId(articleId); | ||
618 | + grassArticleTopic.setCreateTime(time); | ||
619 | + grassArticleTopicDao.insertArticleTopic(grassArticleTopic); | ||
620 | + //后期增加(清理话题缓存) | ||
621 | + GrassCacheReq cacheReq = new GrassCacheReq(); | ||
622 | + cacheReq.setClearCode(1005); | ||
623 | + cacheReq.setTopicId(topicId); | ||
624 | + logger.info("updateArticle clear topicCache topicId={}", topicId); | ||
625 | + grassRefreshCacheService.refreshGrassCache(cacheReq); | ||
626 | + } | ||
627 | + } catch (Exception e) { | ||
628 | + logger.warn("publishArticle ,grassArticleTopicDao insertArticleTopic error, uid is {}, e is {}", req.getAuthorUid(), e); | ||
629 | + } | ||
527 | } | 630 | } |
528 | 631 | ||
529 | //审核 通过--不通过 | 632 | //审核 通过--不通过 |
@@ -796,7 +899,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService { | @@ -796,7 +899,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService { | ||
796 | @Database(ForceMaster = true) | 899 | @Database(ForceMaster = true) |
797 | public void updateArticleDraft(GrassArticleReq req) throws PlatformException { | 900 | public void updateArticleDraft(GrassArticleReq req) throws PlatformException { |
798 | publishCheck(req); | 901 | publishCheck(req); |
799 | - // 操作类型,1 编辑后保存草稿箱 2 编辑后直接发布 3 编辑后定时发布 | 902 | + // 操作类型,1 编辑后保存草稿箱 2 编辑后直接发布 3 编辑后定时发布 4 文章已发布二次编辑再次发布 |
800 | Integer type = req.getDraftType(); | 903 | Integer type = req.getDraftType(); |
801 | 904 | ||
802 | //修改文章内容 | 905 | //修改文章内容 |
@@ -357,6 +357,8 @@ | @@ -357,6 +357,8 @@ | ||
357 | str += optStr; | 357 | str += optStr; |
358 | } | 358 | } |
359 | 359 | ||
360 | + str += "<a role='preview' class='btn-info' dataId='" + rowData.previewUrl + "' index='"+ rowIndex + "' style='margin-left:10px'>预览</a>"; | ||
361 | + | ||
360 | 362 | ||
361 | return str; | 363 | return str; |
362 | } | 364 | } |
@@ -408,6 +410,15 @@ | @@ -408,6 +410,15 @@ | ||
408 | } | 410 | } |
409 | }); | 411 | }); |
410 | 412 | ||
413 | + //预览 | ||
414 | + $(this).datagrid("getPanel").find("a[role='preview']").linkbutton({ | ||
415 | + iconCls : "icon-save", | ||
416 | + onClick: function () { | ||
417 | + var previewUrl = $(this).attr("dataId"); | ||
418 | + articlePreview(previewUrl); | ||
419 | + } | ||
420 | + }); | ||
421 | + | ||
411 | // 查看详情 | 422 | // 查看详情 |
412 | $(this).datagrid("getPanel").find("a[role='showDetail']").linkbutton({ | 423 | $(this).datagrid("getPanel").find("a[role='showDetail']").linkbutton({ |
413 | iconCls : "icon-edit", | 424 | iconCls : "icon-edit", |
@@ -464,6 +475,29 @@ | @@ -464,6 +475,29 @@ | ||
464 | }, "json"); | 475 | }, "json"); |
465 | } | 476 | } |
466 | 477 | ||
478 | + // 预览 | ||
479 | + function articlePreview(previewUrl){ | ||
480 | + var articleEditer = $("<div id='articleEditer' style = 'width:25%;height:80%;overflow:scroll;'>").appendTo($(document.body)); | ||
481 | + var content = '<iframe src="' + previewUrl + '" width="95%" height="95%" frameborder="0"></iframe>'; | ||
482 | + $(articleEditer).myDialog({ | ||
483 | + content: content, | ||
484 | + noheader: true, | ||
485 | + border: true, | ||
486 | + resizable: false,//定义对话框是否可调整尺寸。 | ||
487 | + maximized: false,//默认最大化,可调整为false,改成弹出框模式。 | ||
488 | + modal: false, | ||
489 | + buttons:[ | ||
490 | + { | ||
491 | + text: "关闭", | ||
492 | + iconCls: "icon-cancel", | ||
493 | + handler: function () { | ||
494 | + $(articleEditer).dialog("close"); | ||
495 | + } | ||
496 | + } | ||
497 | + ], | ||
498 | + }); | ||
499 | + } | ||
500 | + | ||
467 | function switchTimer(id, status,publishTime) { | 501 | function switchTimer(id, status,publishTime) { |
468 | debugger | 502 | debugger |
469 | var operateType = status == 1 ? 3 : 4; | 503 | var operateType = status == 1 ? 3 : 4; |
@@ -41,6 +41,7 @@ | @@ -41,6 +41,7 @@ | ||
41 | <div region="center" id="labelGroupList" style="margin-left: 20px"> | 41 | <div region="center" id="labelGroupList" style="margin-left: 20px"> |
42 | <div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll"> | 42 | <div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll"> |
43 | <form name="publishArticleForm" id="publishArticleForm" method="post" > | 43 | <form name="publishArticleForm" id="publishArticleForm" method="post" > |
44 | + <input id="operateType" name="operateType" hidden="hidden"/> | ||
44 | <input id="draftType" name="draftType" hidden="hidden"/> | 45 | <input id="draftType" name="draftType" hidden="hidden"/> |
45 | <input id="draftArticleId" name="articleId" hidden="hidden"/> | 46 | <input id="draftArticleId" name="articleId" hidden="hidden"/> |
46 | <div style="margin-top: 20px;margin-left: 30px"> | 47 | <div style="margin-top: 20px;margin-left: 30px"> |
@@ -158,9 +159,12 @@ | @@ -158,9 +159,12 @@ | ||
158 | 159 | ||
159 | var data = paramObject.mkData; | 160 | var data = paramObject.mkData; |
160 | var editFlag = data.editFlag ; | 161 | var editFlag = data.editFlag ; |
162 | + var subottonUrl = serverContextPath+"/grassArticle/updateArticleDraft"; | ||
161 | if(editFlag == 1){ | 163 | if(editFlag == 1){ |
162 | $("#draftBotton").hide(); | 164 | $("#draftBotton").hide(); |
163 | $("#timerBotton").hide(); | 165 | $("#timerBotton").hide(); |
166 | + $("#operateType").val(1); | ||
167 | + subottonUrl = serverContextPath+"/grassArticle/updateArticle"; | ||
164 | } | 168 | } |
165 | 169 | ||
166 | $("#content").emojioneArea({ | 170 | $("#content").emojioneArea({ |
@@ -431,7 +435,7 @@ | @@ -431,7 +435,7 @@ | ||
431 | width:200, | 435 | width:200, |
432 | onClick: function () { | 436 | onClick: function () { |
433 | $("#publishArticleForm").form("submit",{ | 437 | $("#publishArticleForm").form("submit",{ |
434 | - url : serverContextPath+"/grassArticle/updateArticleDraft", | 438 | + url : subottonUrl, |
435 | onSubmit : function(param) { | 439 | onSubmit : function(param) { |
436 | debugger; | 440 | debugger; |
437 | if (!$("#publishArticleForm").form("validate")) { | 441 | if (!$("#publishArticleForm").form("validate")) { |
@@ -508,7 +508,7 @@ | @@ -508,7 +508,7 @@ | ||
508 | str += "<a role='showDetail' class='btn-info' dataId='"+rowData.articleId+ "' index='"+ rowIndex + "' status='1' style='margin-left:10px'>评论</a>"; | 508 | str += "<a role='showDetail' class='btn-info' dataId='"+rowData.articleId+ "' index='"+ rowIndex + "' status='1' style='margin-left:10px'>评论</a>"; |
509 | } | 509 | } |
510 | 510 | ||
511 | - str += "<a role='preview' class='btn-info' dataId='" + rowData.previewUrl + "' index='"+ rowIndex + "' style='margin-left:10px'>预览</a>"; | 511 | + //str += "<a role='preview' class='btn-info' dataId='" + rowData.previewUrl + "' index='"+ rowIndex + "' style='margin-left:10px'>预览</a>"; |
512 | 512 | ||
513 | return str; | 513 | return str; |
514 | } | 514 | } |
@@ -39,6 +39,7 @@ | @@ -39,6 +39,7 @@ | ||
39 | <div region="center" id="labelGroupList" style="margin-left: 20px;width: 100%"> | 39 | <div region="center" id="labelGroupList" style="margin-left: 20px;width: 100%"> |
40 | <div id="tt" class="easyui-layout" style="overflow-y: scroll;overflow-x: auto;"> | 40 | <div id="tt" class="easyui-layout" style="overflow-y: scroll;overflow-x: auto;"> |
41 | <form name="publishArticleForm" id="publishArticleForm" method="post" > | 41 | <form name="publishArticleForm" id="publishArticleForm" method="post" > |
42 | + <input id="operateType" name="operateType" hidden="hidden"/> | ||
42 | <input id="sort" name="sort" value="2" hidden> | 43 | <input id="sort" name="sort" value="2" hidden> |
43 | <input id="draftArticleId" name="articleId" hidden="hidden"/> | 44 | <input id="draftArticleId" name="articleId" hidden="hidden"/> |
44 | <input id="draftType" name="draftType" hidden="hidden"/> | 45 | <input id="draftType" name="draftType" hidden="hidden"/> |
@@ -189,6 +190,7 @@ | @@ -189,6 +190,7 @@ | ||
189 | //对于内容发布页面进来的编辑,只保留立即发布功能 | 190 | //对于内容发布页面进来的编辑,只保留立即发布功能 |
190 | var data = paramObject.mkData; | 191 | var data = paramObject.mkData; |
191 | var editFlag = data.editFlag ; | 192 | var editFlag = data.editFlag ; |
193 | + var subottonUrl = serverContextPath+"/grassArticle/updateArticleDraft"; | ||
192 | if(editFlag == 1){ | 194 | if(editFlag == 1){ |
193 | var sort = data.sort; | 195 | var sort = data.sort; |
194 | $("#draftBotton").hide(); | 196 | $("#draftBotton").hide(); |
@@ -198,6 +200,9 @@ | @@ -198,6 +200,9 @@ | ||
198 | }else if(sort == 3){ //H5跳转链接 隐藏正文 | 200 | }else if(sort == 3){ //H5跳转链接 隐藏正文 |
199 | $("#contentTR").hide(); | 201 | $("#contentTR").hide(); |
200 | } | 202 | } |
203 | + | ||
204 | + $("#operateType").val(1); | ||
205 | + subottonUrl = serverContextPath+"/grassArticle/updateArticle"; | ||
201 | } | 206 | } |
202 | 207 | ||
203 | UE.delEditor("content"); | 208 | UE.delEditor("content"); |
@@ -496,7 +501,7 @@ | @@ -496,7 +501,7 @@ | ||
496 | width:200, | 501 | width:200, |
497 | onClick: function () { | 502 | onClick: function () { |
498 | $("#publishArticleForm").form("submit",{ | 503 | $("#publishArticleForm").form("submit",{ |
499 | - url : serverContextPath+"/grassArticle/updateArticleDraft", | 504 | + url : subottonUrl, |
500 | onSubmit : function(param) { | 505 | onSubmit : function(param) { |
501 | debugger; | 506 | debugger; |
502 | if (!$("#publishArticleForm").form("validate")) { | 507 | if (!$("#publishArticleForm").form("validate")) { |
-
Please register or login to post a comment