删除章节

main
tamguo 7 years ago
parent 3bfb04067f
commit a58626f03c

@ -24,4 +24,7 @@ public interface IChapterService extends IService<ChapterEntity>{
// 修改章节
public void update(ChapterEntity chapter);
// 删除章节
public void delete(String id);
}

@ -163,4 +163,20 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, ChapterEntity
}
chapterMapper.updateById(entity);
}
@Transactional(readOnly=false)
@SuppressWarnings("unchecked")
@Override
public void delete(String id) {
ChapterEntity chapter = chapterMapper.selectById(id);
chapter.setStatus(ChapterStatusEnum.DELETE);
chapterMapper.updateById(chapter);
// 删除子章节
List<ChapterEntity> childs = chapterMapper.selectList(Condition.create().like("parent_codes", id));
for(int i=0 ; i<childs.size() ; i++) {
ChapterEntity child = childs.get(i);
child.setStatus(ChapterStatusEnum.DELETE);
chapterMapper.updateById(child);
}
}
}

@ -76,4 +76,15 @@ public class ChapterController {
return ExceptionSupport.resolverResult("修改章节", this.getClass(), e);
}
}
@RequestMapping(path="delete" , method=RequestMethod.POST)
@ResponseBody
public Result delete(String id) {
try {
iChapterService.delete(id);
return Result.result(0, null, "章节删除成功!");
} catch (Exception e) {
return ExceptionSupport.resolverResult("删除章节", this.getClass(), e);
}
}
}

@ -81,7 +81,7 @@ content="width=device-width, initial-scale=1, user-scalable=1" name="viewport"/>
<script th:src="${setting.domain + 'common/jeesite.js'}"></script>
<script th:src="${setting.domain + 'common/i18n/jeesite_zh_CN.js'}"></script>
<script th:src="${setting.domain + 'common/common.js'}"></script>
<script>
<script th:inline="javascript">
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
searchForm: $("#searchForm"),
@ -96,6 +96,8 @@ $('#dataGrid').dataGrid({
return '正常';
}else if(val == "disabled"){
return '<span style="color:red;">停用</span>';
}else if(val == "delete"){
return '<span style="color:red;">删除</span>';
}else{
return '<span style="color:red;">未知</span>';
}
@ -103,7 +105,7 @@ $('#dataGrid').dataGrid({
{header:'操作', name:'actions', width:100, sortable:false, title:false, formatter: function(val, obj, row, act){
var actions = [];
actions.push('<a href="tiku/chapter/update?id='+row.id+'" class="btnList" title="编辑章节"><i class="fa fa-pencil"></i></a>&nbsp;');
actions.push('<a href="tiku/chapter/delete?id='+row.id+'" class="btnList" title="删除章节" data-confirm="确认要删除该章节及所有子章节吗?" data-deltreenode="'+row.id+'"><i class="fa fa-trash-o"></i></a>&nbsp;');
actions.push('<a href="'+ctx+'tiku/chapter/delete?id='+row.id+'" class="btnList" title="删除章节" data-confirm="确认要删除该章节及所有子章节吗?" data-deltreenode="'+row.id+'"><i class="fa fa-trash-o"></i></a>&nbsp;');
actions.push('<a href="tiku/chapter/add?parentChapterId='+row.id+'" class="btnList" title="新增下级章节"><i class="fa fa-plus-square"></i></a>&nbsp;');
return actions.join('');
}}

Loading…
Cancel
Save