提交 21f91206 作者: dingtalk_nnkplh

增加发布新闻功能,优化发布通知功能

上级 c8e4c6ac
package com.ruoyi.web.controller.school;
import java.io.UnsupportedEncodingException;
import java.util.List;
import org.apache.commons.codec.binary.Base64;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
......@@ -18,6 +21,7 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import java.net.URLDecoder;
/**
* 新闻与活动Controller
......
......@@ -169,7 +169,7 @@ shiro:
cipherKey:
session:
# Session超时时间,-1代表永不过期(默认30分钟)
expireTime: 30
expireTime: 120
# 同步session到数据库的周期(默认1分钟)
dbSyncPeriod: 1
# 相隔多久检查一次session的有效性,默认就是10分钟
......@@ -187,7 +187,7 @@ xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice/*,/system/demo/*
excludes: /system/notice/*,/system/demo/*,/system/news/*
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
......
......@@ -169,7 +169,7 @@ shiro:
cipherKey:
session:
# Session超时时间,-1代表永不过期(默认30分钟)
expireTime: 30
expireTime: 120
# 同步session到数据库的周期(默认1分钟)
dbSyncPeriod: 1
# 相隔多久检查一次session的有效性,默认就是10分钟
......@@ -187,7 +187,7 @@ xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice/*,/system/demo/*
excludes: /system/notice/*,/system/demo/*,/system/news/*
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
......
......@@ -409,7 +409,7 @@
p: ['class', 'style'],
pre: ['class', 'style'],
s: [],
section:[],
section:['class', 'style'],
small: [],
span: ['class', 'style'],
sub: ['class', 'style'],
......
......@@ -10,30 +10,30 @@
<div class="form-group">
<label class="col-sm-2 control-label is-required">新闻标题:</label>
<div class="col-sm-8">
<input name="title" class="form-control" type="text" required>
<input name="newsTitle" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label is-required">新闻摘要:</label>
<div class="col-sm-8">
<input name="summary" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label is-required">新闻内容:</label>
<div class="col-sm-10">
<script id="editor" name="content" type="text/plain" style="height: 300px;"></script>
<input name="newsSummary" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label is-required">新闻封面:</label>
<input name="cover" id="cover" type="hidden">
<input name="newsCover" id="newsCover" type="hidden">
<div class="col-sm-8">
<div class="file-loading">
<input id="singleCover" name="file" type="file">
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label is-required">新闻内容:</label>
<div class="col-sm-10">
<script id="editor" name="newsContent" type="text/plain" style="height: 300px;"></script>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">备注:</label>
<div class="col-sm-8">
......@@ -45,12 +45,27 @@
<th:block th:include="include :: footer" />
<th:block th:include="include :: ueditor-js" />
<th:block th:include="include :: bootstrap-fileinput-js" />
<script type="text/javascript">
<script th:inline="javascript">
var prefix = ctx + "system/news"
$("#form-news-add").validate({
focusCleanup: true
});
$(document).ready(function () {
// 单图上传
$("#singleCover").fileinput({
uploadUrl: ctx + 'common/upload',
maxFileCount: 1,
autoReplace: true
}).on('fileuploaded', function (event, data, previewId, index) {
var rsp = data.response;
$("#newsCover").val(rsp.fileName);
}).on('fileremoved', function (event, id, index) {
$("input[name='" + event.currentTarget.id + "']").val('')
})
});
var ue = UE.getEditor('editor');
function getContentTxt() {
return UE.getEditor('editor').getContentTxt();
......@@ -59,7 +74,6 @@
function submitHandler() {
if ($.validate.form()) {
var text = getContentTxt();
alert(text);
if (text == '' || text.length == 0) {
$.modal.alertWarning("请输入新闻内容!");
return;
......@@ -67,20 +81,6 @@
$.operate.save(prefix + "/add", $('#form-news-add').serialize());
}
}
$(document).ready(function () {
// 单图上传
$("#singleCover").fileinput({
uploadUrl: ctx + 'common/upload',
maxFileCount: 1,
autoReplace: true
}).on('fileuploaded', function (event, data, previewId, index) {
var rsp = data.response;
$("#cover").val(rsp.fileName);
}).on('fileremoved', function (event, id, index) {
$("input[name='" + event.currentTarget.id + "']").val('')
})
});
</script>
</body>
</html>
\ No newline at end of file
......@@ -11,25 +11,25 @@
<div class="form-group">
<label class="col-sm-2 control-label is-required">新闻标题:</label>
<div class="col-sm-8">
<input name="title" th:field="*{title}" class="form-control" type="text" required>
<input name="newsTitle" th:field="*{newsTitle}" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label is-required">新闻摘要:</label>
<div class="col-sm-8">
<input name="summary" th:field="*{summary}" class="form-control" type="text" required>
<input name="newsSummary" th:field="*{newsSummary}" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label is-required">新闻内容:</label>
<div class="col-sm-10">
<script id="editor" name="content" type="text/plain" style="height: 300px;"></script>
<textarea id="content" style="display: none;">[[*{content}]]</textarea>
<script id="editor" name="newsContent" type="text/plain" style="height: 300px;"></script>
<textarea id="newsContent" style="display: none;">[[*{newsContent}]]</textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label is-required">新闻封面:</label>
<input th:field="*{cover}" id="cover" type="hidden">
<input th:field="*{newsCover}" id="newsCover" type="hidden">
<div class="col-sm-8">
<div class="file-loading">
<input id="singleCover" name="file" type="file">
......@@ -54,7 +54,7 @@
});
$(function () {
var text = $("#content").text();
var text = $("#newsContent").text();
var ue = UE.getEditor('editor');
ue.ready(function () {
ue.setContent(text);
......@@ -81,7 +81,7 @@
//初始化方法
function initUpload() {
var logoUrl = $("#cover").val();//拿到图片路径
var logoUrl = $("#newsCover").val();//拿到图片路径
var preList = new Array();
var initialPreviewConfig = new Array();
//设置初始化区域值
......@@ -126,11 +126,11 @@
// 单图上传
$("#singleCover").on('fileuploaded', function (event, data, previewId, index) {
var rsp = data.response;
var imgPath = $("#cover").val();
var imgPath = $("#newsCover").val();
if(imgPath != null && imgPath != ''){
$("#cover").val(imgPath+","+rsp.fileName);
$("#newsCover").val(imgPath+","+rsp.fileName);
}else{
$("#cover").val(rsp.fileName);
$("#newsCover").val(rsp.fileName);
}
$("#singleCover").fileinput('destroy');//销毁fileUploadFileInput
initUpload();//重新初始化文件预览数据和文件上传附件
......@@ -151,8 +151,8 @@
urlLinkNew = imgArr[i];
}
}
$("#cover").val(urlLinkNew);
console.log($("#cover").val())
$("#newsCover").val(urlLinkNew);
console.log($("#newsCover").val())
});
</script>
</body>
......
......@@ -12,11 +12,11 @@
<ul>
<li>
<label>新闻标题:</label>
<input type="text" name="title"/>
<input type="text" name="newsTitle"/>
</li>
<li>
<label>新闻摘要:</label>
<input type="text" name="summary"/>
<input type="text" name="newsSummary"/>
</li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
......@@ -68,19 +68,19 @@
visible: false
},
{
field: 'title',
field: 'newsTitle',
title: '新闻标题'
},
{
field: 'summary',
field: 'newsSummary',
title: '新闻摘要'
},
{
field: 'creator',
field: 'creatorDesc',
title: '创建者'
},
{
field: 'modifiedBy',
field: 'modifiedByDesc',
title: '更新者'
},
{
......
......@@ -18,8 +18,8 @@
<div class="form-group">
<label class="col-sm-3 control-label is-required">通知类型:</label>
<div class="col-sm-8">
<select id="noticeType1" class="form-control select2-multiple" required>
<option value="1">系统通知</option>
<select id="noticeType1" class="form-control select2-multiple">
<option value="1" selected>系统通知</option>
<option value="2">个人通知</option>
</select>
</div>
......@@ -77,9 +77,8 @@
function submitHandler() {
if ($.validate.form()) {
// var a=$('#noticeType1').val();
// $("#noticeType").val(a);
// alert($("#noticeType").val());
var a=$('#noticeType1').val();
$("#noticeType").val(a);
var text = getContentTxt();
if (text == '' || text.length == 0) {
$.modal.alertWarning("请输入通知内容!");
......
......@@ -2,6 +2,8 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改通知公告')" />
<th:block th:include="include :: select2-css" />
<th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
......@@ -52,6 +54,8 @@
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: ueditor-js" />
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: bootstrap-select-js" />
<script th:inline="javascript">
var prefix = ctx + "business/notice";
$("#form-notice-edit").validate({
......@@ -70,17 +74,6 @@
return UE.getEditor('editor').getContentTxt();
}
function submitHandler() {
if ($.validate.form()) {
var text = getContentTxt();
if (text == '' || text.length == 0) {
$.modal.alertWarning("请输入通知内容!");
return;
}
$.operate.save(prefix + "/edit", $('#form-notice-edit').serialize());
}
}
$(document).ready(function() {
var vSele1=$("#status").val();
$("#status1").append("<option value='1'>正常</option>");
......@@ -106,6 +99,11 @@
$("#status").val(a);
});
$('#status1').on('change', function (e) {
var a=$('#status1').val();
$("#status").val(a);
});
$('#noticeType1').on('select2:select', function (e) {
var a=$('#noticeType1').val();
$("#noticeType").val(a);
......@@ -115,6 +113,17 @@
var a=$('#noticeType1').val();
$("#noticeType").val(a);
});
function submitHandler() {
if ($.validate.form()) {
var text = getContentTxt();
if (text == '' || text.length == 0) {
$.modal.alertWarning("请输入通知内容!");
return;
}
$.operate.save(prefix + "/edit", $('#form-notice-edit').serialize());
}
}
</script>
</body>
</html>
\ No newline at end of file
......@@ -21,15 +21,6 @@
<input id="singleFile" name="file" type="file">
</div>
</div>
<!-- <div class="col-sm-8">-->
<!-- <div class="fileinput fileinput-new" data-provides="fileinput">-->
<!-- <div >-->
<!-- <span class="btn btn-white btn-file">-->
<!-- <input id="materialCover" name="materialCover" type="file">-->
<!-- </span>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
</div>
<div class="form-group">
<label class="col-sm-2 control-label is-required">材料内容:</label>
......
......@@ -20,22 +20,26 @@ public class TbNews extends BaseEntity
/** 新闻标题 */
@Excel(name = "新闻标题")
private String title;
private String newsTitle;
/** 新闻摘要 */
@Excel(name = "新闻摘要")
private String summary;
private String newsSummary;
/** 新闻内容 */
@Excel(name = "新闻内容")
private String content;
private String newsContent;
private String cover;
private String newsCover;
/** 新闻状态(1正常 2关闭) */
@Excel(name = "新闻状态", readConverterExp = "1=正常,2=关闭")
private Integer status;
private String creatorDesc;
private String modifiedByDesc;
public void setId(Long id)
{
this.id = id;
......@@ -45,58 +49,69 @@ public class TbNews extends BaseEntity
{
return id;
}
public void setTitle(String title)
public void setStatus(Integer status)
{
this.title = title;
this.status = status;
}
public String getTitle()
public Integer getStatus()
{
return title;
return status;
}
public void setSummary(String summary)
{
this.summary = summary;
public String getCreatorDesc() {
return creatorDesc;
}
public String getSummary()
{
return summary;
public void setCreatorDesc(String creatorDesc) {
this.creatorDesc = creatorDesc;
}
public void setContent(String content)
{
this.content = content;
public String getModifiedByDesc() {
return modifiedByDesc;
}
public String getContent()
{
return content;
public void setModifiedByDesc(String modifiedByDesc) {
this.modifiedByDesc = modifiedByDesc;
}
public void setStatus(Integer status)
{
this.status = status;
public String getNewsTitle() {
return newsTitle;
}
public Integer getStatus()
{
return status;
public void setNewsTitle(String newsTitle) {
this.newsTitle = newsTitle;
}
public String getNewsSummary() {
return newsSummary;
}
public void setNewsSummary(String newsSummary) {
this.newsSummary = newsSummary;
}
public String getNewsContent() {
return newsContent;
}
public void setNewsContent(String newsContent) {
this.newsContent = newsContent;
}
public String getCover() {
return cover;
public String getNewsCover() {
return newsCover;
}
public void setCover(String cover) {
this.cover = cover;
public void setNewsCover(String newsCover) {
this.newsCover = newsCover;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("title", getTitle())
.append("summary", getSummary())
.append("content", getContent())
.append("status", getStatus())
.append("creator", getCreator())
.append("createTime", getCreateTime())
......
......@@ -2,6 +2,7 @@ package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.TbNews;
import org.apache.ibatis.annotations.Mapper;
/**
* 新闻与活动Mapper接口
......@@ -9,6 +10,7 @@ import com.ruoyi.system.domain.TbNews;
* @author ruoyi
* @date 2022-10-25
*/
@Mapper
public interface TbNewsMapper
{
/**
......
package com.ruoyi.system.service.impl;
import java.util.List;
import java.util.stream.Collectors;
import com.ruoyi.common.utils.DateUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TbNewsMapper;
......@@ -21,6 +24,9 @@ public class TbNewsServiceImpl implements ITbNewsService
@Autowired
private TbNewsMapper tbNewsMapper;
@Autowired
private CommonServiceImpl commonService;
/**
* 查询新闻与活动
*
......@@ -30,7 +36,12 @@ public class TbNewsServiceImpl implements ITbNewsService
@Override
public TbNews selectTbNewsById(Long id)
{
return tbNewsMapper.selectTbNewsById(id);
TbNews tn=tbNewsMapper.selectTbNewsById(id);
tn.setCreatorDesc(commonService.getUserName(tn.getCreator()));
if(ObjectUtils.isNotEmpty(tn.getModifiedBy())){
tn.setModifiedByDesc(commonService.getUserName(tn.getModifiedBy()));
}
return tn;
}
/**
......@@ -42,7 +53,15 @@ public class TbNewsServiceImpl implements ITbNewsService
@Override
public List<TbNews> selectTbNewsList(TbNews tbNews)
{
return tbNewsMapper.selectTbNewsList(tbNews);
List<TbNews> list=tbNewsMapper.selectTbNewsList(tbNews);
list.stream().filter(tbNews1 -> {
tbNews1.setCreatorDesc(commonService.getUserName(tbNews1.getCreator()));
if(ObjectUtils.isNotEmpty(tbNews1.getModifiedBy())){
tbNews1.setModifiedByDesc(commonService.getUserName(tbNews1.getModifiedBy()));
}
return true;
}).collect(Collectors.toList());
return list;
}
/**
......
......@@ -6,10 +6,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="TbNews" id="TbNewsResult">
<result property="id" column="id" />
<result property="title" column="title" />
<result property="summary" column="summary" />
<result property="content" column="content" />
<result property="cover" column="cover" />
<result property="newsTitle" column="news_title" />
<result property="newsSummary" column="news_summary" />
<result property="newsContent" column="news_content" />
<result property="newsCover" column="news_cover" />
<result property="status" column="status" />
<result property="creator" column="creator" />
<result property="createTime" column="create_time" />
......@@ -19,18 +19,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectTbNewsVo">
select id, title, summary, content, cover, status, creator, create_time, modified_by, update_time, remark from tb_news
select id, news_title, news_summary, news_content, news_cover, status, creator, create_time,
modified_by, update_time, remark from tb_news
</sql>
<select id="selectTbNewsList" parameterType="TbNews" resultMap="TbNewsResult">
<include refid="selectTbNewsVo"/>
<where>
<if test="title != null and title != ''"> and title = #{title}</if>
<if test="summary != null and summary != ''"> and summary = #{summary}</if>
<!-- <if test="content != null and content != ''"> and content = #{content}</if>-->
<!-- <if test="status != null "> and status = #{status}</if>-->
<!-- <if test="creator != null "> and creator = #{creator}</if>-->
<!-- <if test="modifiedBy != null "> and modified_by = #{modifiedBy}</if>-->
<if test="newsTitle != null and newsTitle != ''"> and news_title = #{newsTitle}</if>
<if test="newsSummary != null and newsSummary != ''"> and news_summary = #{newsSummary}</if>
</where>
</select>
......@@ -42,15 +39,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertTbNews" parameterType="TbNews" useGeneratedKeys="true" keyProperty="id">
insert into tb_news
<trim prefix="(" suffix=")" suffixOverrides=",">
title,summary,content,cover,status,
news_title,news_summary,news_content,news_cover,status,
<if test="remark != null">remark,</if>
creator,create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="title != null and title != ''">#{title},</if>
<if test="summary != null">#{summary},</if>
<if test="content != null and content != ''">#{content},</if>
<if test="cover != null and cover != ''">#{cover},</if>
<if test="newsTitle != null and newsTitle != ''">#{newsTitle},</if>
<if test="newsSummary != null and newsSummary != '' ">#{newsSummary},</if>
<if test="newsContent != null and newsContent != ''">#{newsContent},</if>
<if test="newsCover != null and newsCover != ''">#{newsCover},</if>
<if test="status != null">#{status},</if>
<if test="remark != null">#{remark},</if>
<if test="creator != null">#{creator},</if>
......@@ -61,10 +58,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateTbNews" parameterType="TbNews">
update tb_news
<trim prefix="SET" suffixOverrides=",">
<if test="title != null and title != ''">title = #{title},</if>
<if test="summary != null">summary = #{summary},</if>
<if test="content != null and content != ''">content = #{content},</if>
<if test="cover != null and cover != ''">cover = #{cover},</if>
<if test="newsTitle != null and newsTitle != ''">news_title = #{newsTitle},</if>
<if test="newsSummary != null and newsSummary != ''">news_summary = #{newsSummary},</if>
<if test="newsContent != null and newsContent != ''">news_content = #{newsContent},</if>
<if test="newsCover != null and newsCover != ''">news_cover = #{newsCover},</if>
<if test="status != null">status = #{status},</if>
<if test="modifiedBy != null">modified_by = #{modifiedBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论