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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
163 additions
and
42 deletions
+163
-42
NewsController.java
...a/io/office/modules/manage/controller/NewsController.java
+57
-23
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
;
package
io
.
office
.
modules
.
manage
.
controller
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
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.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
...
@@ -17,17 +21,17 @@ import io.office.common.utils.PageUtils;
...
@@ -17,17 +21,17 @@ import io.office.common.utils.PageUtils;
import
io.office.common.utils.R
;
import
io.office.common.utils.R
;
/**
/**
* ${comments}
* ${comments}
*
*
* @author wudi
* @author wudi
* @email
* @email
* @date 2021-10-11 14:53:31
* @date 2021-10-11 14:53:31
*/
*/
@RestController
@RestController
@RequestMapping
(
"/news"
)
@RequestMapping
(
"/news"
)
public
class
NewsController
{
@Slf4j
public
class
NewsController
extends
AbstractController
{
@Autowired
@Autowired
private
NewsService
newsService
;
private
NewsService
newsService
;
...
@@ -35,8 +39,8 @@ public class NewsController {
...
@@ -35,8 +39,8 @@ public class NewsController {
* 列表
* 列表
*/
*/
@RequestMapping
(
"/list"
)
@RequestMapping
(
"/list"
)
// @RequiresPermissions("manage:news: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
);
PageUtils
page
=
newsService
.
queryPage
(
params
);
return
R
.
ok
().
put
(
"page"
,
page
);
return
R
.
ok
().
put
(
"page"
,
page
);
...
@@ -47,44 +51,74 @@ public class NewsController {
...
@@ -47,44 +51,74 @@ public class NewsController {
* 信息
* 信息
*/
*/
@RequestMapping
(
"/info/{id}"
)
@RequestMapping
(
"/info/{id}"
)
// @RequiresPermissions("manage:news:info")
// @RequiresPermissions("manage:news:info")
public
R
info
(
@PathVariable
(
"id"
)
Integer
id
){
public
R
info
(
@PathVariable
(
"id"
)
Integer
id
)
{
NewsEntity
news
=
newsService
.
getById
(
id
);
NewsEntity
news
=
newsService
.
getById
(
id
);
return
R
.
ok
().
put
(
"news"
,
news
);
return
R
.
ok
().
put
(
"news"
,
news
);
}
}
/**
/**
* 保存
* 保存
* @param news
* @return R
* @author rkl
* @date 2021/10/13
*/
*/
@RequestMapping
(
"/save"
)
@RequestMapping
(
"/save"
)
// @RequiresPermissions("manage:news:save")
// @RequiresPermissions("manage:news:save")
public
R
save
(
@RequestBody
NewsEntity
news
){
public
R
save
(
@RequestBody
NewsEntity
news
)
{
newsService
.
save
(
news
);
try
{
R
r
=
this
.
newsService
.
insertNews
(
news
,
getUser
());
return
R
.
ok
();
return
r
;
}
catch
(
Exception
e
)
{
log
.
error
(
"save error:"
,
e
);
return
R
.
error
(
e
.
getMessage
());
}
}
}
/**
/**
* 修改
* 修改
*/
*/
@RequestMapping
(
"/update"
)
@RequestMapping
(
"/update"
)
// @RequiresPermissions("manage:news:update")
// @RequiresPermissions("manage:news:update")
public
R
update
(
@RequestBody
NewsEntity
news
){
public
R
update
(
@RequestBody
NewsEntity
news
)
{
newsService
.
updateById
(
news
);
try
{
R
r
=
this
.
newsService
.
updateNews
(
news
,
getUser
());
return
R
.
ok
();
return
r
;
}
catch
(
Exception
e
)
{
log
.
error
(
"update error:"
,
e
);
return
R
.
error
(
e
.
getMessage
());
}
}
}
/**
/**
* 删除
* 删除
*/
*/
@RequestMapping
(
"/delete"
)
@RequestMapping
(
"/delete"
)
// @RequiresPermissions("manage:news:delete")
// @RequiresPermissions("manage:news:delete")
public
R
delete
(
@RequestBody
Integer
[]
ids
){
public
R
delete
(
@RequestBody
List
<
Long
>
ids
)
{
newsService
.
removeByIds
(
Arrays
.
asList
(
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;
...
@@ -5,8 +5,14 @@ import com.baomidou.mybatisplus.annotation.TableName;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.Date
;
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
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
/**
/**
* ${comments}
* ${comments}
*
*
...
@@ -25,23 +31,23 @@ public class NewsEntity implements Serializable {
...
@@ -25,23 +31,23 @@ public class NewsEntity implements Serializable {
@TableId
@TableId
private
Integer
id
;
private
Integer
id
;
/**
/**
*
$column.comments
*
没有使用
*/
*/
private
Integer
columnid
;
private
Integer
columnid
;
/**
/**
*
$column.comments
*
标题
*/
*/
private
String
title
;
private
String
title
;
/**
/**
*
$column.comments
*
老标题
*/
*/
private
String
titleOld
;
private
String
titleOld
;
/**
/**
*
$column.comments
*
关键字
*/
*/
private
String
keyword
;
private
String
keyword
;
/**
/**
*
$column.comments
*
简介
*/
*/
private
String
brief
;
private
String
brief
;
/**
/**
...
@@ -53,27 +59,27 @@ public class NewsEntity implements Serializable {
...
@@ -53,27 +59,27 @@ public class NewsEntity implements Serializable {
*/
*/
private
Date
updatedate
;
private
Date
updatedate
;
/**
/**
*
$column.comments
*
作者
*/
*/
private
String
author
;
private
String
author
;
/**
/**
*
$column.comments
*
稿源
*/
*/
private
String
source
;
private
String
source
;
/**
/**
*
$column.comments
*
等级
*/
*/
private
Integer
levels
;
private
Integer
levels
;
/**
/**
*
$column.comments
*
跳转路径
*/
*/
private
String
directpath
;
private
String
directpath
;
/**
/**
*
$column.comments
*
图片地址
*/
*/
private
String
pic
;
private
String
pic
;
/**
/**
*
$column.comments
*
内容
*/
*/
private
String
content
;
private
String
content
;
/**
/**
...
@@ -81,19 +87,19 @@ public class NewsEntity implements Serializable {
...
@@ -81,19 +87,19 @@ public class NewsEntity implements Serializable {
*/
*/
private
Integer
hits
;
private
Integer
hits
;
/**
/**
*
$column.comments
*
编辑
*/
*/
private
String
editor
;
private
String
editor
;
/**
/**
*
$column.comments
*
最后修改人
*/
*/
private
String
lasteditor
;
private
String
lasteditor
;
/**
/**
*
$column.comments
*
分类id
*/
*/
private
Integer
classid
;
private
Integer
classid
;
/**
/**
*
$column.comments
*
出版时间
*/
*/
private
Date
publicdate
;
private
Date
publicdate
;
/**
/**
...
@@ -105,7 +111,7 @@ public class NewsEntity implements Serializable {
...
@@ -105,7 +111,7 @@ public class NewsEntity implements Serializable {
*/
*/
private
String
ishead
;
private
String
ishead
;
/**
/**
*
$column.comments
*
状态
*/
*/
private
Integer
status
;
private
Integer
status
;
/**
/**
...
@@ -113,7 +119,7 @@ public class NewsEntity implements Serializable {
...
@@ -113,7 +119,7 @@ public class NewsEntity implements Serializable {
*/
*/
private
String
auditor
;
private
String
auditor
;
/**
/**
*
$column.comments
*
显示时间
*/
*/
private
String
showtime
;
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;
...
@@ -2,9 +2,11 @@ package io.office.modules.manage.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
io.office.common.utils.PageUtils
;
import
io.office.common.utils.PageUtils
;
import
io.office.common.utils.R
;
import
io.office.modules.manage.entity.NewsEntity
;
import
io.office.modules.manage.entity.NewsEntity
;
import
io.office.modules.sys.entity.SysUserEntity
;
import
java.util.
Map
;
import
java.util.
*
;
/**
/**
* ${comments}
* ${comments}
...
@@ -16,5 +18,13 @@ import java.util.Map;
...
@@ -16,5 +18,13 @@ import java.util.Map;
public
interface
NewsService
extends
IService
<
NewsEntity
>
{
public
interface
NewsService
extends
IService
<
NewsEntity
>
{
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
);
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
;
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
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
...
@@ -16,14 +25,75 @@ import io.office.modules.manage.service.NewsService;
...
@@ -16,14 +25,75 @@ import io.office.modules.manage.service.NewsService;
@Service
(
"newsService"
)
@Service
(
"newsService"
)
public
class
NewsServiceImpl
extends
ServiceImpl
<
NewsDao
,
NewsEntity
>
implements
NewsService
{
public
class
NewsServiceImpl
extends
ServiceImpl
<
NewsDao
,
NewsEntity
>
implements
NewsService
{
@Override
@Override
public
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
)
{
public
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
)
{
IPage
<
NewsEntity
>
page
=
this
.
page
(
IPage
<
NewsEntity
>
page
=
this
.
page
(
new
Query
<
NewsEntity
>().
getPage
(
params
),
new
Query
<
NewsEntity
>().
getPage
(
params
),
new
QueryWrapper
<
NewsEntity
>()
new
QueryWrapper
<
NewsEntity
>()
);
);
return
new
PageUtils
(
page
);
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