Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gs1-office-web-sit
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴迪
gs1-office-web-sit
Commits
122e842f
Commit
122e842f
authored
Oct 13, 2021
by
rongkailun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文章管理 新增 删除 修改 审核 功能新增
parent
9a56e38a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
156 additions
and
35 deletions
+156
-35
NewsController.java
...a/io/office/modules/manage/controller/NewsController.java
+50
-16
NewsEntity.java
...main/java/io/office/modules/manage/entity/NewsEntity.java
+23
-17
NewsService.java
...in/java/io/office/modules/manage/service/NewsService.java
+11
-1
NewsServiceImpl.java
...o/office/modules/manage/service/impl/NewsServiceImpl.java
+72
-1
No files found.
src/main/java/io/office/modules/manage/controller/NewsController.java
View file @
122e842f
package
io
.
office
.
modules
.
manage
.
controller
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
import
io.office.modules.sys.controller.AbstractController
;
import
io.office.modules.sys.entity.SysUserEntity
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
...
...
@@ -17,7 +21,6 @@ import io.office.common.utils.PageUtils;
import
io.office.common.utils.R
;
/**
* ${comments}
*
...
...
@@ -27,7 +30,8 @@ import io.office.common.utils.R;
*/
@RestController
@RequestMapping
(
"/news"
)
public
class
NewsController
{
@Slf4j
public
class
NewsController
extends
AbstractController
{
@Autowired
private
NewsService
newsService
;
...
...
@@ -36,7 +40,7 @@ public class NewsController {
*/
@RequestMapping
(
"/list"
)
// @RequiresPermissions("manage:news:list")
public
R
list
(
@RequestParam
Map
<
String
,
Object
>
params
){
public
R
list
(
@RequestParam
Map
<
String
,
Object
>
params
)
{
PageUtils
page
=
newsService
.
queryPage
(
params
);
return
R
.
ok
().
put
(
"page"
,
page
);
...
...
@@ -48,21 +52,28 @@ public class NewsController {
*/
@RequestMapping
(
"/info/{id}"
)
// @RequiresPermissions("manage:news:info")
public
R
info
(
@PathVariable
(
"id"
)
Integer
id
){
public
R
info
(
@PathVariable
(
"id"
)
Integer
id
)
{
NewsEntity
news
=
newsService
.
getById
(
id
);
return
R
.
ok
().
put
(
"news"
,
news
);
}
/**
* 保存
* @param news
* @return R
* @author rkl
* @date 2021/10/13
*/
@RequestMapping
(
"/save"
)
// @RequiresPermissions("manage:news:save")
public
R
save
(
@RequestBody
NewsEntity
news
){
newsService
.
save
(
news
);
return
R
.
ok
();
public
R
save
(
@RequestBody
NewsEntity
news
)
{
try
{
R
r
=
this
.
newsService
.
insertNews
(
news
,
getUser
());
return
r
;
}
catch
(
Exception
e
)
{
log
.
error
(
"save error:"
,
e
);
return
R
.
error
(
e
.
getMessage
());
}
}
/**
...
...
@@ -70,10 +81,14 @@ public class NewsController {
*/
@RequestMapping
(
"/update"
)
// @RequiresPermissions("manage:news:update")
public
R
update
(
@RequestBody
NewsEntity
news
){
newsService
.
updateById
(
news
);
return
R
.
ok
();
public
R
update
(
@RequestBody
NewsEntity
news
)
{
try
{
R
r
=
this
.
newsService
.
updateNews
(
news
,
getUser
());
return
r
;
}
catch
(
Exception
e
)
{
log
.
error
(
"update error:"
,
e
);
return
R
.
error
(
e
.
getMessage
());
}
}
/**
...
...
@@ -81,10 +96,29 @@ public class NewsController {
*/
@RequestMapping
(
"/delete"
)
// @RequiresPermissions("manage:news:delete")
public
R
delete
(
@RequestBody
Integer
[]
ids
){
newsService
.
removeByIds
(
Arrays
.
asList
(
ids
));
public
R
delete
(
@RequestBody
List
<
Long
>
ids
)
{
try
{
R
r
=
this
.
newsService
.
deleteNews
(
ids
,
getUser
());
return
r
;
}
catch
(
Exception
e
)
{
log
.
error
(
"delete error:"
,
e
);
return
R
.
error
(
e
.
getMessage
());
}
}
return
R
.
ok
();
/**
* 删除
*/
@RequestMapping
(
"/verifyNews"
)
// @RequiresPermissions("manage:news:verify")
public
R
verify
(
@RequestBody
NewsEntity
news
)
{
try
{
R
r
=
this
.
newsService
.
verifyNews
(
news
,
getUser
());
return
r
;
}
catch
(
Exception
e
)
{
log
.
error
(
"delete error:"
,
e
);
return
R
.
error
(
e
.
getMessage
());
}
}
}
src/main/java/io/office/modules/manage/entity/NewsEntity.java
View file @
122e842f
...
...
@@ -5,8 +5,14 @@ import com.baomidou.mybatisplus.annotation.TableName;
import
java.io.Serializable
;
import
java.util.Date
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.office.common.validator.group.AddGroup
;
import
io.office.common.validator.group.UpdateGroup
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
/**
* ${comments}
*
...
...
@@ -25,23 +31,23 @@ public class NewsEntity implements Serializable {
@TableId
private
Integer
id
;
/**
*
$column.comments
*
没有使用
*/
private
Integer
columnid
;
/**
*
$column.comments
*
标题
*/
private
String
title
;
/**
*
$column.comments
*
老标题
*/
private
String
titleOld
;
/**
*
$column.comments
*
关键字
*/
private
String
keyword
;
/**
*
$column.comments
*
简介
*/
private
String
brief
;
/**
...
...
@@ -53,27 +59,27 @@ public class NewsEntity implements Serializable {
*/
private
Date
updatedate
;
/**
*
$column.comments
*
作者
*/
private
String
author
;
/**
*
$column.comments
*
稿源
*/
private
String
source
;
/**
*
$column.comments
*
等级
*/
private
Integer
levels
;
/**
*
$column.comments
*
跳转路径
*/
private
String
directpath
;
/**
*
$column.comments
*
图片地址
*/
private
String
pic
;
/**
*
$column.comments
*
内容
*/
private
String
content
;
/**
...
...
@@ -81,19 +87,19 @@ public class NewsEntity implements Serializable {
*/
private
Integer
hits
;
/**
*
$column.comments
*
编辑
*/
private
String
editor
;
/**
*
$column.comments
*
最后修改人
*/
private
String
lasteditor
;
/**
*
$column.comments
*
分类id
*/
private
Integer
classid
;
/**
*
$column.comments
*
出版时间
*/
private
Date
publicdate
;
/**
...
...
@@ -105,7 +111,7 @@ public class NewsEntity implements Serializable {
*/
private
String
ishead
;
/**
*
$column.comments
*
状态
*/
private
Integer
status
;
/**
...
...
@@ -113,7 +119,7 @@ public class NewsEntity implements Serializable {
*/
private
String
auditor
;
/**
*
$column.comments
*
显示时间
*/
private
String
showtime
;
/**
...
...
src/main/java/io/office/modules/manage/service/NewsService.java
View file @
122e842f
...
...
@@ -2,9 +2,11 @@ package io.office.modules.manage.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
io.office.common.utils.PageUtils
;
import
io.office.common.utils.R
;
import
io.office.modules.manage.entity.NewsEntity
;
import
io.office.modules.sys.entity.SysUserEntity
;
import
java.util.
Map
;
import
java.util.
*
;
/**
* ${comments}
...
...
@@ -16,5 +18,13 @@ import java.util.Map;
public
interface
NewsService
extends
IService
<
NewsEntity
>
{
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
);
R
insertNews
(
NewsEntity
news
,
SysUserEntity
user
);
R
updateNews
(
NewsEntity
news
,
SysUserEntity
user
);
R
deleteNews
(
List
ids
,
SysUserEntity
user
);
R
verifyNews
(
NewsEntity
newsEntity
,
SysUserEntity
user
);
}
src/main/java/io/office/modules/manage/service/impl/NewsServiceImpl.java
View file @
122e842f
package
io
.
office
.
modules
.
manage
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
io.office.common.utils.DateUtils
;
import
io.office.common.utils.R
;
import
io.office.modules.manage.entity.NewsclassEntity
;
import
io.office.modules.sys.entity.SysUserEntity
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
...
...
@@ -16,14 +25,75 @@ import io.office.modules.manage.service.NewsService;
@Service
(
"newsService"
)
public
class
NewsServiceImpl
extends
ServiceImpl
<
NewsDao
,
NewsEntity
>
implements
NewsService
{
@Override
public
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
)
{
IPage
<
NewsEntity
>
page
=
this
.
page
(
new
Query
<
NewsEntity
>().
getPage
(
params
),
new
QueryWrapper
<
NewsEntity
>()
);
return
new
PageUtils
(
page
);
}
@Override
public
R
insertNews
(
NewsEntity
news
,
SysUserEntity
user
)
{
news
.
setEditor
(
user
.
getUsername
());
news
.
setLasteditor
(
user
.
getUsername
());
news
.
setStartdate
(
new
Date
());
news
.
setPublicdate
(
new
Date
());
int
insert
=
baseMapper
.
insert
(
news
);
if
(
insert
>
0
){
return
R
.
ok
(
"新增成功!"
);
}
else
{
return
R
.
error
(
"新增失败!"
);
}
}
@Override
public
R
updateNews
(
NewsEntity
news
,
SysUserEntity
user
)
{
if
(
news
.
getId
()
==
null
){
return
R
.
error
(
"id不能为空!"
);
}
QueryWrapper
<
NewsEntity
>
newsEntityQueryWrapper
=
new
QueryWrapper
<>();
newsEntityQueryWrapper
.
eq
(
"id"
,
news
.
getId
());
news
.
setEditor
(
user
.
getUsername
());
news
.
setLasteditor
(
user
.
getUsername
());
int
update
=
baseMapper
.
update
(
news
,
newsEntityQueryWrapper
);
if
(
update
>
0
){
return
R
.
ok
(
"修改成功!"
);
}
else
{
return
R
.
error
(
"修改失败!"
);
}
}
@Override
public
R
deleteNews
(
List
ids
,
SysUserEntity
user
)
{
NewsEntity
news
=
new
NewsEntity
();
news
.
setLevels
(
0
);
QueryWrapper
<
NewsEntity
>
newsEntityQueryWrapper
=
new
QueryWrapper
<>();
newsEntityQueryWrapper
.
in
(
"id"
,
ids
);
int
delete
=
baseMapper
.
update
(
news
,
newsEntityQueryWrapper
);
if
(
delete
>
0
){
return
R
.
ok
(
"删除成功!"
);
}
else
{
return
R
.
error
(
"删除失败!"
);
}
}
@Override
public
R
verifyNews
(
NewsEntity
news
,
SysUserEntity
user
)
{
news
.
setAuditor
(
user
.
getUsername
());
news
.
setCheckdate
(
new
Date
());
news
.
setLasteditor
(
user
.
getUsername
());
QueryWrapper
<
NewsEntity
>
newsEntityQueryWrapper
=
new
QueryWrapper
<>();
newsEntityQueryWrapper
.
eq
(
"id"
,
news
.
getId
());
int
verify
=
baseMapper
.
update
(
news
,
newsEntityQueryWrapper
);
if
(
verify
>
0
){
return
R
.
ok
(
"审核成功!"
);
}
else
{
return
R
.
error
(
"审核失败!"
);
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment