新闻新增取消发布功能

内容管理取消发布功能
This commit is contained in:
Renpc-kilig 2024-06-13 11:56:11 +08:00
parent 43edb57c07
commit 468bff63ac
10 changed files with 159 additions and 9 deletions

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -188,4 +188,6 @@ public interface IContentService {
List<ContentDTO> contentList(Map<String, Object> params);
void cancel(String contentId);
void publish(String contentId);
}

View File

@ -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);
}
}

View File

@ -186,4 +186,8 @@ public interface INewsService {
Integer count(Map<String, Object> params);
List<NewsDTO> listTop(Map<String, Object> params);
void cancel(String newsId);
void publish(String newsId);
}

View File

@ -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<NewsDTO> list(Map<String, Object> params) {
List<NewsDTO> 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);
}
}

View File

@ -118,7 +118,14 @@
},
{field: 'cancel', width: 180, title: '取消发布', align:'center',
templet: function (row) {
var rowData = '<a class="layui-btn layui-btn-xs" lay-event="cancel">取消发布</a>';
var rowData = row.sendStatus;
if(rowData == 'save') {
rowData = '<a class="layui-btn layui-btn-xs layui-bg-green" lay-event="publish">发布</a>';
}
if(rowData == 'published') {
rowData = '<a class="layui-btn layui-btn-xs layui-bg-red" lay-event="cancel">取消发布</a>';
}
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);

View File

@ -124,7 +124,21 @@
}
return rowData;
}
}/*,
},
{field: 'cancel', width: 180, title: '取消发布', align:'center',
templet: function (row) {
var rowData = row.sendStatus;
if(rowData == 'save') {
rowData = '<a class="layui-btn layui-btn-xs layui-bg-green" lay-event="publish">发布</a>';
}
if(rowData == 'published') {
rowData = '<a class="layui-btn layui-btn-xs layui-bg-red" lay-event="cancel">取消发布</a>';
}
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,

View File

@ -25,7 +25,7 @@
<div class="layui-form-item">
<label class="layui-form-label">标题</label>
<div class="layui-input-block">
<input type="text" id="title" name="title" class="layui-input" value="" placeholder="请输入标题" maxlength="255">
<input type="text" lay-verify="required" id="title" name="title" class="layui-input" value="" placeholder="请输入标题" maxlength="255">
</div>
</div>
<div class="layui-form-item">
@ -45,7 +45,7 @@
<label class="layui-form-label">新闻类型</label>
<div class="layui-input-block layui-form" id="newsTypeSelectTemplateBox" lay-filter="newsTypeSelectTemplateBox"></div>
<script id="newsTypeSelectTemplate" type="text/html">
<select id="newsType" name="newsType" lay-filter="newsType">
<select id="newsType" name="newsType" lay-verify="required" lay-filter="newsType">
<option value="">请选择内容类型</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.dataId}}">{{item.dataName}}</option>

View File

@ -25,7 +25,7 @@
<div class="layui-form-item">
<label class="layui-form-label">标题</label>
<div class="layui-input-block">
<input type="text" id="title" name="title" class="layui-input" value="" placeholder="请输入标题" maxlength="255">
<input type="text" lay-verify="required" id="title" name="title" class="layui-input" value="" placeholder="请输入标题" maxlength="255">
</div>
</div>
<div class="layui-form-item">
@ -45,7 +45,7 @@
<label class="layui-form-label">新闻类型</label>
<div class="layui-input-block layui-form" id="newsTypeSelectTemplateBox" lay-filter="newsTypeSelectTemplateBox"></div>
<script id="newsTypeSelectTemplate" type="text/html">
<select id="newsType" name="newsType" lay-filter="newsType">
<select id="newsType" name="newsType" lay-verify="required" lay-filter="newsType">
<option value="">请选择内容类型</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.dataId}}">{{item.dataName}}</option>