├── .gitignore ├── README.md ├── pom.xml └── src └── main ├── java └── com │ └── flowingsun │ ├── admin │ ├── controller │ │ └── AdminController.java │ └── dto │ │ └── AdminBlogQuery.java │ ├── article │ ├── controller │ │ └── ArticleController.java │ ├── dao │ │ ├── ArticleMapper.java │ │ └── ArticleMapper.xml │ ├── dto │ │ ├── ArticleInfo.java │ │ ├── ArticleTag.java │ │ ├── ArticleThank.java │ │ ├── BlogInfo.java │ │ └── RegularRecommend.java │ ├── entity │ │ ├── Article.java │ │ └── Category.java │ ├── service │ │ ├── ArticleService.java │ │ └── ArticleServiceImpl.java │ └── vo │ │ ├── CategoryArticleQuery.java │ │ ├── PageNotice.java │ │ └── TagArticleQuery.java │ ├── behavior │ ├── controller │ │ └── BehaviorController.java │ ├── dao │ │ ├── CollectionMapper.java │ │ ├── CollectionMapper.xml │ │ ├── CommentLikeMapper.java │ │ ├── CommentLikeMapper.xml │ │ ├── CommentMapper.java │ │ ├── CommentMapper.xml │ │ ├── DiscussionMapper.java │ │ ├── DiscussionMapper.xml │ │ ├── PictureMapper.java │ │ ├── PictureMapper.xml │ │ ├── ThankMapper.java │ │ ├── ThankMapper.xml │ │ ├── UrlCollectionMapper.java │ │ └── UrlCollectionMapper.xml │ ├── dto │ │ └── BehaviorStatus.java │ ├── entity │ │ ├── Collection.java │ │ ├── Comment.java │ │ ├── CommentLike.java │ │ ├── Discussion.java │ │ ├── Picture.java │ │ ├── Thank.java │ │ └── UrlCollection.java │ ├── service │ │ ├── BehaviorService.java │ │ └── BehaviorServiceImpl.java │ └── vo │ │ └── PictureQuery.java │ ├── common │ ├── annotation │ │ └── MethodExcuteTimeLog.java │ ├── dao │ │ ├── BlogVisitorMapper.java │ │ ├── BlogVisitorMapper.xml │ │ └── RedisDAO.java │ ├── dto │ │ └── ResponseDto.java │ ├── entity │ │ └── BlogVisitor.java │ ├── interceptor │ │ ├── MethodExcuteTimeInterceptor.java │ │ └── SessionInterceptor.java │ ├── security │ │ ├── CustomCredentialsMatcher.java │ │ └── MyRealm.java │ └── utils │ │ ├── DateUtils.java │ │ ├── InfoCountUtils.java │ │ ├── MD5Utils.java │ │ ├── PageQueryBean.java │ │ ├── ResultUtils.java │ │ ├── SerializeUtils.java │ │ ├── changeListFormatUtils.java │ │ ├── email │ │ └── service │ │ │ └── EmailService.java │ │ └── loginCheckUtils.java │ ├── exception │ └── BusinessException.java │ ├── spider │ ├── controller │ │ └── SpiderController.java │ └── service │ │ ├── BasicCrawlController.java │ │ ├── BasicCrawler.java │ │ ├── ImageCrawlController.java │ │ └── ImageCrawler.java │ └── user │ ├── controller │ └── UserController.java │ ├── dao │ ├── PermissionMapper.java │ ├── PermissionMapper.xml │ ├── RoleMapper.java │ ├── RoleMapper.xml │ ├── RolePermissonMapper.java │ ├── RolePermissonMapper.xml │ ├── UserMapper.java │ ├── UserMapper.xml │ ├── UserRoleMapper.java │ └── UserRoleMapper.xml │ ├── entity │ ├── Permission.java │ ├── Role.java │ ├── RolePermisson.java │ ├── User.java │ └── UserRole.java │ └── service │ ├── UserService.java │ └── UserServiceImpl.java ├── resources ├── conf │ ├── logstash-mysql.conf │ ├── nginx.conf │ ├── redis.conf │ ├── server-1.xml │ └── server-2.xml ├── generatorConfig.xml ├── jdbc.properties ├── log4j.properties ├── log4j2.properties ├── mailConfig.properties ├── spring-cfg.xml ├── spring-mvc.xml ├── spring-shiro.xml └── sql │ ├── article_main_categary.sql │ ├── article_second_categary.sql │ ├── create-table.sql │ ├── permission.sql │ ├── role.sql │ ├── role_permission.sql │ └── user_role.sql └── webapp ├── WEB-INF ├── views │ ├── 403.vm │ ├── admin │ │ ├── adminHome.vm │ │ ├── editBlog.vm │ │ ├── editTag.vm │ │ └── writeBlog.vm │ ├── article │ │ ├── categoryArticle-json.vm │ │ ├── categoryArticle.vm │ │ ├── elasticSearch.vm │ │ ├── singleArticle-json.vm │ │ ├── singleArticle.vm │ │ └── tagArticle.vm │ ├── index.vm │ └── user │ │ ├── activiate.vm │ │ ├── categoryArticle.vm │ │ ├── donateMoney.vm │ │ ├── manageCenter.vm │ │ └── onlineUtils.vm └── web.xml ├── error └── 400.vm └── static └── userFile └── images └── elegent.jpeg /.gitignore: -------------------------------------------------------------------------------- 1 | # ignore all .idea dir 2 | /.idea 3 | 4 | # ignore all META-INF dir 5 | /META-INF 6 | 7 | # ignore all .iml file 8 | *.iml 9 | 10 | # ignore all target file 11 | /target 12 | 13 | # ignore all out dir 14 | /out 15 | 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 【概述】 2 | 这是在第一版的【个人博客系统】 的基础上开发的第二版个人博客系统,基于SSM框架的Java8、Maven构建,github地址:https://github.com/Flowingsun007/LyonBlog 3 | 这个项目是个人学java时自己做的,从前端-到后端-数据库都是100%原创的~第一版的项目是jsp+servlet写的,学了SSM后重构了一次才有的这个项目,里面代码写的比较水,勿喷~新人学习玩耍还是可以的~P.S.后面有时间会不断重构和优化里面的代码^_^ 4 | ## 1.项目展示 5 | ### 【页面】: 6 | ![](https://pic3.zhimg.com/v2-8938aa61be97b55c37009744c761a44a_r.jpg) 7 | ![](https://pic3.zhimg.com/v2-cdc3a4b107a010dc54203b33bfc50176_r.jpg) 8 | ![](https://pic2.zhimg.com/v2-5f1e438570a24223d22356e0e48c91ed_r.jpg) 9 | ### 【功能】: 10 | 用户登录注册、MD5加密、邮箱验证。 11 | 博客文章前台展示、文章点赞、评论、收藏,支持对评论进行点赞和讨论。 12 | 后台admin管理,支持文章的新增、修改、删除、文章和标签批量管理。 13 | 个人中心,查看收藏的文章、用户上传图片、照片墙。 14 | ## 2.技术栈 15 | #### 开发环境: 16 | macOS/Win10系统+Idea开发+Maven构建+Git版本控制 17 | #### 前端: 18 | html+css+javascript;bootstrap+jquery+ajax; 19 | #### 模板引擎: 20 | velocity 21 | #### 开源弹框组件: 22 | sweetalert 23 | #### Markdown编辑器: 24 | Editor.md 25 | #### 容器: 26 | Tomcat9 27 | #### 权限: 28 | Apache Shrio 29 | #### 后端: 30 | Spring+SpringMVC+Mybatis+Mysql+Druid 31 | #### 缓存+session管理: 32 | Redis。由于2个Tomcat可能部署在不同的服务器上,故涉及到session共享的问题,此处用redis来管理所有session,同时redis兼缓存一些文章分类信息、标签信息等。 33 | #### 反向代理+动静分离: 34 | Nginx。Nginx作为统一入口,静态资源请求如js、图片、css文件等直接由nginx处理,动态请求转发至Tomcat中处理。 35 | 目前配置了2个Tomcat,Nginx采取默认的轮训处理请求。 36 | #### 全文检索: 37 | ElasticSearch是流行的全文检索服务器,主要用于博客搜索。Logstash设定了简单的增量导入,从Mysql中定时查询文章内容放入Elasticsearch中,从而提供博客文章全文检索的功能,避免直接查数据库带来较大的开销。 38 | #### 架构图: 39 | ![](https://pic3.zhimg.com/80/v2-72fae8ab4a314f253d214dcb3f70d80e_hd.jpg) 40 | ## 3.项目部署 41 | 由于主项目是在Mac上开发的,所以对Linux系统比较友好。Github地址:Flowingsun007/LyonBlog ,欢迎点赞~ 42 | ### 【分支】: 43 | * master:本地mac上开发,同步更新的分支 44 | * centOS:用于在阿里云服务器上的分支,基本和master分支类似,有个别配置如jdbc.properties、log4j.properties、EmailService.java(发送注册邮件)有些许不同 45 | * windows:仅仅是为了跑起来而新建的此分支,不保证及时更新。BTW:我发现mac上看的前端效果比较好看,到windows上就比较丑了....我也很无奈~ 46 | ### 【项目标准配置】: 47 | * 0.JDK1.8 48 | * 1.Mysql5.7 49 | * 2.Tomcat9(2个) 50 | * 3.Nginx1.14.0 51 | * 4.Redis4.0.10 52 | * 5.Elaticsearch、Logstash——6.4.2 53 | #### Mysql配置 54 | * a.数据库连接:resources文件夹下的jdbc.properties 55 | * b.数据库的sql包括ddl和dml,放在项目resources文件夹下。 56 | #### Tomcat配置 57 | 只需要改server.xml文件中的几个地方即可,这里提供我本地的配置文件做参考。 58 | #### log4j配置 59 | 主要是log4j.properties里修改几种类别日志存放路径 60 | #### Nginx、Redis配置 61 | 同样,提供本地参考,所有的关键配置文件都放在resources/conf文件夹下。 62 | #### 静态资源配置 63 | 由于项目用的是Nginx,动静分离的,所以静态资源全部放置在Nginx下的html文件夹下,可以在百度网盘下载: 64 | 链接:https://pan.baidu.com/s/1K2Ahz_L4cYR04YtgdCmSGA 65 | 提取码:bdbb 66 | ### 【启动和运行】 67 | #### 项目启动标准配置: 68 | Nginx+Redis+2个Tomcat+Elasticsearch+Logstash 69 | #### 项目启动最简配置: 70 | Nginx+Redis+1个Tomcat 71 | #### 启动顺序: 72 | 首先安装好Mysql,Mysql的表和数据建好、安装和配置Tomcat、Nginx、Redis,然后就可以启动了。 73 | Nginx和Redis先启动,然后启动Tomcat,在Idea中可以直接启动Tomcat、或者手动打war包放入Tomcat中运行。 74 | ##### Tomcat启动完成后再启动Elasticsearch+logstash。Elasticsearch+logstash是可选项,可以不启动。 75 | ### 【文件夹结构】 76 | ![](https://pic1.zhimg.com/80/v2-a95cec3239527b265b191c368e888e04_hd.jpg) 77 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/admin/dto/AdminBlogQuery.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.admin.dto; 2 | 3 | import com.flowingsun.article.entity.Category; 4 | import com.flowingsun.common.utils.PageQueryBean; 5 | 6 | import java.util.Date; 7 | 8 | public class AdminBlogQuery extends PageQueryBean { 9 | /** 10 | * 文章ID 11 | */ 12 | private Integer articleId; 13 | /** 14 | * 文章主分类ID 15 | */ 16 | private Integer articleMid; 17 | /** 18 | * 文章二级分类ID 19 | */ 20 | private Integer articleCid; 21 | /** 22 | * 文章标题 23 | */ 24 | private String articlTitle; 25 | /** 26 | * 文章创建者Id 27 | */ 28 | private Integer userId; 29 | /** 30 | * 文章创建时间 31 | */ 32 | private Date createDate; 33 | /** 34 | * 文章修改时间 35 | */ 36 | private Date editDate; 37 | /** 38 | * 分类选择 39 | */ 40 | private Category categoryChoice; 41 | /** 42 | * 文章标签ID 43 | */ 44 | private Integer tagId; 45 | /** 46 | * 文章-标签关系ID 47 | */ 48 | private Integer tagRelationId; 49 | /** 50 | * 标签名 51 | */ 52 | private String tagName; 53 | /** 54 | * 当前页数 55 | */ 56 | private Integer pageNum; 57 | /** 58 | * 每页显示个数 59 | */ 60 | private Integer pageSize; 61 | 62 | public Integer getTagId() { 63 | return tagId; 64 | } 65 | 66 | public void setTagId(Integer tagId) { 67 | this.tagId = tagId; 68 | } 69 | 70 | public Integer getTagRelationId() { 71 | return tagRelationId; 72 | } 73 | 74 | public void setTagRelationId(Integer tagRelationId) { 75 | this.tagRelationId = tagRelationId; 76 | } 77 | 78 | public String getTagName() { 79 | return tagName; 80 | } 81 | 82 | public void setTagName(String tagName) { 83 | this.tagName = tagName; 84 | } 85 | @Override 86 | public Integer getPageNum() { 87 | return super.getPageNum(); 88 | } 89 | 90 | @Override 91 | public void setPageNum(Integer pageNum) { 92 | super.pageNum = pageNum; 93 | } 94 | 95 | @Override 96 | public Integer getPageSize() { 97 | return super.getPageSize(); 98 | } 99 | 100 | @Override 101 | public void setPageSize(Integer pageSize) { 102 | super.pageSize = pageSize; 103 | } 104 | 105 | public Category getCategoryChoice() { 106 | return categoryChoice; 107 | } 108 | 109 | public void setCategoryChoice(Category categoryChoice) { 110 | this.categoryChoice = categoryChoice; 111 | } 112 | 113 | public Integer getArticleId() { 114 | return articleId; 115 | } 116 | 117 | public void setArticleId(Integer articleId) { 118 | this.articleId = articleId; 119 | } 120 | 121 | public Integer getArticleMid() { 122 | return articleMid; 123 | } 124 | 125 | public void setArticleMid(Integer articleMid) { 126 | this.articleMid = articleMid; 127 | } 128 | 129 | public Integer getArticleCid() { 130 | return articleCid; 131 | } 132 | 133 | public void setArticleCid(Integer articleCid) { 134 | this.articleCid = articleCid; 135 | } 136 | 137 | public String getArticlTitle() { 138 | return articlTitle; 139 | } 140 | 141 | public void setArticlTitle(String articlTitle) { 142 | this.articlTitle = articlTitle; 143 | } 144 | 145 | public Integer getUserId() { 146 | return userId; 147 | } 148 | 149 | public void setUserId(Integer userId) { 150 | this.userId = userId; 151 | } 152 | 153 | public Date getCreateDate() { 154 | return createDate; 155 | } 156 | 157 | public void setCreateDate(Date createDate) { 158 | this.createDate = createDate; 159 | } 160 | 161 | public Date getEditDate() { 162 | return editDate; 163 | } 164 | 165 | public void setEditDate(Date editDate) { 166 | this.editDate = editDate; 167 | } 168 | 169 | } 170 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/article/dao/ArticleMapper.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.article.dao; 2 | 3 | import com.flowingsun.admin.dto.AdminBlogQuery; 4 | import com.flowingsun.article.dto.ArticleInfo; 5 | import com.flowingsun.article.dto.ArticleTag; 6 | import com.flowingsun.article.dto.RegularRecommend; 7 | import com.flowingsun.article.entity.*; 8 | import org.apache.ibatis.annotations.Param; 9 | import org.springframework.stereotype.Component; 10 | 11 | 12 | import java.util.List; 13 | @Component 14 | public interface ArticleMapper { 15 | /** 16 | * 查询所有文章主分类 17 | */ 18 | List selectMainCategory(); 19 | /** 20 | * 根据文章标签名查标签ID 21 | */ 22 | int selectTagIdByTagName(String tagName); 23 | /** 24 | * 查询文章所有标签名 25 | */ 26 | List selectTagsNameByPrimarykey(Integer id); 27 | /** 28 | * 查询文章信息 29 | */ 30 | ArticleInfo selectInfoByPrimaryKey(Integer articleId); 31 | /** 32 | * 删除文章 33 | */ 34 | Integer deleteByPrimaryKey(Integer id); 35 | /** 36 | * 给文章插入一条标签关系 37 | */ 38 | int insertTagRelation(ArticleTag articleTag); 39 | /** 40 | * 新增一个标签 41 | */ 42 | int insertNewTag(ArticleTag articleTag); 43 | /** 44 | * 新增一篇文章 45 | */ 46 | int insertNewArticle(Article article); 47 | 48 | int insertSelective(Article record); 49 | /** 50 | * 根据ID查询文章 51 | */ 52 | Article selectByPrimaryKey(Integer id); 53 | 54 | int updateByPrimaryKeySelective(Article record); 55 | 56 | int updateByPrimaryKeyWithBLOBs(Article record); 57 | /** 58 | * 编辑(更新)文章 59 | */ 60 | int updateByPrimaryKey(Article record); 61 | /** 62 | * 查询所有标签 63 | */ 64 | List selectAllTag(); 65 | /** 66 | * 查询文章所有标签 67 | */ 68 | List selectArticleTagsByPrimarykey(Integer id); 69 | /** 70 | * 根据主分类id查主分类名称 71 | */ 72 | String selectMainCategoryNameById(Integer id); 73 | /** 74 | * 根据二级分类id查二级分类名称 75 | */ 76 | String selectSecondCategoryNameById(Integer id); 77 | /** 78 | * 根据cId查分类文章 79 | */ 80 | List
selectCategoryArticles(@Param("cId") Integer cId, @Param("startNum") Integer pageNum, @Param("pageSize") Integer pageSize); 81 | /** 82 | * 根据cId,userId查用户分类文章 83 | */ 84 | List
selectUserCategoryArticles(@Param("cId") Integer cId, @Param("userid") Integer userid, @Param("startNum") Integer pageNum, @Param("pageSize") Integer pageSize); 85 | /** 86 | * 根据tagId查分类文章 87 | */ 88 | List
selectTagArticles(@Param("tagId") Integer tagId, @Param("startNum") Integer pageNum, @Param("pageSize") Integer pageSize); 89 | /** 90 | * 根据主分类id查对应二级分类 91 | */ 92 | List selectSecondCatogoryByMid(Integer mId); 93 | /** 94 | * 根据cId查文章总数 95 | */ 96 | Integer selectCategoryArticlesCount(Integer cId); 97 | /** 98 | * 根据cId查用户创作的文章总数 99 | */ 100 | Integer selectUserCategoryArticlesCount(@Param("cId") Integer cId, @Param("userId") Integer userId); 101 | /** 102 | * 根据mId查文章总数 103 | */ 104 | Integer selectMainCategoryArticlesCount(Integer mId); 105 | /** 106 | * 根据mId,userId查文章总数 107 | */ 108 | Integer selectUserMainCategoryArticlesCount(@Param("mId") Integer mId, @Param("userId") Integer userId); 109 | /** 110 | * 检测articleId下的文章是否存在 111 | */ 112 | Integer selectArticleCountById(Integer articleId); 113 | /** 114 | * 查询所有文章数量 115 | */ 116 | Integer selectAllArticleCount(); 117 | /** 118 | * 查询所有用户文章数量 119 | */ 120 | Integer selectUserAllArticleCount(Integer userId); 121 | /** 122 | * 根据查询条件查询相应文章 123 | */ 124 | List
selectAllArticleByQueryCondition(AdminBlogQuery adminBlogQuery); 125 | /** 126 | * 根据查询条件查询相应用户文章 127 | */ 128 | List
selectUserAllArticleByQueryCondition(AdminBlogQuery adminBlogQuery); 129 | /** 130 | * 根据tagId查询拥有此标签的文章数 131 | */ 132 | Integer selectTagCountByTagId(Integer tagId); 133 | /** 134 | * 删除一条文章标签关系 135 | */ 136 | Integer deleteTagRelation(@Param("articleId") Integer articleId, @Param("tagId") Integer tagId); 137 | /** 138 | * 删除一个tag标签 139 | */ 140 | Integer deleteTagByTagId(Integer tagId); 141 | /** 142 | * 批量修改文章分类 143 | */ 144 | int changeArticleCategoryById(Category articles); 145 | /** 146 | * 查询一条文章标签关系 147 | */ 148 | Integer selectTagRelationByTagIdArticleId(@Param("articleId") Integer articleId, @Param("tagId") Integer tagId); 149 | /** 150 | * 文章推荐:【上一页】 151 | */ 152 | RegularRecommend selectPreviousArticle(RegularRecommend recommendBean); 153 | /** 154 | * 文章推荐:【下一页】 155 | */ 156 | RegularRecommend selectNextArticle(RegularRecommend recommendBean); 157 | 158 | } 159 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/article/dto/ArticleInfo.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.article.dto; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | public class ArticleInfo { 8 | 9 | private Integer articleId; 10 | 11 | private Integer userid; 12 | 13 | private String articleTitle; 14 | 15 | private String articleSubtitle; 16 | 17 | private Date createDate; 18 | 19 | private Date editDate; 20 | 21 | private Integer articleSecondId; 22 | 23 | private Integer articleMainId; 24 | 25 | private String articleMainName; 26 | 27 | private String articleSecondName; 28 | 29 | private Integer articleComment; 30 | 31 | private Integer articleThank; 32 | 33 | private Integer articleCollection; 34 | 35 | private Integer articleView; 36 | 37 | private int tagId; 38 | 39 | private String tagName; 40 | 41 | private List articleTags; 42 | 43 | public Integer getArticleId() { 44 | return articleId; 45 | } 46 | 47 | public void setArticleId(Integer articleId) { 48 | this.articleId = articleId; 49 | } 50 | 51 | public Integer getUserid() { 52 | return userid; 53 | } 54 | 55 | public void setUserid(Integer userid) { 56 | this.userid = userid; 57 | } 58 | 59 | public String getArticleTitle() { 60 | return articleTitle; 61 | } 62 | 63 | public void setArticleTitle(String articleTitle) { 64 | this.articleTitle = articleTitle; 65 | } 66 | 67 | public String getArticleSubtitle() { 68 | return articleSubtitle; 69 | } 70 | 71 | public void setArticleSubtitle(String articleSubtitle) { 72 | this.articleSubtitle = articleSubtitle; 73 | } 74 | 75 | public Date getCreateDate() { 76 | return createDate; 77 | } 78 | 79 | public void setCreateDate(Date createDate) { 80 | this.createDate = createDate; 81 | } 82 | 83 | public Date getEditDate() { 84 | return editDate; 85 | } 86 | 87 | public void setEditDate(Date editDate) { 88 | this.editDate = editDate; 89 | } 90 | 91 | public Integer getArticleSecondId() { 92 | return articleSecondId; 93 | } 94 | 95 | public void setArticleSecondId(Integer articleSecondId) { 96 | this.articleSecondId = articleSecondId; 97 | } 98 | 99 | public Integer getArticleMainId() { 100 | return articleMainId; 101 | } 102 | 103 | public void setArticleMainId(Integer articleMainId) { 104 | this.articleMainId = articleMainId; 105 | } 106 | 107 | public String getArticleMainName() { 108 | return articleMainName; 109 | } 110 | 111 | public void setArticleMainName(String articleMainName) { 112 | this.articleMainName = articleMainName; 113 | } 114 | 115 | public String getArticleSecondName() { 116 | return articleSecondName; 117 | } 118 | 119 | public void setArticleSecondName(String articleSecondName) { 120 | this.articleSecondName = articleSecondName; 121 | } 122 | 123 | public Integer getArticleComment() { 124 | return articleComment; 125 | } 126 | 127 | public void setArticleComment(Integer articleComment) { 128 | this.articleComment = articleComment; 129 | } 130 | 131 | public Integer getArticleThank() { 132 | return articleThank; 133 | } 134 | 135 | public void setArticleThank(Integer articleThank) { 136 | this.articleThank = articleThank; 137 | } 138 | 139 | public Integer getArticleCollection() { 140 | return articleCollection; 141 | } 142 | 143 | public void setArticleCollection(Integer articleCollection) { 144 | this.articleCollection = articleCollection; 145 | } 146 | 147 | public Integer getArticleView() { 148 | return articleView; 149 | } 150 | 151 | public void setArticleView(Integer articleView) { 152 | this.articleView = articleView; 153 | } 154 | 155 | public int getTagId() { 156 | return tagId; 157 | } 158 | 159 | public void setTagId(int tagId) { 160 | this.tagId = tagId; 161 | } 162 | 163 | public String getTagName() { 164 | return tagName; 165 | } 166 | 167 | public void setTagName(String tagName) { 168 | this.tagName = tagName; 169 | } 170 | 171 | public List getArticleTags() { 172 | return articleTags; 173 | } 174 | 175 | public void setArticleTags(List articleTags) { 176 | this.articleTags = articleTags; 177 | } 178 | 179 | @Override 180 | public String toString() { 181 | return "ArticleInfo{" + 182 | "articleId=" + articleId + 183 | ", userid=" + userid + 184 | ", articleTitle='" + articleTitle + '\'' + 185 | ", articleSubtitle='" + articleSubtitle + '\'' + 186 | ", createDate=" + createDate + 187 | ", editDate=" + editDate + 188 | ", articleSecondId=" + articleSecondId + 189 | ", articleMainId=" + articleMainId + 190 | ", articleMainName='" + articleMainName + '\'' + 191 | ", articleSecondName='" + articleSecondName + '\'' + 192 | ", articleComment=" + articleComment + 193 | ", articleThank=" + articleThank + 194 | ", tagId=" + tagId + 195 | ", tagName='" + tagName + '\'' + 196 | ", articleTags=" + articleTags + 197 | '}'; 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/article/dto/ArticleTag.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.article.dto; 2 | 3 | import java.io.Serializable; 4 | import java.sql.Timestamp; 5 | import java.util.Date; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public class ArticleTag implements Serializable { 10 | 11 | public ArticleTag(){ 12 | this.createDate = new Timestamp(new Date().getTime()); 13 | } 14 | 15 | private Integer articleId; 16 | 17 | private Integer tagId; 18 | 19 | private String tagName; 20 | 21 | private Date createDate; 22 | 23 | private Map tagMap; 24 | 25 | private String articleIdStr; 26 | 27 | private String articleTagsStr; 28 | 29 | public String getArticleIdStr() { 30 | return articleIdStr; 31 | } 32 | 33 | public void setArticleIdStr(String articleIdStr) { 34 | this.articleIdStr = articleIdStr; 35 | } 36 | 37 | public String getArticleTagsStr() { 38 | return articleTagsStr; 39 | } 40 | 41 | public void setArticleTagsStr(String articleTagsStr) { 42 | this.articleTagsStr = articleTagsStr; 43 | } 44 | 45 | public Integer getArticleId() { 46 | return articleId; 47 | } 48 | 49 | public void setArticleId(Integer articleId) { 50 | this.articleId = articleId; 51 | } 52 | 53 | public Integer getTagId() { 54 | return tagId; 55 | } 56 | 57 | public void setTagId(Integer tagId) { 58 | this.tagId = tagId; 59 | } 60 | 61 | public String getTagName() { 62 | return tagName; 63 | } 64 | 65 | public void setTagName(String tagName) { 66 | this.tagName = tagName; 67 | } 68 | 69 | public Map getTagMap() { 70 | return tagMap; 71 | } 72 | 73 | public void setTagMap(Map tagMap) { 74 | this.tagMap = tagMap; 75 | } 76 | 77 | public Date getCreateDate() { 78 | return createDate; 79 | } 80 | 81 | public void setCreateDate(Date createDate) { 82 | this.createDate = createDate; 83 | } 84 | 85 | @Override 86 | public String toString() { 87 | return "ArticleTag{" + 88 | "articleId=" + articleId + 89 | ", tagId=" + tagId + 90 | ", tagName='" + tagName + '\'' + 91 | ", createDate=" + createDate + 92 | ", tagMap=" + tagMap + 93 | ", articleIdStr='" + articleIdStr + '\'' + 94 | ", articleTagsStr='" + articleTagsStr + '\'' + 95 | '}'; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/article/dto/ArticleThank.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.article.dto; 2 | 3 | import java.util.Date; 4 | 5 | public class ArticleThank { 6 | 7 | private Integer articleId; 8 | 9 | private Integer thankNum; 10 | 11 | private Integer userId; 12 | 13 | private String userName; 14 | 15 | private Date thankDate; 16 | 17 | public Integer getArticleId() { 18 | return articleId; 19 | } 20 | 21 | public void setArticleId(Integer articleId) { 22 | this.articleId = articleId; 23 | } 24 | 25 | public Integer getThankNum() { 26 | return thankNum; 27 | } 28 | 29 | public void setThankNum(Integer thankNum) { 30 | this.thankNum = thankNum; 31 | } 32 | 33 | public Integer getUserId() { 34 | return userId; 35 | } 36 | 37 | public void setUserId(Integer userId) { 38 | this.userId = userId; 39 | } 40 | 41 | public String getUserName() { 42 | return userName; 43 | } 44 | 45 | public void setUserName(String userName) { 46 | this.userName = userName; 47 | } 48 | 49 | public Date getThankDate() { 50 | return thankDate; 51 | } 52 | 53 | public void setThankDate(Date thankDate) { 54 | this.thankDate = thankDate; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/article/dto/BlogInfo.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.article.dto; 2 | 3 | import java.util.Date; 4 | 5 | public class BlogInfo { 6 | 7 | private String viewCount; 8 | 9 | private String visitorCount; 10 | 11 | private String userCount; 12 | 13 | private String articleCount; 14 | 15 | private String commentCount; 16 | 17 | private String thankCount; 18 | 19 | private String collectionCount; 20 | 21 | public String getViewCount() { 22 | return viewCount; 23 | } 24 | 25 | public void setViewCount(String viewCount) { 26 | this.viewCount = viewCount; 27 | } 28 | 29 | public String getVisitorCount() { 30 | return visitorCount; 31 | } 32 | 33 | public void setVisitorCount(String visitorCount) { 34 | this.visitorCount = visitorCount; 35 | } 36 | 37 | public String getUserCount() { 38 | return userCount; 39 | } 40 | 41 | public void setUserCount(String userCount) { 42 | this.userCount = userCount; 43 | } 44 | 45 | public String getArticleCount() { 46 | return articleCount; 47 | } 48 | 49 | public void setArticleCount(String articleCount) { 50 | this.articleCount = articleCount; 51 | } 52 | 53 | public String getCommentCount() { 54 | return commentCount; 55 | } 56 | 57 | public void setCommentCount(String commentCount) { 58 | this.commentCount = commentCount; 59 | } 60 | 61 | public String getThankCount() { 62 | return thankCount; 63 | } 64 | 65 | public void setThankCount(String thankCount) { 66 | this.thankCount = thankCount; 67 | } 68 | 69 | public String getCollectionCount() { 70 | return collectionCount; 71 | } 72 | 73 | public void setCollectionCount(String collectionCount) { 74 | this.collectionCount = collectionCount; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/article/dto/RegularRecommend.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.article.dto; 2 | 3 | public class RegularRecommend { 4 | 5 | private Integer articleId; 6 | 7 | private Integer previousArticleId; 8 | 9 | private Integer nextArticleId; 10 | 11 | private String previousTitle; 12 | 13 | private String nextTitle; 14 | 15 | public Integer getArticleId() { 16 | return articleId; 17 | } 18 | 19 | public void setArticleId(Integer articleId) { 20 | this.articleId = articleId; 21 | } 22 | 23 | public Integer getPreviousArticleId() { 24 | return previousArticleId; 25 | } 26 | 27 | public void setPreviousArticleId(Integer previousArticleId) { 28 | this.previousArticleId = previousArticleId; 29 | } 30 | 31 | public Integer getNextArticleId() { 32 | return nextArticleId; 33 | } 34 | 35 | public void setNextArticleId(Integer nextArticleId) { 36 | this.nextArticleId = nextArticleId; 37 | } 38 | 39 | public String getPreviousTitle() { 40 | return previousTitle; 41 | } 42 | 43 | public void setPreviousTitle(String previousTitle) { 44 | this.previousTitle = previousTitle; 45 | } 46 | 47 | public String getNextTitle() { 48 | return nextTitle; 49 | } 50 | 51 | public void setNextTitle(String nextTitle) { 52 | this.nextTitle = nextTitle; 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return "RegularRecommend{" + 58 | "previousArticleId=" + previousArticleId + 59 | ", nextArticleId=" + nextArticleId + 60 | ", previousTitle='" + previousTitle + '\'' + 61 | ", nextTitle='" + nextTitle + '\'' + 62 | '}'; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/article/entity/Category.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.article.entity; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | public class Category implements Serializable{ 8 | 9 | private Integer articleId; 10 | 11 | private Integer mainCategoryId; 12 | 13 | private Integer secondCategoryId; 14 | 15 | private String mainCategoryName; 16 | 17 | private String secondCategoryName; 18 | 19 | private Map mainCategoryMap; 20 | 21 | private Map secondCategoryMap; 22 | 23 | private List> mainCategorys; 24 | 25 | private List> secondCategorys; 26 | 27 | private String articleIdStr; 28 | 29 | private Integer[] idIntList; 30 | 31 | public Integer[] getIdIntList() { 32 | return idIntList; 33 | } 34 | 35 | public void setIdIntList(Integer[] idIntList) { 36 | this.idIntList = idIntList; 37 | } 38 | 39 | public String getArticleIdStr() { 40 | return articleIdStr; 41 | } 42 | 43 | public void setArticleIdStr(String articleIdStr) { 44 | this.articleIdStr = articleIdStr; 45 | } 46 | 47 | public Integer getArticleId() { 48 | return articleId; 49 | } 50 | 51 | public void setArticleId(Integer articleId) { 52 | this.articleId = articleId; 53 | } 54 | 55 | public Integer getMainCategoryId() { 56 | return mainCategoryId; 57 | } 58 | 59 | public void setMainCategoryId(Integer mainCategoryId) { 60 | this.mainCategoryId = mainCategoryId; 61 | } 62 | 63 | public Integer getSecondCategoryId() { 64 | return secondCategoryId; 65 | } 66 | 67 | public void setSecondCategoryId(Integer secondCategoryId) { 68 | this.secondCategoryId = secondCategoryId; 69 | } 70 | 71 | public String getMainCategoryName() { 72 | return mainCategoryName; 73 | } 74 | 75 | public void setMainCategoryName(String mainCategoryName) { 76 | this.mainCategoryName = mainCategoryName; 77 | } 78 | 79 | public String getSecondCategoryName() { 80 | return secondCategoryName; 81 | } 82 | 83 | public void setSecondCategoryName(String secondCategoryName) { 84 | this.secondCategoryName = secondCategoryName; 85 | } 86 | 87 | public Map getMainCategoryMap() { 88 | return mainCategoryMap; 89 | } 90 | 91 | public void setMainCategoryMap(Map mainCategoryMap) { 92 | this.mainCategoryMap = mainCategoryMap; 93 | } 94 | 95 | public Map getSecondCategoryMap() { 96 | return secondCategoryMap; 97 | } 98 | 99 | public void setSecondCategoryMap(Map secondCategoryMap) { 100 | this.secondCategoryMap = secondCategoryMap; 101 | } 102 | 103 | public List> getMainCategorys() { 104 | return mainCategorys; 105 | } 106 | 107 | public void setMainCategorys(List> mainCategorys) { 108 | this.mainCategorys = mainCategorys; 109 | } 110 | 111 | public List> getSecondCategorys() { 112 | return secondCategorys; 113 | } 114 | 115 | public void setSecondCategorys(List> secondCategorys) { 116 | this.secondCategorys = secondCategorys; 117 | } 118 | 119 | @Override 120 | public String toString() { 121 | return "Category{" + 122 | "articleId=" + articleId + 123 | ", mainCategoryId=" + mainCategoryId + 124 | ", secondCategoryId=" + secondCategoryId + 125 | ", mainCategoryName='" + mainCategoryName + '\'' + 126 | ", secondCategoryName='" + secondCategoryName + '\'' + 127 | ", mainCategoryMap=" + mainCategoryMap + 128 | ", secondCategoryMap=" + secondCategoryMap + 129 | ", mainCategorys=" + mainCategorys + 130 | ", secondCategorys=" + secondCategorys + 131 | ", articleIdStr='" + articleIdStr + '\'' + 132 | '}'; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/article/service/ArticleService.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.article.service; 2 | 3 | import com.flowingsun.admin.dto.AdminBlogQuery; 4 | import com.flowingsun.article.dto.ArticleTag; 5 | import com.flowingsun.article.dto.BlogInfo; 6 | import com.flowingsun.article.dto.RegularRecommend; 7 | import com.flowingsun.article.entity.*; 8 | import com.flowingsun.article.vo.CategoryArticleQuery; 9 | import com.flowingsun.article.vo.TagArticleQuery; 10 | import com.flowingsun.common.dto.ResponseDto; 11 | 12 | import java.util.List; 13 | 14 | public interface ArticleService { 15 | 16 | String categorySelectAjax(Integer mId); 17 | 18 | List getCategory(); 19 | 20 | Category getAllCategory(); 21 | 22 | int getTagId(String tagName); 23 | 24 | Article getArticle(Integer id); 25 | 26 | String createArticle(Article article); 27 | 28 | ResponseDto createUserArticle(Article article)throws Exception; 29 | 30 | CategoryArticleQuery getCategoryArticles(Integer cId, CategoryArticleQuery categoryArticleQuery); 31 | 32 | CategoryArticleQuery getUserCategoryArticles(Integer cId, CategoryArticleQuery categoryArticleQuery,Long userId); 33 | 34 | TagArticleQuery getTagArticles(TagArticleQuery queryBean); 35 | 36 | AdminBlogQuery getAllArticles(AdminBlogQuery queryBean); 37 | 38 | AdminBlogQuery getUserAllArticles(AdminBlogQuery queryBean, Long userId); 39 | 40 | List selectAllTag(); 41 | 42 | void deleteArticleRelations(int articleId); 43 | 44 | String editArticle(Article article); 45 | 46 | String changeArticleCategory(Category articles); 47 | 48 | String deleteOneArticle(Integer articleId); 49 | 50 | String deleteBatchArticle(String articleIdStr); 51 | 52 | Integer addArticleTag(Integer articleId, String tagName) throws Exception; 53 | 54 | Integer addArticleTagQuick(Integer articleId, String tagName) throws Exception; 55 | 56 | Integer addArticleTagQuick(Integer articleId, Integer tagId, String tagName) throws Exception; 57 | 58 | String batchAddArticleTag(ArticleTag tagBean); 59 | 60 | Integer deleteArticleOneTag(Integer articleId, String tagName); 61 | 62 | String resetArticleTag(ArticleTag tagBean); 63 | 64 | String batchResetArticleTag(ArticleTag tagBean); 65 | 66 | Integer createOneTag(ArticleTag tagBean); 67 | 68 | Integer createOneTag(String tagName); 69 | 70 | Integer createOneTagRelation(ArticleTag tagBean); 71 | 72 | Integer createOneTagRelation(Integer articleId, Integer tagId, String tagName); 73 | 74 | Integer deleteOneTag(Integer tagId); 75 | 76 | Integer deleteOneTagRelation(Integer tagId, Integer articleId); 77 | 78 | boolean checkTagExist(String tagName); 79 | 80 | boolean checkTagRelationExist(Integer articleId, Integer tagId); 81 | 82 | boolean checkArticleExist(Integer articleId); 83 | 84 | String deleteArticleAllTag(ArticleTag tagBean); 85 | 86 | Integer deleteArticleAllTag(Integer articleId); 87 | 88 | String batchDeleteArticleTag(ArticleTag tagBean); 89 | 90 | String batchDeleteArticleAllTag(ArticleTag tagBean); 91 | 92 | RegularRecommend getRegularRecommendArticle(Integer articleId); 93 | 94 | BlogInfo selectInfomation(); 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/article/vo/CategoryArticleQuery.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.article.vo; 2 | 3 | import com.flowingsun.common.utils.PageQueryBean; 4 | 5 | public class CategoryArticleQuery extends PageQueryBean { 6 | /** 7 | * 文章ID 8 | */ 9 | private Integer articleId; 10 | /** 11 | * 主分类ID 12 | */ 13 | private Integer mId; 14 | /** 15 | * 二级分类ID 16 | */ 17 | private Integer cId; 18 | 19 | public Integer getArticleId() { 20 | return articleId; 21 | } 22 | 23 | public void setArticleId(Integer articleId) { 24 | this.articleId = articleId; 25 | } 26 | 27 | public Integer getmId() { 28 | return mId; 29 | } 30 | 31 | public void setmId(Integer mId) { 32 | this.mId = mId; 33 | } 34 | 35 | public Integer getcId() { 36 | return cId; 37 | } 38 | 39 | public void setcId(Integer cId) { 40 | this.cId = cId; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "CategoryArticleQuery{" + 46 | "articleId=" + articleId + 47 | ", mId=" + mId + 48 | ", cId=" + cId + 49 | ", pageNum=" + pageNum + 50 | ", pageSize=" + pageSize + 51 | '}'; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/article/vo/PageNotice.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.article.vo; 2 | /** 3 | *@Author Lyon[flowingsun007@163.com] 4 | *@Date 18/06/6 20:27 5 | *@Description 用于用户登录注册等页面状态,信息的显示和通知 6 | */ 7 | public class PageNotice { 8 | private Integer status; 9 | private String notice; 10 | 11 | public Integer getStatus() { 12 | return status; 13 | } 14 | 15 | public void setStatus(Integer status) { 16 | this.status = status; 17 | } 18 | 19 | public String getNotice() { 20 | return notice; 21 | } 22 | 23 | public void setNotice(String notice) { 24 | this.notice = notice; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "PageNotice{" + 30 | "status=" + status + 31 | ", notice='" + notice + '\'' + 32 | '}'; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/article/vo/TagArticleQuery.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.article.vo; 2 | 3 | import com.flowingsun.common.utils.PageQueryBean; 4 | 5 | public class TagArticleQuery extends PageQueryBean { 6 | /** 7 | * 文章标签ID 8 | */ 9 | private Integer tagid; 10 | /** 11 | * 标签名 12 | */ 13 | private Integer tagname; 14 | 15 | public Integer getTagid() { 16 | return tagid; 17 | } 18 | 19 | public void setTagid(Integer tagid) { 20 | this.tagid = tagid; 21 | } 22 | 23 | public Integer getTagname() { 24 | return tagname; 25 | } 26 | 27 | public void setTagname(Integer tagname) { 28 | this.tagname = tagname; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/dao/CollectionMapper.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.behavior.dao; 2 | 3 | import com.flowingsun.behavior.entity.Collection; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.List; 8 | 9 | @Component 10 | public interface CollectionMapper { 11 | 12 | int deleteByPrimaryKey(Integer id); 13 | 14 | int insertCollection(Collection record); 15 | 16 | int insertSelective(Collection record); 17 | 18 | int selectCollectionCount(); 19 | 20 | Collection selectByPrimaryKey(Integer id); 21 | 22 | Integer selectCollectionCountByCollectionbean(Collection thankBean); 23 | 24 | Integer selectCollectionStatusByAidUid(@Param("userId") Long userId, @Param("articleId") Integer articleId); 25 | 26 | int updateByPrimaryKeySelective(Collection record); 27 | 28 | int updateByPrimaryKey(Collection record); 29 | 30 | int selectCollectionCountByUserid(Long userid); 31 | 32 | List selectCollectionsByUserid(Long userid); 33 | 34 | int deleteByArticleId(int articleId); 35 | 36 | void deleteByUserIdAndArticleId(@Param("userId") Long userId, @Param("articleId") Integer articleId); 37 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/dao/CollectionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | id, articleId, userId, collectDate 13 | 14 | 17 | 20 | 23 | 26 | 33 | 39 | 40 | delete from collection 41 | where id = #{id,jdbcType=INTEGER} 42 | 43 | 44 | DELETE FROM collection 45 | WHERE articleId = #{articleId,jdbcType=INTEGER} 46 | 47 | 48 | DELETE FROM collection 49 | WHERE userId = #{userId} AND articleId = #{articleId,jdbcType=INTEGER} 50 | 51 | 52 | INSERT IGNORE INTO collection (articleId, userId,collectDate) 53 | VALUES (#{articleid,jdbcType=INTEGER}, #{userid,jdbcType=BIGINT},#{collectdate,jdbcType=TIMESTAMP}) 54 | 55 | 56 | insert into collection 57 | 58 | 59 | id, 60 | 61 | 62 | articleId, 63 | 64 | 65 | userId, 66 | 67 | 68 | collectDate, 69 | 70 | 71 | 72 | 73 | #{id,jdbcType=INTEGER}, 74 | 75 | 76 | #{articleid,jdbcType=INTEGER}, 77 | 78 | 79 | #{userid,jdbcType=BIGINT}, 80 | 81 | 82 | #{collectdate,jdbcType=TIMESTAMP}, 83 | 84 | 85 | 86 | 87 | update collection 88 | 89 | 90 | articleId = #{articleid,jdbcType=INTEGER}, 91 | 92 | 93 | userId = #{userid,jdbcType=BIGINT}, 94 | 95 | 96 | collectDate = #{collectdate,jdbcType=TIMESTAMP}, 97 | 98 | 99 | where id = #{id,jdbcType=INTEGER} 100 | 101 | 102 | update collection 103 | set articleId = #{articleid,jdbcType=INTEGER}, 104 | userId = #{userid,jdbcType=BIGINT}, 105 | collectDate = #{collectdate,jdbcType=TIMESTAMP} 106 | where id = #{id,jdbcType=INTEGER} 107 | 108 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/dao/CommentLikeMapper.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.behavior.dao; 2 | 3 | import com.flowingsun.behavior.entity.CommentLike; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public interface CommentLikeMapper { 8 | 9 | int deleteByCommentId(int id); 10 | 11 | int deleteByPrimaryKey(Integer id); 12 | 13 | int insert(CommentLike record); 14 | 15 | int insertSelective(CommentLike record); 16 | 17 | CommentLike selectByPrimaryKey(Integer id); 18 | 19 | int updateByPrimaryKeySelective(CommentLike record); 20 | 21 | int updateByPrimaryKey(CommentLike record); 22 | 23 | int selectLikeCountByCommentLikeBean(CommentLike bean); 24 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/dao/CommentLikeMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | id, articleId, mainUserId, commentId, userId, likeDate 14 | 15 | 21 | 24 | 25 | delete from comment_like 26 | where id = #{id,jdbcType=INTEGER} 27 | 28 | 29 | DELETE FROM comment_like 30 | WHERE commentId = #{commentId,jdbcType=INTEGER} 31 | 32 | 33 | insert into comment_like (id, articleId, mainUserId, 34 | commentId, userId, likeDate 35 | ) 36 | values (#{id,jdbcType=INTEGER}, #{articleid,jdbcType=INTEGER}, #{mainuserid,jdbcType=BIGINT}, 37 | #{commentid,jdbcType=INTEGER}, #{userid,jdbcType=BIGINT}, #{likedate,jdbcType=TIMESTAMP} 38 | ) 39 | 40 | 41 | insert into comment_like 42 | 43 | 44 | id, 45 | 46 | 47 | articleId, 48 | 49 | 50 | mainUserId, 51 | 52 | 53 | commentId, 54 | 55 | 56 | userId, 57 | 58 | 59 | likeDate, 60 | 61 | 62 | 63 | 64 | #{id,jdbcType=INTEGER}, 65 | 66 | 67 | #{articleid,jdbcType=INTEGER}, 68 | 69 | 70 | #{mainuserid,jdbcType=BIGINT}, 71 | 72 | 73 | #{commentid,jdbcType=INTEGER}, 74 | 75 | 76 | #{userid,jdbcType=BIGINT}, 77 | 78 | 79 | #{likedate,jdbcType=TIMESTAMP}, 80 | 81 | 82 | 83 | 84 | update comment_like 85 | 86 | 87 | articleId = #{articleid,jdbcType=INTEGER}, 88 | 89 | 90 | mainUserId = #{mainuserid,jdbcType=BIGINT}, 91 | 92 | 93 | commentId = #{commentid,jdbcType=INTEGER}, 94 | 95 | 96 | userId = #{userid,jdbcType=BIGINT}, 97 | 98 | 99 | likeDate = #{likedate,jdbcType=TIMESTAMP}, 100 | 101 | 102 | where id = #{id,jdbcType=INTEGER} 103 | 104 | 105 | update comment_like 106 | set articleId = #{articleid,jdbcType=INTEGER}, 107 | mainUserId = #{mainuserid,jdbcType=BIGINT}, 108 | commentId = #{commentid,jdbcType=INTEGER}, 109 | userId = #{userid,jdbcType=BIGINT}, 110 | likeDate = #{likedate,jdbcType=TIMESTAMP} 111 | where id = #{id,jdbcType=INTEGER} 112 | 113 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/dao/CommentMapper.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.behavior.dao; 2 | 3 | import com.flowingsun.behavior.entity.Comment; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.List; 8 | 9 | @Component 10 | public interface CommentMapper { 11 | int deleteByPrimaryKey(Integer id); 12 | 13 | int insert(Comment record); 14 | 15 | int selectCommentCount(); 16 | 17 | Integer insertSelective(Comment commentBean); 18 | 19 | Comment selectByPrimaryKey(Integer id); 20 | 21 | Integer selectCommentStatusByAidUid(@Param("userId") Long userId, @Param("articleId") Integer articleId); 22 | 23 | int updateByPrimaryKeySelective(Comment record); 24 | 25 | int updateByPrimaryKey(Comment record); 26 | 27 | List selectAllCommentByArticleid(Integer articleId); 28 | 29 | List selectCommentByCommentLikeCountDesc(Integer id); 30 | 31 | int selectCommentCountByUserid(Long userid); 32 | 33 | List selectCommentsIdByArticleId(int articleId); 34 | 35 | int deleteByArticleId(int articleId); 36 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/dao/DiscussionMapper.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.behavior.dao; 2 | 3 | import com.flowingsun.behavior.entity.Discussion; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public interface DiscussionMapper { 8 | int deleteByPrimaryKey(Integer id); 9 | 10 | int insert(Discussion record); 11 | 12 | int insertSelective(Discussion record); 13 | 14 | Discussion selectByPrimaryKey(Integer id); 15 | 16 | int updateByPrimaryKeySelective(Discussion record); 17 | 18 | int updateByPrimaryKey(Discussion record); 19 | 20 | int deleteByCommentId(int commentId); 21 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/dao/DiscussionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | id, articleId, main_userId, main_commentId, userId, discussion, discussDate 15 | 16 | 22 | 23 | DELETE FROM discussion 24 | WHERE main_commentId = #{commentId,jdbcType=INTEGER} 25 | 26 | 27 | delete from discussion 28 | where id = #{id,jdbcType=INTEGER} 29 | 30 | 31 | insert into discussion (id, articleId, main_userId, 32 | main_commentId, userId, discussion, 33 | discussDate) 34 | values (#{id,jdbcType=INTEGER}, #{articleid,jdbcType=INTEGER}, #{mainUserid,jdbcType=BIGINT}, 35 | #{mainCommentid,jdbcType=INTEGER}, #{userid,jdbcType=BIGINT}, #{discussion,jdbcType=VARCHAR}, 36 | #{discussdate,jdbcType=TIMESTAMP}) 37 | 38 | 39 | insert into discussion 40 | 41 | 42 | id, 43 | 44 | 45 | articleId, 46 | 47 | 48 | main_userId, 49 | 50 | 51 | main_commentId, 52 | 53 | 54 | userId, 55 | 56 | 57 | discussion, 58 | 59 | 60 | discussDate, 61 | 62 | 63 | 64 | 65 | #{id,jdbcType=INTEGER}, 66 | 67 | 68 | #{articleid,jdbcType=INTEGER}, 69 | 70 | 71 | #{mainUserid,jdbcType=BIGINT}, 72 | 73 | 74 | #{mainCommentid,jdbcType=INTEGER}, 75 | 76 | 77 | #{userid,jdbcType=BIGINT}, 78 | 79 | 80 | #{discussion,jdbcType=VARCHAR}, 81 | 82 | 83 | #{discussdate,jdbcType=TIMESTAMP}, 84 | 85 | 86 | 87 | 88 | update discussion 89 | 90 | 91 | articleId = #{articleid,jdbcType=INTEGER}, 92 | 93 | 94 | main_userId = #{mainUserid,jdbcType=BIGINT}, 95 | 96 | 97 | main_commentId = #{mainCommentid,jdbcType=INTEGER}, 98 | 99 | 100 | userId = #{userid,jdbcType=BIGINT}, 101 | 102 | 103 | discussion = #{discussion,jdbcType=VARCHAR}, 104 | 105 | 106 | discussDate = #{discussdate,jdbcType=TIMESTAMP}, 107 | 108 | 109 | where id = #{id,jdbcType=INTEGER} 110 | 111 | 112 | update discussion 113 | set articleId = #{articleid,jdbcType=INTEGER}, 114 | main_userId = #{mainUserid,jdbcType=BIGINT}, 115 | main_commentId = #{mainCommentid,jdbcType=INTEGER}, 116 | userId = #{userid,jdbcType=BIGINT}, 117 | discussion = #{discussion,jdbcType=VARCHAR}, 118 | discussDate = #{discussdate,jdbcType=TIMESTAMP} 119 | where id = #{id,jdbcType=INTEGER} 120 | 121 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/dao/PictureMapper.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.behavior.dao; 2 | 3 | import com.flowingsun.behavior.entity.Picture; 4 | import com.flowingsun.behavior.vo.PictureQuery; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.Date; 8 | import java.util.List; 9 | @Component 10 | public interface PictureMapper { 11 | 12 | Picture selectByPrimaryKey(Integer id); 13 | 14 | List selectByImageCreateDate(PictureQuery pictureQuery); 15 | 16 | List selectByQueryDateRange(PictureQuery pictureQuery); 17 | 18 | int selectCountByQueryDateRange(PictureQuery pictureQuery); 19 | 20 | int insert(Picture record); 21 | 22 | int insertSelective(Picture record); 23 | 24 | int updateByPrimaryKeySelective(Picture record); 25 | 26 | int updateByPrimaryKey(Picture record); 27 | 28 | int deleteByPrimaryKey(Integer id); 29 | 30 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/dao/PictureMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | id, userId, createDate, filePath, details 22 | 23 | 27 | 36 | 43 | 49 | 50 | delete from picture 51 | where id = #{id,jdbcType=INTEGER} 52 | 53 | 54 | INSERT IGNORE INTO picture (userId, createDate,filePath, details) 55 | VALUES (#{userid,jdbcType=BIGINT}, #{createdate,jdbcType=TIMESTAMP}, 56 | #{filepath,jdbcType=VARCHAR}, #{details,jdbcType=VARCHAR}) 57 | 58 | 59 | insert into picture 60 | 61 | 62 | id, 63 | 64 | 65 | userId, 66 | 67 | 68 | createDate, 69 | 70 | 71 | filePath, 72 | 73 | 74 | details, 75 | 76 | 77 | 78 | 79 | #{id,jdbcType=INTEGER}, 80 | 81 | 82 | #{userid,jdbcType=BIGINT}, 83 | 84 | 85 | #{createdate,jdbcType=TIMESTAMP}, 86 | 87 | 88 | #{filepath,jdbcType=VARCHAR}, 89 | 90 | 91 | #{details,jdbcType=VARCHAR}, 92 | 93 | 94 | 95 | 96 | update picture 97 | 98 | 99 | userId = #{userid,jdbcType=BIGINT}, 100 | 101 | 102 | createDate = #{createdate,jdbcType=TIMESTAMP}, 103 | 104 | 105 | filePath = #{filepath,jdbcType=VARCHAR}, 106 | 107 | 108 | details = #{details,jdbcType=VARCHAR}, 109 | 110 | 111 | where id = #{id,jdbcType=INTEGER} 112 | 113 | 114 | update picture 115 | set userId = #{userid,jdbcType=BIGINT}, 116 | createDate = #{createdate,jdbcType=TIMESTAMP}, 117 | filePath = #{filepath,jdbcType=VARCHAR}, 118 | details = #{details,jdbcType=VARCHAR} 119 | where id = #{id,jdbcType=INTEGER} 120 | 121 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/dao/ThankMapper.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.behavior.dao; 2 | 3 | import com.flowingsun.behavior.entity.Thank; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public interface ThankMapper { 9 | 10 | int deleteByPrimaryKey(Integer id); 11 | 12 | int insertThank(Thank record); 13 | 14 | int insertSelective(Thank record); 15 | 16 | int selectThankCount(); 17 | 18 | Thank selectByPrimaryKey(Integer id); 19 | 20 | Integer selectThankNumByThankbean(Thank thankBean); 21 | 22 | Integer selectThankStatusByAidUid(@Param("userId") Long userId, @Param("articleId") Integer articleId); 23 | 24 | int updateByPrimaryKeySelective(Thank record); 25 | 26 | int updateByPrimaryKey(Thank record); 27 | 28 | int selectThankCountByUserid(Long userid); 29 | 30 | int deleteByArticleId(int articleId); 31 | 32 | void deleteByUserIdAndArticleId(@Param("userId") Long userId, @Param("articleId") Integer articleId); 33 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/dao/ThankMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | id, articleId, userId, thankDate 12 | 13 | 16 | 19 | 22 | 25 | 31 | 32 | delete from thank 33 | where id = #{id,jdbcType=INTEGER} 34 | 35 | 36 | DELETE FROM thank 37 | WHERE articleId = #{articleId,jdbcType=INTEGER} 38 | 39 | 40 | DELETE FROM thank 41 | WHERE articleId = #{articleId,jdbcType=INTEGER} AND userId = #{userId} 42 | 43 | 44 | INSERT IGNORE INTO thank (articleId, userId,thankDate) 45 | VALUES (#{articleid,jdbcType=INTEGER}, #{userid,jdbcType=BIGINT},#{thankdate,jdbcType=TIMESTAMP}) 46 | 47 | 48 | insert into thank 49 | 50 | 51 | id, 52 | 53 | 54 | articleId, 55 | 56 | 57 | userId, 58 | 59 | 60 | thankDate, 61 | 62 | 63 | 64 | 65 | #{id,jdbcType=INTEGER}, 66 | 67 | 68 | #{articleid,jdbcType=INTEGER}, 69 | 70 | 71 | #{userid,jdbcType=BIGINT}, 72 | 73 | 74 | #{thankdate,jdbcType=TIMESTAMP}, 75 | 76 | 77 | 78 | 79 | update thank 80 | 81 | 82 | articleId = #{articleid,jdbcType=INTEGER}, 83 | 84 | 85 | userId = #{userid,jdbcType=BIGINT}, 86 | 87 | 88 | thankDate = #{thankdate,jdbcType=TIMESTAMP}, 89 | 90 | 91 | where id = #{id,jdbcType=INTEGER} 92 | 93 | 94 | update thank 95 | set articleId = #{articleid,jdbcType=INTEGER}, 96 | userId = #{userid,jdbcType=BIGINT}, 97 | thankDate = #{thankdate,jdbcType=TIMESTAMP} 98 | where id = #{id,jdbcType=INTEGER} 99 | 100 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/dao/UrlCollectionMapper.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.behavior.dao; 2 | 3 | import com.flowingsun.behavior.entity.Collection; 4 | import com.flowingsun.behavior.entity.UrlCollection; 5 | import org.apache.ibatis.annotations.Param; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.List; 9 | 10 | @Component 11 | public interface UrlCollectionMapper { 12 | 13 | int insertSelective(UrlCollection record); 14 | 15 | int selectUrlCollectionCount(); 16 | 17 | UrlCollection selectByPrimaryKey(Integer id); 18 | 19 | List selectUrlCollectionsByUserId(Long userId); 20 | 21 | int selectUrlCollectionsByIdAndUserId(@Param("userId") Integer urlCollectionId, @Param("userId") Long userId); 22 | 23 | int updateByPrimaryKeySelective(UrlCollection record); 24 | 25 | int updateByPrimaryKey(UrlCollection record); 26 | 27 | int deleteByPrimaryKey(Integer id); 28 | 29 | void deleteByurlCollectionIdAndUserId(@Param("urlCollectionId") Integer urlCollectionId, @Param("userId") Integer userId); 30 | 31 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/dao/UrlCollectionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | id, userId, url, description, createDate, editDate 14 | 15 | 16 | 17 | insert into collection 18 | 19 | 20 | id, 21 | 22 | 23 | userId, 24 | 25 | 26 | url, 27 | 28 | 29 | description, 30 | 31 | 32 | createDate, 33 | 34 | 35 | editDate, 36 | 37 | 38 | 39 | 40 | #{id,jdbcType=INTEGER}, 41 | 42 | 43 | #{userId,jdbcType=BIGINT}, 44 | 45 | 46 | #{url,jdbcType=VARCHAR}, 47 | 48 | 49 | #{description,jdbcType=VARCHAR}, 50 | 51 | 52 | #{createDate,jdbcType=TIMESTAMP}, 53 | 54 | 55 | #{editDate,jdbcType=TIMESTAMP}, 56 | 57 | 58 | 59 | 60 | 63 | 69 | 74 | 79 | 80 | 81 | UPDATE url_collection 82 | 83 | 84 | userId = #{userId,jdbcType=BIGINT}, 85 | 86 | 87 | url = #{url,jdbcType=VARCHAR}, 88 | 89 | 90 | description = #{description,jdbcType=VARCHAR}, 91 | 92 | 93 | createDate = #{createDate,jdbcType=TIMESTAMP}, 94 | 95 | 96 | editDate = #{editDate,jdbcType=TIMESTAMP}, 97 | 98 | 99 | WHERE id = #{id,jdbcType=INTEGER} 100 | 101 | 102 | 103 | delete from collection 104 | where id = #{id,jdbcType=INTEGER} 105 | 106 | 107 | DELETE FROM collection 108 | WHERE id = #{urlCollectionId} AND userId = #{userId,jdbcType=BIGINT} 109 | 110 | 111 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/dto/BehaviorStatus.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.behavior.dto; 2 | 3 | 4 | import com.flowingsun.behavior.entity.Collection; 5 | 6 | import java.util.List; 7 | 8 | public class BehaviorStatus { 9 | 10 | private Long userid; 11 | 12 | private byte viewStatus; 13 | 14 | private byte thankStatus; 15 | 16 | private byte collectStatus; 17 | 18 | private byte commentStatus; 19 | 20 | private byte commentLikeStatus; 21 | 22 | private byte commentDiscussStatus; 23 | 24 | private int viewCount; 25 | 26 | private int thankCount; 27 | 28 | private int collectionCount; 29 | 30 | private int commentCount; 31 | 32 | private int commentLikeCount; 33 | 34 | private int commentDiscussCount; 35 | 36 | private List collectionList; 37 | 38 | public byte getCommentDiscussStatus() { 39 | return commentDiscussStatus; 40 | } 41 | 42 | public void setCommentDiscussStatus(byte commentDiscussStatus) { 43 | this.commentDiscussStatus = commentDiscussStatus; 44 | } 45 | 46 | public Long getUserid() { 47 | return userid; 48 | } 49 | 50 | public void setUserid(Long userid) { 51 | this.userid = userid; 52 | } 53 | 54 | public byte getViewStatus() { 55 | return viewStatus; 56 | } 57 | 58 | public void setViewStatus(byte viewStatus) { 59 | this.viewStatus = viewStatus; 60 | } 61 | 62 | public byte getThankStatus() { 63 | return thankStatus; 64 | } 65 | 66 | public void setThankStatus(byte thankStatus) { 67 | this.thankStatus = thankStatus; 68 | } 69 | 70 | public byte getCollectStatus() { 71 | return collectStatus; 72 | } 73 | 74 | public void setCollectStatus(byte collectStatus) { 75 | this.collectStatus = collectStatus; 76 | } 77 | 78 | public byte getCommentStatus() { 79 | return commentStatus; 80 | } 81 | 82 | public void setCommentStatus(byte commentStatus) { 83 | this.commentStatus = commentStatus; 84 | } 85 | 86 | public byte getCommentLikeStatus() { 87 | return commentLikeStatus; 88 | } 89 | 90 | public void setCommentLikeStatus(byte commentLikeStatus) { 91 | this.commentLikeStatus = commentLikeStatus; 92 | } 93 | 94 | public int getViewCount() { 95 | return viewCount; 96 | } 97 | 98 | public void setViewCount(int viewCount) { 99 | this.viewCount = viewCount; 100 | } 101 | 102 | public int getThankCount() { 103 | return thankCount; 104 | } 105 | 106 | public void setThankCount(int thankCount) { 107 | this.thankCount = thankCount; 108 | } 109 | 110 | public int getCollectionCount() { 111 | return collectionCount; 112 | } 113 | 114 | public void setCollectionCount(int collectionCount) { 115 | this.collectionCount = collectionCount; 116 | } 117 | 118 | public int getCommentCount() { 119 | return commentCount; 120 | } 121 | 122 | public void setCommentCount(int commentCount) { 123 | this.commentCount = commentCount; 124 | } 125 | 126 | public int getCommentLikeCount() { 127 | return commentLikeCount; 128 | } 129 | 130 | public void setCommentLikeCount(int commentLikeCount) { 131 | this.commentLikeCount = commentLikeCount; 132 | } 133 | 134 | public int getCommentDiscussCount() { 135 | return commentDiscussCount; 136 | } 137 | 138 | public void setCommentDiscussCount(int commentDiscussCount) { 139 | this.commentDiscussCount = commentDiscussCount; 140 | } 141 | 142 | public List getCollectionList() { 143 | return collectionList; 144 | } 145 | 146 | public void setCollectionList(List collectionList) { 147 | this.collectionList = collectionList; 148 | } 149 | 150 | } 151 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/entity/Collection.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.behavior.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class Collection { 6 | 7 | private Integer id; 8 | 9 | private Integer articleid; 10 | 11 | private String articleTitle; 12 | 13 | private Long userid; 14 | 15 | private Date collectdate; 16 | 17 | private byte collectStatus; 18 | 19 | public byte getCollectStatus() { 20 | return collectStatus; 21 | } 22 | 23 | public void setCollectStatus(byte collectStatus) { 24 | this.collectStatus = collectStatus; 25 | } 26 | 27 | public Integer getId() { 28 | return id; 29 | } 30 | 31 | public void setId(Integer id) { 32 | this.id = id; 33 | } 34 | 35 | public Integer getArticleid() { 36 | return articleid; 37 | } 38 | 39 | public void setArticleid(Integer articleid) { 40 | this.articleid = articleid; 41 | } 42 | 43 | public String getArticleTitle() { 44 | return articleTitle; 45 | } 46 | 47 | public void setArticleTitle(String articleTitle) { 48 | this.articleTitle = articleTitle; 49 | } 50 | 51 | public Long getUserid() { 52 | return userid; 53 | } 54 | 55 | public void setUserid(Long userid) { 56 | this.userid = userid; 57 | } 58 | 59 | public Date getCollectdate() { 60 | return collectdate; 61 | } 62 | 63 | public void setCollectdate(Date collectdate) { 64 | this.collectdate = collectdate; 65 | } 66 | 67 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/entity/Comment.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.behavior.entity; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | public class Comment { 7 | private Integer id; 8 | 9 | private Integer articleid; 10 | 11 | private Long userid; 12 | 13 | private String userName; 14 | 15 | private String comment; 16 | 17 | private Date commentdate; 18 | 19 | private Integer commentLikeNum; 20 | 21 | private List discussionList; 22 | 23 | private byte commentStatus; 24 | 25 | public byte getCommentStatus() { 26 | return commentStatus; 27 | } 28 | 29 | public void setCommentStatus(byte commentStatus) { 30 | this.commentStatus = commentStatus; 31 | } 32 | 33 | public Integer getCommentLikeNum() { 34 | return commentLikeNum; 35 | } 36 | 37 | public void setCommentLikeNum(Integer commentLikeNum) { 38 | this.commentLikeNum = commentLikeNum; 39 | } 40 | 41 | public String getUserName() { 42 | return userName; 43 | } 44 | 45 | public void setUserName(String userName) { 46 | this.userName = userName; 47 | } 48 | 49 | public List getDiscussionList() { 50 | return discussionList; 51 | } 52 | 53 | public void setDiscussionList(List discussionList) { 54 | this.discussionList = discussionList; 55 | } 56 | 57 | public Integer getId() { 58 | return id; 59 | } 60 | 61 | public void setId(Integer id) { 62 | this.id = id; 63 | } 64 | 65 | public Integer getArticleid() { 66 | return articleid; 67 | } 68 | 69 | public void setArticleid(Integer articleid) { 70 | this.articleid = articleid; 71 | } 72 | 73 | public Long getUserid() { 74 | return userid; 75 | } 76 | 77 | public void setUserid(Long userid) { 78 | this.userid = userid; 79 | } 80 | 81 | public String getComment() { 82 | return comment; 83 | } 84 | 85 | public void setComment(String comment) { 86 | this.comment = comment == null ? null : comment.trim(); 87 | } 88 | 89 | public Date getCommentdate() { 90 | return commentdate; 91 | } 92 | 93 | public void setCommentdate(Date commentdate) { 94 | this.commentdate = commentdate; 95 | } 96 | 97 | @Override 98 | public String toString() { 99 | return "Comment{" + 100 | "id=" + id + 101 | ", articleid=" + articleid + 102 | ", userid=" + userid + 103 | ", userName='" + userName + '\'' + 104 | ", comment='" + comment + '\'' + 105 | ", commentdate=" + commentdate + 106 | ", commentLikeNum=" + commentLikeNum + 107 | ", discussionList=" + discussionList + 108 | '}'; 109 | } 110 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/entity/CommentLike.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.behavior.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class CommentLike { 6 | private Integer id; 7 | 8 | private Integer articleid; 9 | 10 | private Long mainuserid; 11 | 12 | private Integer commentid; 13 | 14 | private Long userid; 15 | 16 | private Date likedate; 17 | 18 | private byte commentLikeStatus; 19 | 20 | public byte getCommentLikeStatus() { 21 | return commentLikeStatus; 22 | } 23 | 24 | public void setCommentLikeStatus(byte commentLikeStatus) { 25 | this.commentLikeStatus = commentLikeStatus; 26 | } 27 | 28 | public Integer getId() { 29 | return id; 30 | } 31 | 32 | public void setId(Integer id) { 33 | this.id = id; 34 | } 35 | 36 | public Integer getArticleid() { 37 | return articleid; 38 | } 39 | 40 | public void setArticleid(Integer articleid) { 41 | this.articleid = articleid; 42 | } 43 | 44 | public Long getMainuserid() { 45 | return mainuserid; 46 | } 47 | 48 | public void setMainuserid(Long mainuserid) { 49 | this.mainuserid = mainuserid; 50 | } 51 | 52 | public Integer getCommentid() { 53 | return commentid; 54 | } 55 | 56 | public void setCommentid(Integer commentid) { 57 | this.commentid = commentid; 58 | } 59 | 60 | public Long getUserid() { 61 | return userid; 62 | } 63 | 64 | public void setUserid(Long userid) { 65 | this.userid = userid; 66 | } 67 | 68 | public Date getLikedate() { 69 | return likedate; 70 | } 71 | 72 | public void setLikedate(Date likedate) { 73 | this.likedate = likedate; 74 | } 75 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/entity/Discussion.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.behavior.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class Discussion { 6 | private Integer id; 7 | 8 | private Integer articleid; 9 | 10 | private Long mainUserid; 11 | 12 | private String mainUsername; 13 | 14 | private Integer mainCommentid; 15 | 16 | private Long userid; 17 | 18 | private String userName; 19 | 20 | private String discussion; 21 | 22 | private Date discussdate; 23 | 24 | private byte discussionStatus; 25 | 26 | public byte getDiscussionStatus() { 27 | return discussionStatus; 28 | } 29 | 30 | public void setDiscussionStatus(byte discussionStatus) { 31 | this.discussionStatus = discussionStatus; 32 | } 33 | 34 | public Integer getId() { 35 | return id; 36 | } 37 | 38 | public void setId(Integer id) { 39 | this.id = id; 40 | } 41 | 42 | public Integer getArticleid() { 43 | return articleid; 44 | } 45 | 46 | public void setArticleid(Integer articleid) { 47 | this.articleid = articleid; 48 | } 49 | 50 | public Long getMainUserid() { 51 | return mainUserid; 52 | } 53 | 54 | public void setMainUserid(Long mainUserid) { 55 | this.mainUserid = mainUserid; 56 | } 57 | 58 | public String getMainUsername() { 59 | return mainUsername; 60 | } 61 | 62 | public void setMainUsername(String mainUsername) { 63 | this.mainUsername = mainUsername; 64 | } 65 | 66 | public Integer getMainCommentid() { 67 | return mainCommentid; 68 | } 69 | 70 | public void setMainCommentid(Integer mainCommentid) { 71 | this.mainCommentid = mainCommentid; 72 | } 73 | 74 | public Long getUserid() { 75 | return userid; 76 | } 77 | 78 | public void setUserid(Long userid) { 79 | this.userid = userid; 80 | } 81 | 82 | public String getUserName() { 83 | return userName; 84 | } 85 | 86 | public void setUserName(String userName) { 87 | this.userName = userName; 88 | } 89 | 90 | public String getDiscussion() { 91 | return discussion; 92 | } 93 | 94 | public void setDiscussion(String discussion) { 95 | this.discussion = discussion == null ? null : discussion.trim(); 96 | } 97 | 98 | public Date getDiscussdate() { 99 | return discussdate; 100 | } 101 | 102 | public void setDiscussdate(Date discussdate) { 103 | this.discussdate = discussdate; 104 | } 105 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/entity/Picture.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.behavior.entity; 2 | 3 | import com.flowingsun.behavior.vo.PictureQuery; 4 | 5 | import java.util.Date; 6 | import java.util.List; 7 | 8 | public class Picture { 9 | private Integer id; 10 | 11 | private Long userid; 12 | 13 | private Date createdate; 14 | 15 | private String filepath; 16 | 17 | private String details; 18 | 19 | public Integer getId() { 20 | return id; 21 | } 22 | 23 | public void setId(Integer id) { 24 | this.id = id; 25 | } 26 | 27 | public Long getUserid() { 28 | return userid; 29 | } 30 | 31 | public void setUserid(Long userid) { 32 | this.userid = userid; 33 | } 34 | 35 | public Date getCreatedate() { 36 | return createdate; 37 | } 38 | 39 | public void setCreatedate(Date createdate) { 40 | this.createdate = createdate; 41 | } 42 | 43 | public String getFilepath() { 44 | return filepath; 45 | } 46 | 47 | public void setFilepath(String filepath) { 48 | this.filepath = filepath == null ? null : filepath.trim(); 49 | } 50 | 51 | public String getDetails() { 52 | return details; 53 | } 54 | 55 | public void setDetails(String details) { 56 | this.details = details == null ? null : details.trim(); 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | return "Picture{" + 62 | "id=" + id + 63 | ", userid=" + userid + 64 | ", createdate=" + createdate + 65 | ", filepath='" + filepath + '\'' + 66 | ", details='" + details + '\'' + 67 | '}'; 68 | } 69 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/entity/Thank.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.behavior.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class Thank { 6 | private Integer id; 7 | 8 | private Integer articleid; 9 | 10 | private Long userid; 11 | 12 | private Date thankdate; 13 | 14 | private byte thankStatus; 15 | 16 | public byte getThankStatus() { 17 | return thankStatus; 18 | } 19 | 20 | public void setThankStatus(byte thankStatus) { 21 | this.thankStatus = thankStatus; 22 | } 23 | 24 | public Integer getId() { 25 | return id; 26 | } 27 | 28 | public void setId(Integer id) { 29 | this.id = id; 30 | } 31 | 32 | public Integer getArticleid() { 33 | return articleid; 34 | } 35 | 36 | public void setArticleid(Integer articleid) { 37 | this.articleid = articleid; 38 | } 39 | 40 | public Long getUserid() { 41 | return userid; 42 | } 43 | 44 | public void setUserid(Long userid) { 45 | this.userid = userid; 46 | } 47 | 48 | public Date getThankdate() { 49 | return thankdate; 50 | } 51 | 52 | public void setThankdate(Date thankdate) { 53 | this.thankdate = thankdate; 54 | } 55 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/entity/UrlCollection.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.behavior.entity; 2 | 3 | import java.sql.Timestamp; 4 | import java.util.Date; 5 | 6 | public class UrlCollection { 7 | 8 | public UrlCollection(){ 9 | this.createDate = new Timestamp(new Date().getTime()); 10 | this.editDate = new Timestamp(new Date().getTime()); 11 | } 12 | 13 | private Integer id; 14 | 15 | private Long userId; 16 | 17 | private String url; 18 | 19 | private String description; 20 | 21 | private Date createDate; 22 | 23 | private Date editDate; 24 | 25 | public Integer getId() { 26 | return id; 27 | } 28 | 29 | public void setId(Integer id) { 30 | this.id = id; 31 | } 32 | 33 | public Long getUserId() { 34 | return userId; 35 | } 36 | 37 | public void setUserId(Long userId) { 38 | this.userId = userId; 39 | } 40 | 41 | public String getUrl() { 42 | return url; 43 | } 44 | 45 | public void setUrl(String url) { 46 | this.url = url; 47 | } 48 | 49 | public String getDescription() { 50 | return description; 51 | } 52 | 53 | public void setDescription(String description) { 54 | this.description = description; 55 | } 56 | 57 | public Date getCreateDate() { 58 | return createDate; 59 | } 60 | 61 | public void setCreateDate(Date createDate) { 62 | this.createDate = createDate; 63 | } 64 | 65 | public Date getEditDate() { 66 | return editDate; 67 | } 68 | 69 | public void setEditDate(Date editDate) { 70 | this.editDate = editDate; 71 | } 72 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/service/BehaviorService.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.behavior.service; 2 | 3 | import com.flowingsun.article.entity.Article; 4 | import com.flowingsun.behavior.dto.BehaviorStatus; 5 | import com.flowingsun.behavior.entity.*; 6 | import com.flowingsun.behavior.vo.PictureQuery; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.web.multipart.MultipartFile; 9 | import org.springframework.web.multipart.MultipartHttpServletRequest; 10 | 11 | import javax.servlet.http.HttpServletRequest; 12 | import java.text.ParseException; 13 | import java.util.List; 14 | 15 | public interface BehaviorService { 16 | 17 | String setComment(Comment commentBean, HttpServletRequest request); 18 | 19 | String setThank(Thank thankBean, HttpServletRequest request); 20 | 21 | String setCommentLike(CommentLike commentLikeBean, HttpServletRequest request); 22 | 23 | boolean saveUserImage(Picture picture); 24 | 25 | String imageUpload(MultipartHttpServletRequest request, String description); 26 | 27 | PictureQuery getUserImages(PictureQuery pictureQuery) throws ParseException; 28 | 29 | Article getUserArticleBehavior(Article article, Long userId); 30 | 31 | List
getUserArticleListBehavior(List
articleList, Long userId); 32 | 33 | String getMoneyDonatePage(HttpServletRequest request); 34 | 35 | String setCommentDiscussion(Discussion discussion, HttpServletRequest request); 36 | 37 | String setCollect(Collection collectBean, HttpServletRequest request); 38 | 39 | BehaviorStatus getUserBehavior(Long userid); 40 | 41 | String getUserArticleCollections(HttpServletRequest request); 42 | /** 43 | * @author lyon 44 | * @date 2019/1/8 20:51 45 | * @detail 根据url截图网页快照 46 | */ 47 | String getScreenShot(String url)throws Exception; 48 | 49 | UrlCollection collectUrl(UrlCollection bean)throws Exception; 50 | /** 51 | * 设置用户头像 52 | */ 53 | String setUserHeadImage(MultipartFile multipartFile, HttpServletRequest request); 54 | 55 | String onlineUtils(HttpServletRequest request); 56 | 57 | List detectImage(MultipartHttpServletRequest request, String description); 58 | 59 | String shellExec(String command) throws Exception; 60 | 61 | List downloadVideo(String url); 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/behavior/vo/PictureQuery.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.behavior.vo; 2 | 3 | import com.flowingsun.behavior.entity.Picture; 4 | import com.flowingsun.common.utils.PageQueryBean; 5 | 6 | import java.util.Date; 7 | import java.util.List; 8 | 9 | public class PictureQuery extends PageQueryBean{ 10 | 11 | private Long userid; 12 | 13 | private String username; 14 | 15 | private Date createDate; 16 | 17 | private Date startDate ; 18 | 19 | private Date endDate ; 20 | 21 | private Date rangeDate; 22 | 23 | private List pictureList; 24 | 25 | public List getPictureList() { 26 | return pictureList; 27 | } 28 | 29 | public void setPictureList(List pictureList) { 30 | this.pictureList = pictureList; 31 | } 32 | 33 | public Date getCreateDate() { 34 | return createDate; 35 | } 36 | 37 | public void setCreateDate(Date createDate) { 38 | this.createDate = createDate; 39 | } 40 | 41 | public Long getUserid() { 42 | return userid; 43 | } 44 | 45 | public void setUserid(Long userid) { 46 | this.userid = userid; 47 | } 48 | 49 | public String getUsername() { 50 | return username; 51 | } 52 | 53 | public void setUsername(String username) { 54 | this.username = username; 55 | } 56 | 57 | public Date getStartDate() { 58 | return startDate; 59 | } 60 | 61 | public void setStartDate(Date startDate) { 62 | this.startDate = startDate; 63 | } 64 | 65 | public Date getEndDate() { 66 | return endDate; 67 | } 68 | 69 | public void setEndDate(Date endDate) { 70 | this.endDate = endDate; 71 | } 72 | 73 | public Date getRangeDate() { 74 | return rangeDate; 75 | } 76 | 77 | public void setRangeDate(Date rangeDate) { 78 | this.rangeDate = rangeDate; 79 | } 80 | 81 | @Override 82 | public String toString() { 83 | return "PictureQuery{" + 84 | "userid=" + userid + 85 | ", username='" + username + '\'' + 86 | ", createDate=" + createDate + 87 | ", startDate=" + startDate + 88 | ", endDate=" + endDate + 89 | ", rangeDate=" + rangeDate + 90 | ", pictureList=" + pictureList + 91 | '}'; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/common/annotation/MethodExcuteTimeLog.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.common.annotation; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({java.lang.annotation.ElementType.METHOD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | public @interface MethodExcuteTimeLog { 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/common/dao/BlogVisitorMapper.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.common.dao; 2 | 3 | import com.flowingsun.common.entity.BlogVisitor; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public interface BlogVisitorMapper { 8 | int deleteByPrimaryKey(Long id); 9 | 10 | int insert(BlogVisitor record); 11 | 12 | int insertSelective(BlogVisitor record); 13 | 14 | BlogVisitor selectByPrimaryKey(Long id); 15 | 16 | int updateByPrimaryKeySelective(BlogVisitor record); 17 | 18 | int updateByPrimaryKey(BlogVisitor record); 19 | 20 | int selectVisitorCount(); 21 | 22 | int selectViewCount(); 23 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/common/dao/BlogVisitorMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | id, userId, articleId, os, browser, ip, sourceUrl, targetUrl, dateTime 17 | 18 | 21 | 24 | 30 | 31 | delete from visitor_info 32 | where id = #{id,jdbcType=BIGINT} 33 | 34 | 35 | insert into visitor_info (id, userId, articleId, 36 | os, browser, ip, sourceUrl, 37 | targetUrl, dateTime) 38 | values (#{id,jdbcType=BIGINT}, #{userid,jdbcType=BIGINT}, #{articleid,jdbcType=INTEGER}, 39 | #{os,jdbcType=VARCHAR}, #{browser,jdbcType=VARCHAR}, #{ip,jdbcType=VARCHAR}, #{sourceurl,jdbcType=VARCHAR}, 40 | #{targeturl,jdbcType=VARCHAR}, #{datetime,jdbcType=TIMESTAMP}) 41 | 42 | 43 | insert into visitor_info 44 | 45 | 46 | id, 47 | 48 | 49 | userId, 50 | 51 | 52 | articleId, 53 | 54 | 55 | os, 56 | 57 | 58 | browser, 59 | 60 | 61 | ip, 62 | 63 | 64 | sourceUrl, 65 | 66 | 67 | targetUrl, 68 | 69 | 70 | dateTime, 71 | 72 | 73 | 74 | 75 | #{id,jdbcType=BIGINT}, 76 | 77 | 78 | #{userid,jdbcType=BIGINT}, 79 | 80 | 81 | #{articleid,jdbcType=INTEGER}, 82 | 83 | 84 | #{os,jdbcType=VARCHAR}, 85 | 86 | 87 | #{browser,jdbcType=VARCHAR}, 88 | 89 | 90 | #{ip,jdbcType=VARCHAR}, 91 | 92 | 93 | #{sourceurl,jdbcType=VARCHAR}, 94 | 95 | 96 | #{targeturl,jdbcType=VARCHAR}, 97 | 98 | 99 | #{datetime,jdbcType=TIMESTAMP}, 100 | 101 | 102 | 103 | 104 | update visitor_info 105 | 106 | 107 | userId = #{userid,jdbcType=BIGINT}, 108 | 109 | 110 | articleId = #{articleid,jdbcType=INTEGER}, 111 | 112 | 113 | os = #{os,jdbcType=VARCHAR}, 114 | 115 | 116 | browser = #{browser,jdbcType=VARCHAR}, 117 | 118 | 119 | ip = #{ip,jdbcType=VARCHAR}, 120 | 121 | 122 | sourceUrl = #{sourceurl,jdbcType=VARCHAR}, 123 | 124 | 125 | targetUrl = #{targeturl,jdbcType=VARCHAR}, 126 | 127 | 128 | dateTime = #{datetime,jdbcType=TIMESTAMP}, 129 | 130 | 131 | where id = #{id,jdbcType=BIGINT} 132 | 133 | 134 | update visitor_info 135 | set userId = #{userid,jdbcType=BIGINT}, 136 | articleId = #{articleid,jdbcType=INTEGER}, 137 | os = #{os,jdbcType=VARCHAR}, 138 | browser = #{browser,jdbcType=VARCHAR}, 139 | ip = #{ip,jdbcType=VARCHAR}, 140 | sourceUrl = #{sourceurl,jdbcType=VARCHAR}, 141 | targetUrl = #{targeturl,jdbcType=VARCHAR}, 142 | dateTime = #{datetime,jdbcType=TIMESTAMP} 143 | where id = #{id,jdbcType=BIGINT} 144 | 145 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/common/dto/ResponseDto.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.common.dto; 2 | 3 | /** 4 | * @author Lyon 5 | * @date 2019/1/8 22:15 6 | * @description ResponseDto 7 | **/ 8 | public class ResponseDto { 9 | 10 | private String code; 11 | 12 | private String msg; 13 | 14 | private Object data; 15 | 16 | public String getCode() { 17 | return code; 18 | } 19 | 20 | public void setCode(String code) { 21 | this.code = code; 22 | } 23 | 24 | public String getMsg() { 25 | return msg; 26 | } 27 | 28 | public void setMsg(String msg) { 29 | this.msg = msg; 30 | } 31 | 32 | public Object getData() { 33 | return data; 34 | } 35 | 36 | public void setData(Object data) { 37 | this.data = data; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/common/entity/BlogVisitor.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.common.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class BlogVisitor { 6 | private Long id; 7 | 8 | private Long userid; 9 | 10 | private Integer articleid; 11 | 12 | private String os; 13 | 14 | private String browser; 15 | 16 | private String ip; 17 | 18 | private String sourceurl; 19 | 20 | private String targeturl; 21 | 22 | private Date datetime; 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public void setId(Long id) { 29 | this.id = id; 30 | } 31 | 32 | public Long getUserid() { 33 | return userid; 34 | } 35 | 36 | public void setUserid(Long userid) { 37 | this.userid = userid; 38 | } 39 | 40 | public Integer getArticleid() { 41 | return articleid; 42 | } 43 | 44 | public void setArticleid(Integer articleid) { 45 | this.articleid = articleid; 46 | } 47 | 48 | public String getOs() { 49 | return os; 50 | } 51 | 52 | public void setOs(String os) { 53 | this.os = os == null ? null : os.trim(); 54 | } 55 | 56 | public String getBrowser() { 57 | return browser; 58 | } 59 | 60 | public void setBrowser(String browser) { 61 | this.browser = browser == null ? null : browser.trim(); 62 | } 63 | 64 | public String getIp() { 65 | return ip; 66 | } 67 | 68 | public void setIp(String ip) { 69 | this.ip = ip == null ? null : ip.trim(); 70 | } 71 | 72 | public String getSourceurl() { 73 | return sourceurl; 74 | } 75 | 76 | public void setSourceurl(String sourceurl) { 77 | this.sourceurl = sourceurl == null ? null : sourceurl.trim(); 78 | } 79 | 80 | public String getTargeturl() { 81 | return targeturl; 82 | } 83 | 84 | public void setTargeturl(String targeturl) { 85 | this.targeturl = targeturl == null ? null : targeturl.trim(); 86 | } 87 | 88 | public Date getDatetime() { 89 | return datetime; 90 | } 91 | 92 | public void setDatetime(Date datetime) { 93 | this.datetime = datetime; 94 | } 95 | 96 | @Override 97 | public String toString() { 98 | return "BlogVisitor{" + 99 | "id=" + id + 100 | ", userid=" + userid + 101 | ", articleid=" + articleid + 102 | ", os='" + os + '\'' + 103 | ", browser='" + browser + '\'' + 104 | ", ip='" + ip + '\'' + 105 | ", sourceurl='" + sourceurl + '\'' + 106 | ", targeturl='" + targeturl + '\'' + 107 | ", datetime=" + datetime + 108 | '}'; 109 | } 110 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/common/interceptor/MethodExcuteTimeInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.common.interceptor; 2 | 3 | import com.flowingsun.common.annotation.MethodExcuteTimeLog; 4 | import org.aspectj.lang.ProceedingJoinPoint; 5 | import org.aspectj.lang.annotation.Around; 6 | import org.aspectj.lang.annotation.Aspect; 7 | import org.aspectj.lang.annotation.Pointcut; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.stereotype.Component; 11 | 12 | @Aspect 13 | @Component 14 | public class MethodExcuteTimeInterceptor { 15 | 16 | private static Logger logger = LoggerFactory.getLogger(MethodExcuteTimeLog.class); 17 | 18 | @Pointcut("@annotation(com.flowingsun.common.annotation.MethodExcuteTimeLog)") 19 | public void logMethodTimePointcut() { 20 | 21 | } 22 | 23 | @Around("logMethodTimePointcut()") 24 | public Object interceptor(ProceedingJoinPoint pjp) { 25 | long startTime = System.currentTimeMillis(); 26 | Object result = null; 27 | try { 28 | result = pjp.proceed(); 29 | } catch (Throwable e) { 30 | logger.error(e.getMessage(), e); 31 | throw new RuntimeException(e); 32 | } 33 | 34 | logger.info("\n---------------------------【方法执行时间统计】--------------------------\nmethod:"+pjp.getSignature().getDeclaringTypeName() + "." + pjp.getSignature().getName()+"\nexecute time: " + (System.currentTimeMillis() - startTime) + "(ms)\n"); 35 | return result; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/common/interceptor/SessionInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.common.interceptor; 2 | 3 | import com.flowingsun.common.dao.BlogVisitorMapper; 4 | import com.flowingsun.common.dao.RedisDAO; 5 | import com.flowingsun.common.entity.BlogVisitor; 6 | import com.flowingsun.common.utils.InfoCountUtils; 7 | import org.apache.log4j.Logger; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.scheduling.annotation.Async; 10 | import org.springframework.web.servlet.HandlerInterceptor; 11 | import org.springframework.web.servlet.ModelAndView; 12 | 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | 16 | import static org.apache.log4j.Level.INFO; 17 | 18 | public class SessionInterceptor implements HandlerInterceptor { 19 | 20 | private static Logger logger = Logger.getLogger(SessionInterceptor.class); 21 | 22 | @Autowired 23 | private BlogVisitorMapper blogVisitorMapper; 24 | 25 | @Autowired 26 | private RedisDAO redisDAO; 27 | 28 | @Override 29 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 30 | //访问目的url 31 | String uri = request.getRequestURI(); 32 | //用户id信息 33 | Long userId = (Long)request.getSession().getAttribute("userId"); 34 | if((uri.indexOf("admin")>=0)||uri.indexOf("user/userInfo")>=0||uri.indexOf("spider")>=0){ 35 | if(userId!=null){ return true; } 36 | response.sendRedirect("/user/login"); 37 | return false; 38 | } 39 | //访问文章信息 40 | if((uri.indexOf("article")>=0) || (uri.indexOf("user")>=0) || (uri.indexOf("behavior")>=0)){ 41 | //获取请求详细信息 42 | BlogVisitor blogVisitor = InfoCountUtils.getVisitorInfo(request); 43 | if(userId!=null&&userId!=0){ 44 | blogVisitor.setUserid(userId); 45 | } 46 | String articleId = request.getParameter("articleId"); 47 | if(articleId!=null&&articleId!=""){ 48 | blogVisitor.setArticleid(Integer.parseInt(articleId)); 49 | } 50 | blogVisitorMapper.insertSelective(blogVisitor); 51 | this.updateBlogViewCount(); 52 | this.updateBlogVisitorCount(); 53 | logger.log(INFO,"\n---------------------------访客信息统计---------------------------\n"+blogVisitor.toString()); 54 | return true; 55 | } 56 | if((uri.startsWith("login"))||(uri.startsWith("register"))||(uri.startsWith("logout"))){ 57 | request.getRequestDispatcher("user/login").forward(request,response); 58 | return false; 59 | } 60 | 61 | 62 | 63 | request.getRequestDispatcher("/user/login").forward(request,response); 64 | return false; 65 | } 66 | 67 | @Override 68 | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { 69 | 70 | } 71 | 72 | @Override 73 | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { 74 | 75 | } 76 | 77 | @Async 78 | public void updateBlogVisitorCount(){ 79 | String s = String.valueOf(blogVisitorMapper.selectVisitorCount()); 80 | redisDAO.setString("visitorCount",s); 81 | } 82 | 83 | @Async 84 | public void updateBlogViewCount(){ 85 | String s = String.valueOf(blogVisitorMapper.selectViewCount()); 86 | redisDAO.setString("viewCount",s); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/common/security/CustomCredentialsMatcher.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.common.security; 2 | 3 | import com.flowingsun.common.utils.MD5Utils; 4 | import com.flowingsun.common.utils.loginCheckUtils; 5 | import com.flowingsun.user.entity.User; 6 | import com.flowingsun.user.service.UserService; 7 | import org.apache.shiro.authc.AuthenticationInfo; 8 | import org.apache.shiro.authc.AuthenticationToken; 9 | import org.apache.shiro.authc.UsernamePasswordToken; 10 | import org.apache.shiro.authc.credential.SimpleCredentialsMatcher; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | 13 | import java.io.UnsupportedEncodingException; 14 | import java.security.NoSuchAlgorithmException; 15 | 16 | /** 17 | *@Author Lyon[flowingsun007@163.com] 18 | *@Date 18/05/29 20:53 19 | *@Description 自定义密码验证 20 | * 主要用于登录验证 21 | */ 22 | public class CustomCredentialsMatcher extends SimpleCredentialsMatcher { 23 | 24 | @Autowired 25 | private UserService userService; 26 | @Override 27 | public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) { 28 | 29 | try { 30 | UsernamePasswordToken usertoken = (UsernamePasswordToken) token; 31 | String username = usertoken.getUsername(); 32 | User userInfo = new User(); 33 | if(loginCheckUtils.checkMobileNumber(username)==true){ 34 | userInfo.setTelephone(username); 35 | }else if(loginCheckUtils.checkEmail(username)==true){ 36 | userInfo.setUseremail(username); 37 | } 38 | String password = String.valueOf(usertoken.getPassword()); 39 | User user = userService.findUserByUserToken(userInfo); 40 | //saltPass = 原密码password + 手机号 + salt盐 41 | //saltPass经过MD5加密后才是存在数据库中的密码串(userpass) 42 | String saltPass = password+user.getTelephone()+user.getSalt(); 43 | Object tokenCredentials = MD5Utils.encryptPassword(saltPass); 44 | Object accountCredentials =getCredentials(info); 45 | return equals(tokenCredentials,accountCredentials); 46 | } catch (NoSuchAlgorithmException e) { 47 | e.printStackTrace(); 48 | } catch (UnsupportedEncodingException e) { 49 | e.printStackTrace(); 50 | } 51 | return false; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/common/security/MyRealm.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.common.security; 2 | 3 | import com.flowingsun.common.dao.RedisDAO; 4 | import com.flowingsun.common.utils.loginCheckUtils; 5 | import com.flowingsun.user.entity.Permission; 6 | import com.flowingsun.user.entity.Role; 7 | import com.flowingsun.user.entity.User; 8 | import com.flowingsun.user.service.UserService; 9 | import org.apache.shiro.SecurityUtils; 10 | import org.apache.shiro.authc.*; 11 | import org.apache.shiro.authz.AuthorizationInfo; 12 | import org.apache.shiro.authz.SimpleAuthorizationInfo; 13 | import org.apache.shiro.realm.AuthorizingRealm; 14 | import org.apache.shiro.subject.PrincipalCollection; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | 17 | public class MyRealm extends AuthorizingRealm { 18 | @Autowired 19 | private UserService userService; 20 | 21 | @Autowired 22 | private RedisDAO redisDAO; 23 | 24 | 25 | /** 26 | *@Author Lyon[flowingsun007@163.com] 27 | *@Date 18/09/12 09:59 28 | *@Param [principalCollection] 29 | *@Return org.apache.shiro.authz.AuthorizationInfo 30 | *@Description doGetAuthorizationInfo 31 | * 用户角色及权限认证 32 | * 根据用户的userId查询其所有的角色role即权限permission,最后将信息装入authorizationInfo返回 33 | */ 34 | @Override 35 | protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { 36 | Long userId = (Long)SecurityUtils.getSubject().getSession().getAttribute("userId"); 37 | SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo(); 38 | if(userId!=null){ 39 | User user = userService.getUserByUserId(userId); 40 | if(user.getRoleList()!=null){ 41 | for(Role role :user.getRoleList()){ 42 | authorizationInfo.addRole(role.getRole()); 43 | for(Permission permission :role.getPermissionList()){ 44 | authorizationInfo.addStringPermission(permission.getPermission()); 45 | } 46 | } 47 | } 48 | }else{ 49 | authorizationInfo=null; 50 | } 51 | return authorizationInfo; 52 | } 53 | 54 | 55 | 56 | /** 57 | *@Author Lyon[flowingsun007@163.com] 58 | *@Date 18/09/12 09:54 59 | *@Param [authenticationToken] 60 | *@Return org.apache.shiro.authc.AuthenticationInfo 61 | *@Description doGetAuthenticationInfo 62 | * 用户登录认证 63 | * 根据用户输入的手机号/邮箱号实例化一个userInfo对象,根据此对象查数据库 64 | * 查询到user结果则登录成功,尝试将用户信息放入redis中缓存,否则返回null。 65 | */ 66 | @Override 67 | protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException { 68 | System.out.println("\n----------------------------------用户登录认证----------------------------------\n"); 69 | UsernamePasswordToken usernamePasswordToke = (UsernamePasswordToken)authenticationToken; 70 | String username = usernamePasswordToke.getUsername(); 71 | User userInfo = new User(); 72 | if(loginCheckUtils.checkMobileNumber(username)==true){ 73 | userInfo.setTelephone(username); 74 | }else if(loginCheckUtils.checkEmail(username)==true){ 75 | userInfo.setUseremail(username); 76 | } 77 | User user = userService.findUserByUserToken(userInfo); 78 | if(user!=null){ 79 | AuthenticationInfo info = new SimpleAuthenticationInfo(user.getTelephone(), user.getUserpass(), getName()); 80 | SecurityUtils.getSubject().getSession().setAttribute("userId",user.getId()); 81 | user.setRoleList(null); 82 | String result = redisDAO.setRedisUser(user); 83 | if(result!=null){ 84 | System.out.println("\n----------------------------------用户信息:存入redis----------------------------------\n"+result); 85 | } 86 | return info; 87 | }else{ 88 | return null; 89 | } 90 | 91 | } 92 | } 93 | 94 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/common/utils/DateUtils.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.common.utils; 2 | 3 | import java.util.Calendar; 4 | import java.util.Date; 5 | 6 | public class DateUtils { 7 | 8 | private static Calendar calendar = Calendar.getInstance(); 9 | /** 10 | *@Author Lyon[flowingsun007@163.com] 11 | *@Date 18/05/2 16:20 12 | *@Description 计算今天周几 13 | */ 14 | public static int getTodayWeek(){ 15 | calendar.setTime(new Date()); 16 | int week = calendar.get(Calendar.DAY_OF_WEEK)-1; 17 | if(week<0) week=7; 18 | return week; 19 | } 20 | 21 | /** 22 | *@Author Lyon[flowingsun007@163.com] 23 | *@Date 18/05/2 16:20 24 | *@Description 计算工作分钟数 25 | */ 26 | public static int getMinute(Date startDate,Date endDate){ 27 | long start = startDate.getTime(); 28 | long end = endDate.getTime(); 29 | int minute = (int)(end-start)/(1000*60); 30 | return minute; 31 | } 32 | 33 | /** 34 | *@Author Lyon[flowingsun007@163.com] 35 | *@Date 18/05/2 16:27 36 | *@Description 从数据库获取的某个(时分秒)时间 + 当前年月日,返回装配后的时间 37 | */ 38 | public static Date getDate(int hour,int minute,int second){ 39 | calendar.setTime(new Date()); 40 | calendar.set(Calendar.HOUR_OF_DAY,hour); 41 | calendar.set(Calendar.MINUTE,minute); 42 | calendar.set(Calendar.SECOND,second); 43 | return calendar.getTime(); 44 | } 45 | 46 | /** 47 | *@Author Lyon[flowingsun007@163.com] 48 | *@Date 18/05/6 23:00 49 | *@Description 从数据库取出的某个(时分秒)时间 + 1970年1月1日,返回装配后的时间 50 | * P.S.不用装配,默认取出的(时分秒)时间会自动装配成此格式。 51 | */ 52 | public static Date getPartTime(int hour,int minute,int second){ 53 | calendar.set(Calendar.HOUR_OF_DAY,hour); 54 | calendar.set(Calendar.MINUTE,minute); 55 | calendar.set(Calendar.SECOND,second); 56 | calendar.set(1970,0,1); 57 | return calendar.getTime(); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/common/utils/MD5Utils.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.common.utils; 2 | 3 | import org.apache.commons.codec.binary.Base64; 4 | //import sun.misc.BASE64Encoder; 5 | import java.io.UnsupportedEncodingException; 6 | import java.security.MessageDigest; 7 | import java.security.NoSuchAlgorithmException; 8 | 9 | /** 10 | *@Author Lyon[flowingsun007@163.com] 11 | *@Date 18/05/9 17:29 12 | *@Description 用户密码MD5加密解密校验 13 | */ 14 | public class MD5Utils { 15 | public static String encryptPassword(String saltPass) throws NoSuchAlgorithmException, UnsupportedEncodingException { 16 | MessageDigest md5 = MessageDigest.getInstance("MD5"); 17 | //BASE64Encoder base64Encoder = new BASE64Encoder(); 18 | //String result = base64Encoder.encode(md5.digest(saltPass.getBytes("utf-8"))); 19 | String result = Base64.encodeBase64String(md5.digest(saltPass.getBytes("utf-8"))); 20 | System.out.println(result); 21 | return result; 22 | } 23 | 24 | public static boolean checkPassword(String inputPass,String userPhone, String dbSalt, String dbSaltedPwd) throws UnsupportedEncodingException, NoSuchAlgorithmException { 25 | String saltPass = inputPass + userPhone + dbSalt; 26 | String result = encryptPassword(saltPass); 27 | if(result.equals(dbSaltedPwd)){ 28 | return true; 29 | }else { 30 | return false; 31 | } 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/common/utils/PageQueryBean.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.common.utils; 2 | import java.util.List; 3 | 4 | public class PageQueryBean { 5 | private static final Integer DEFAULT_PAGE_SIZE = 10; 6 | private static final Integer DEFAULT_PAGE_NUM = 1; 7 | private Integer total; //总记录数 8 | public Integer pageNum; //当前页数 9 | public Integer pageSize; //每页显示条数 10 | private Integer pageCount; //总页数 11 | private Integer startRow; //查询起始条数 12 | private List dataList; //存放List类型数据 13 | 14 | 15 | public List getDataList() { 16 | return dataList; 17 | } 18 | 19 | public void setDataList(List dataList) { 20 | this.dataList = dataList; 21 | } 22 | 23 | public Integer getStartRow() { 24 | if(startRow==null){ 25 | if(pageNum==null){ 26 | startRow = 0; 27 | }else{ 28 | startRow = (pageNum-1) * getPageSize(); 29 | } 30 | } 31 | return startRow; 32 | } 33 | 34 | public void setStartRow(Integer startRow) { 35 | this.startRow = startRow; 36 | } 37 | 38 | public Integer getTotal() { 39 | return total; 40 | } 41 | 42 | public void setTotal(Integer total) { 43 | this.total = total; 44 | Integer pageCount = (total%pageSize==0) ? total/pageSize : total/pageSize+1; 45 | setPageCount(pageCount); 46 | } 47 | 48 | public Integer getPageNum() { 49 | if(pageNum==null){ 50 | return DEFAULT_PAGE_NUM; 51 | }else{ 52 | if(pageNum<1){ 53 | pageNum = 0; 54 | }else{ 55 | if(total!=null){ 56 | if(pageNum>total){ 57 | pageNum = total-1; 58 | }else if(pageNum>pageCount){ 59 | pageNum = pageCount; 60 | } 61 | } 62 | } 63 | return pageNum; 64 | } 65 | } 66 | 67 | public void setPageNum(Integer pageNum) { 68 | if(pageNum<1){ 69 | this.pageNum = DEFAULT_PAGE_NUM; 70 | }else{ 71 | this.pageNum = pageNum; 72 | } 73 | } 74 | 75 | public Integer getPageSize() { 76 | if (pageSize==null){ 77 | return DEFAULT_PAGE_SIZE; 78 | }else{ 79 | return pageSize; 80 | } 81 | } 82 | 83 | public void setPageSize(Integer pageSize) { 84 | if(pageSize<1){ 85 | this.pageSize = DEFAULT_PAGE_SIZE; 86 | }else{ 87 | this.pageSize = pageSize; 88 | } 89 | } 90 | 91 | public Integer getPageCount() { 92 | return pageCount; 93 | } 94 | 95 | public void setPageCount(Integer pageCount) { 96 | this.pageCount = pageCount; 97 | } 98 | 99 | @Override 100 | public String toString() { 101 | return "PageQueryBean{" + 102 | "total=" + total + 103 | ", pageNum=" + pageNum + 104 | ", pageSize=" + pageSize + 105 | ", pageCount=" + pageCount + 106 | ", startRow=" + startRow + 107 | ", dataList=" + dataList + 108 | '}'; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/common/utils/ResultUtils.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.common.utils; 2 | 3 | import com.flowingsun.common.dto.ResponseDto; 4 | import com.flowingsun.exception.BusinessException; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | /** 9 | * @author Lyon 10 | * @date 2019/1/8 22:16 11 | * @description ResultUtils 12 | **/ 13 | public class ResultUtils { 14 | public final static String CODE = "code"; 15 | public final static String MSG = "msg"; 16 | public final static String DATA = "data"; 17 | private static Logger logger = LoggerFactory.getLogger(ResultUtils.class); 18 | 19 | /** 20 | * 封装只有结果的返回数据。 21 | * 22 | * @return 23 | */ 24 | public static ResponseDto getResult() { 25 | ResponseDto result = new ResponseDto(); 26 | result.setCode("OK"); 27 | result.setMsg("success"); 28 | return result; 29 | } 30 | 31 | /** 32 | * 封装包含信息的返回数据 33 | * 34 | * @param msg 35 | * @return 36 | */ 37 | public static ResponseDto getResult(String msg) { 38 | ResponseDto result = new ResponseDto(); 39 | result.setMsg(msg); 40 | return result; 41 | } 42 | 43 | /** 44 | * 封装包含内容的返回数据。 45 | * 46 | * @return 47 | */ 48 | public static ResponseDto getResult(Object obj) { 49 | ResponseDto result = getResult(); 50 | result.setData(obj); 51 | result.setCode("200"); 52 | return result; 53 | } 54 | 55 | public static ResponseDto getResultEx(Exception e) { 56 | logger.error(e.getMessage()); 57 | ResponseDto result = new ResponseDto(); 58 | result.setCode("ERROR"); 59 | if (e instanceof BusinessException) { 60 | BusinessException be = (BusinessException) e; 61 | result.setMsg(be.getMessage()); 62 | logger.error(be.getMessage(), be); 63 | } else { 64 | result.setMsg(e.getMessage()); 65 | logger.error("系统错误", e); 66 | } 67 | return result; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/common/utils/SerializeUtils.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.common.utils; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.io.ByteArrayOutputStream; 5 | import java.io.ObjectInputStream; 6 | import java.io.ObjectOutputStream; 7 | 8 | public class SerializeUtils { 9 | public static byte[] serialize(Object object)throws Exception { 10 | ObjectOutputStream oos = null; 11 | ByteArrayOutputStream baos = null; 12 | // 序列化 13 | baos = new ByteArrayOutputStream(); 14 | oos = new ObjectOutputStream(baos); 15 | oos.writeObject(object); 16 | byte[] bytes = baos.toByteArray(); 17 | return bytes; 18 | } 19 | 20 | public static Object unserialize( byte[] bytes)throws Exception { 21 | ByteArrayInputStream bais = null; 22 | // 反序列化 23 | bais = new ByteArrayInputStream(bytes); 24 | ObjectInputStream ois = new ObjectInputStream(bais); 25 | return ois.readObject(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/common/utils/changeListFormatUtils.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.common.utils; 2 | 3 | public class changeListFormatUtils { 4 | 5 | public static Integer[] str2intList(String[] strList) throws NumberFormatException{ 6 | Integer[] intList = new Integer[strList.length]; 7 | for(Integer i=0;i链接以激活注册!

"; 59 | MimeMessage mimeMessage = mailSender.createMimeMessage(); 60 | // 设置utf-8或GBK编码,否则邮件会有乱码 61 | MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, "UTF-8"); 62 | messageHelper.setFrom(EMAILFORM, "稳稳地幸福(Lyon)"); 63 | messageHelper.setTo(toEmail); 64 | messageHelper.setSubject(subject); 65 | messageHelper.setText(content,true); 66 | mailSender.send(mimeMessage); 67 | } 68 | 69 | /** 70 | * 发送邮件 71 | * 72 | * @param mailMap 收件人与邮件内容集合 73 | * @throws MessagingException 异常 74 | */ 75 | public static void sendHtmlMail(Map mailMap) throws MessagingException{ 76 | MimeMessage mimeMessage = mailSender.createMimeMessage(); 77 | // 设置utf-8编码 78 | MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, "UTF-8"); 79 | messageHelper.setFrom(EMAILFORM); 80 | Iterator iterator = mailMap.keySet().iterator(); 81 | while (iterator.hasNext()) { 82 | messageHelper.setTo(iterator.next()); 83 | messageHelper.setText(mailMap.get(iterator.next()), true); 84 | mailSender.send(mimeMessage); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/common/utils/loginCheckUtils.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.common.utils; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | public class loginCheckUtils { 7 | /** 8 | * 验证邮箱 9 | * 10 | * @param email 11 | * @return 12 | */ 13 | 14 | public static boolean checkEmail(String email) { 15 | boolean flag = false; 16 | try { 17 | String check = "^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"; 18 | Pattern regex = Pattern.compile(check); 19 | Matcher matcher = regex.matcher(email); 20 | flag = matcher.matches(); 21 | } catch (Exception e) { 22 | flag = false; 23 | } 24 | return flag; 25 | } 26 | 27 | /** 28 | * 验证手机号码,11位数字,1开通,第二位数必须是3456789这些数字之一 * 29 | * @param mobileNumber 30 | * @return 31 | */ 32 | public static boolean checkMobileNumber(String mobileNumber) { 33 | boolean flag = false; 34 | try { 35 | // Pattern regex = Pattern.compile("^(((13[0-9])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8})|(0\\d{2}-\\d{8})|(0\\d{3}-\\d{7})$"); 36 | Pattern regex = Pattern.compile("^1[345789]\\d{9}$"); 37 | Matcher matcher = regex.matcher(mobileNumber); 38 | flag = matcher.matches(); 39 | } catch (Exception e) { 40 | e.printStackTrace(); 41 | flag = false; 42 | 43 | } 44 | return flag; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.exception; 2 | 3 | /** 4 | * @author Lyon 5 | * @date 2019/1/8 22:18 6 | * @description BusinessException 7 | **/ 8 | public class BusinessException extends RuntimeException { 9 | 10 | private static final long serialVersionUID = -1719909808663638420L; 11 | 12 | public String code; 13 | 14 | public BusinessException(String message) { 15 | super(message); 16 | } 17 | 18 | public BusinessException(String code, String message) { 19 | super(message); 20 | this.code = code; 21 | } 22 | 23 | public String getCode() { 24 | return code; 25 | } 26 | 27 | public void setCode(String code) { 28 | this.code = code; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/spider/controller/SpiderController.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.spider.controller; 2 | 3 | 4 | import com.flowingsun.spider.service.BasicCrawlController; 5 | import com.flowingsun.spider.service.ImageCrawlController; 6 | import org.springframework.stereotype.Controller; 7 | 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | 11 | 12 | @Controller 13 | @RequestMapping("spider") 14 | public class SpiderController { 15 | 16 | @GetMapping("/crawlHtml") 17 | @ResponseBody 18 | public void crawlHtml(){ 19 | System.out.println("开始crawlHtml..........."); 20 | BasicCrawlController crawlController = new BasicCrawlController(); 21 | String[] s1 = new String[4]; 22 | //项目配置存放路径(运行后会自动生成配置,存放在路径下的frontier文件夹中) 23 | s1[0] = "/usr/local/data/LyonBlog/spider/html"; 24 | //爬虫线程数 25 | s1[1] = "2"; 26 | //爬取内容的存放路径 27 | s1[2] = "/usr/local/data/LyonBlog/spider/html/developerworks"; 28 | //要爬取的目标网址 29 | s1[3] = "https://www.ibm.com/developerworks/cn/java"; 30 | try{ 31 | crawlController.main(s1); 32 | }catch (Exception e){ 33 | e.printStackTrace(); 34 | } 35 | System.out.println("结束crawlHtml..........."); 36 | } 37 | 38 | @GetMapping("/crawlImage") 39 | @ResponseBody 40 | public void crawlImage(){ 41 | //参数:项目配置存放路径;爬虫线程数;内容存储路径;目标网址 42 | System.out.println("开始crawlImage..........."); 43 | ImageCrawlController imageCrawlController = new ImageCrawlController(); 44 | String[] s = new String[3]; 45 | String[] crawlDomains = new String[2]; 46 | //项目配置存放路径(运行后会自动生成配置,存放在路径下的frontier文件夹中) 47 | s[0] = "/usr/local/data/LyonBlog/spider/image"; 48 | //爬虫线程数 49 | s[1] = "2"; 50 | //爬取内容的存放路径 51 | s[2] = "/usr/local/data/LyonBlog/spider/image/developerworks"; 52 | //要爬取的目标网址 53 | crawlDomains[0] = "https://www.ibm.com/developerworks/cn/java"; 54 | crawlDomains[1] = "https://www.ibm.com/developerworks/cn"; 55 | try{ 56 | imageCrawlController.main(s,crawlDomains); 57 | }catch (Exception e){ 58 | e.printStackTrace(); 59 | } 60 | System.out.println("结束crawlImage..........."); 61 | } 62 | 63 | 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/spider/service/BasicCrawlController.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.flowingsun.spider.service; 19 | 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | 23 | import edu.uci.ics.crawler4j.crawler.CrawlConfig; 24 | import edu.uci.ics.crawler4j.crawler.CrawlController; 25 | import edu.uci.ics.crawler4j.fetcher.PageFetcher; 26 | import edu.uci.ics.crawler4j.robotstxt.RobotstxtConfig; 27 | import edu.uci.ics.crawler4j.robotstxt.RobotstxtServer; 28 | 29 | /** 30 | * @author Yasser Ganjisaffar 31 | */ 32 | public class BasicCrawlController { 33 | private static final Logger logger = LoggerFactory.getLogger(BasicCrawlController.class); 34 | 35 | public static void main(String[] args) throws Exception { 36 | 37 | /* 38 | * crawlStorageFolder is a folder where intermediate crawl data is 39 | * stored. 40 | */ 41 | String crawlStorageFolder = args[0]; 42 | //String crawlStorageFolder = "C:\\Users\\flowi\\Desktop\\Heatmap3D"; 43 | 44 | /* 45 | * numberOfCrawlers shows the number of concurrent threads that should 46 | * be initiated for crawling. 47 | */ 48 | int numberOfCrawlers = Integer.parseInt(args[1]); 49 | //int numberOfCrawlers = 4; 50 | 51 | CrawlConfig config = new CrawlConfig(); 52 | //遵守网站的禁止爬虫提示?false 53 | config.setRespectNoFollow(false); 54 | config.setRespectNoIndex(false); 55 | 56 | config.setCrawlStorageFolder(crawlStorageFolder); 57 | 58 | /* 59 | * Be polite: Make sure that we don't send more than 1 request per 60 | * second (1000 milliseconds between requests). 61 | */ 62 | config.setPolitenessDelay(1000); 63 | 64 | /* 65 | * You can set the maximum crawl depth here. The default value is -1 for 66 | * unlimited depth 67 | */ 68 | config.setMaxDepthOfCrawling(2); 69 | 70 | /* 71 | * You can set the maximum number of pages to crawl. The default value 72 | * is -1 for unlimited number of pages 73 | */ 74 | config.setMaxPagesToFetch(1000); 75 | 76 | /** 77 | * Do you want crawler4j to crawl also binary data ? 78 | * example: the contents of pdf, or the metadata of images etc 79 | */ 80 | config.setIncludeBinaryContentInCrawling(false); 81 | 82 | /* 83 | * Do you need to set a proxy? If so, you can use: 84 | * config.setProxyHost("proxyserver.example.com"); 85 | * config.setProxyPort(8080); 86 | * 87 | * If your proxy also needs authentication: 88 | * config.setProxyUsername(username); config.getProxyPassword(password); 89 | */ 90 | 91 | /* 92 | * This config parameter can be used to set your crawl to be resumable 93 | * (meaning that you can resume the crawl from a previously 94 | * interrupted/crashed crawl). Note: if you enable resuming feature and 95 | * want to start a fresh crawl, you need to delete the contents of 96 | * rootFolder manually. 97 | */ 98 | config.setResumableCrawling(false); 99 | 100 | /* 101 | * Set this to true if you want crawling to stop whenever an unexpected error 102 | * occurs. You'll probably want this set to true when you first start testing 103 | * your crawler, and then set to false once you're ready to let the crawler run 104 | * for a long time. 105 | */ 106 | //config.setHaltOnError(true); 107 | 108 | /* 109 | * Instantiate the controller for this crawl. 110 | */ 111 | PageFetcher pageFetcher = new PageFetcher(config); 112 | RobotstxtConfig robotstxtConfig = new RobotstxtConfig(); 113 | robotstxtConfig.setUserAgentName("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36"); 114 | RobotstxtServer robotstxtServer = new RobotstxtServer(robotstxtConfig, pageFetcher); 115 | CrawlController controller = new CrawlController(config, pageFetcher, robotstxtServer); 116 | 117 | /* 118 | * For each crawl, you need to add some seed urls. These are the first 119 | * URLs that are fetched and then the crawler starts following links 120 | * which are found in these pages 121 | */ 122 | String storageFolder = args[2]; 123 | String crawlDomain = args[3]; 124 | controller.addSeed(crawlDomain); 125 | 126 | BasicCrawler.configure(crawlDomain, storageFolder); 127 | 128 | /* 129 | * Start the crawl. This is a blocking operation, meaning that your code 130 | * will reach the line after this only when crawling is finished. 131 | */ 132 | controller.start(BasicCrawler.class, numberOfCrawlers); 133 | } 134 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/spider/service/BasicCrawler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.flowingsun.spider.service; 19 | 20 | import java.io.File; 21 | import java.io.FileWriter; 22 | import java.util.Set; 23 | import java.util.UUID; 24 | import java.util.regex.Pattern; 25 | 26 | import org.apache.http.Header; 27 | 28 | import edu.uci.ics.crawler4j.crawler.Page; 29 | import edu.uci.ics.crawler4j.crawler.WebCrawler; 30 | import edu.uci.ics.crawler4j.parser.HtmlParseData; 31 | import edu.uci.ics.crawler4j.url.WebURL; 32 | 33 | /** 34 | * @author Yasser Ganjisaffar 35 | */ 36 | public class BasicCrawler extends WebCrawler { 37 | 38 | private static final Pattern IMAGE_EXTENSIONS = Pattern.compile(".*\\.(bmp|gif|jpg|png)$"); 39 | 40 | //添加了文件分隔符和换行符,屏蔽win和linux差异 41 | private static final String FILE_SEPARATOR = System.getProperty("file.separator"); 42 | private static final String LINE_SEPARATOR = System.lineSeparator(); 43 | 44 | private static String crawlDomain; 45 | 46 | private static File storageFolder; 47 | 48 | public static void configure(String domain, String storageFolderName) { 49 | crawlDomain = domain; 50 | storageFolder = new File(storageFolderName); 51 | if (!storageFolder.exists()) { 52 | storageFolder.mkdirs(); 53 | } 54 | } 55 | 56 | /** 57 | * You should implement this function to specify whether the given url 58 | * should be crawled or not (based on your crawling logic). 59 | */ 60 | @Override 61 | public boolean shouldVisit(Page referringPage, WebURL url) { 62 | String href = url.getURL().toLowerCase(); 63 | // Ignore the url if it has an extension that matches our defined set of image extensions. 64 | if (IMAGE_EXTENSIONS.matcher(href).matches()) { 65 | return false; 66 | } 67 | 68 | // Only accept the url if it is in the "www.ics.uci.edu" domain and protocol is "http". 69 | return href.startsWith(crawlDomain); 70 | } 71 | 72 | /** 73 | * This function is called when a page is fetched and ready to be processed 74 | * by your program. 75 | */ 76 | @Override 77 | public void visit(Page page) { 78 | System.out.println("进入visit方法......"); 79 | int docid = page.getWebURL().getDocid(); 80 | String url = page.getWebURL().getURL(); 81 | String domain = page.getWebURL().getDomain(); 82 | String path = page.getWebURL().getPath(); 83 | String subDomain = page.getWebURL().getSubDomain(); 84 | String parentUrl = page.getWebURL().getParentUrl(); 85 | String anchor = page.getWebURL().getAnchor(); 86 | 87 | // logger.debug("Docid: {}", docid); 88 | // logger.info("URL: {}", url); 89 | // logger.debug("Domain: '{}'", domain); 90 | // logger.debug("Sub-domain: '{}'", subDomain); 91 | // logger.debug("Path: '{}'", path); 92 | // logger.debug("Parent page: {}", parentUrl); 93 | // logger.debug("Anchor text: {}", anchor); 94 | 95 | System.out.println("------------------------URL:------------------------" + LINE_SEPARATOR + url); 96 | 97 | if (page.getParseData() instanceof HtmlParseData) { 98 | HtmlParseData htmlParseData = (HtmlParseData) page.getParseData(); 99 | String text = htmlParseData.getText(); 100 | String html = htmlParseData.getHtml(); 101 | Set links = htmlParseData.getOutgoingUrls(); 102 | 103 | String name = storageFolder.getAbsolutePath() + FILE_SEPARATOR +"visiturl.txt"; 104 | // 打开一个写文件器,true表示以追加的形式写文件,false表示覆盖 105 | try(FileWriter writer = new FileWriter(name, true)){ 106 | writer.write(url+LINE_SEPARATOR); 107 | }catch (Exception e){ 108 | e.printStackTrace(); 109 | } 110 | 111 | String content = storageFolder.getAbsolutePath() + FILE_SEPARATOR + UUID.randomUUID() + ".html"; 112 | // 打开一个写文件器,true表示以追加的形式写文件,false表示覆盖 113 | try(FileWriter writer = new FileWriter(content, false)){ 114 | writer.write(html); 115 | }catch (Exception e){ 116 | e.printStackTrace(); 117 | } 118 | 119 | System.out.println("纯文本长度: " + text.length()); 120 | System.out.println("html长度: " + html.length()); 121 | System.out.println("输出链接个数: " + links.size()); 122 | 123 | } 124 | 125 | // //记录响应头信息 126 | // Header[] responseHeaders = page.getFetchResponseHeaders(); 127 | // if (responseHeaders != null) { 128 | // logger.debug("Response headers:"); 129 | // for (Header header : responseHeaders) { 130 | // logger.debug("\t{}: {}", header.getName(), header.getValue()); 131 | // } 132 | // } 133 | 134 | logger.debug("============="); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/spider/service/ImageCrawlController.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.spider.service; 2 | 3 | /** 4 | * @author Lyon 5 | * @date 2019/1/13 20:33 6 | * @description ImageCrawlController 7 | **/ 8 | /** 9 | * Licensed to the Apache Software Foundation (ASF) under one or more 10 | * contributor license agreements. See the NOTICE file distributed with 11 | * this work for additional information regarding copyright ownership. 12 | * The ASF licenses this file to You under the Apache License, Version 2.0 13 | * (the "License"); you may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | 26 | import org.apache.http.message.BasicHeader; 27 | import org.slf4j.Logger; 28 | import org.slf4j.LoggerFactory; 29 | 30 | import edu.uci.ics.crawler4j.crawler.CrawlConfig; 31 | import edu.uci.ics.crawler4j.crawler.CrawlController; 32 | import edu.uci.ics.crawler4j.fetcher.PageFetcher; 33 | import edu.uci.ics.crawler4j.robotstxt.RobotstxtConfig; 34 | import edu.uci.ics.crawler4j.robotstxt.RobotstxtServer; 35 | 36 | import java.util.Collection; 37 | import java.util.HashSet; 38 | 39 | /** 40 | * @author Yasser Ganjisaffar 41 | */ 42 | public class ImageCrawlController { 43 | private static final Logger logger = LoggerFactory.getLogger(ImageCrawlController.class); 44 | 45 | public static void main(String[] args, String[] crawlDomains) throws Exception { 46 | if (args.length < 3) { 47 | logger.info("Needed parameters: "); 48 | logger.info("\t rootFolder (it will contain intermediate crawl data)"); 49 | logger.info("\t numberOfCrawlers (number of concurrent threads)"); 50 | logger.info("\t storageFolder (a folder for storing downloaded images)"); 51 | return; 52 | } 53 | 54 | String rootFolder = args[0]; 55 | int numberOfCrawlers = Integer.parseInt(args[1]); 56 | String storageFolder = args[2]; 57 | 58 | CrawlConfig config = new CrawlConfig(); 59 | //遵守网站的禁止爬虫提示?false 60 | config.setRespectNoFollow(false); 61 | config.setRespectNoIndex(false); 62 | Collection headers = new HashSet(); 63 | BasicHeader h0 = new BasicHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"); 64 | BasicHeader h1 = new BasicHeader("Accept-Encoding","gzip, deflate, br"); 65 | BasicHeader h2 = new BasicHeader("Accept-Language","zh-CN,zh;q=0.9"); 66 | BasicHeader h3 = new BasicHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36"); 67 | headers.add(h0); 68 | headers.add(h1); 69 | headers.add(h2); 70 | headers.add(h3); 71 | //遵守网站的禁止爬虫提示?false 72 | config.setRespectNoIndex(false); 73 | config.setRespectNoFollow(false); 74 | //设置默认请求头(但是没什么用,源码发请求时没用到) 75 | config.setDefaultHeaders(headers); 76 | //设置内容存储文件夹 77 | config.setCrawlStorageFolder(rootFolder); 78 | //设置请求头user-angent 79 | config.setUserAgentString("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36"); 80 | 81 | /* 82 | * Since images are binary content, we need to set this parameter to 83 | * true to make sure they are included in the crawl. 84 | */ 85 | //是否提取页面二进制数据(图像、视频) 86 | config.setIncludeBinaryContentInCrawling(true); 87 | //爬取请求延时1秒 88 | config.setPolitenessDelay(1000); 89 | // //最大爬取深度:10 90 | // config.setMaxDepthOfCrawling(10); 91 | //设置最大页面爬取数量 92 | config.setMaxPagesToFetch(5000); 93 | 94 | 95 | PageFetcher pageFetcher = new PageFetcher(config); 96 | RobotstxtConfig robotstxtConfig = new RobotstxtConfig(); 97 | robotstxtConfig.setUserAgentName("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36"); 98 | RobotstxtServer robotstxtServer = new RobotstxtServer(robotstxtConfig, pageFetcher); 99 | CrawlController controller = new CrawlController(config, pageFetcher, robotstxtServer); 100 | 101 | for (String domain : crawlDomains) { 102 | controller.addSeed(domain); 103 | } 104 | 105 | ImageCrawler.configure(crawlDomains, storageFolder); 106 | 107 | controller.start(ImageCrawler.class, numberOfCrawlers); 108 | } 109 | } 110 | 111 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/user/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.user.controller; 2 | 3 | import com.flowingsun.article.entity.Category; 4 | import com.flowingsun.article.service.ArticleService; 5 | import com.flowingsun.article.vo.PageNotice; 6 | import com.flowingsun.behavior.dto.BehaviorStatus; 7 | import com.flowingsun.behavior.service.BehaviorService; 8 | import com.flowingsun.behavior.vo.PictureQuery; 9 | import com.flowingsun.user.entity.User; 10 | import com.flowingsun.user.service.UserService; 11 | import org.apache.shiro.authz.annotation.Logical; 12 | import org.apache.shiro.authz.annotation.RequiresRoles; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.stereotype.Controller; 15 | import org.springframework.ui.Model; 16 | import org.springframework.web.bind.annotation.RequestBody; 17 | import org.springframework.web.bind.annotation.RequestMapping; 18 | import org.springframework.web.bind.annotation.RequestParam; 19 | import org.springframework.web.bind.annotation.ResponseBody; 20 | 21 | import javax.servlet.http.HttpServletRequest; 22 | import java.io.UnsupportedEncodingException; 23 | import java.security.NoSuchAlgorithmException; 24 | import java.text.ParseException; 25 | import java.util.List; 26 | 27 | 28 | @Controller 29 | @RequestMapping("user") 30 | public class UserController { 31 | 32 | @Autowired 33 | private UserService userService; 34 | 35 | @Autowired 36 | private ArticleService articleService; 37 | 38 | @Autowired 39 | private BehaviorService behaviorService; 40 | 41 | 42 | @RequestMapping("/userInfo") 43 | @ResponseBody 44 | public User getUserInfo(HttpServletRequest request){ 45 | return userService.getUserInfo(request); 46 | } 47 | 48 | @RequestMapping(value={"/login","/logout","/register"}) 49 | public String toHome(Model model){ 50 | List categorys = articleService.getCategory(); 51 | model.addAttribute("categorys",categorys); 52 | return "index"; 53 | } 54 | 55 | 56 | @RequestMapping("/login/check") 57 | @ResponseBody 58 | public String checkLogin(@RequestBody User user, HttpServletRequest request) throws UnsupportedEncodingException, NoSuchAlgorithmException { 59 | return userService.UserLogin(user, request); 60 | } 61 | 62 | @RequestMapping("/logout/check") 63 | @ResponseBody 64 | public String checkLogin(HttpServletRequest request){ 65 | return userService.UserLogout(request); 66 | } 67 | 68 | @RequestMapping("/register/check") 69 | @ResponseBody 70 | public String checkRegister(@RequestBody User user,HttpServletRequest request) throws UnsupportedEncodingException, NoSuchAlgorithmException { 71 | return userService.UserRegister(user,request); 72 | } 73 | 74 | @RequestMapping("/register/activate") 75 | public String userActivate(@RequestParam(value="code",required = true) Integer code,@RequestParam(value="userphone",required = true) String userphone,HttpServletRequest request,Model model){ 76 | PageNotice pageNotice = userService.userActivate(code,userphone,request); 77 | model.addAttribute("pageNotice",pageNotice); 78 | return "/user/activiate"; 79 | } 80 | 81 | 82 | @RequiresRoles(value={"blogAdmin","blogManager","register","consumer"},logical = Logical.OR) 83 | @RequestMapping("/manageCenter") 84 | public String userManageCenter( 85 | Model model,HttpServletRequest request, 86 | @RequestParam(value="pageNum",required=false,defaultValue = "1")Integer pageNum, 87 | @RequestParam(value="pageSize",required=false,defaultValue = "20")Integer pageSize 88 | ) throws ParseException { 89 | Long userid = (Long)request.getSession().getAttribute("userId"); 90 | PictureQuery pictureQuery = new PictureQuery(); 91 | pictureQuery.setPageNum(pageNum); 92 | pictureQuery.setPageSize(pageSize); 93 | List categorys = articleService.getCategory(); 94 | PictureQuery pictureQueryList = behaviorService.getUserImages(pictureQuery); 95 | String resultInfo = (String) request.getAttribute("resultInfo"); 96 | BehaviorStatus behaviorBean = behaviorService.getUserBehavior(userid); 97 | model.addAttribute("behaviorBean",behaviorBean); 98 | model.addAttribute("resultInfo",resultInfo); 99 | model.addAttribute("categorys",categorys); 100 | model.addAttribute("pictureQueryList",pictureQueryList); 101 | return "/user/manageCenter"; 102 | } 103 | 104 | 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/user/dao/PermissionMapper.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.user.dao; 2 | 3 | import com.flowingsun.user.entity.Permission; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public interface PermissionMapper { 8 | int deleteByPrimaryKey(Byte permissionid); 9 | 10 | int insert(Permission record); 11 | 12 | int insertSelective(Permission record); 13 | 14 | Permission selectByPrimaryKey(Byte permissionid); 15 | 16 | int updateByPrimaryKeySelective(Permission record); 17 | 18 | int updateByPrimaryKey(Permission record); 19 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/user/dao/PermissionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | permissionid, permission, description 11 | 12 | 18 | 19 | delete from permission 20 | where permissionid = #{permissionid,jdbcType=TINYINT} 21 | 22 | 23 | insert into permission (permissionid, permission, description 24 | ) 25 | values (#{permissionid,jdbcType=TINYINT}, #{permission,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR} 26 | ) 27 | 28 | 29 | insert into permission 30 | 31 | 32 | permissionid, 33 | 34 | 35 | permission, 36 | 37 | 38 | description, 39 | 40 | 41 | 42 | 43 | #{permissionid,jdbcType=TINYINT}, 44 | 45 | 46 | #{permission,jdbcType=VARCHAR}, 47 | 48 | 49 | #{description,jdbcType=VARCHAR}, 50 | 51 | 52 | 53 | 54 | update permission 55 | 56 | 57 | permission = #{permission,jdbcType=VARCHAR}, 58 | 59 | 60 | description = #{description,jdbcType=VARCHAR}, 61 | 62 | 63 | where permissionid = #{permissionid,jdbcType=TINYINT} 64 | 65 | 66 | update permission 67 | set permission = #{permission,jdbcType=VARCHAR}, 68 | description = #{description,jdbcType=VARCHAR} 69 | where permissionid = #{permissionid,jdbcType=TINYINT} 70 | 71 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/user/dao/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.user.dao; 2 | 3 | import com.flowingsun.user.entity.Role; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public interface RoleMapper { 8 | int deleteByPrimaryKey(Byte roleid); 9 | 10 | int insert(Role record); 11 | 12 | int insertSelective(Role record); 13 | 14 | Role selectByPrimaryKey(Byte roleid); 15 | 16 | int updateByPrimaryKeySelective(Role record); 17 | 18 | int updateByPrimaryKey(Role record); 19 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/user/dao/RoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | roleid, role, description 11 | 12 | 18 | 19 | delete from role 20 | where roleid = #{roleid,jdbcType=TINYINT} 21 | 22 | 23 | insert into role (roleid, role, description 24 | ) 25 | values (#{roleid,jdbcType=TINYINT}, #{role,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR} 26 | ) 27 | 28 | 29 | insert into role 30 | 31 | 32 | roleid, 33 | 34 | 35 | role, 36 | 37 | 38 | description, 39 | 40 | 41 | 42 | 43 | #{roleid,jdbcType=TINYINT}, 44 | 45 | 46 | #{role,jdbcType=VARCHAR}, 47 | 48 | 49 | #{description,jdbcType=VARCHAR}, 50 | 51 | 52 | 53 | 54 | update role 55 | 56 | 57 | role = #{role,jdbcType=VARCHAR}, 58 | 59 | 60 | description = #{description,jdbcType=VARCHAR}, 61 | 62 | 63 | where roleid = #{roleid,jdbcType=TINYINT} 64 | 65 | 66 | update role 67 | set role = #{role,jdbcType=VARCHAR}, 68 | description = #{description,jdbcType=VARCHAR} 69 | where roleid = #{roleid,jdbcType=TINYINT} 70 | 71 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/user/dao/RolePermissonMapper.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.user.dao; 2 | 3 | import com.flowingsun.user.entity.RolePermisson; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public interface RolePermissonMapper { 9 | 10 | Integer insertByRoleIdPermissionId(@Param("roleId") Integer roleId, @Param("permissionId") Integer permissionId); 11 | 12 | int insert(RolePermisson record); 13 | 14 | int insertSelective(RolePermisson record); 15 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/user/dao/RolePermissonMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | insert into role_permission (role_id, permission_id) 10 | values (#{roleId,jdbcType=TINYINT}, #{permissionId,jdbcType=TINYINT}) 11 | 12 | 13 | insert into role_permission 14 | 15 | 16 | role_id, 17 | 18 | 19 | permission_id, 20 | 21 | 22 | 23 | 24 | #{roleId,jdbcType=TINYINT}, 25 | 26 | 27 | #{permissionId,jdbcType=TINYINT}, 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/user/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.user.dao; 2 | 3 | import com.flowingsun.user.entity.User; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public interface UserMapper { 9 | 10 | Integer insertByUserRegister(User user); 11 | 12 | int insertSelective(User record); 13 | 14 | Long selectUseridByUserphone(String userphone); 15 | 16 | User selectByPrimaryKey(Long id); 17 | 18 | User selectByUserToken(User user); 19 | 20 | int selectUserCount(); 21 | 22 | int updateByPrimaryKey(User record); 23 | 24 | int updateByPrimaryKeySelective(User record); 25 | 26 | Integer updateUserStatusByUserphone(@Param("userstatus") int userstatus, @Param("userphone") String userphone); 27 | 28 | int updateUserHeadImage(@Param("userId") Long userId, @Param("headImage") String headImage); 29 | 30 | Integer deleteByUserphone(String userphone); 31 | 32 | int deleteByPrimaryKey(Long id); 33 | 34 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/user/dao/UserRoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.user.dao; 2 | 3 | import com.flowingsun.user.entity.UserRole; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public interface UserRoleMapper { 9 | int deleteByPrimaryKey(Long userId); 10 | 11 | int insert(UserRole record); 12 | 13 | int insertSelective(UserRole record); 14 | 15 | UserRole selectByPrimaryKey(Long userId); 16 | 17 | int updateByPrimaryKeySelective(UserRole record); 18 | 19 | int updateByPrimaryKey(UserRole record); 20 | 21 | Integer insertByUseridRoleid(@Param("userId") Long userId, @Param("roleId") Integer roleId); 22 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/user/dao/UserRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | user_id, role_id 10 | 11 | 17 | 18 | delete from user_role 19 | where user_id = #{userId,jdbcType=BIGINT} 20 | 21 | 22 | INSERT INTO user_role (user_id, role_id) 23 | VALUES (#{userId,jdbcType=BIGINT}, #{roleId,jdbcType=TINYINT}) 24 | 25 | 26 | insert into user_role (user_id, role_id) 27 | values (#{userId,jdbcType=BIGINT}, #{roleId,jdbcType=TINYINT}) 28 | 29 | 30 | insert into user_role 31 | 32 | 33 | user_id, 34 | 35 | 36 | role_id, 37 | 38 | 39 | 40 | 41 | #{userId,jdbcType=BIGINT}, 42 | 43 | 44 | #{roleId,jdbcType=TINYINT}, 45 | 46 | 47 | 48 | 49 | update user_role 50 | 51 | 52 | role_id = #{roleId,jdbcType=TINYINT}, 53 | 54 | 55 | where user_id = #{userId,jdbcType=BIGINT} 56 | 57 | 58 | update user_role 59 | set role_id = #{roleId,jdbcType=TINYINT} 60 | where user_id = #{userId,jdbcType=BIGINT} 61 | 62 | -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/user/entity/Permission.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.user.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Permission implements Serializable{ 6 | private Byte permissionid; 7 | 8 | private String permission; 9 | 10 | private String description; 11 | 12 | public Byte getPermissionid() { 13 | return permissionid; 14 | } 15 | 16 | public void setPermissionid(Byte permissionid) { 17 | this.permissionid = permissionid; 18 | } 19 | 20 | public String getPermission() { 21 | return permission; 22 | } 23 | 24 | public void setPermission(String permission) { 25 | this.permission = permission == null ? null : permission.trim(); 26 | } 27 | 28 | public String getDescription() { 29 | return description; 30 | } 31 | 32 | public void setDescription(String description) { 33 | this.description = description == null ? null : description.trim(); 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/user/entity/Role.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.user.entity; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | public class Role implements Serializable { 7 | private Byte roleid; 8 | 9 | private String role; 10 | 11 | private String description; 12 | 13 | private List permissionList; 14 | 15 | public List getPermissionList() { 16 | return permissionList; 17 | } 18 | 19 | public void setPermissionList(List permissionList) { 20 | this.permissionList = permissionList; 21 | } 22 | 23 | public Byte getRoleid() { 24 | return roleid; 25 | } 26 | 27 | public void setRoleid(Byte roleid) { 28 | this.roleid = roleid; 29 | } 30 | 31 | public String getRole() { 32 | return role; 33 | } 34 | 35 | public void setRole(String role) { 36 | this.role = role == null ? null : role.trim(); 37 | } 38 | 39 | public String getDescription() { 40 | return description; 41 | } 42 | 43 | public void setDescription(String description) { 44 | this.description = description == null ? null : description.trim(); 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "Role{" + 50 | "roleid=" + roleid + 51 | ", role='" + role + '\'' + 52 | ", description='" + description + '\'' + 53 | ", permissionList=" + permissionList + 54 | '}'; 55 | } 56 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/user/entity/RolePermisson.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.user.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | public class RolePermisson implements Serializable { 6 | private Byte roleId; 7 | 8 | private Byte permissionId; 9 | 10 | public Byte getRoleId() { 11 | return roleId; 12 | } 13 | 14 | public void setRoleId(Byte roleId) { 15 | this.roleId = roleId; 16 | } 17 | 18 | public Byte getPermissionId() { 19 | return permissionId; 20 | } 21 | 22 | public void setPermissionId(Byte permissionId) { 23 | this.permissionId = permissionId; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "RolePermisson{" + 29 | "roleId=" + roleId + 30 | ", permissionId=" + permissionId + 31 | '}'; 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/user/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.user.entity; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | public class User implements Serializable { 7 | private Long id; 8 | 9 | private String telephone; 10 | 11 | private String useremail; 12 | 13 | private String username; 14 | 15 | private String userpass; 16 | 17 | private String headImage; 18 | 19 | private String salt; 20 | 21 | private Integer userstatus; 22 | 23 | private List roleList; 24 | 25 | public String getSalt() { 26 | return salt; 27 | } 28 | 29 | public void setSalt(String salt) { 30 | this.salt = salt; 31 | } 32 | 33 | public Integer getUserstatus() { 34 | return userstatus; 35 | } 36 | 37 | public void setUserstatus(Integer userstatus) { 38 | this.userstatus = userstatus; 39 | } 40 | 41 | public Long getId() { 42 | return id; 43 | } 44 | 45 | public void setId(Long id) { 46 | this.id = id; 47 | } 48 | 49 | public String getTelephone() { 50 | return telephone; 51 | } 52 | 53 | public void setTelephone(String telephone) { 54 | this.telephone = telephone; 55 | } 56 | 57 | public String getUseremail() { 58 | return useremail; 59 | } 60 | 61 | public void setUseremail(String useremail) { 62 | this.useremail = useremail; 63 | } 64 | 65 | public String getUsername() { 66 | return username; 67 | } 68 | 69 | public void setUsername(String username) { 70 | this.username = username; 71 | } 72 | 73 | public String getUserpass() { 74 | return userpass; 75 | } 76 | 77 | public void setUserpass(String userpass) { 78 | this.userpass = userpass; 79 | } 80 | 81 | public String getHeadImage() { 82 | return headImage; 83 | } 84 | 85 | public void setHeadImage(String headImage) { 86 | this.headImage = headImage == null ? null : headImage.trim(); 87 | } 88 | 89 | public List getRoleList() { 90 | return roleList; 91 | } 92 | 93 | public void setRoleList(List roleList) { 94 | this.roleList = roleList; 95 | } 96 | 97 | @Override 98 | public String toString() { 99 | return "User{" + 100 | "id=" + id + 101 | ", telephone='" + telephone + '\'' + 102 | ", useremail='" + useremail + '\'' + 103 | ", username='" + username + '\'' + 104 | ", userpass='" + userpass + '\'' + 105 | ", headImage='" + headImage + '\'' + 106 | ", salt='" + salt + '\'' + 107 | ", userstatus=" + userstatus + 108 | ", roleList=" + roleList + 109 | '}'; 110 | } 111 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/user/entity/UserRole.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.user.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | public class UserRole implements Serializable { 6 | private Long userId; 7 | 8 | private Byte roleId; 9 | 10 | public Long getUserId() { 11 | return userId; 12 | } 13 | 14 | public void setUserId(Long userId) { 15 | this.userId = userId; 16 | } 17 | 18 | public Byte getRoleId() { 19 | return roleId; 20 | } 21 | 22 | public void setRoleId(Byte roleId) { 23 | this.roleId = roleId; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "UserRole{" + 29 | "userId=" + userId + 30 | ", roleId=" + roleId + 31 | '}'; 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /src/main/java/com/flowingsun/user/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.flowingsun.user.service; 2 | 3 | import com.flowingsun.article.vo.PageNotice; 4 | import com.flowingsun.user.entity.User; 5 | import org.springframework.ui.Model; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpSession; 9 | import java.io.UnsupportedEncodingException; 10 | import java.security.NoSuchAlgorithmException; 11 | 12 | public interface UserService { 13 | 14 | String UserRegister(User user, HttpServletRequest request) throws UnsupportedEncodingException, NoSuchAlgorithmException; 15 | 16 | String UserLogin(User user, HttpServletRequest request) throws UnsupportedEncodingException, NoSuchAlgorithmException; 17 | 18 | String UserLogout(HttpServletRequest request); 19 | 20 | User findUserByUserToken(User userInput); 21 | 22 | User getUserByUserId(Long userId); 23 | 24 | PageNotice userActivate(Integer code, String userphone, HttpServletRequest request); 25 | 26 | boolean setDefaultUserRole(String userphone); 27 | 28 | User getUserInfo(HttpServletRequest request); 29 | 30 | User getUserInfo(); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/conf/logstash-mysql.conf: -------------------------------------------------------------------------------- 1 | input { 2 | jdbc { 3 | jdbc_driver_library => "/usr/local/logstash-6.4.2/mysql-connector-java-5.1.36.jar" 4 | jdbc_driver_class => "com.mysql.jdbc.Driver" 5 | ##jdbc:mysql://localhost:3306/LyonBlog?characterEncoding=UTF-8&useSSL=false 6 | jdbc_connection_string => "jdbc:mysql://localhost:3306/LyonBlog" 7 | jdbc_user => "root" 8 | jdbc_password => "admin" 9 | schedule => "* * * * *" 10 | statement => "SELECT * FROM article WHERE article.edit_date >= :sql_last_value" 11 | jdbc_paging_enabled => "true" 12 | jdbc_page_size => "50000" 13 | } 14 | } 15 | output { 16 | elasticsearch { 17 | hosts => ["localhost:9200"] 18 | index => "articles" 19 | } 20 | stdout { codec => json_lines } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/resources/conf/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | #user nobody; 3 | worker_processes 1; 4 | 5 | error_log logs/error.log; 6 | #error_log logs/error.log notice; 7 | #error_log logs/error.log info; 8 | 9 | #pid logs/nginx.pid; 10 | 11 | 12 | events { 13 | worker_connections 1024; 14 | } 15 | 16 | 17 | http { 18 | include mime.types; 19 | default_type application/octet-stream; 20 | 21 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 22 | '$status $body_bytes_sent "$http_referer" ' 23 | '"$http_user_agent" "$http_x_forwarded_for"'; 24 | 25 | access_log logs/access.log main; 26 | 27 | sendfile on; 28 | #tcp_nopush on; 29 | 30 | #keepalive_timeout 0; 31 | keepalive_timeout 100; 32 | 33 | #gzip on; 34 | client_max_body_size 100m; 35 | 36 | upstream myServer{ #服务器/集群的名字 37 | #服务器ip和端口号 38 | server 127.0.0.1:8090; 39 | server 127.0.0.1:8091; 40 | } 41 | 42 | server { 43 | listen 80; 44 | server_name 127.0.0.1; 45 | 46 | client_max_body_size 100m; #添加对文件上传的限制 47 | access_log /usr/local/nginx/logs/serverAccess.log main; 48 | error_log /usr/local/nginx/logs/serverError.log debug; 49 | 50 | #charset koi8-r; 51 | 52 | #access_log logs/host.access.log main; 53 | 54 | location / { 55 | root html; 56 | index index.html index.htm; 57 | proxy_pass http://myServer; 58 | # 设置超时时间3秒(如果有一个server挂了自动切换到下一个) 59 | proxy_connect_timeout 3; 60 | } 61 | 62 | location ~\.(css|js|png|jpg|JPG|jpeg|svg|bmp|swf|gif|mp3|mp4|woff|ttf)$ { 63 | root /usr/local/nginx/html/; 64 | } 65 | 66 | #error_page 404 /404.html; 67 | 68 | # redirect server error pages to the static page /50x.html 69 | # 70 | error_page 500 502 503 504 /50x.html; 71 | location = /50x.html { 72 | root html; 73 | } 74 | 75 | # proxy the PHP scripts to Apache listening on 127.0.0.1:80 76 | # 77 | #location ~ \.php$ { 78 | # proxy_pass http://127.0.0.1; 79 | #} 80 | 81 | # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 82 | # 83 | #location ~ \.php$ { 84 | # root html; 85 | # fastcgi_pass 127.0.0.1:9000; 86 | # fastcgi_index index.php; 87 | # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 88 | # include fastcgi_params; 89 | #} 90 | 91 | # deny access to .htaccess files, if Apache's document root 92 | # concurs with nginx's one 93 | # 94 | #location ~ /\.ht { 95 | # deny all; 96 | #} 97 | } 98 | 99 | 100 | # another virtual host using mix of IP-, name-, and port-based configuration 101 | # 102 | #server { 103 | # listen 8000; 104 | # listen somename:8080; 105 | # server_name somename alias another.alias; 106 | 107 | # location / { 108 | # root html; 109 | # index index.html index.htm; 110 | # } 111 | #} 112 | 113 | 114 | # HTTPS server 115 | # 116 | #server { 117 | # listen 443 ssl; 118 | # server_name localhost; 119 | 120 | # ssl_certificate cert.pem; 121 | # ssl_certificate_key cert.key; 122 | 123 | # ssl_session_cache shared:SSL:1m; 124 | # ssl_session_timeout 5m; 125 | 126 | # ssl_ciphers HIGH:!aNULL:!MD5; 127 | # ssl_prefer_server_ciphers on; 128 | 129 | # location / { 130 | # root html; 131 | # index index.html index.htm; 132 | # } 133 | #} 134 | 135 | } 136 | -------------------------------------------------------------------------------- /src/main/resources/generatorConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 52 | 53 | 54 | 55 | 56 | 57 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 86 | 87 | 88 | 89 | 90 |
91 |
92 | 93 |
-------------------------------------------------------------------------------- /src/main/resources/jdbc.properties: -------------------------------------------------------------------------------- 1 | driverClassName=com.mysql.cj.jdbc.Driver 2 | validationQuery=SELECT 1 3 | jdbc_url=jdbc:mysql://localhost:3306/LyonBlog?useSSL=false&serverTimezone=UTC 4 | jdbc_username=root 5 | jdbc_password=password 6 | -------------------------------------------------------------------------------- /src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | ###################################### 2 | # log4j配置相关说明 3 | ###################################### 4 | #%p 输出优先级,即DEBUG,INFO,WARN,ERROR,FATAL 5 | #%r 输出自应用启动到输出该log信息耗费的毫秒数 6 | #%c 输出所属的类目,通常就是所在类的全名 7 | #%t 输出产生该日志事件的线程名 8 | #%m 输出代码中指定的信息 9 | #%n 输出一个回车换行符,Windows平台为“\r\n”,Unix平台为“\n” 10 | #%d 输出日志时间点的日期或时间,默认格式为ISO8601,也可以在其后指定格式,比如:%d{yyyy MM dd HH:mm:ss,SSS},输出类似: 2002年10月18日 22:10:28,921 11 | #%l 输出日志事件的发生位置,包括类目名、发生的线程,以及在代码中的行数。举例:Testlog4.main(TestLog4.java:10) 12 | #log4j提供4种布局: 13 | #org.apache.log4j.HTMLLayout(以HTML表格形式布局) 14 | #org.apache.log4j.PatternLayout(可以灵活地指定布局模式), 15 | #org.apache.log4j.SimpleLayout(包含日志信息的级别和信息字符串), 16 | #org.apache.log4j.TTCCLayout(包含日志产生的时间、线程、类别等等信息 17 | #log4j中有五级logger 输出级别: 18 | #FATAL 0 19 | #ERROR 3 20 | #WARN 4 21 | #INFO 6 22 | #DEBUG 7 23 | ###################################### 24 | # log4j相关配置 25 | ###################################### 26 | #日志输出级别设置 27 | log4j.rootLogger=stdout,error,warn,info,debug 28 | #设置stdout的日志输出控制台 29 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 30 | #输出日志到控制台的方式,默认为System.out 31 | log4j.appender.stdout.Target=System.out 32 | #设置使用灵活布局 33 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 34 | #灵活定义输出格式 35 | log4j.appender.stdout.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH:mm:ss}] %l %m %n 36 | 37 | #设置error的日志输出控制台 38 | log4j.appender.error=org.apache.log4j.DailyRollingFileAppender 39 | #设置error的输出日志 40 | 41 | #log4j.appender.error.File=/home/lyon/Java/PersonalProject/MyBlog/logs/error/error.log 42 | log4j.appender.error.File=/usr/local/project/LyonBlog/logs/error/error.log 43 | #设置为按天输出(#'_' yyyy-MM-dd-HH 每小时;'_' yyyy-MM-dd-HH-mm 每分钟) 44 | log4j.appender.debug.DatePattern='_' yyyy-MM-dd 45 | #设置error的日志最大限制 46 | #log4j.appender.error.MaxFileSize=1024KB 47 | #最多只保存100个备份文件 48 | #log4j.appender.error.MaxBackupIndex=100 49 | #输出ERROR级别以上的日志 50 | log4j.appender.error.Threshold=ERROR 51 | #设置使用灵活布局 52 | log4j.appender.error.layout=org.apache.log4j.PatternLayout 53 | #灵活定义输出格式 54 | log4j.appender.error.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH:mm:ss}] %l %t %m %n 55 | 56 | #设置warn的日志输出控制台 57 | log4j.appender.warn=org.apache.log4j.DailyRollingFileAppender 58 | #设置warn的输出日志 59 | #log4j.appender.warn.File=/home/lyon/Java/PersonalProject/MyBlog/logs/warn/warn.log 60 | log4j.appender.warn.File=/usr/local/project/LyonBlog/logs/warn/warn.log 61 | #设置为按天输出(#'_' yyyy-MM-dd-HH 每小时;'_' yyyy-MM-dd-HH-mm 每分钟) 62 | log4j.appender.debug.DatePattern='_' yyyy-MM-dd 63 | #设置warn的日志最大限制 64 | #log4j.appender.warn.MaxFileSize=1024KB 65 | #最多只保存50个备份文件 66 | #log4j.appender.warn.MaxBackupIndex=50 67 | #输出WARN级别以上的日志 68 | log4j.appender.warn.Threshold=WARN 69 | #设置使用灵活布局 70 | log4j.appender.warn.layout=org.apache.log4j.PatternLayout 71 | #灵活定义输出格式 72 | log4j.appender.warn.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH:mm:ss}] %l %t %m %n 73 | 74 | #设置info的日志输出控制台 75 | log4j.appender.info=org.apache.log4j.DailyRollingFileAppender 76 | #设置info的输出日志 77 | #log4j.appender.info.File=/home/lyon/Java/PersonalProject/MyBlog/logs/info/info.log 78 | log4j.appender.info.File=/usr/local/project/LyonBlog/logs/info/info.log 79 | #设置为按天输出(#'_' yyyy-MM-dd-HH 每小时;'_' yyyy-MM-dd-HH-mm 每分钟) 80 | log4j.appender.debug.DatePattern='_' yyyy-MM-dd 81 | #设置info的日志最大限制 82 | #log4j.appender.info.MaxFileSize=1024KB 83 | #最多只保存200个备份文件 84 | #log4j.appender.info.MaxBackupIndex=200 85 | #输出INFO级别以上的日志 86 | log4j.appender.info.Threshold=INFO 87 | #设置使用灵活布局 88 | log4j.appender.info.layout=org.apache.log4j.PatternLayout 89 | #灵活定义输出格式 90 | log4j.appender.info.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH:mm:ss}] %l %t %m %n 91 | 92 | #设置debug的日志输出控制台 93 | log4j.appender.debug=org.apache.log4j.DailyRollingFileAppender 94 | #设置debug的输出日志 95 | #log4j.appender.debug.File=/home/lyon/Java/PersonalProject/MyBlog/logs/debug/debug.log 96 | log4j.appender.debug.File=/usr/local/project/LyonBlog/logs/debug/debug.log 97 | #设置为按天输出(#'_' yyyy-MM-dd-HH 每小时;'_' yyyy-MM-dd-HH-mm 每分钟) 98 | log4j.appender.debug.DatePattern='_' yyyy-MM-dd 99 | #设置debug的日志最大限制 100 | #log4j.appender.debug.MaxFileSize=2048KB 101 | #最多只保存100个备份文件 102 | #log4j.appender.debug.MaxBackupIndex=100 103 | #输出DEBUG级别以上的日志 104 | log4j.appender.debug.Threshold=DEBUG 105 | #设置使用灵活布局 106 | log4j.appender.debug.layout=org.apache.log4j.PatternLayout 107 | #灵活定义输出格式 108 | log4j.appender.debug.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH:mm:ss}] %l %t %m %n 109 | 110 | ###显示SQL语句部分 111 | log4j.logger.com.mybatis=DEBUG 112 | log4j.logger.com.mybatis.common.jdbc.SimpleDataSource=DEBUG 113 | log4j.logger.com.mybatis.common.jdbc.ScriptRunner=DEBUG 114 | log4j.logger.com.mybatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG 115 | log4j.logger.java.sql.Connection=DEBUG 116 | log4j.logger.java.sql.Statement=DEBUG 117 | log4j.logger.java.sql.PreparedStatement=DEBUG 118 | log4j.logger.java.sql.ResultSet=DEBUG 119 | -------------------------------------------------------------------------------- /src/main/resources/log4j2.properties: -------------------------------------------------------------------------------- 1 | appender.console.type = Console 2 | appender.console.name = console 3 | appender.console.layout.type = PatternLayout 4 | 5 | rootLogger.level = info 6 | rootLogger.appenderRef.console.ref = console -------------------------------------------------------------------------------- /src/main/resources/mailConfig.properties: -------------------------------------------------------------------------------- 1 | mailHost=smtp.qq.com 2 | mailPort=465 3 | mailUsername=76xxxxxxx56@qq.com 4 | mailPassword=tvbqwkpgiwigbffe 5 | mailFrom=76XXXXXX56@qq.com 6 | mailTimeout=10000 7 | -------------------------------------------------------------------------------- /src/main/resources/spring-mvc.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | text/html;charset=UTF-8 40 | application/json;charset=UTF-8 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | utf-8 67 | utf-8 68 | false 69 | 1 70 | false 71 | 72 | 73 | 74 | 75 | 76 | 77 | 403 78 | 403 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /src/main/resources/spring-shiro.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | /static/**=anon 40 | /login=anon 41 | /article/uploadfile=anon 42 | 43 | /user/userinfo=anon 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/main/resources/sql/article_main_categary.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : 百度云服务器 5 | Source Server Type : MySQL 6 | Source Server Version : 50646 7 | Source Host : 106.13.189.205:3306 8 | Source Schema : LyonBlog 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50646 12 | File Encoding : 65001 13 | 14 | Date: 15/12/2019 22:52:41 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for article_main_categary 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `article_main_categary`; 24 | CREATE TABLE `article_main_categary` ( 25 | `id` int(10) NOT NULL AUTO_INCREMENT, 26 | `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, 27 | PRIMARY KEY (`id`) USING BTREE 28 | ) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; 29 | 30 | -- ---------------------------- 31 | -- Records of article_main_categary 32 | -- ---------------------------- 33 | INSERT INTO `article_main_categary` VALUES (1, 'Code'); 34 | INSERT INTO `article_main_categary` VALUES (2, '数据库'); 35 | INSERT INTO `article_main_categary` VALUES (3, '服务器'); 36 | INSERT INTO `article_main_categary` VALUES (4, '操作系统'); 37 | INSERT INTO `article_main_categary` VALUES (5, '计算机科学'); 38 | INSERT INTO `article_main_categary` VALUES (6, '深度学习'); 39 | INSERT INTO `article_main_categary` VALUES (7, '工具'); 40 | INSERT INTO `article_main_categary` VALUES (8, '资源'); 41 | INSERT INTO `article_main_categary` VALUES (9, '生活'); 42 | 43 | SET FOREIGN_KEY_CHECKS = 1; 44 | -------------------------------------------------------------------------------- /src/main/resources/sql/article_second_categary.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : 百度云服务器 5 | Source Server Type : MySQL 6 | Source Server Version : 50646 7 | Source Host : 106.13.189.205:3306 8 | Source Schema : LyonBlog 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50646 12 | File Encoding : 65001 13 | 14 | Date: 15/12/2019 22:52:49 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for article_second_categary 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `article_second_categary`; 24 | CREATE TABLE `article_second_categary` ( 25 | `id` int(10) NOT NULL AUTO_INCREMENT, 26 | `mainId` int(10) NULL DEFAULT NULL, 27 | `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, 28 | PRIMARY KEY (`id`) USING BTREE, 29 | INDEX `fk_secondary_category`(`mainId`) USING BTREE, 30 | CONSTRAINT `fk_secondary_category` FOREIGN KEY (`mainId`) REFERENCES `article_main_categary` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT 31 | ) ENGINE = InnoDB AUTO_INCREMENT = 44 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; 32 | 33 | -- ---------------------------- 34 | -- Records of article_second_categary 35 | -- ---------------------------- 36 | INSERT INTO `article_second_categary` VALUES (1, 1, 'Java基础'); 37 | INSERT INTO `article_second_categary` VALUES (2, 1, 'Python基础'); 38 | INSERT INTO `article_second_categary` VALUES (3, 1, 'Java项目'); 39 | INSERT INTO `article_second_categary` VALUES (4, 1, 'Python项目'); 40 | INSERT INTO `article_second_categary` VALUES (5, 1, 'Spring'); 41 | INSERT INTO `article_second_categary` VALUES (6, 1, 'JVM'); 42 | INSERT INTO `article_second_categary` VALUES (7, 1, 'Socket'); 43 | INSERT INTO `article_second_categary` VALUES (8, 1, '多线程'); 44 | INSERT INTO `article_second_categary` VALUES (9, 1, '数据分析可视化'); 45 | INSERT INTO `article_second_categary` VALUES (10, 1, '爬虫'); 46 | INSERT INTO `article_second_categary` VALUES (11, 1, 'web前端'); 47 | INSERT INTO `article_second_categary` VALUES (12, 1, 'C/C++'); 48 | INSERT INTO `article_second_categary` VALUES (13, 2, 'MySQL'); 49 | INSERT INTO `article_second_categary` VALUES (14, 2, 'MongoDB'); 50 | INSERT INTO `article_second_categary` VALUES (15, 3, 'Tomcat'); 51 | INSERT INTO `article_second_categary` VALUES (16, 3, 'Netty'); 52 | INSERT INTO `article_second_categary` VALUES (17, 3, 'Redis'); 53 | INSERT INTO `article_second_categary` VALUES (18, 3, 'Elasticsearch'); 54 | INSERT INTO `article_second_categary` VALUES (19, 3, 'Docker'); 55 | INSERT INTO `article_second_categary` VALUES (20, 3, 'Nginx'); 56 | INSERT INTO `article_second_categary` VALUES (21, 4, 'Ubuntu'); 57 | INSERT INTO `article_second_categary` VALUES (22, 4, 'Linux'); 58 | INSERT INTO `article_second_categary` VALUES (23, 4, 'Windows'); 59 | INSERT INTO `article_second_categary` VALUES (24, 5, '计算机网络'); 60 | INSERT INTO `article_second_categary` VALUES (25, 5, '数据结构和算法'); 61 | INSERT INTO `article_second_categary` VALUES (26, 5, '计算机组成原理'); 62 | INSERT INTO `article_second_categary` VALUES (27, 5, '计算机操作系统'); 63 | INSERT INTO `article_second_categary` VALUES (28, 6, '基础概念'); 64 | INSERT INTO `article_second_categary` VALUES (29, 6, '目标检测'); 65 | INSERT INTO `article_second_categary` VALUES (30, 6, 'GAN'); 66 | INSERT INTO `article_second_categary` VALUES (31, 6, 'OpenCV'); 67 | INSERT INTO `article_second_categary` VALUES (32, 6, 'AI平台'); 68 | INSERT INTO `article_second_categary` VALUES (33, 7, '在线工具'); 69 | INSERT INTO `article_second_categary` VALUES (34, 8, '软件'); 70 | INSERT INTO `article_second_categary` VALUES (35, 8, '电影'); 71 | INSERT INTO `article_second_categary` VALUES (36, 8, '音乐'); 72 | INSERT INTO `article_second_categary` VALUES (37, 8, 'PDF书'); 73 | INSERT INTO `article_second_categary` VALUES (38, 8, '公开课'); 74 | INSERT INTO `article_second_categary` VALUES (39, 9, '个人感悟'); 75 | INSERT INTO `article_second_categary` VALUES (40, 9, '文章转载'); 76 | INSERT INTO `article_second_categary` VALUES (41, 9, '朝花夕拾'); 77 | INSERT INTO `article_second_categary` VALUES (42, 9, '寻常巷陌'); 78 | INSERT INTO `article_second_categary` VALUES (43, 9, '吃喝玩乐'); 79 | 80 | SET FOREIGN_KEY_CHECKS = 1; 81 | -------------------------------------------------------------------------------- /src/main/resources/sql/permission.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : 百度云服务器 5 | Source Server Type : MySQL 6 | Source Server Version : 50646 7 | Source Host : 106.13.189.205:3306 8 | Source Schema : LyonBlog 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50646 12 | File Encoding : 65001 13 | 14 | Date: 15/12/2019 22:55:45 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for permission 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `permission`; 24 | CREATE TABLE `permission` ( 25 | `permissionid` tinyint(20) NOT NULL, 26 | `permission` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, 27 | `description` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, 28 | PRIMARY KEY (`permissionid`) USING BTREE 29 | ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; 30 | 31 | -- ---------------------------- 32 | -- Records of permission 33 | -- ---------------------------- 34 | INSERT INTO `permission` VALUES (1, 'admin:delete', '删除文章操作'); 35 | INSERT INTO `permission` VALUES (2, 'admin:editBlog', '编辑文章内容'); 36 | INSERT INTO `permission` VALUES (3, 'admin:editTag', '修改文章标签'); 37 | INSERT INTO `permission` VALUES (4, 'article:changeCategory', '修改文章分类'); 38 | INSERT INTO `permission` VALUES (5, 'admin:home', '后台管理首页'); 39 | INSERT INTO `permission` VALUES (6, 'article:comment', '评论文章'); 40 | INSERT INTO `permission` VALUES (7, 'behavior:thank', '感谢文章'); 41 | INSERT INTO `permission` VALUES (8, 'article:collect', '收藏文章'); 42 | INSERT INTO `permission` VALUES (9, 'article:share', '分享文章'); 43 | INSERT INTO `permission` VALUES (10, 'article:single', '浏览某篇文章'); 44 | INSERT INTO `permission` VALUES (11, 'article:category', '浏览分类文章'); 45 | INSERT INTO `permission` VALUES (12, 'user:userInfo', '取用户登录信息'); 46 | INSERT INTO `permission` VALUES (13, 'behavior:uploadImage', '上传图片'); 47 | INSERT INTO `permission` VALUES (14, 'behavior:elasticSearch', '关键字文章搜索'); 48 | 49 | SET FOREIGN_KEY_CHECKS = 1; 50 | -------------------------------------------------------------------------------- /src/main/resources/sql/role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : 百度云服务器 5 | Source Server Type : MySQL 6 | Source Server Version : 50646 7 | Source Host : 106.13.189.205:3306 8 | Source Schema : LyonBlog 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50646 12 | File Encoding : 65001 13 | 14 | Date: 15/12/2019 22:55:37 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for role 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `role`; 24 | CREATE TABLE `role` ( 25 | `roleid` tinyint(20) NOT NULL, 26 | `role` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, 27 | `description` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '角色描述', 28 | PRIMARY KEY (`roleid`) USING BTREE 29 | ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; 30 | 31 | -- ---------------------------- 32 | -- Records of role 33 | -- ---------------------------- 34 | INSERT INTO `role` VALUES (1, 'blogAdmin', '系统创建者'); 35 | INSERT INTO `role` VALUES (2, 'blogManager', '博客管理员'); 36 | INSERT INTO `role` VALUES (3, 'consumer', 'VIP会员'); 37 | INSERT INTO `role` VALUES (4, 'register', '注册用户'); 38 | INSERT INTO `role` VALUES (5, 'register_unchecked', '未激活注册用户'); 39 | INSERT INTO `role` VALUES (6, 'staff', '普通游客'); 40 | 41 | SET FOREIGN_KEY_CHECKS = 1; 42 | -------------------------------------------------------------------------------- /src/main/resources/sql/role_permission.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : 百度云服务器 5 | Source Server Type : MySQL 6 | Source Server Version : 50646 7 | Source Host : 106.13.189.205:3306 8 | Source Schema : LyonBlog 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50646 12 | File Encoding : 65001 13 | 14 | Date: 15/12/2019 22:55:22 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for role_permission 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `role_permission`; 24 | CREATE TABLE `role_permission` ( 25 | `role_id` tinyint(20) NOT NULL, 26 | `permission_id` tinyint(20) NOT NULL, 27 | UNIQUE INDEX `role_permission_nuique`(`role_id`, `permission_id`) USING BTREE 28 | ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; 29 | 30 | -- ---------------------------- 31 | -- Records of role_permission 32 | -- ---------------------------- 33 | INSERT INTO `role_permission` VALUES (1, 1); 34 | INSERT INTO `role_permission` VALUES (1, 2); 35 | INSERT INTO `role_permission` VALUES (1, 3); 36 | INSERT INTO `role_permission` VALUES (1, 4); 37 | INSERT INTO `role_permission` VALUES (1, 5); 38 | INSERT INTO `role_permission` VALUES (1, 6); 39 | INSERT INTO `role_permission` VALUES (1, 7); 40 | INSERT INTO `role_permission` VALUES (1, 8); 41 | INSERT INTO `role_permission` VALUES (1, 9); 42 | INSERT INTO `role_permission` VALUES (1, 10); 43 | INSERT INTO `role_permission` VALUES (1, 11); 44 | INSERT INTO `role_permission` VALUES (1, 12); 45 | INSERT INTO `role_permission` VALUES (1, 13); 46 | INSERT INTO `role_permission` VALUES (1, 14); 47 | INSERT INTO `role_permission` VALUES (2, 3); 48 | INSERT INTO `role_permission` VALUES (2, 5); 49 | INSERT INTO `role_permission` VALUES (2, 6); 50 | INSERT INTO `role_permission` VALUES (2, 7); 51 | INSERT INTO `role_permission` VALUES (2, 8); 52 | INSERT INTO `role_permission` VALUES (2, 9); 53 | INSERT INTO `role_permission` VALUES (2, 10); 54 | INSERT INTO `role_permission` VALUES (2, 11); 55 | INSERT INTO `role_permission` VALUES (2, 12); 56 | INSERT INTO `role_permission` VALUES (2, 13); 57 | INSERT INTO `role_permission` VALUES (2, 14); 58 | INSERT INTO `role_permission` VALUES (3, 6); 59 | INSERT INTO `role_permission` VALUES (3, 7); 60 | INSERT INTO `role_permission` VALUES (3, 8); 61 | INSERT INTO `role_permission` VALUES (3, 9); 62 | INSERT INTO `role_permission` VALUES (3, 10); 63 | INSERT INTO `role_permission` VALUES (3, 11); 64 | INSERT INTO `role_permission` VALUES (3, 12); 65 | INSERT INTO `role_permission` VALUES (3, 13); 66 | INSERT INTO `role_permission` VALUES (3, 14); 67 | INSERT INTO `role_permission` VALUES (4, 6); 68 | INSERT INTO `role_permission` VALUES (4, 7); 69 | INSERT INTO `role_permission` VALUES (4, 8); 70 | INSERT INTO `role_permission` VALUES (4, 9); 71 | INSERT INTO `role_permission` VALUES (4, 10); 72 | INSERT INTO `role_permission` VALUES (4, 11); 73 | INSERT INTO `role_permission` VALUES (4, 12); 74 | INSERT INTO `role_permission` VALUES (4, 13); 75 | INSERT INTO `role_permission` VALUES (4, 14); 76 | INSERT INTO `role_permission` VALUES (5, 9); 77 | INSERT INTO `role_permission` VALUES (5, 10); 78 | INSERT INTO `role_permission` VALUES (5, 11); 79 | INSERT INTO `role_permission` VALUES (5, 12); 80 | INSERT INTO `role_permission` VALUES (5, 14); 81 | INSERT INTO `role_permission` VALUES (6, 9); 82 | INSERT INTO `role_permission` VALUES (6, 10); 83 | INSERT INTO `role_permission` VALUES (6, 11); 84 | INSERT INTO `role_permission` VALUES (6, 12); 85 | 86 | SET FOREIGN_KEY_CHECKS = 1; 87 | -------------------------------------------------------------------------------- /src/main/resources/sql/user_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : 百度云服务器 5 | Source Server Type : MySQL 6 | Source Server Version : 50646 7 | Source Host : 106.13.189.205:3306 8 | Source Schema : LyonBlog 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50646 12 | File Encoding : 65001 13 | 14 | Date: 16/12/2019 13:33:34 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for user_role 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `user_role`; 24 | CREATE TABLE `user_role` ( 25 | `user_id` bigint(20) NOT NULL, 26 | `role_id` tinyint(20) NOT NULL, 27 | PRIMARY KEY (`user_id`) USING BTREE 28 | ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; 29 | 30 | -- ---------------------------- 31 | -- Records of user_role 32 | -- ---------------------------- 33 | INSERT INTO `user_role` VALUES (2, 1); 34 | 35 | SET FOREIGN_KEY_CHECKS = 1; 36 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | LyonBlog 9 | 10 | 11 | contextConfigLocation 12 | classpath:spring-cfg.xml 13 | 14 | 15 | 16 | 17 | 18 | encodingFilter 19 | org.springframework.web.filter.CharacterEncodingFilter 20 | true 21 | 22 | encoding 23 | utf-8 24 | 25 | 26 | 27 | encodingFilter 28 | /* 29 | 30 | 31 | 32 | 33 | org.springframework.web.context.ContextLoaderListener 34 | 35 | 36 | 37 | 38 | springSessionRepositoryFilter 39 | org.springframework.web.filter.DelegatingFilterProxy 40 | 41 | 42 | springSessionRepositoryFilter 43 | /* 44 | REQUEST 45 | ERROR 46 | 47 | 48 | 49 | 50 | 51 | shiroFilter 52 | org.springframework.web.filter.DelegatingFilterProxy 53 | true 54 | 55 | 56 | targetFilterLifecycle 57 | true 58 | 59 | 60 | 61 | shiroFilter 62 | /* 63 | 64 | 65 | 66 | 67 | SpringMVC 68 | org.springframework.web.servlet.DispatcherServlet 69 | 70 | contextConfigLocation 71 | classpath:spring-mvc.xml 72 | 73 | 1 74 | true 75 | 76 | 77 | SpringMVC 78 | / 79 | 80 | 81 | 82 | default 83 | /static/* 84 | 85 | 86 | 87 | log4jConfigLocation 88 | classpath:log4j.properties 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | DruidStatView 101 | com.alibaba.druid.support.http.StatViewServlet 102 | 103 | 104 | resetEnable 105 | false 106 | 107 | 108 | 109 | loginUsername 110 | druid123 111 | 112 | 113 | 114 | loginPassword 115 | druid123 116 | 117 | 118 | 119 | DruidStatView 120 | /druid/* 121 | 122 | 123 | 124 | 125 | DruidWebStatFilter 126 | com.alibaba.druid.support.http.WebStatFilter 127 | 128 | exclusions 129 | *.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/* 130 | 131 | 132 | 133 | DruidWebStatFilter 134 | /* 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /src/main/webapp/error/400.vm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flowingsun007/LyonBlog/4f0f20696d95ac3454e14a1f92130dd228b0b3b5/src/main/webapp/error/400.vm -------------------------------------------------------------------------------- /src/main/webapp/static/userFile/images/elegent.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flowingsun007/LyonBlog/4f0f20696d95ac3454e14a1f92130dd228b0b3b5/src/main/webapp/static/userFile/images/elegent.jpeg --------------------------------------------------------------------------------