package com.linn.home.controller;
import com.github.pagehelper.PageInfo;
import com.linn.frame.controller.BaseController;
import com.linn.frame.entity.ResultBean;
import com.linn.frame.util.DateUtils;
import com.linn.frame.util.SysContent;
import com.linn.home.entity.Archive;
import com.linn.home.entity.Article;
import com.linn.home.service.ArticleService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* Created by admin on 2018/1/14.
*/
@Controller
public class ArticleController extends BaseController {
@Resource
private ArticleService articleService;
/**
* 发布文章
*
* @return
*/
@ResponseBody
@RequestMapping(value = "/publishArticle",method = RequestMethod.POST)
public ResultBean publishArticle(Article article) throws Exception {
if(StringUtils.isEmpty(article.getId())) {
//添加
article.setGmtCreate(new Date());
article.setGmtModified(new Date());
int ret = articleService.addArticle(article);
}else {
//更新
article.setGmtModified(new Date());
int ret = articleService.updateArticle(article);
}
return new ResultBean(SysContent.SUCCESS,"发布成功");
}
/**
* 查找所有文章
*
* @return
*/
@ResponseBody
@RequestMapping("/toArticleListAdmin")
public List<Article> toArticleListAdmin() throws Exception {
List<Article> articles = articleService.findArticleListAdmin();
return articles;
}
/**
* 跳转到文章列表
*
* @return
*/
@ResponseBody
@RequestMapping("/toArticleList")
public PageInfo toArticleList(@RequestBody Map<String, String> map) throws Exception {
PageInfo pageInfo = new PageInfo();
if(map.containsKey("pageNum") && !StringUtils.isEmpty(map.get("pageNum"))){
Integer pageNum = Integer.parseInt(map.get("pageNum"));
pageInfo.setPageNum(pageNum);
}else{
pageInfo.setPageNum(1);
}
if(map.containsKey("pageSize") && !StringUtils.isEmpty(map.get("pageSize"))){
Integer pageSize = Integer.parseInt(map.get("pageSize"));
pageInfo.setPageSize(pageSize);
}else{
pageInfo.setPageSize(15);
}
if(map.containsKey("categoryId") && !StringUtils.isEmpty(map.get("categoryId"))){
Integer categoryId = Integer.parseInt(map.get("categoryId"));
pageInfo = articleService.selectArticleByCategoryId(categoryId,pageInfo);
}
if(map.containsKey("date") && !StringUtils.isEmpty(map.get("date")) ){
String date = map.get("date");
Date firstDay = DateUtils.firstDayByMonth(date);
Date lastDay = DateUtils.lastDayByMonth(date);
pageInfo = articleService.selectArticleByArchiveDate(firstDay,lastDay,pageInfo);
}
return pageInfo;
}
@ResponseBody
@RequestMapping("/toArticleDetail")
private Article toArticleDetail(@RequestBody Article article) throws Exception {
if(article != null) {
article = articleService.selectArticleById(article.getId());
}
return article;
}
@ResponseBody
@RequestMapping("/getArchiveList")
private List<Archive> getArchiveList(HttpServletRequest request, HttpServletResponse response) throws Exception {
List<Archive> archives = null;
archives = articleService.selectAllArchive();
return archives;
}
@ResponseBody
@RequestMapping("/delArticle")
public ResultBean delArticle(int[] ids) throws Exception {
if(ids!=null && ids.length > 0){
for (int id: ids) {
int ret = articleService.deleteArticle(id);
}
}
return new ResultBean(SysContent.SUCCESS,"删除成功");
}
@ResponseBody
@RequestMapping("/searchArticleList")
private PageInfo searchArticleList(@RequestBody Map<String, String> map) throws Exception {
PageInfo pageInfo = new PageInfo();
if(map.containsKey("pageNum") && !StringUtils.isEmpty(map.get("pageNum"))){
Integer pageNum = Integer.parseInt(map.get("pageNum"));
pageInfo.setPageNum(pageNum);
}else{
pageInfo.setPageNum(1);
}
if(map.containsKey("pageSize") && !StringUtils.isEmpty(map.get("pageSize"))){
Integer pageSize = Integer.parseInt(map.get("pageSize"));
pageInfo.setPageSize(pageSize);
}else{
pageInfo.setPageSize(15);
}
if(map.containsKey("searchContent") && !StringUtils.isEmpty(map.get("searchContent"))){
String searchContent = map.get("searchContent");
pageInfo = articleService.selectArticleBySearch(searchContent,pageInfo);
}else {//为传入任何条件,则显示最近记录
pageInfo = articleService.selectArticleList(pageInfo);
}
return pageInfo;
}
@RequestMapping("/uploadImage")
public void uploadImage(
@RequestParam(value = "upload",required = false) CommonsMultipartFile file,
HttpServletRequest request,
HttpServletResponse response,
ModelMap model
) {
List<String> urls = new ArrayList<String>();
String path = request.getSession().getServletContext().getRealPath("upload");
String fileName = file.getOriginalFilename();
File targetFile = new File(path,fileName);
if(!targetFile.exists()){
targetFile.mkdirs();
}
//保存
try{
file.transferTo(targetFile);
urls.add(request.getContextPath() + "/upload/" + fileName);
}catch (Exception e){
logger.error(e.getMessage(), e);
}
// 结合ckeditor功能
// imageContextPath为图片在服务器地址,如upload/123.jpg,非绝对路径
String imageContextPath = request.getContextPath() + "/upload/" + fileName;
String callback = request.getParameter("CKEditorFuncNum");
StringBuffer sb = new StringBuffer();
sb.append("<script type=\"text/javascript\">");
sb.append("window.parent.CKEDITOR.tools.callFunction(" + callback + ",'" + imageContextPath + "',''" + ")");
sb.append("</script>");
writer(response,sb.toString());
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
angularjs+html+ssm搭建的个人博客系统.zip
共834个文件
js:352个
css:173个
png:87个
0 下载量 179 浏览量
2024-08-21
12:12:21
上传
评论
收藏 8.04MB ZIP 举报
温馨提示
项目工程资源经过严格测试可直接运行成功且功能正常的情况才上传,可轻松copy复刻,拿到资料包后可轻松复现出一样的项目,本人系统开发经验充足(全栈开发),有任何使用问题欢迎随时与我联系,我会及时为您解惑,提供帮助 【资源内容】:项目具体内容可查看/点击本页面下方的*资源详情*,包含完整源码+工程文件+说明(若有)等。【若无VIP,此资源可私信获取】 【本人专注IT领域】:有任何使用问题欢迎随时与我联系,我会及时解答,第一时间为您提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 【适合场景】:相关项目设计中,皆可应用在项目开发、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面中 可借鉴此优质项目实现复刻,也可基于此项目来扩展开发出更多功能 #注 1. 本资源仅用于开源学习和技术交流。不可商用等,一切后果由使用者承担 2. 部分字体及插图等来自网络,若是侵权请联系删除,本人不对所涉及的版权问题或内容负法律责任。收取的费用仅用于整理和收集资料耗费时间的酬劳 3. 积分资源不提供使用问题指导/解答
资源推荐
资源详情
资源评论
收起资源包目录
angularjs+html+ssm搭建的个人博客系统.zip (834个子文件)
bootstrap.css 143KB
bootstrap.min.css 118KB
samples.css 64KB
editor_ie8.css 48KB
editor_iequirks.css 47KB
editor_ie.css 47KB
editor_gecko.css 46KB
editor.css 46KB
font-awesome.css 37KB
font-awesome.min.css 32KB
dialog_ie8.css 15KB
dialog_iequirks.css 14KB
dialog_ie.css 14KB
layer.css 14KB
dialog.css 13KB
sweetalert.css 13KB
codemirror.css 8KB
toastr.css 7KB
bootstrap-table.css 7KB
toastr.min.css 6KB
bootstrap-table.min.css 6KB
layer.css 5KB
sample.css 5KB
jquery.validator.css 4KB
evalute.css 3KB
metisMenu.css 3KB
style.css 3KB
contents.css 3KB
default.css 3KB
metisMenu.min.css 3KB
railscasts.css 2KB
arta.css 2KB
purebasic.css 2KB
monokai_sublime.css 2KB
obsidian.css 2KB
xcode.css 2KB
sunburst.css 2KB
googlecode.css 2KB
monokai.css 2KB
school_book.css 2KB
grayscale.css 2KB
outputxhtml.css 2KB
magula.css 2KB
far.css 2KB
zenburn.css 2KB
brown_paper.css 2KB
docco.css 2KB
atelier-lakeside.light.css 2KB
atelier-lakeside.dark.css 2KB
atelier-seaside.light.css 2KB
dark.css 2KB
atelier-seaside.dark.css 2KB
atelier-forest.light.css 2KB
atelier-forest.dark.css 2KB
atelier-heath.light.css 2KB
idea.css 2KB
atelier-heath.dark.css 2KB
atelier-dune.light.css 2KB
atelier-dune.dark.css 2KB
fontello.css 2KB
github.css 2KB
pojoaque.css 2KB
tomorrow-night-blue.css 2KB
solarized_dark.css 2KB
solarized_light.css 2KB
tomorrow-night.css 2KB
rainbow.css 2KB
foundation.css 2KB
dashboard.css 2KB
vs.css 2KB
tomorrow-night-eighties.css 2KB
tomorrow-night-bright.css 1KB
templates.css 1KB
paraiso.light.css 1KB
paraiso.dark.css 1KB
copyformatting.css 1KB
ir_black.css 1KB
gruvbox-light.css 1KB
gruvbox-dark.css 1KB
qicaistyle.css 1KB
tomorrow.css 1KB
vs2015.css 1KB
mm-vertical.css 1KB
hybrid.css 1KB
atelier-estuary-light.css 1KB
atelier-savanna-light.css 1KB
atelier-plateau-light.css 1KB
atelier-estuary-dark.css 1KB
atelier-savanna-dark.css 1KB
atelier-plateau-dark.css 1KB
atelier-cave-light.css 1KB
agate.css 1KB
atelier-cave-dark.css 1KB
atom-one-light.css 1KB
atom-one-dark.css 1KB
wsc.css 1KB
routeros.css 1KB
toolbar.css 1KB
railscasts.css 1KB
sunburst.css 1KB
共 834 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
热爱技术。
- 粉丝: 2562
- 资源: 7860
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功