Commit 122e842f by rongkailun

文章管理 新增 删除 修改 审核 功能新增

parent 9a56e38a
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,17 +21,17 @@ import io.office.common.utils.PageUtils;
import io.office.common.utils.R;
/**
* ${comments}
*
* @author wudi
* @email
* @email
* @date 2021-10-11 14:53:31
*/
@RestController
@RequestMapping("/news")
public class NewsController {
@Slf4j
public class NewsController extends AbstractController {
@Autowired
private NewsService newsService;
......@@ -35,8 +39,8 @@ public class NewsController {
* 列表
*/
@RequestMapping("/list")
// @RequiresPermissions("manage:news:list")
public R list(@RequestParam Map<String, Object> params){
// @RequiresPermissions("manage:news:list")
public R list(@RequestParam Map<String, Object> params) {
PageUtils page = newsService.queryPage(params);
return R.ok().put("page", page);
......@@ -47,44 +51,74 @@ public class NewsController {
* 信息
*/
@RequestMapping("/info/{id}")
// @RequiresPermissions("manage:news:info")
public R info(@PathVariable("id") Integer id){
NewsEntity news = newsService.getById(id);
// @RequiresPermissions("manage:news:info")
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();
// @RequiresPermissions("manage:news:save")
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());
}
}
/**
* 修改
*/
@RequestMapping("/update")
// @RequiresPermissions("manage:news:update")
public R update(@RequestBody NewsEntity news){
newsService.updateById(news);
return R.ok();
// @RequiresPermissions("manage:news:update")
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());
}
}
/**
* 删除
*/
@RequestMapping("/delete")
// @RequiresPermissions("manage:news:delete")
public R delete(@RequestBody Integer[] ids){
newsService.removeByIds(Arrays.asList(ids));
// @RequiresPermissions("manage:news:delete")
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());
}
}
}
......@@ -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;
/**
......
......@@ -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);
}
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment