package cn.lightchen.controller;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.github.pagehelper.PageInfo;
import com.vdurmont.emoji.EmojiParser;
import cn.lightchen.constant.ErrorConstant;
import cn.lightchen.constant.Types;
import cn.lightchen.constant.WebConst;
import cn.lightchen.dto.ArchiveDto;
import cn.lightchen.dto.cond.ContentCond;
import cn.lightchen.exception.BusinessException;
import cn.lightchen.model.CommentDomain;
import cn.lightchen.model.ContentDomain;
import cn.lightchen.service.comment.CommentService;
import cn.lightchen.service.content.ContentService;
import cn.lightchen.service.meta.MetaService;
import cn.lightchen.service.option.OptionService;
import cn.lightchen.service.site.SiteService;
import cn.lightchen.utils.APIResponse;
import cn.lightchen.utils.DateKit;
import cn.lightchen.utils.IPKit;
import cn.lightchen.utils.PatternKit;
import cn.lightchen.utils.TaleUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import springfox.documentation.annotations.ApiIgnore;
/**
* 首页和关于我的页面控制器
* Created by Donghua.Chen on 2018/4/28.
*/
@Api("网站首页和关于页面")
@Controller
public class HomeController extends BaseController{
@Autowired
private ContentService contentService;
@Autowired
private MetaService metaService;
@Autowired
private SiteService siteService;
@Autowired
private CommentService commentService;
@Autowired
private OptionService optionService;
@ApiIgnore
@GetMapping(value = {"/about", "/about/index"})
public String getAbout(HttpServletRequest request){
this.blogBaseData(request, null);//获取友链
request.setAttribute("active","about");
return "site/about";
}
@ApiOperation("blog首页")
@GetMapping(value = {"/blog/","/blog/index"})
public String blogIndex(
HttpServletRequest request,
@ApiParam(name = "limit", value = "页数", required = false)
@RequestParam(name = "limit", required = false, defaultValue = "11")
int limit
){
return this.blogIndex(request, 1, limit);
}
@ApiOperation("blog首页-分页")
@GetMapping(value = "/blog/page/{p}")
public String blogIndex(
HttpServletRequest request,
@PathVariable("p")
int p,
@RequestParam(value = "limit", required = false, defaultValue = "11")
int limit
){
p = p < 0 || p > WebConst.MAX_PAGE ? 1 : p;
ContentCond contentCond = new ContentCond();
contentCond.setType(Types.ARTICLE.getType());
PageInfo<ContentDomain> articles = contentService.getArticlesByCond(contentCond, p, limit);
request.setAttribute("articles", articles);//文章列表
request.setAttribute("type", "articles");
request.setAttribute("active", "blog");
// this.blogBaseData(request, contentCond);//获取公共分类标签等数据
return "site/blog";
}
@ApiOperation("文章内容页")
@GetMapping(value = "/blog/article/{cid}")
public String post(
@ApiParam(name = "cid", value = "文章主键", required = true)
@PathVariable("cid")
Integer cid,
HttpServletRequest request
){
ContentDomain atricle = contentService.getAtricleById(cid);
request.setAttribute("article", atricle);
ContentCond contentCond = new ContentCond();
contentCond.setType(Types.ARTICLE.getType());
// this.blogBaseData(request, contentCond);//获取公共分类标签等数据
//更新文章的点击量
this.updateArticleHit(atricle.getCid(),atricle.getHits());
List<CommentDomain> commentsPaginator = commentService.getCommentsByCId(cid);
request.setAttribute("comments", commentsPaginator);
request.setAttribute("active","blog");
return "site/blog-details";
}
/**
* 更新文章的点击率
*
* @param cid
* @param chits
*/
private void updateArticleHit(Integer cid, Integer chits) {
Integer hits = cache.hget("article", "hits");
if (chits == null) {
chits = 0;
}
hits = null == hits ? 1 : hits + 1;
if (hits >= WebConst.HIT_EXCEED) {
ContentDomain temp = new ContentDomain();
temp.setCid(cid);
temp.setHits(chits + hits);
contentService.updateContentByCid(temp);
cache.hset("article", "hits", 1);
} else {
cache.hset("article", "hits", hits);
}
}
@ApiOperation("归档页-按日期")
@GetMapping(value = "/blog/archives/{date}")
public String archives(
@ApiParam(name = "date", value = "归档日期", required = true)
@PathVariable("date")
String date,
HttpServletRequest request
){
ContentCond contentCond = new ContentCond();
Date sd = DateKit.dateFormat(date, "yyyy年MM月");
int start = DateKit.getUnixTimeByDate(sd);
int end = DateKit.getUnixTimeByDate(DateKit.dateAdd(DateKit.INTERVAL_MONTH, sd, 1)) - 1;
contentCond.setStartTime(start);
contentCond.setEndTime(end);
contentCond.setType(Types.ARTICLE.getType());
List<ArchiveDto> archives = siteService.getArchives(contentCond);
request.setAttribute("archives_list",archives);
// this.blogBaseData(request, contentCond);//获取公共分类标签等数据
return "blog/archives";
}
@ApiOperation("归档页-按年份")
@GetMapping(value = "/blog/archives/year/{year}")
public String archivesAtYear(
@ApiParam(name = "year", value = "归档日期", required = true)
@PathVariable("year")
String year,
HttpServletRequest request
){
ContentCond contentCond = new ContentCond();
int start = DateKit.getUnixTimeByDate(DateKit.getYearStartDay(year, "yyyy"));
int end = DateKit.getUnixTimeByDate(DateKit.getYearEndDay(year, "yyyy"));
contentCond.setStartTime(start);
contentCond.setEndTime(end);
contentCond.setType(Types.ARTICLE.getType());
List<ArchiveDto> archives = siteService.getArchives(contentCond);
request.setAttribute("archives_list",archives);
// this.blogBaseData(request, contentCond);//获取公共分类标签等数据
return "blog/archives";
}
@ApiOperation("归档页")
@GetMapping(value = {"/blog/archives", "/blog/archives/index"})
public String archives(HttpServletRequest request){
ContentCond contentCond = new ContentCond();
contentCond.setType(Types.ARTICLE.getType());
List<ArchiveDto> archives = siteService.getArchives(contentCond);
request.setAttribute("archives_list",archives);
// this.blogBaseData(request,contentCond);//获取公共分类标签等数据
return "blog/archives";
}
@ApiOperation("分类")
@GetMapping(value = "/blog/categories/{category}")
public String categories(
@ApiParam(name = "category", value
没有合适的资源?快使用搜索试试~ 我知道了~
个人博客项目源码(java)
共1490个文件
js:444个
html:256个
png:232个
4星 · 超过85%的资源 需积分: 33 138 下载量 143 浏览量
2018-10-24
16:32:40
上传
评论 24
收藏 52.92MB ZIP 举报
温馨提示
本项目根据企业项目的逻辑制作的个人blog,分为前后台系统,结合最新springboot、mybatis、yml配置文件、文件上传等技术点完成,可以学习该项目的技术点,若下载后不可用,请留言,并给我邮箱,重发一份给你,若想制作项目,请访问官方网站:www.aigxgg.com 进行了解,请下载后,留个好评,也请关注我,后期更有更多技术资源上传,谢谢!
资源推荐
资源详情
资源评论
收起资源包目录
个人博客项目源码(java) (1490个子文件)
AUTHORS 6KB
AUTHORS 6KB
DateKit.class 15KB
HomeController.class 15KB
TaleUtils.class 13KB
Commons.class 12KB
ArticleController.class 9KB
MetaServiceImpl.class 8KB
SiteServiceImpl.class 8KB
ContentServiceImpl.class 8KB
AttAchController.class 8KB
IndexController.class 6KB
BaseInterceptor.class 6KB
CommentServiceImpl.class 6KB
AuthController.class 6KB
UUID.class 5KB
SettingController.class 5KB
CommentController.class 5KB
LinksController.class 4KB
CategoryController.class 4KB
ContentDomain.class 4KB
Tools.class 4KB
OptionServiceImpl.class 3KB
MapCache.class 3KB
AttAchServiceImpl.class 3KB
WebLogAspect.class 3KB
CommentDomain.class 3KB
BaseController.class 3KB
BusinessException.class 3KB
PatternKit.class 3KB
UserDomain.class 2KB
LogServiceImpl.class 2KB
Swagger2.class 2KB
APIResponse.class 2KB
UserServiceImpl.class 2KB
IPKit.class 2KB
Types.class 2KB
MetaDomain.class 2KB
ContentCond.class 2KB
AliCloudService.class 2KB
LogActions.class 2KB
LogDomain.class 2KB
AttAchDomain.class 2KB
AttAchDto.class 2KB
GlobalExceptionHandler.class 2KB
AdminCommons.class 1KB
ContentDao.class 1KB
ArchiveDto.class 1KB
ContentService.class 1KB
CommentCond.class 1KB
DateKit$1.class 1KB
StatisticsDto.class 1KB
CommentDao.class 1KB
UserController.class 1KB
WebMvcConfig.class 1KB
RelationShipDao.class 1KB
WebConst.class 1KB
MetaDao.class 1KB
MetaService.class 1KB
SiteService.class 1001B
OptionsDomain.class 992B
CommentService.class 957B
MapCache$CacheObject.class 923B
MyBlogApplication.class 874B
AttAchDao.class 837B
UserCond.class 790B
RelationShipDomain.class 787B
MetaCond.class 766B
AttAchService.class 736B
OptionDao.class 711B
ErrorConstant$Article.class 710B
GsonUtils.class 689B
UserDao.class 665B
OptionService.class 663B
RelationShipServiceImpl.class 638B
MyBlogApplicationTests.class 636B
WxPayOrder.class 605B
ErrorConstant.class 597B
ErrorConstant$Meta.class 576B
BaseDto.class 572B
LogDao.class 566B
LogService.class 545B
MetaDto.class 525B
ErrorConstant$Att.class 500B
ErrorConstant$Comment.class 500B
ErrorConstant$Auth.class 461B
UserService.class 451B
ErrorConstant$Common.class 440B
ErrorConstant$Option.class 376B
RelationShipService.class 149B
.classpath 1KB
mvnw.cmd 5KB
bootstrap.min.css 118KB
bootstrap.min.css 118KB
editormd.css 76KB
editormd.css 76KB
style.css 68KB
style.css 68KB
editormd.min.css 60KB
editormd.min.css 60KB
共 1490 条
- 1
- 2
- 3
- 4
- 5
- 6
- 15
资源评论
- geqianqing2019-08-27有不少例子可以参考,目前正需要.
- johnny000002019-06-11项目下载之后,有import sun.misc.BASE64Encoder; 这个包不能加载不知道是什么原因,按照网上解决办法依然无法解决。872021340@qq.com。谢谢
- 薄荷街的兔比先生2019-04-19没有建表语句吗?bug修得完2019-04-22在项目中
- cwj124952352019-03-31主页请求是多少?bug修得完2019-04-22有说明文档
- 青汁2018-12-26项目是可运行,但是有些前端请求页面访问不到,整体来说还是有参考价值的。
bug修得完
- 粉丝: 10
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Jurassic Pack Vol. II Dinosaurs 侏罗纪包卷恐龙二号Unity游戏模型资源unitypackage
- Jurassic Pack Vol. III Dinosaurs 侏罗纪包卷恐龙三号Unity游戏模型资源unitypackag
- Ultimate Seating Controller 终极座椅控制器Unity游戏开发插件资源unitypackage
- 什么是人工智能-关于人工智能的相关介绍说明
- Figma Converter for Unity适用Unity的Figma转换器Unity游戏开发插件unitypackage
- Creepy Animatronic Anims 令人毛骨悚然的电子动画Unity游戏动画插件资源unitypackage
- Rankings & Leaderboards 排名和排行榜Unity游戏开发插件资源unitypackage
- Semantic Color Palette 语义调色板Unity游戏开发插件资源unitypackage
- Low Poly Nature:Lush and Diverse Environments低聚自然郁郁Unity低多边形模型资源
- voc数据集是什么-我们如何使用voc数据集
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功