Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
ruoyi
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
范晓龙
ruoyi
Commits
c8e4c6ac
提交
c8e4c6ac
authored
10月 25, 2022
作者:
dingtalk_nnkplh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加发布新闻功能
上级
c6508d67
显示空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
901 行增加
和
8 行删除
+901
-8
TbNewsController.java
...ava/com/ruoyi/web/controller/school/TbNewsController.java
+129
-0
add.html
...admin/src/main/resources/templates/business/news/add.html
+87
-0
edit.html
...dmin/src/main/resources/templates/business/news/edit.html
+160
-0
news.html
...dmin/src/main/resources/templates/business/news/news.html
+106
-0
add.html
...min/src/main/resources/templates/business/notice/add.html
+3
-3
edit.html
...-admin/src/main/resources/templates/system/demo/edit.html
+0
-5
TbNews.java
...-system/src/main/java/com/ruoyi/system/domain/TbNews.java
+108
-0
TbNewsMapper.java
...m/src/main/java/com/ruoyi/system/mapper/TbNewsMapper.java
+61
-0
ITbNewsService.java
...rc/main/java/com/ruoyi/system/service/ITbNewsService.java
+61
-0
TbNewsServiceImpl.java
...java/com/ruoyi/system/service/impl/TbNewsServiceImpl.java
+98
-0
TbNewsMapper.xml
...-system/src/main/resources/mapper/system/TbNewsMapper.xml
+88
-0
没有找到文件。
ruoyi-admin/src/main/java/com/ruoyi/web/controller/school/TbNewsController.java
0 → 100644
浏览文件 @
c8e4c6ac
package
com
.
ruoyi
.
web
.
controller
.
school
;
import
java.util.List
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.ModelMap
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.ruoyi.common.annotation.Log
;
import
com.ruoyi.common.enums.BusinessType
;
import
com.ruoyi.system.domain.TbNews
;
import
com.ruoyi.system.service.ITbNewsService
;
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
;
/**
* 新闻与活动Controller
*
* @author ruoyi
* @date 2022-10-25
*/
@Controller
@RequestMapping
(
"/system/news"
)
public
class
TbNewsController
extends
BaseController
{
private
String
prefix
=
"business/news"
;
@Autowired
private
ITbNewsService
tbNewsService
;
@RequiresPermissions
(
"system:news:view"
)
@GetMapping
()
public
String
news
()
{
return
prefix
+
"/news"
;
}
/**
* 查询新闻与活动列表
*/
@RequiresPermissions
(
"system:news:list"
)
@PostMapping
(
"/list"
)
@ResponseBody
public
TableDataInfo
list
(
TbNews
tbNews
)
{
startPage
();
List
<
TbNews
>
list
=
tbNewsService
.
selectTbNewsList
(
tbNews
);
return
getDataTable
(
list
);
}
/**
* 导出新闻与活动列表
*/
@RequiresPermissions
(
"system:news:export"
)
@Log
(
title
=
"新闻与活动"
,
businessType
=
BusinessType
.
EXPORT
)
@PostMapping
(
"/export"
)
@ResponseBody
public
AjaxResult
export
(
TbNews
tbNews
)
{
List
<
TbNews
>
list
=
tbNewsService
.
selectTbNewsList
(
tbNews
);
ExcelUtil
<
TbNews
>
util
=
new
ExcelUtil
<
TbNews
>(
TbNews
.
class
);
return
util
.
exportExcel
(
list
,
"新闻与活动数据"
);
}
/**
* 新增新闻与活动
*/
@GetMapping
(
"/add"
)
public
String
add
()
{
return
prefix
+
"/add"
;
}
/**
* 新增保存新闻与活动
*/
@RequiresPermissions
(
"system:news:add"
)
@Log
(
title
=
"新闻与活动"
,
businessType
=
BusinessType
.
INSERT
)
@PostMapping
(
"/add"
)
@ResponseBody
public
AjaxResult
addSave
(
TbNews
tbNews
)
{
tbNews
.
setCreator
(
getUserId
());
return
toAjax
(
tbNewsService
.
insertTbNews
(
tbNews
));
}
/**
* 修改新闻与活动
*/
@RequiresPermissions
(
"system:news:edit"
)
@GetMapping
(
"/edit/{id}"
)
public
String
edit
(
@PathVariable
(
"id"
)
Long
id
,
ModelMap
mmap
)
{
TbNews
tbNews
=
tbNewsService
.
selectTbNewsById
(
id
);
mmap
.
put
(
"tbNews"
,
tbNews
);
return
prefix
+
"/edit"
;
}
/**
* 修改保存新闻与活动
*/
@RequiresPermissions
(
"system:news:edit"
)
@Log
(
title
=
"新闻与活动"
,
businessType
=
BusinessType
.
UPDATE
)
@PostMapping
(
"/edit"
)
@ResponseBody
public
AjaxResult
editSave
(
TbNews
tbNews
)
{
tbNews
.
setModifiedBy
(
getUserId
());
return
toAjax
(
tbNewsService
.
updateTbNews
(
tbNews
));
}
/**
* 删除新闻与活动
*/
@RequiresPermissions
(
"system:news:remove"
)
@Log
(
title
=
"新闻与活动"
,
businessType
=
BusinessType
.
DELETE
)
@PostMapping
(
"/remove"
)
@ResponseBody
public
AjaxResult
remove
(
String
ids
)
{
return
toAjax
(
tbNewsService
.
deleteTbNewsByIds
(
ids
));
}
}
ruoyi-admin/src/main/resources/templates/business/news/add.html
0 → 100644
浏览文件 @
c8e4c6ac
<!DOCTYPE html>
<html
lang=
"zh"
xmlns:th=
"http://www.thymeleaf.org"
>
<head>
<th:block
th:include=
"include :: header('新增新闻与活动')"
/>
<th:block
th:include=
"include :: bootstrap-fileinput-css"
/>
</head>
<body
class=
"white-bg"
>
<div
class=
"wrapper wrapper-content animated fadeInRight ibox-content"
>
<form
class=
"form-horizontal m"
id=
"form-news-add"
>
<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
>
</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>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label is-required"
>
新闻封面:
</label>
<input
name=
"cover"
id=
"cover"
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"
>
备注:
</label>
<div
class=
"col-sm-8"
>
<input
name=
"remark"
class=
"form-control"
type=
"text"
>
</div>
</div>
</form>
</div>
<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"
>
var
prefix
=
ctx
+
"system/news"
$
(
"#form-news-add"
).
validate
({
focusCleanup
:
true
});
var
ue
=
UE
.
getEditor
(
'editor'
);
function
getContentTxt
()
{
return
UE
.
getEditor
(
'editor'
).
getContentTxt
();
}
function
submitHandler
()
{
if
(
$
.
validate
.
form
())
{
var
text
=
getContentTxt
();
alert
(
text
);
if
(
text
==
''
||
text
.
length
==
0
)
{
$
.
modal
.
alertWarning
(
"请输入新闻内容!"
);
return
;
}
$
.
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
ruoyi-admin/src/main/resources/templates/business/news/edit.html
0 → 100644
浏览文件 @
c8e4c6ac
<!DOCTYPE html>
<html
lang=
"zh"
xmlns:th=
"http://www.thymeleaf.org"
>
<head>
<th:block
th:include=
"include :: header('修改新闻与活动')"
/>
<th:block
th:include=
"include :: bootstrap-fileinput-css"
/>
</head>
<body
class=
"white-bg"
>
<div
class=
"wrapper wrapper-content animated fadeInRight ibox-content"
>
<form
class=
"form-horizontal m"
id=
"form-news-edit"
th:object=
"${tbNews}"
>
<input
name=
"id"
th:field=
"*{id}"
type=
"hidden"
>
<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
>
</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
>
</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>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label is-required"
>
新闻封面:
</label>
<input
th:field=
"*{cover}"
id=
"cover"
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"
>
备注:
</label>
<div
class=
"col-sm-8"
>
<input
name=
"remark"
th:field=
"*{remark}"
class=
"form-control"
type=
"text"
>
</div>
</div>
</form>
</div>
<th:block
th:include=
"include :: footer"
/>
<th:block
th:include=
"include :: ueditor-js"
/>
<th:block
th:include=
"include :: bootstrap-fileinput-js"
/>
<script
th:inline=
"javascript"
>
var
prefix
=
ctx
+
"system/news"
;
$
(
"#form-news-edit"
).
validate
({
focusCleanup
:
true
});
$
(
function
()
{
var
text
=
$
(
"#content"
).
text
();
var
ue
=
UE
.
getEditor
(
'editor'
);
ue
.
ready
(
function
()
{
ue
.
setContent
(
text
);
});
})
function
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-news-edit'
).
serialize
());
}
}
//初始化文件预览数据和文件上传附件
initUpload
();
//初始化方法
function
initUpload
()
{
var
logoUrl
=
$
(
"#cover"
).
val
();
//拿到图片路径
var
preList
=
new
Array
();
var
initialPreviewConfig
=
new
Array
();
//设置初始化区域值
if
(
logoUrl
!=
null
&&
logoUrl
!=
''
){
var
imgArr
=
logoUrl
.
split
(
","
);
for
(
var
i
=
0
;
i
<
imgArr
.
length
;
i
++
)
{
preList
[
i
]
=
imgArr
[
i
]
var
a
=
{
// caption : '主图'+(i+1),
// width: '120px',
url
:
'/common/del'
,
key
:
i
,
extra
:
{
url
:
imgArr
[
i
]}
}
initialPreviewConfig
.
push
(
a
);
}
}
$
(
"#singleCover"
).
fileinput
({
language
:
'zh'
,
//设置语言
uploadUrl
:
"/common/upload"
,
//上传的地址,改成自己的
allowedFileExtensions
:[
'bmp'
,
'gif'
,
'jpg'
,
'jpeg'
,
'png'
],
//接收的文件后缀
initialPreviewAsData
:
true
,
initialPreview
:
preList
,
//预览图片
uploadAsync
:
true
,
//默认异步上传
showUpload
:
true
,
//是否显示上传按钮
showRemove
:
false
,
//显示移除按钮
showPreview
:
true
,
//是否显示预览
showCaption
:
false
,
//是否显示标题
browseClass
:
"btn btn-primary"
,
//按钮样式
dropZoneEnabled
:
false
,
//是否显示拖拽区域
maxFileCount
:
1
,
//表示允许同时上传的最大文件个数
maxFileSize
:
10
*
1024
*
1024
,
messages
:
{
maxFileSize
:
'文件上传的最大大小为 10MB'
,
acceptFileTypes
:
'此文件是不支持的图片格式'
},
enctype
:
'multipart/form-data'
,
validateInitialCount
:
true
,
msgFilesTooMany
:
5
,
autoReplace
:
false
,
initialPreviewConfig
:
initialPreviewConfig
});
}
// 单图上传
$
(
"#singleCover"
).
on
(
'fileuploaded'
,
function
(
event
,
data
,
previewId
,
index
)
{
var
rsp
=
data
.
response
;
var
imgPath
=
$
(
"#cover"
).
val
();
if
(
imgPath
!=
null
&&
imgPath
!=
''
){
$
(
"#cover"
).
val
(
imgPath
+
","
+
rsp
.
fileName
);
}
else
{
$
(
"#cover"
).
val
(
rsp
.
fileName
);
}
$
(
"#singleCover"
).
fileinput
(
'destroy'
);
//销毁fileUploadFileInput
initUpload
();
//重新初始化文件预览数据和文件上传附件
$
(
'#singleCover'
).
fileinput
(
'enable'
);
//enable作用:destroy并重新初始化fileinput插件后,插件会处于disable状态
});
//删除方法
$
(
'#singleCover'
).
on
(
'filepredelete'
,
function
(
event
,
key
,
jqXHR
,
data
)
{
//就是在删除原图片之前触发,而新选择的图片不会触发。能满足我们的要求。
console
.
log
(
'Key = '
+
key
);
var
logoUrl
=
$
(
"#cover"
).
val
();
var
urlLinkNew
=
''
;
var
imgArr
=
logoUrl
.
split
(
","
);
for
(
var
i
=
0
;
i
<
imgArr
.
length
;
i
++
)
{
if
(
i
==
key
)
continue
;
if
(
urlLinkNew
!=
''
){
urlLinkNew
=
urlLinkNew
+
","
+
imgArr
[
i
];
}
else
{
urlLinkNew
=
imgArr
[
i
];
}
}
$
(
"#cover"
).
val
(
urlLinkNew
);
console
.
log
(
$
(
"#cover"
).
val
())
});
</script>
</body>
</html>
\ No newline at end of file
ruoyi-admin/src/main/resources/templates/business/news/news.html
0 → 100644
浏览文件 @
c8e4c6ac
<!DOCTYPE html>
<html
lang=
"zh"
xmlns:th=
"http://www.thymeleaf.org"
xmlns:shiro=
"http://www.pollix.at/thymeleaf/shiro"
>
<head>
<th:block
th:include=
"include :: header('新闻与活动列表')"
/>
</head>
<body
class=
"gray-bg"
>
<div
class=
"container-div"
>
<div
class=
"row"
>
<div
class=
"col-sm-12 search-collapse"
>
<form
id=
"formId"
>
<div
class=
"select-list"
>
<ul>
<li>
<label>
新闻标题:
</label>
<input
type=
"text"
name=
"title"
/>
</li>
<li>
<label>
新闻摘要:
</label>
<input
type=
"text"
name=
"summary"
/>
</li>
<a
class=
"btn btn-primary btn-rounded btn-sm"
onclick=
"$.table.search()"
><i
class=
"fa fa-search"
></i>
搜索
</a>
<a
class=
"btn btn-warning btn-rounded btn-sm"
onclick=
"$.form.reset()"
><i
class=
"fa fa-refresh"
></i>
重置
</a>
</li>
</ul>
</div>
</form>
</div>
<div
class=
"btn-group-sm"
id=
"toolbar"
role=
"group"
>
<a
class=
"btn btn-success"
onclick=
"$.operate.add()"
shiro:hasPermission=
"system:news:add"
>
<i
class=
"fa fa-plus"
></i>
添加
</a>
<a
class=
"btn btn-primary single disabled"
onclick=
"$.operate.edit()"
shiro:hasPermission=
"system:news:edit"
>
<i
class=
"fa fa-edit"
></i>
修改
</a>
<a
class=
"btn btn-danger multiple disabled"
onclick=
"$.operate.removeAll()"
shiro:hasPermission=
"system:news:remove"
>
<i
class=
"fa fa-remove"
></i>
删除
</a>
<a
class=
"btn btn-warning"
onclick=
"$.table.exportExcel()"
shiro:hasPermission=
"system:news:export"
>
<i
class=
"fa fa-download"
></i>
导出
</a>
</div>
<div
class=
"col-sm-12 select-table table-striped"
>
<table
id=
"bootstrap-table"
></table>
</div>
</div>
</div>
<th:block
th:include=
"include :: footer"
/>
<script
th:inline=
"javascript"
>
var
editFlag
=
[[
$
{@
permission
.
hasPermi
(
'system:news:edit'
)}]];
var
removeFlag
=
[[
$
{@
permission
.
hasPermi
(
'system:news:remove'
)}]];
var
prefix
=
ctx
+
"system/news"
;
$
(
function
()
{
var
options
=
{
url
:
prefix
+
"/list"
,
createUrl
:
prefix
+
"/add"
,
updateUrl
:
prefix
+
"/edit/{id}"
,
removeUrl
:
prefix
+
"/remove"
,
exportUrl
:
prefix
+
"/export"
,
modalName
:
"新闻与活动"
,
columns
:
[{
checkbox
:
true
},
{
field
:
'id'
,
title
:
'${comment}'
,
visible
:
false
},
{
field
:
'title'
,
title
:
'新闻标题'
},
{
field
:
'summary'
,
title
:
'新闻摘要'
},
{
field
:
'creator'
,
title
:
'创建者'
},
{
field
:
'modifiedBy'
,
title
:
'更新者'
},
{
field
:
'remark'
,
title
:
'备注'
},
{
title
:
'操作'
,
align
:
'center'
,
formatter
:
function
(
value
,
row
,
index
)
{
var
actions
=
[];
actions
.
push
(
'<a class="btn btn-success btn-xs '
+
editFlag
+
'" href="javascript:void(0)" onclick="$.operate.edit(
\'
'
+
row
.
id
+
'
\'
)"><i class="fa fa-edit"></i>编辑</a> '
);
actions
.
push
(
'<a class="btn btn-danger btn-xs '
+
removeFlag
+
'" href="javascript:void(0)" onclick="$.operate.remove(
\'
'
+
row
.
id
+
'
\'
)"><i class="fa fa-remove"></i>删除</a>'
);
return
actions
.
join
(
''
);
}
}]
};
$
.
table
.
init
(
options
);
});
</script>
</body>
</html>
\ No newline at end of file
ruoyi-admin/src/main/resources/templates/business/notice/add.html
浏览文件 @
c8e4c6ac
...
...
@@ -77,9 +77,9 @@
function
submitHandler
()
{
if
(
$
.
validate
.
form
())
{
var
a
=
$
(
'#noticeType1'
).
val
();
$
(
"#noticeType"
).
val
(
a
);
alert
(
$
(
"#noticeType"
).
val
());
//
var a=$('#noticeType1').val();
//
$("#noticeType").val(a);
//
alert($("#noticeType").val());
var
text
=
getContentTxt
();
if
(
text
==
''
||
text
.
length
==
0
)
{
$
.
modal
.
alertWarning
(
"请输入通知内容!"
);
...
...
ruoyi-admin/src/main/resources/templates/system/demo/edit.html
浏览文件 @
c8e4c6ac
...
...
@@ -25,12 +25,7 @@
</div>
</div>
<div
class=
"form-group"
>
<!-- <label class="col-sm-3 control-label is-required">材料内容:</label>-->
<label
class=
"col-sm-2 control-label is-required"
>
材料内容:
</label>
<!-- <div class="col-sm-8">-->
<!-- <input type="hidden" class="form-control" th:field="*{materialContent}">-->
<!-- <div class="summernote" id="materialContent"></div>-->
<!-- </div>-->
<div
class=
"col-sm-10"
>
<script
id=
"editor"
name=
"materialContent"
type=
"text/plain"
style=
"height: 300px;"
></script>
<textarea
id=
"materialContent"
style=
"display: none;"
>
[[*{materialContent}]]
</textarea>
...
...
ruoyi-system/src/main/java/com/ruoyi/system/domain/TbNews.java
0 → 100644
浏览文件 @
c8e4c6ac
package
com
.
ruoyi
.
system
.
domain
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
com.ruoyi.common.annotation.Excel
;
import
com.ruoyi.common.core.domain.BaseEntity
;
/**
* 新闻与活动对象 tb_news
*
* @author ruoyi
* @date 2022-10-25
*/
public
class
TbNews
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
/** $column.columnComment */
private
Long
id
;
/** 新闻标题 */
@Excel
(
name
=
"新闻标题"
)
private
String
title
;
/** 新闻摘要 */
@Excel
(
name
=
"新闻摘要"
)
private
String
summary
;
/** 新闻内容 */
@Excel
(
name
=
"新闻内容"
)
private
String
content
;
private
String
cover
;
/** 新闻状态(1正常 2关闭) */
@Excel
(
name
=
"新闻状态"
,
readConverterExp
=
"1=正常,2=关闭"
)
private
Integer
status
;
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
Long
getId
()
{
return
id
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setSummary
(
String
summary
)
{
this
.
summary
=
summary
;
}
public
String
getSummary
()
{
return
summary
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
public
String
getContent
()
{
return
content
;
}
public
void
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
}
public
Integer
getStatus
()
{
return
status
;
}
public
String
getCover
()
{
return
cover
;
}
public
void
setCover
(
String
cover
)
{
this
.
cover
=
cover
;
}
@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
())
.
append
(
"modifiedBy"
,
getModifiedBy
())
.
append
(
"updateTime"
,
getUpdateTime
())
.
append
(
"remark"
,
getRemark
())
.
toString
();
}
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TbNewsMapper.java
0 → 100644
浏览文件 @
c8e4c6ac
package
com
.
ruoyi
.
system
.
mapper
;
import
java.util.List
;
import
com.ruoyi.system.domain.TbNews
;
/**
* 新闻与活动Mapper接口
*
* @author ruoyi
* @date 2022-10-25
*/
public
interface
TbNewsMapper
{
/**
* 查询新闻与活动
*
* @param id 新闻与活动主键
* @return 新闻与活动
*/
public
TbNews
selectTbNewsById
(
Long
id
);
/**
* 查询新闻与活动列表
*
* @param tbNews 新闻与活动
* @return 新闻与活动集合
*/
public
List
<
TbNews
>
selectTbNewsList
(
TbNews
tbNews
);
/**
* 新增新闻与活动
*
* @param tbNews 新闻与活动
* @return 结果
*/
public
int
insertTbNews
(
TbNews
tbNews
);
/**
* 修改新闻与活动
*
* @param tbNews 新闻与活动
* @return 结果
*/
public
int
updateTbNews
(
TbNews
tbNews
);
/**
* 删除新闻与活动
*
* @param id 新闻与活动主键
* @return 结果
*/
public
int
deleteTbNewsById
(
Long
id
);
/**
* 批量删除新闻与活动
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public
int
deleteTbNewsByIds
(
String
[]
ids
);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/ITbNewsService.java
0 → 100644
浏览文件 @
c8e4c6ac
package
com
.
ruoyi
.
system
.
service
;
import
java.util.List
;
import
com.ruoyi.system.domain.TbNews
;
/**
* 新闻与活动Service接口
*
* @author ruoyi
* @date 2022-10-25
*/
public
interface
ITbNewsService
{
/**
* 查询新闻与活动
*
* @param id 新闻与活动主键
* @return 新闻与活动
*/
public
TbNews
selectTbNewsById
(
Long
id
);
/**
* 查询新闻与活动列表
*
* @param tbNews 新闻与活动
* @return 新闻与活动集合
*/
public
List
<
TbNews
>
selectTbNewsList
(
TbNews
tbNews
);
/**
* 新增新闻与活动
*
* @param tbNews 新闻与活动
* @return 结果
*/
public
int
insertTbNews
(
TbNews
tbNews
);
/**
* 修改新闻与活动
*
* @param tbNews 新闻与活动
* @return 结果
*/
public
int
updateTbNews
(
TbNews
tbNews
);
/**
* 批量删除新闻与活动
*
* @param ids 需要删除的新闻与活动主键集合
* @return 结果
*/
public
int
deleteTbNewsByIds
(
String
ids
);
/**
* 删除新闻与活动信息
*
* @param id 新闻与活动主键
* @return 结果
*/
public
int
deleteTbNewsById
(
Long
id
);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbNewsServiceImpl.java
0 → 100644
浏览文件 @
c8e4c6ac
package
com
.
ruoyi
.
system
.
service
.
impl
;
import
java.util.List
;
import
com.ruoyi.common.utils.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.system.mapper.TbNewsMapper
;
import
com.ruoyi.system.domain.TbNews
;
import
com.ruoyi.system.service.ITbNewsService
;
import
com.ruoyi.common.core.text.Convert
;
/**
* 新闻与活动Service业务层处理
*
* @author ruoyi
* @date 2022-10-25
*/
@Service
public
class
TbNewsServiceImpl
implements
ITbNewsService
{
@Autowired
private
TbNewsMapper
tbNewsMapper
;
/**
* 查询新闻与活动
*
* @param id 新闻与活动主键
* @return 新闻与活动
*/
@Override
public
TbNews
selectTbNewsById
(
Long
id
)
{
return
tbNewsMapper
.
selectTbNewsById
(
id
);
}
/**
* 查询新闻与活动列表
*
* @param tbNews 新闻与活动
* @return 新闻与活动
*/
@Override
public
List
<
TbNews
>
selectTbNewsList
(
TbNews
tbNews
)
{
return
tbNewsMapper
.
selectTbNewsList
(
tbNews
);
}
/**
* 新增新闻与活动
*
* @param tbNews 新闻与活动
* @return 结果
*/
@Override
public
int
insertTbNews
(
TbNews
tbNews
)
{
tbNews
.
setStatus
(
1
);
tbNews
.
setCreateTime
(
DateUtils
.
getNowDate
());
return
tbNewsMapper
.
insertTbNews
(
tbNews
);
}
/**
* 修改新闻与活动
*
* @param tbNews 新闻与活动
* @return 结果
*/
@Override
public
int
updateTbNews
(
TbNews
tbNews
)
{
tbNews
.
setUpdateTime
(
DateUtils
.
getNowDate
());
return
tbNewsMapper
.
updateTbNews
(
tbNews
);
}
/**
* 批量删除新闻与活动
*
* @param ids 需要删除的新闻与活动主键
* @return 结果
*/
@Override
public
int
deleteTbNewsByIds
(
String
ids
)
{
return
tbNewsMapper
.
deleteTbNewsByIds
(
Convert
.
toStrArray
(
ids
));
}
/**
* 删除新闻与活动信息
*
* @param id 新闻与活动主键
* @return 结果
*/
@Override
public
int
deleteTbNewsById
(
Long
id
)
{
return
tbNewsMapper
.
deleteTbNewsById
(
id
);
}
}
ruoyi-system/src/main/resources/mapper/system/TbNewsMapper.xml
0 → 100644
浏览文件 @
c8e4c6ac
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.ruoyi.system.mapper.TbNewsMapper"
>
<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=
"status"
column=
"status"
/>
<result
property=
"creator"
column=
"creator"
/>
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"modifiedBy"
column=
"modified_by"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"remark"
column=
"remark"
/>
</resultMap>
<sql
id=
"selectTbNewsVo"
>
select id, title, summary, content, 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>-->
</where>
</select>
<select
id=
"selectTbNewsById"
parameterType=
"Long"
resultMap=
"TbNewsResult"
>
<include
refid=
"selectTbNewsVo"
/>
where id = #{id}
</select>
<insert
id=
"insertTbNews"
parameterType=
"TbNews"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into tb_news
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
title,summary,content,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=
"status != null"
>
#{status},
</if>
<if
test=
"remark != null"
>
#{remark},
</if>
<if
test=
"creator != null"
>
#{creator},
</if>
<if
test=
"createTime != null"
>
#{createTime},
</if>
</trim>
</insert>
<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=
"status != null"
>
status = #{status},
</if>
<if
test=
"modifiedBy != null"
>
modified_by = #{modifiedBy},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"remark != null"
>
remark = #{remark},
</if>
</trim>
where id = #{id}
</update>
<delete
id=
"deleteTbNewsById"
parameterType=
"Long"
>
delete from tb_news where id = #{id}
</delete>
<delete
id=
"deleteTbNewsByIds"
parameterType=
"String"
>
delete from tb_news where id in
<foreach
item=
"id"
collection=
"array"
open=
"("
separator=
","
close=
")"
>
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论