提交 21f91206 作者: dingtalk_nnkplh

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

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