forked from YuKongEr/blog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
833 additions
and
61 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
src/main/java/ssm/blog/controller/admin/BlogController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package ssm.blog.controller.admin; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import javax.annotation.Resource; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.JSONArray; | ||
import com.alibaba.fastjson.JSONObject; | ||
import com.alibaba.fastjson.serializer.SerializerFeature; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
import ssm.blog.entity.Blog; | ||
import ssm.blog.entity.PageBean; | ||
import ssm.blog.service.BlogService; | ||
import ssm.blog.util.ResponseUtil; | ||
|
||
/** | ||
* @Description 管理员博客Controller层 | ||
* @author xp | ||
* | ||
*/ | ||
@Controller | ||
@RequestMapping("/admin/blog") | ||
public class BlogController { | ||
|
||
@Resource | ||
private BlogService blogService; | ||
|
||
|
||
|
||
//后台分页查询博客信息 | ||
@RequestMapping("/listBlog") | ||
public String listBlog( | ||
@RequestParam(value="page", required=false)String page, | ||
@RequestParam(value="rows", required=false)String rows, | ||
Blog s_blog, | ||
HttpServletResponse response) throws Exception { | ||
|
||
PageBean<Blog> pageBean = new PageBean<Blog>(Integer.parseInt(page), Integer.parseInt(rows)); | ||
|
||
pageBean = blogService.listBlog(s_blog.getTitle(),pageBean); | ||
|
||
|
||
JSONObject result = new JSONObject(); | ||
JSON.DEFFAULT_DATE_FORMAT="yyyy-MM-dd"; | ||
String jsonStr = JSONObject.toJSONString(pageBean.getResult(), | ||
SerializerFeature.DisableCircularReferenceDetect, | ||
SerializerFeature.WriteDateUseDateFormat); | ||
JSONArray array = JSON.parseArray(jsonStr); | ||
result.put("rows", array); | ||
result.put("total", pageBean.getTotal()); | ||
ResponseUtil.write(response, result); | ||
return null; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package ssm.blog.dao; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import ssm.blog.entity.Blog; | ||
|
||
/** | ||
* @Description 博客Dao接口 | ||
* @author Ni Shengwu | ||
* | ||
*/ | ||
public interface BlogDao { | ||
|
||
|
||
// 分页查询博客 | ||
public List<Blog> listBlog(Map<String, Object> map); | ||
|
||
// 获取总记录数 | ||
public Long getTotal(String title); | ||
|
||
// 根据博客类型的id查询该类型下的博客数量 | ||
public Integer getBlogByTypeId(Integer typeId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
package ssm.blog.entity; | ||
|
||
import java.util.Date; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
/** | ||
* @Description 博客实体 | ||
* @author Ni Shengwu | ||
* | ||
*/ | ||
public class Blog { | ||
|
||
private Integer id; | ||
private String title; | ||
private String summary; | ||
private Date releaseDate; | ||
private Integer clickHit; | ||
private Integer replyHit; | ||
private String content; | ||
private String contentNoTag; //不带标签的博客内容,用于Lucene索引中 | ||
private String keyWord; //关键字,用空格隔开 | ||
|
||
private BlogType blogType; //博客类型 | ||
private Integer blogCount; //博客数量,非博客实际属性,用于根据发布日期归档查询 | ||
private String releaseDateStr; //发布日期的字符串,只取年月 | ||
|
||
private List<String> imageList = new LinkedList<String>();//博客里存的图片,主要用于展示缩略图 | ||
|
||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Integer id) { | ||
this.id = id; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
public String getSummary() { | ||
return summary; | ||
} | ||
|
||
public void setSummary(String summary) { | ||
this.summary = summary; | ||
} | ||
|
||
public Date getReleaseDate() { | ||
return releaseDate; | ||
} | ||
|
||
public void setReleaseDate(Date releaseDate) { | ||
this.releaseDate = releaseDate; | ||
} | ||
|
||
public Integer getClickHit() { | ||
return clickHit; | ||
} | ||
|
||
public void setClickHit(Integer clickHit) { | ||
this.clickHit = clickHit; | ||
} | ||
|
||
public Integer getReplyHit() { | ||
return replyHit; | ||
} | ||
|
||
public void setReplyHit(Integer replyHit) { | ||
this.replyHit = replyHit; | ||
} | ||
|
||
public String getContent() { | ||
return content; | ||
} | ||
|
||
public void setContent(String content) { | ||
this.content = content; | ||
} | ||
|
||
public String getKeyWord() { | ||
return keyWord; | ||
} | ||
|
||
public void setKeyWord(String keyWord) { | ||
this.keyWord = keyWord; | ||
} | ||
|
||
public BlogType getBlogType() { | ||
return blogType; | ||
} | ||
|
||
public void setBlogType(BlogType blogType) { | ||
this.blogType = blogType; | ||
} | ||
|
||
public Integer getBlogCount() { | ||
return blogCount; | ||
} | ||
|
||
public void setBlogCount(Integer blogCount) { | ||
this.blogCount = blogCount; | ||
} | ||
|
||
public String getReleaseDateStr() { | ||
return releaseDateStr; | ||
} | ||
|
||
public void setReleaseDateStr(String releaseDateStr) { | ||
this.releaseDateStr = releaseDateStr; | ||
} | ||
|
||
public List<String> getImageList() { | ||
return imageList; | ||
} | ||
|
||
public void setImageList(List<String> imageList) { | ||
this.imageList = imageList; | ||
} | ||
|
||
public String getContentNoTag() { | ||
return contentNoTag; | ||
} | ||
|
||
public void setContentNoTag(String contentNoTag) { | ||
this.contentNoTag = contentNoTag; | ||
} | ||
|
||
} |
Oops, something went wrong.