From 468bff63ac95683a5ce8238bc114c2be28391025 Mon Sep 17 00:00:00 2001 From: Renpc-kilig <308442850@qq.com> Date: Thu, 13 Jun 2024 11:56:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E9=97=BB=E6=96=B0=E5=A2=9E=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E5=8F=91=E5=B8=83=E5=8A=9F=E8=83=BD=20=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E7=AE=A1=E7=90=86=E5=8F=96=E6=B6=88=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/content/ContentController.java | 11 ++++ .../controller/api/news/NewsController.java | 22 +++++++ .../service/content/IContentService.java | 2 + .../content/impl/ContentServiceImpl.java | 7 +++ .../operator/service/news/INewsService.java | 4 ++ .../service/news/impl/NewsServiceImpl.java | 23 ++++++- .../resources/templates/content/list.html | 28 ++++++++- src/main/resources/templates/news/list.html | 63 ++++++++++++++++++- src/main/resources/templates/news/save.html | 4 +- src/main/resources/templates/news/update.html | 4 +- 10 files changed, 159 insertions(+), 9 deletions(-) diff --git a/src/main/java/cn/com/tenlion/operator/controller/api/content/ContentController.java b/src/main/java/cn/com/tenlion/operator/controller/api/content/ContentController.java index 85f9e1f..35454e6 100644 --- a/src/main/java/cn/com/tenlion/operator/controller/api/content/ContentController.java +++ b/src/main/java/cn/com/tenlion/operator/controller/api/content/ContentController.java @@ -119,4 +119,15 @@ public class ContentController extends DefaultBaseController { return new SuccessResult(); } + @ApiOperation(value = "发布", notes = "发布接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "contentId", value = "内容主体表ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PutMapping("publish/{contentId}") + public SuccessResult publish(@PathVariable("contentId") String contentId) { + contentService.publish(contentId); + return new SuccessResult(); + } + } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/operator/controller/api/news/NewsController.java b/src/main/java/cn/com/tenlion/operator/controller/api/news/NewsController.java index 63f7150..39b0cc7 100644 --- a/src/main/java/cn/com/tenlion/operator/controller/api/news/NewsController.java +++ b/src/main/java/cn/com/tenlion/operator/controller/api/news/NewsController.java @@ -108,4 +108,26 @@ public class NewsController extends DefaultBaseController { return new SuccessResultData<>(newsService.count(params)); } + @ApiOperation(value = "取消发布", notes = "取消发布接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "newsId", value = "内容主体表ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PutMapping("cancel/{newsId}") + public SuccessResult cancel(@PathVariable("newsId") String newsId) { + newsService.cancel(newsId); + return new SuccessResult(); + } + + @ApiOperation(value = "发布", notes = "发布接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "newsId", value = "内容主体表ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PutMapping("publish/{newsId}") + public SuccessResult publish(@PathVariable("newsId") String newsId) { + newsService.publish(newsId); + return new SuccessResult(); + } + } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/operator/service/content/IContentService.java b/src/main/java/cn/com/tenlion/operator/service/content/IContentService.java index cf6ff5a..7b3e361 100644 --- a/src/main/java/cn/com/tenlion/operator/service/content/IContentService.java +++ b/src/main/java/cn/com/tenlion/operator/service/content/IContentService.java @@ -188,4 +188,6 @@ public interface IContentService { List contentList(Map params); void cancel(String contentId); + + void publish(String contentId); } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/operator/service/content/impl/ContentServiceImpl.java b/src/main/java/cn/com/tenlion/operator/service/content/impl/ContentServiceImpl.java index ae1d9c5..bfeebcd 100644 --- a/src/main/java/cn/com/tenlion/operator/service/content/impl/ContentServiceImpl.java +++ b/src/main/java/cn/com/tenlion/operator/service/content/impl/ContentServiceImpl.java @@ -205,4 +205,11 @@ public class ContentServiceImpl extends DefaultBaseService implements IContentSe update(contentId, contentVO); } + @Override + public void publish(String contentId) { + ContentVO contentVO = new ContentVO(); + contentVO.setSendStatus("published"); + update(contentId, contentVO); + } + } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/operator/service/news/INewsService.java b/src/main/java/cn/com/tenlion/operator/service/news/INewsService.java index d9c7bd3..5dbadb8 100644 --- a/src/main/java/cn/com/tenlion/operator/service/news/INewsService.java +++ b/src/main/java/cn/com/tenlion/operator/service/news/INewsService.java @@ -186,4 +186,8 @@ public interface INewsService { Integer count(Map params); List listTop(Map params); + + void cancel(String newsId); + + void publish(String newsId); } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/operator/service/news/impl/NewsServiceImpl.java b/src/main/java/cn/com/tenlion/operator/service/news/impl/NewsServiceImpl.java index 10ebbc3..8c016df 100644 --- a/src/main/java/cn/com/tenlion/operator/service/news/impl/NewsServiceImpl.java +++ b/src/main/java/cn/com/tenlion/operator/service/news/impl/NewsServiceImpl.java @@ -1,5 +1,6 @@ package cn.com.tenlion.operator.service.news.impl; +import cn.com.tenlion.operator.pojo.vos.content.ContentVO; import ink.wgink.common.base.DefaultBaseService; import ink.wgink.module.dictionary.pojo.dtos.DataDTO; import ink.wgink.module.dictionary.service.IDataService; @@ -147,9 +148,11 @@ public class NewsServiceImpl extends DefaultBaseService implements INewsService public List list(Map params) { List list = newsDao.list(params); for (NewsDTO newsDTO : list) { - DataDTO dataDTO = dataService.get(newsDTO.getNewsType()); - if (null != dataDTO) { - newsDTO.setNewsTypeName(dataDTO.getDataName()); + if(StringUtils.isNotEmpty(newsDTO.getNewsType())) { + DataDTO dataDTO = dataService.get(newsDTO.getNewsType()); + if (null != dataDTO) { + newsDTO.setNewsTypeName(dataDTO.getDataName()); + } } if (StringUtils.isNotEmpty(newsDTO.getPublishTime())) { newsDTO.setPublishTimeSub1(newsDTO.getPublishTime().substring(0, 7)); @@ -203,4 +206,18 @@ public class NewsServiceImpl extends DefaultBaseService implements INewsService return newsDTOS; } + @Override + public void cancel(String newsId) { + NewsVO newsVO = new NewsVO(); + newsVO.setSendStatus("save"); + update(newsId, newsVO); + } + + @Override + public void publish(String newsId) { + NewsVO newsVO = new NewsVO(); + newsVO.setSendStatus("published"); + update(newsId, newsVO); + } + } diff --git a/src/main/resources/templates/content/list.html b/src/main/resources/templates/content/list.html index c7d0e1d..a6d8ab6 100644 --- a/src/main/resources/templates/content/list.html +++ b/src/main/resources/templates/content/list.html @@ -118,7 +118,14 @@ }, {field: 'cancel', width: 180, title: '取消发布', align:'center', templet: function (row) { - var rowData = '取消发布'; + var rowData = row.sendStatus; + if(rowData == 'save') { + rowData = '发布'; + } + if(rowData == 'published') { + rowData = '取消发布'; + } + return rowData; } }, @@ -157,9 +164,28 @@ addSub(data); }else if('cancel' == obj.event) { cancel(data); + }else if('publish' == obj.event) { + publish(data); } }); + function publish(insertData) { + top.dialog.confirm(top.dataMessage.commit, function(index) { + top.dialog.close(index); + var loadLayerIndex; + top.restAjax.put(top.restAjax.path('api/content/publish/{contentId}', [insertData.contentId]), null, null, function(code, data) { + top.dialog.msg('发布成功'); + reloadTable(); + }, function(code, data) { + top.dialog.msg(data.msg); + }, function() { + loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3}); + }, function() { + top.dialog.close(loadLayerIndex); + }); + }); + } + function cancel(insertData) { top.dialog.confirm(top.dataMessage.commit, function(index) { top.dialog.close(index); diff --git a/src/main/resources/templates/news/list.html b/src/main/resources/templates/news/list.html index be86e7c..096dd6f 100644 --- a/src/main/resources/templates/news/list.html +++ b/src/main/resources/templates/news/list.html @@ -124,7 +124,21 @@ } return rowData; } - }/*, + }, + {field: 'cancel', width: 180, title: '取消发布', align:'center', + templet: function (row) { + var rowData = row.sendStatus; + if(rowData == 'save') { + rowData = '发布'; + } + if(rowData == 'published') { + rowData = '取消发布'; + } + + return rowData; + } + } + /*, {field: 'checkStatus', width: 180, title: '审核状态', align:'center', templet: function(row) { var rowData = row[this.field]; @@ -156,6 +170,51 @@ } }); } + + //监听行单击事件 + table.on('tool(dataTable)', function (obj) { + var data = obj.data; + if('cancel' == obj.event) { + cancel(data); + }else if('publish' == obj.event) { + publish(data); + } + }); + + function publish(insertData) { + top.dialog.confirm(top.dataMessage.commit, function(index) { + top.dialog.close(index); + var loadLayerIndex; + top.restAjax.put(top.restAjax.path('api/news/publish/{newsId}', [insertData.newsId]), null, null, function(code, data) { + top.dialog.msg('发布成功'); + reloadTable(); + }, function(code, data) { + top.dialog.msg(data.msg); + }, function() { + loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3}); + }, function() { + top.dialog.close(loadLayerIndex); + }); + }); + } + + function cancel(insertData) { + top.dialog.confirm(top.dataMessage.commit, function(index) { + top.dialog.close(index); + var loadLayerIndex; + top.restAjax.put(top.restAjax.path('api/news/cancel/{newsId}', [insertData.newsId]), null, null, function(code, data) { + top.dialog.msg('取消发布成功'); + reloadTable(); + }, function(code, data) { + top.dialog.msg(data.msg); + }, function() { + loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3}); + }, function() { + top.dialog.close(loadLayerIndex); + }); + }); + } + // 重载表格 function reloadTable(currentPage) { table.reload('dataTable', { @@ -239,6 +298,8 @@ top.dialog.msg(top.dataMessage.table.selectEdit); } else if(checkDatas.length > 1) { top.dialog.msg(top.dataMessage.table.selectOneEdit); + } else if(checkDatas[0].sendStatus != 'save') { + top.dialog.msg('当前信息已经发布,不可修改'); } else { layer.open({ type: 2, diff --git a/src/main/resources/templates/news/save.html b/src/main/resources/templates/news/save.html index 7a2bce0..f388c98 100644 --- a/src/main/resources/templates/news/save.html +++ b/src/main/resources/templates/news/save.html @@ -25,7 +25,7 @@
- +
@@ -45,7 +45,7 @@