Răsfoiți Sursa

完成评论管理

shuzheng 9 ani în urmă
părinte
comite
af8ee1fa74

+ 2 - 2
zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsCommentController.java

@@ -39,7 +39,7 @@ public class CmsCommentController extends BaseController {
 	@RequiresPermissions("cms:comment:read")
 	@RequiresPermissions("cms:comment:read")
 	@RequestMapping(value = "/index", method = RequestMethod.GET)
 	@RequestMapping(value = "/index", method = RequestMethod.GET)
 	public String index() {
 	public String index() {
-		return "/manage/commentcomment/index";
+		return "/manage/comment/index";
 	}
 	}
 
 
 	@ApiOperation(value = "评论列表")
 	@ApiOperation(value = "评论列表")
@@ -57,7 +57,7 @@ public class CmsCommentController extends BaseController {
 		if (!StringUtils.isBlank(sort) && !StringUtils.isBlank(order)) {
 		if (!StringUtils.isBlank(sort) && !StringUtils.isBlank(order)) {
 			cmsCommentExample.setOrderByClause(sort + " " + order);
 			cmsCommentExample.setOrderByClause(sort + " " + order);
 		}
 		}
-		List<CmsComment> rows = cmsCommentService.selectByExample(cmsCommentExample);
+		List<CmsComment> rows = cmsCommentService.selectByExampleWithBLOBs(cmsCommentExample);
 		long total = cmsCommentService.countByExample(cmsCommentExample);
 		long total = cmsCommentService.countByExample(cmsCommentExample);
 		Map<String, Object> result = new HashMap<>();
 		Map<String, Object> result = new HashMap<>();
 		result.put("rows", rows);
 		result.put("rows", rows);

+ 5 - 0
zheng-cms/zheng-cms-admin/src/main/webapp/WEB-INF/jsp/manage/article/index.jsp

@@ -60,6 +60,7 @@ $(function() {
 			{field: 'type', title: '类型', sortable: true, align: 'center', formatter: 'typeFormatter'},
 			{field: 'type', title: '类型', sortable: true, align: 'center', formatter: 'typeFormatter'},
 			{field: 'status', title: '审核', sortable: true, align: 'center', formatter: 'statusFormatter'},
 			{field: 'status', title: '审核', sortable: true, align: 'center', formatter: 'statusFormatter'},
 			{field: 'readnumber', title: '阅读量'},
 			{field: 'readnumber', title: '阅读量'},
+			{field: 'ctime', title: '创建时间', formatter: 'timeFormatter'},
 			{field: 'action', title: '操作', align: 'center', formatter: 'actionFormatter', events: 'actionEvents', clickToSelect: false}
 			{field: 'action', title: '操作', align: 'center', formatter: 'actionFormatter', events: 'actionEvents', clickToSelect: false}
 		]
 		]
 	});
 	});
@@ -92,6 +93,10 @@ function statusFormatter(value, row, index) {
 		return '<span class="label label-success">已通过</span>';
 		return '<span class="label label-success">已通过</span>';
 	}
 	}
 }
 }
+// 格式化时间
+function timeFormatter(value , row, index) {
+	return new Date(value).toLocaleString();
+}
 // 新增
 // 新增
 var createDialog;
 var createDialog;
 function createAction() {
 function createAction() {

+ 175 - 0
zheng-cms/zheng-cms-admin/src/main/webapp/WEB-INF/jsp/manage/comment/index.jsp

@@ -0,0 +1,175 @@
+<%@ page contentType="text/html; charset=utf-8"%>
+<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
+<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
+<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
+<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
+<c:set var="basePath" value="${pageContext.request.contextPath}"/>
+<!DOCTYPE HTML>
+<html lang="zh-cn">
+<head>
+	<meta charset="utf-8">
+	<meta http-equiv="X-UA-Compatible" content="IE=edge">
+	<meta name="viewport" content="width=device-width, initial-scale=1">
+	<title>评论管理</title>
+	<jsp:include page="/resources/inc/head.jsp" flush="true"/>
+</head>
+<body>
+<div id="main">
+	<div id="toolbar">
+		<shiro:hasPermission name="cms:comment:delete"><a class="waves-effect waves-button" href="javascript:;" onclick="deleteAction()"><i class="zmdi zmdi-close"></i> 删除评论</a></shiro:hasPermission>
+	</div>
+	<table id="table"></table>
+</div>
+<jsp:include page="/resources/inc/footer.jsp" flush="true"/>
+<script>
+var $table = $('#table');
+$(function() {
+	// bootstrap table初始化
+	$table.bootstrapTable({
+		url: '${basePath}/manage/comment/list',
+		height: getHeight(),
+		striped: true,
+		search: true,
+		showRefresh: true,
+		showColumns: true,
+		minimumCountColumns: 2,
+		clickToSelect: true,
+		detailView: true,
+		detailFormatter: 'detailFormatter',
+		pagination: true,
+		paginationLoop: false,
+		sidePagination: 'server',
+		silentSort: false,
+		smartDisplay: false,
+		escape: true,
+		searchOnEnterKey: true,
+		idField: 'commentId',
+		sortOrder: 'desc',
+		maintainSelected: true,
+		toolbar: '#toolbar',
+		columns: [
+			{field: 'ck', checkbox: true},
+			{field: 'commentId', title: '编号', sortable: true, align: 'center'},
+			{field: 'content', title: '内容'},
+			{field: 'ip', title: 'IP地址'},
+			{field: 'agent', title: '用户标识'},
+			{field: 'ctime', title: '创建时间', formatter: 'timeFormatter'},
+			{field: 'action', title: '操作', align: 'center', formatter: 'actionFormatter', events: 'actionEvents', clickToSelect: false}
+		]
+	});
+});
+// 格式化操作按钮
+function actionFormatter(value, row, index) {
+    return [
+        '<a class="update" href="javascript:;" onclick="updateAction()" data-toggle="tooltip" title="Edit"><i class="glyphicon glyphicon-edit"></i></a> ',
+        '<a class="delete" href="javascript:;" onclick="deleteAction()" data-toggle="tooltip" title="Remove"><i class="glyphicon glyphicon-remove"></i></a>'
+    ].join('');
+}
+// 格式化时间
+function timeFormatter(value , row, index) {
+	return new Date(value).toLocaleString();
+}
+// 删除
+var deleteDialog;
+function deleteAction() {
+	var rows = $table.bootstrapTable('getSelections');
+	if (rows.length == 0) {
+		$.confirm({
+			title: false,
+			content: '请至少选择一条记录!',
+			autoClose: 'cancel|3000',
+			backgroundDismiss: true,
+			buttons: {
+				cancel: {
+					text: '取消',
+					btnClass: 'waves-effect waves-button'
+				}
+			}
+		});
+	} else {
+		deleteDialog = $.confirm({
+			type: 'red',
+			animationSpeed: 300,
+			title: false,
+			content: '确认删除该标签吗?',
+			buttons: {
+				confirm: {
+					text: '确认',
+					btnClass: 'waves-effect waves-button',
+					action: function () {
+						var ids = new Array();
+						for (var i in rows) {
+							ids.push(rows[i].commentId);
+						}
+						$.ajax({
+							type: 'get',
+							url: '${basePath}/manage/comment/delete/' + ids.join("-"),
+							success: function(result) {
+								if (result.code != 1) {
+									if (result.data instanceof Array) {
+										$.each(result.data, function(index, value) {
+											$.confirm({
+												theme: 'dark',
+												animation: 'rotateX',
+												closeAnimation: 'rotateX',
+												title: false,
+												content: value.errorMsg,
+												buttons: {
+													confirm: {
+														text: '确认',
+														btnClass: 'waves-effect waves-button waves-light'
+													}
+												}
+											});
+										});
+									} else {
+										$.confirm({
+											theme: 'dark',
+											animation: 'rotateX',
+											closeAnimation: 'rotateX',
+											title: false,
+											content: result.data.errorMsg,
+											buttons: {
+												confirm: {
+													text: '确认',
+													btnClass: 'waves-effect waves-button waves-light'
+												}
+											}
+										});
+									}
+								} else {
+									deleteDialog.close();
+									$table.bootstrapTable('refresh');
+								}
+							},
+							error: function(XMLHttpRequest, textStatus, errorThrown) {
+								$.confirm({
+									theme: 'dark',
+									animation: 'rotateX',
+									closeAnimation: 'rotateX',
+									title: false,
+									content: textStatus,
+									buttons: {
+										confirm: {
+											text: '确认',
+											btnClass: 'waves-effect waves-button waves-light'
+										}
+									}
+								});
+							}
+						});
+					}
+				},
+				cancel: {
+					text: '取消',
+					btnClass: 'waves-effect waves-button'
+				}
+			}
+		});
+	}
+}
+</script>
+</body>
+</html>