package cn.springboottestdemo.testdemo1.controller;
import cn.springboottestdemo.testdemo1.pojo.NewsComment;
import cn.springboottestdemo.testdemo1.pojo.NewsDetail;
import cn.springboottestdemo.testdemo1.service.CommentService;
import cn.springboottestdemo.testdemo1.service.NewsService;
import cn.springboottestdemo.testdemo1.util.DtoUtil;
import cn.springboottestdemo.testdemo1.util.Page;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@org.springframework.stereotype.Controller
@RequestMapping("/news")
public class Controller extends BaseController {
@Resource
private NewsService newsService;
@Resource
private CommentService commentService;
@RequestMapping("/get")
@ResponseBody
public Object get(){
return DtoUtil.returnSuccess(newsService.getlimit());
}
@RequestMapping("/get1")
@ResponseBody
public Object get1(Page page, @RequestParam(value = "title",required = false) String title){
NewsDetail newsDetail=new NewsDetail();
Map map=new HashMap();
if(title==null||title==""){
title="";
newsDetail.setTitle(title);
}else{
newsDetail.setTitle(title);
}
page.setCount(newsService.count(newsDetail));
if (page.getPageIndex()==0||page.getPageIndex()==null){
page.setPageIndex(1);
}
List<NewsDetail> list=newsService.getlimit1(page,newsDetail);
String pageinfo=this.getPageInfo(page,title);
map.put("list",list);
map.put("pageinfo",pageinfo);
map.put("page",page);
map.put("title",title);
return DtoUtil.returnSuccess(map);
}
@RequestMapping("/beforlookComment")
@ResponseBody
public Object beforlookComment(Integer id){
return DtoUtil.returnSuccess(id);
}
@RequestMapping("/lookComment")
@ResponseBody
public Object lookComment(Integer newsid){
List<NewsComment> l=commentService.getBynewsId(newsid);
return DtoUtil.returnSuccess(l);
}
@RequestMapping("/update")
@ResponseBody
public Object update(Integer newsid){
return DtoUtil.returnSuccess(newsid);
}
@RequestMapping("/doupdate")
@ResponseBody
public Object doupdate(NewsComment newsComment){
try{
newsComment.setCreatedate(new Date());
int a=commentService.add(newsComment);
if(a>0){
return DtoUtil.returnSuccess();
}
}catch (Exception e){
e.getStackTrace();
}
return DtoUtil.returnFaile();
}
@RequestMapping("/delete")
@ResponseBody
public Object delete(Integer id){
commentService.delete(id);
int a=newsService.delete(id);
if(a>0){
return DtoUtil.returnSuccess("删除成功!","");
}
return DtoUtil.returnFaile("删除失败!","");
}
private String getPageInfo(Page page, @RequestParam(required = false) String title){
StringBuffer pageCode = new StringBuffer();
if (page.getPageIndex()>=page.getTatoleCount()){
pageCode.append("<a href='list.html?title="+title+"&pageIndex=1'>首页</a>");
pageCode.append("<a href='list.html?title="+title+"&pageIndex="+(page.getPageIndex()-1)+"'>上一页</a>");
}else if (page.getPageIndex()==1){
pageCode.append("<a href='list.html?title="+title+"&pageIndex="+(page.getPageIndex()+1)+"'>下一页</a>");
pageCode.append("<a href='list.html?title="+title+"&pageIndex="+page.getTatoleCount()+"'>尾页</a>");
} else{
pageCode.append("<a href='list.html?title="+title+"&pageIndex=1'>首页</a>");
pageCode.append("<a href='list.html?title="+title+"&pageIndex="+(page.getPageIndex()-1)+"'>上一页</a>");
pageCode.append("<a href='list.html?title="+title+"&pageIndex="+(page.getPageIndex()+1)+"'>下一页</a>");
pageCode.append("<a href='list.html?title="+title+"&pageIndex="+page.getTatoleCount()+"'>尾页</a>");
}
return pageCode.toString();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
SpringBoot框架,前后端分离写的新闻管理系统
共153个文件
xml:89个
java:15个
class:15个
1星 需积分: 38 77 下载量 187 浏览量
2018-10-22
15:28:41
上传
评论 15
收藏 185KB RAR 举报
温馨提示
SpringBoot框架,前后端分离写的新闻管理系统,采用Ajax传输数据
资源推荐
资源详情
资源评论
收起资源包目录
SpringBoot框架,前后端分离写的新闻管理系统 (153个子文件)
Controller.class 6KB
NewServiceImp.class 2KB
DtoUtil.class 2KB
NewsDetail.class 2KB
Dto.class 2KB
Page.class 2KB
NewsComment.class 1KB
CommentServiceImp.class 1KB
NewsMapper.class 1KB
BaseController.class 1001B
NewsService.class 951B
Testdemo1Application.class 930B
Testdemo1ApplicationTests.class 667B
CommentMapper.class 515B
CommentService.class 435B
mvnw.cmd 5KB
list.css 379B
list.css 379B
update.css 224B
update.css 224B
lookcomment.css 168B
lookcomment.css 168B
.gitignore 268B
update.html 1KB
update.html 1KB
add.html 972B
add.html 972B
list.html 961B
list.html 961B
lookcomment.html 901B
lookcomment.html 901B
testdemo1.iml 9KB
maven-wrapper.jar 46KB
Controller.java 4KB
DtoUtil.java 2KB
NewServiceImp.java 1KB
NewsDetail.java 1KB
Page.java 1KB
NewsComment.java 1003B
CommentServiceImp.java 850B
Dto.java 841B
NewsMapper.java 695B
Testdemo1Application.java 622B
NewsService.java 600B
BaseController.java 528B
CommentMapper.java 359B
Testdemo1ApplicationTests.java 351B
CommentService.java 302B
jquery-1.8.3.min.js 91KB
jquery-1.8.3.min.js 91KB
list.js 5KB
list.js 5KB
update.js 3KB
update.js 3KB
lookcomment.js 3KB
lookcomment.js 3KB
common.js 1KB
common.js 1KB
add.js 1KB
add.js 1KB
mvnw 6KB
application.properties 671B
application.properties 597B
maven-wrapper.properties 110B
workspace.xml 52KB
uiDesigner.xml 9KB
pom.xml 4KB
NewsMapper.xml 3KB
NewsMapper.xml 3KB
Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_0_6_RELEASE.xml 769B
Maven__org_springframework_boot_spring_boot_starter_thymeleaf_2_0_6_RELEASE.xml 762B
Maven__org_springframework_boot_spring_boot_starter_logging_2_0_6_RELEASE.xml 748B
Maven__org_springframework_boot_spring_boot_starter_tomcat_2_0_6_RELEASE.xml 741B
Maven__org_springframework_boot_spring_boot_autoconfigure_2_0_6_RELEASE.xml 734B
CommentMapper.xml 731B
CommentMapper.xml 731B
Maven__org_mybatis_spring_boot_mybatis_spring_boot_autoconfigure_1_1_1.xml 730B
Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_9_7.xml 729B
Maven__org_springframework_boot_spring_boot_starter_test_2_0_6_RELEASE.xml 727B
Maven__org_springframework_boot_spring_boot_starter_json_2_0_6_RELEASE.xml 727B
Maven__org_springframework_boot_spring_boot_starter_jdbc_2_0_6_RELEASE.xml 727B
Maven__org_thymeleaf_extras_thymeleaf_extras_java8time_3_0_1_RELEASE.xml 725B
Maven__org_springframework_boot_spring_boot_starter_aop_2_0_6_RELEASE.xml 720B
Maven__org_springframework_boot_spring_boot_starter_web_2_0_6_RELEASE.xml 720B
Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml 700B
Maven__org_springframework_boot_spring_boot_starter_2_0_6_RELEASE.xml 692B
Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_9_7.xml 688B
Maven__org_mybatis_spring_boot_mybatis_spring_boot_starter_1_1_1.xml 688B
Maven__org_hibernate_validator_hibernate_validator_6_0_13_Final.xml 681B
Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_9_7.xml 674B
Maven__org_springframework_boot_spring_boot_test_2_0_6_RELEASE.xml 671B
Maven__org_springframework_spring_expression_5_0_10_RELEASE.xml 665B
Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_34.xml 660B
Maven__org_springframework_spring_context_5_0_10_RELEASE.xml 644B
Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_0.xml 644B
Maven__org_thymeleaf_thymeleaf_spring5_3_0_10_RELEASE.xml 641B
Maven__org_springframework_spring_webmvc_5_0_10_RELEASE.xml 637B
Maven__org_springframework_boot_spring_boot_2_0_6_RELEASE.xml 636B
Maven__org_springframework_spring_beans_5_0_10_RELEASE.xml 630B
compiler.xml 630B
共 153 条
- 1
- 2
资源评论
- zw4961925162019-10-13垃圾项目,本人只是懒不想做,但是这个项目很垃圾
- 宝爷~2022-03-07前端还是在后端项目里,没有学习价值
- qq_390742602019-03-09一样一样的
- 宜城有少年2018-11-08根本就没有分离啊,前端还是在后端项目里
BZDY
- 粉丝: 3
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功