Commit 48e7604a by Java-聂换换

系统消息

parent 5d766a78
...@@ -40,11 +40,21 @@ public class Article extends DataEntity<Article> { ...@@ -40,11 +40,21 @@ public class Article extends DataEntity<Article> {
private String customContentView; // 自定义内容视图 private String customContentView; // 自定义内容视图
private String viewConfig; // 视图参数 private String viewConfig; // 视图参数
private Date sendDate;
private String scope;
private Integer isFlow = 0;
private Integer isTip = 0;
private ArticleData articleData; //文章副表 private ArticleData articleData; //文章副表
private Date beginDate; // 开始时间 private Date beginDate; // 开始时间
private Date endDate; // 结束时间 private Date endDate; // 结束时间
private Integer sendDateType;
private User user; private User user;
public Article() { public Article() {
...@@ -235,6 +245,45 @@ public class Article extends DataEntity<Article> { ...@@ -235,6 +245,45 @@ public class Article extends DataEntity<Article> {
return CmsUtils.formatImageSrcToWeb(this.image); return CmsUtils.formatImageSrcToWeb(this.image);
} }
public Date getSendDate() {
return sendDate;
}
public void setSendDate(Date sendDate) {
this.sendDate = sendDate;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public Integer getIsFlow() {
return isFlow;
}
public void setIsFlow(Integer isFlow) {
this.isFlow = isFlow;
}
public Integer getIsTip() {
return isTip;
}
public void setIsTip(Integer isTip) {
this.isTip = isTip;
}
public Integer getSendDateType() {
return sendDateType;
}
public void setSendDateType(Integer sendDateType) {
this.sendDateType = sendDateType;
}
} }
...@@ -152,4 +152,74 @@ public class ArticleController extends BaseController { ...@@ -152,4 +152,74 @@ public class ArticleController extends BaseController {
tplList = TplUtils.tplTrim(tplList, Article.DEFAULT_TEMPLATE, ""); tplList = TplUtils.tplTrim(tplList, Article.DEFAULT_TEMPLATE, "");
return tplList; return tplList;
} }
@RequiresPermissions("cms:article:view")
@RequestMapping(value = "message/form")
public String messageForm(Article article, Model model) {
// 如果当前传参有子节点,则选择取消传参选择
if (article.getCategory()!=null && StringUtils.isNotBlank(article.getCategory().getId())){
List<Category> list = categoryService.findByParentId(article.getCategory().getId(), Site.getCurrentSiteId());
if (list.size() > 0){
article.setCategory(null);
}else{
article.setCategory(categoryService.get(article.getCategory().getId()));
}
}
article.setArticleData(articleDataService.get(article.getId()));
// if (article.getCategory()=null && StringUtils.isNotBlank(article.getCategory().getId())){
// Category category = categoryService.get(article.getCategory().getId());
// }
model.addAttribute("contentViewList",getTplContent());
model.addAttribute("article_DEFAULT_TEMPLATE",Article.DEFAULT_TEMPLATE);
model.addAttribute("article", article);
CmsUtils.addViewConfigAttribute(model, article.getCategory());
return "modules/cms/articleMessageForm";
}
@RequiresPermissions("cms:article:view")
@RequestMapping(value = {"message/list"})
public String messageList(Article article, HttpServletRequest request, HttpServletResponse response, Model model) {
// for (int i=0; i<10000000; i++){
// Article a = new Article();
// a.setCategory(new Category(article.getCategory().getId()));
// a.setTitle("测试测试测试测试测试测试测试测试"+a.getCategory().getId());
// a.setArticleData(new ArticleData());
// a.getArticleData().setContent(a.getTitle());
// articleService.save(a);
// }
Page<Article> page = articleService.findPage(new Page<Article>(request, response), article, true);
model.addAttribute("page", page);
return "modules/cms/articleMessageList";
}
@RequiresPermissions("cms:article:edit")
@RequestMapping(value = "message/save")
public String messageSave(Article article, Model model, RedirectAttributes redirectAttributes) {
if (!beanValidator(model, article)){
return form(article, model);
}
if(article.getScope()!=null){
article.getScope().replaceAll(",","");
}
articleService.save(article);
addMessage(redirectAttributes, "保存消息'" + StringUtils.abbr(article.getTitle(),50) + "'成功");
String categoryId = article.getCategory()!=null?article.getCategory().getId():null;
return "redirect:" + adminPath + "/cms/article/message/list?repage&category.id=28";
}
@RequiresPermissions("cms:article:edit")
@RequestMapping(value = "message/delete")
public String messageDelete(Article article, String categoryId, @RequestParam(required=false) Boolean isRe, RedirectAttributes redirectAttributes) {
// 如果没有审核权限,则不允许删除或发布。
if (!UserUtils.getSubject().isPermitted("cms:article:audit")){
addMessage(redirectAttributes, "你没有删除或发布权限");
}
articleService.delete(article, isRe);
addMessage(redirectAttributes, (isRe!=null&&isRe?"发布":"删除")+"文章成功");
return "redirect:" + adminPath + "/cms/article/message/list?repage&category.id="+(categoryId!=null?categoryId:"");
}
} }
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
a.update_by AS "updateBy.id", a.update_by AS "updateBy.id",
a.update_date AS "updateDate", a.update_date AS "updateDate",
a.remarks AS "remarks", a.remarks AS "remarks",
a.scope AS "scope",
a.is_flow AS "isFlow",
a.is_tip AS "isTip",
a.send_date AS "sendDate",
a.del_flag AS "delFlag", a.del_flag AS "delFlag",
c.name AS "category.name", c.name AS "category.name",
u.name AS "user.name" u.name AS "user.name"
...@@ -119,6 +123,10 @@ ...@@ -119,6 +123,10 @@
weight_date, weight_date,
hits, hits,
posid, posid,
is_flow,
is_tip,
scope,
send_date,
custom_content_view, custom_content_view,
view_config, view_config,
create_by, create_by,
...@@ -140,6 +148,10 @@ ...@@ -140,6 +148,10 @@
#{weightDate}, #{weightDate},
#{hits}, #{hits},
#{posid}, #{posid},
#{isFlow},
#{isTip},
#{scope},
#{sendDate},
#{customContentView}, #{customContentView},
#{viewConfig}, #{viewConfig},
#{createBy.id}, #{createBy.id},
...@@ -170,6 +182,10 @@ ...@@ -170,6 +182,10 @@
update_by = #{updateBy.id}, update_by = #{updateBy.id},
update_date = #{updateDate}, update_date = #{updateDate},
remarks = #{remarks}, remarks = #{remarks},
is_flow = #{isFlow},
is_tip = #{isTip},
scope = #{scope},
send_date = #{sendDate},
del_flag = #{delFlag} del_flag = #{delFlag}
WHERE id = #{id} WHERE id = #{id}
</update> </update>
......
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>文章管理</title>
<meta name="decorator" content="default"/>
<script type="text/javascript">
$(document).ready(function() {
$("#timing").click(function () {
$("#sendDate").show();
});
$("#immediately").click(function () {
$("#sendDate").hide();
});
if($("#link").val()){
$('#linkBody').show();
$('#url').attr("checked", true);
}
$("#title").focus();
$("#inputForm").validate({
submitHandler: function(form){
if ($("#categoryId").val()==""){
$("#categoryName").focus();
top.$.jBox.tip('请选择归属栏目','warning');
}else if (CKEDITOR.instances.content.getData()=="" && $("#link").val().trim()==""){
top.$.jBox.tip('请填写正文','warning');
}else{
loading('正在提交,请稍等...');
form.submit();
}
},
errorContainer: "#messageBox",
errorPlacement: function(error, element) {
$("#messageBox").text("输入有误,请先更正。");
if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
error.appendTo(element.parent().parent());
} else {
error.insertAfter(element);
}
}
});
});
</script>
</head>
<body>
<ul class="nav nav-tabs">
<li><a href="${ctx}/cms/article/message/list?category.id=28">消息列表</a></li>
<li class="active"><a href="<c:url value='${ctx}/cms/article/message/form?id=${article.id}&category.id=${article.category.id}'><c:param name='category.name' value='${article.category.name}'/></c:url>">消息<shiro:hasPermission name="cms:article:edit">${not empty article.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="cms:article:edit">查看</shiro:lacksPermission></a></li>
</ul><br/>
<form:form id="inputForm" modelAttribute="article" action="${ctx}/cms/article/message/save" method="post" class="form-horizontal">
<form:hidden path="id"/>
<sys:message content="${message}"/>
<div class="control-group">
<label class="control-label">主题:</label>
<div class="controls">
<form:input path="title" htmlEscape="false" maxlength="200" class="input-xxlarge measure-input required"/>
&nbsp;
<c:if test="${article.isTip eq 1}">
<form:checkbox path="isTip" value="1" checked="checked"/>
</c:if>
<c:if test="${article.isTip ne 1}">
<form:checkbox path="isTip" value="1"/>
</c:if>
同步到首页弹窗
<c:if test="${article.isFlow eq 1}">
<form:checkbox path="isFlow" value="1" checked="checked"/>
</c:if>
<c:if test="${article.isFlow ne 1}">
<form:checkbox path="isFlow" value="1"/>
</c:if>同步到首页滚动新闻
<form:input path="category.id" value="28" cssStyle="display: none"/>
</div>
</div>
<div class="control-group">
<label class="control-label">内容:</label>
<div class="controls">
<form:textarea id="content" htmlEscape="true" path="articleData.content" rows="4" maxlength="200" class="input-xxlarge"/>
<sys:ckeditor replace="content" uploadPath="/cms/article" />
</div>
</div>
<div class="control-group">
<label class="control-label">推送范围:</label>
<div class="controls">
<%--<form:checkbox path="scope" value="SABCDE"/>全部<br/>--%>
<c:if test="${fn:contains(article.scope,'S') eq true}">
<form:checkbox path="scope" value="S" checked="checked"/>管理员<br/>
</c:if>
<c:if test="${fn:contains(article.scope,'S') eq false}">
<form:checkbox path="scope" value="S"/>管理员<br/>
</c:if>
<c:if test="${fn:contains(article.scope,'A') eq true}">
<form:checkbox path="scope" value="A" checked="checked"/>王者<br/>
</c:if>
<c:if test="${fn:contains(article.scope,'A') eq false}">
<form:checkbox path="scope" value="A"/>王者<br/>
</c:if>
<c:if test="${fn:contains(article.scope,'B') eq true}">
<form:checkbox path="scope" value="B" checked="checked"/>钻石<br/>
</c:if>
<c:if test="${fn:contains(article.scope,'B') eq false}">
<form:checkbox path="scope" value="B"/>钻石<br/>
</c:if>
<c:if test="${fn:contains(article.scope,'C') eq true}">
<form:checkbox path="scope" value="C" checked="checked"/>黄金<br/>
</c:if>
<c:if test="${fn:contains(article.scope,'C') eq false}">
<form:checkbox path="scope" value="C"/>黄金<br/>
</c:if>
<c:if test="${fn:contains(article.scope,'D') eq true}">
<form:checkbox path="scope" value="D" checked="checked"/>白银<br/>
</c:if>
<c:if test="${fn:contains(article.scope,'D') eq false}">
<form:checkbox path="scope" value="D"/>白银<br/>
</c:if>
<c:if test="${fn:contains(article.scope,'E') eq true}">
<form:checkbox path="scope" value="E" checked="checked"/>青铜<br/>
</c:if>
<c:if test="${fn:contains(article.scope,'E') eq false}">
<form:checkbox path="scope" value="E"/>青铜<br/>
</c:if>
<%--<form:checkbox path="scope" value="B"/><br/>--%>
<%--<form:checkbox path="scope" value="C"/><br/>--%>
<%--<form:checkbox path="scope" value="D"/><br/>--%>
<%--<form:checkbox path="scope" value="E"/><br/>--%>
</div>
</div>
<div class="control-group">
<label class="control-label">发布时间:</label>
<div class="controls">
<c:if test="${article.sendDate eq null || article.sendDate eq ''}">
<input type="radio" name="sendDateType" id="immediately" value="0" checked="checked"/>立即
<input type="radio" name="sendDateType"id="timing" value="1"/>定时
</c:if>
<c:if test="${article.sendDate ne null && article.sendDate ne ''}">
<input type="radio" name="sendDateType" value="0" id="immediately"/>立即
<input type="radio" name="sendDateType"id="timing" value="1" checked="checked"/>定时
</c:if>
<%--<form:radiobutton path="sendDateType" checked="true" value="0" id="immediately"/>立即--%>
<%--<form:radiobutton path="sendDateType" checked ="false" value="1" id="timing"/>定时--%>
<input id="sendDate" name="sendDate" type="text" <c:if test="${article.sendDate eq null }"> style="display: none" </c:if> readonly="readonly" maxlength="20" class="input-medium Wdate"
value="<fmt:formatDate value="${article.sendDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
</div>
</div>
<%--<shiro:hasPermission name="cms:article:audit">--%>
<%--<div class="control-group">--%>
<%--<label class="control-label">发布状态:</label>--%>
<%--<div class="controls">--%>
<%--<form:radiobuttons path="delFlag" items="${fns:getDictList('cms_del_flag')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required"/>--%>
<%--<span class="help-inline"></span>--%>
<%--</div>--%>
<%--</div>--%>
<%--</shiro:hasPermission>--%>
<div class="form-actions">
<shiro:hasPermission name="cms:article:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
</div>
</form:form>
</body>
</html>
\ No newline at end of file
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>文章管理</title>
<meta name="decorator" content="default"/>
<script type="text/javascript">
function viewComment(href){
top.$.jBox.open('iframe:'+href,'查看评论',$(top.document).width()-220,$(top.document).height()-120,{
buttons:{"关闭":true},
loaded:function(h){
$(".jbox-content", top.document).css("overflow-y","hidden");
$(".nav,.form-actions,[class=btn]", h.find("iframe").contents()).hide();
$("body", h.find("iframe").contents()).css("margin","10px");
}
});
return false;
}
function page(n,s){
$("#pageNo").val(n);
$("#pageSize").val(s);
$("#searchForm").submit();
return false;
}
</script>
</head>
<body>
<ul class="nav nav-tabs">
<li class="active"><a href="${ctx}/cms/article/message/list?category.id=28">消息列表</a></li>
<shiro:hasPermission name="cms:article:edit"><li><a href="<c:url value='${fns:getAdminPath()}/cms/article/message/form?id=${article.id}&category.id=20'><c:param name='category.name' value='${article.category.name}'/></c:url>">消息添加</a></li></shiro:hasPermission>
</ul>
<form:form id="searchForm" modelAttribute="article" action="${ctx}/cms/article/" method="post" class="breadcrumb form-search">
<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
<label>栏目:</label><sys:treeselect id="category" name="category.id" value="${article.category.id}" labelName="category.name" labelValue="${article.category.name}"
title="栏目" url="/cms/category/treeData" module="article" notAllowSelectRoot="false" cssClass="input-small"/>
<label>主题:</label><form:input path="title" htmlEscape="false" maxlength="50" class="input-small"/>&nbsp;
<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>&nbsp;&nbsp;
<label>状态:</label><form:radiobuttons onclick="$('#searchForm').submit();" path="delFlag" items="${fns:getDictList('cms_del_flag')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
</form:form>
<sys:message content="${message}"/>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
<thead><tr><th>栏目</th><th>标题</th><th>权重</th><th>点击数</th><th>发布者</th><th>更新时间</th><th>操作</th></tr></thead>
<tbody>
<c:forEach items="${page.list}" var="article">
<tr>
<td><a href="javascript:" onclick="$('#categoryId').val('${article.category.id}');$('#categoryName').val('${article.category.name}');$('#searchForm').submit();return false;">${article.category.name}</a></td>
<td><a href="${ctx}/cms/article/form?id=${article.id}" title="${article.title}">${fns:abbr(article.title,40)}</a></td>
<td>${article.weight}</td>
<td>${article.hits}</td>
<td>${article.user.name}</td>
<td><fmt:formatDate value="${article.updateDate}" type="both"/></td>
<td>
<a href="${pageContext.request.contextPath}${fns:getFrontPath()}/view-${article.category.id}-${article.id}${fns:getUrlSuffix()}" target="_blank">访问</a>
<shiro:hasPermission name="cms:article:edit">
<c:if test="${article.category.allowComment eq '1'}"><shiro:hasPermission name="cms:comment:view">
<a href="${ctx}/cms/comment/?module=article&contentId=${article.id}&delFlag=2" onclick="return viewComment(this.href);">评论</a>
</shiro:hasPermission></c:if>
<a href="${ctx}/cms/article/message/form?id=${article.id}">修改</a>
<shiro:hasPermission name="cms:article:audit">
<a href="${ctx}/cms/article/message/delete?id=${article.id}${article.delFlag ne 0?'&isRe=true':''}&categoryId=${article.category.id}" onclick="return confirmx('确认要${article.delFlag ne 0?'发布':'删除'}该文章吗?', this.href)" >${article.delFlag ne 0?'发布':'删除'}</a>
</shiro:hasPermission>
</shiro:hasPermission>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<div class="pagination">${page}</div>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment