From d358591da28ed0bb606b27117cbfa5c3a0be4fb1 Mon Sep 17 00:00:00 2001 From: "yadong.zhang" Date: Sat, 1 Sep 2018 09:48:55 +0800 Subject: [PATCH] =?UTF-8?q?1.=20springboot=20->=202.0=202.=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=8D=9A=E5=AE=A2=E8=BF=81=E7=A7=BB=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81csdn=E3=80=81iteye=E5=92=8C=E6=85=95?= =?UTF-8?q?=E8=AF=BE=E7=BD=91=E5=B9=B3=E5=8F=B0=203.=20=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E5=8F=82=E8=80=83readme.md=E5=92=8Cupdate.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 178 +- blog-admin/pom.xml | 91 +- .../blog/controller/ErrorPagesController.java | 37 +- .../controller/ExceptionHandleController.java | 24 +- .../blog/controller/PassportController.java | 26 +- .../zyd/blog/controller/RenderController.java | 71 +- .../blog/controller/RestApiController.java | 39 + .../controller/RestArticleController.java | 17 + .../controller/RestCommentController.java | 37 +- .../blog/controller/RestConfigController.java | 3 + .../blog/controller/RestLinkController.java | 7 + .../blog/controller/RestNoticeController.java | 9 + .../controller/RestRemoverController.java | 56 + .../controller/RestResourcesController.java | 8 + .../blog/controller/RestRoleController.java | 9 + .../blog/controller/RestTagController.java | 7 + .../controller/RestTemplateController.java | 7 + .../blog/controller/RestTypeController.java | 24 +- .../blog/controller/RestUpdateController.java | 7 + .../blog/controller/RestUserController.java | 10 +- .../com/zyd/blog/core/config/ShiroConfig.java | 38 +- .../zyd/blog/core/config/WebMvcConfig.java | 47 + .../RememberAuthenticationInterceptor.java | 81 + .../com/zyd/blog/core/shiro/ShiroService.java | 6 +- .../zyd/blog/core/shiro/realm/ShiroRealm.java | 21 +- .../websocket}/config/WebSocketConfig.java | 7 +- .../websocket/server/ZydWebsocketServer.java | 45 +- .../core/websocket/util}/WebSocketUtil.java | 52 +- .../src/main/resources/application-dev.yml | 46 + .../src/main/resources/application-test.yml | 50 + blog-admin/src/main/resources/application.yml | 76 +- blog-admin/src/main/resources/banner.txt | 22 + .../src/main/resources/logback-spring.xml | 55 + blog-admin/src/main/resources/logback.xml | 51 - .../resources/static/assets/css/zhyd.core.css | 6 +- .../static/assets/images/back_disabled.png | Bin 1361 -> 0 bytes .../static/assets/images/back_enabled.png | Bin 1379 -> 0 bytes .../assets/images/back_enabled_hover.png | Bin 1375 -> 0 bytes .../static/assets/images/favicon.ico | Bin 4286 -> 4286 bytes .../static/assets/images/favicon.png | Bin 1678 -> 0 bytes .../static/assets/images/forward_disabled.png | Bin 1363 -> 0 bytes .../static/assets/images/forward_enabled.png | Bin 1380 -> 0 bytes .../assets/images/forward_enabled_hover.png | Bin 1379 -> 0 bytes .../static/assets/images/picture.jpg | Bin 25720 -> 0 bytes .../static/assets/images/reward/wx_code.png | Bin 0 -> 72452 bytes .../assets/images/reward/wx_reward_code.png | Bin 0 -> 191021 bytes .../static/assets/images/reward/zfb_code.png | Bin 0 -> 76729 bytes .../assets/images/spider/cookie/cookie.png | Bin 0 -> 343513 bytes .../static/assets/images/spider/uid/csdn.png | Bin 0 -> 229372 bytes .../static/assets/images/spider/uid/imooc.png | Bin 0 -> 187879 bytes .../static/assets/images/spider/uid/iteye.png | Bin 0 -> 79916 bytes .../static/assets/images/transparent.png | Bin 1084 -> 0 bytes .../assets/js/codemirror.inline-attachment.js | 91 + .../static/assets/js/inline-attachment.js | 399 ++ .../static/assets/js/jquery.smartWizard.js | 451 ++ .../static/assets/js/wangEditor.min.js | 22 - .../resources/static/assets/js/zhyd.core.js | 325 +- .../static/assets/js/zhyd.publish-article.js | 178 + .../resources/static/assets/js/zyd.table.js | 22 +- .../resources/static/assets/js/zyd.tool.js | 110 +- .../main/resources/templates/article/list.ftl | 122 +- .../templates/article/publish-md.ftl | 294 ++ .../resources/templates/article/publish.ftl | 339 +- .../main/resources/templates/article/tags.ftl | 126 +- .../resources/templates/article/types.ftl | 211 +- .../main/resources/templates/comment/list.ftl | 377 +- .../src/main/resources/templates/config.ftl | 121 +- .../main/resources/templates/error/401.ftl | 5 +- .../main/resources/templates/error/403.ftl | 5 +- .../main/resources/templates/error/404.ftl | 5 +- .../main/resources/templates/error/500.ftl | 5 +- .../src/main/resources/templates/icons.ftl | 2286 +------- .../{layout/header.ftl => include/macros.ftl} | 26 +- .../src/main/resources/templates/index.ftl | 97 +- .../resources/templates/layout/footer.ftl | 6 +- .../resources/templates/layout/setting.ftl | 80 +- .../resources/templates/layout/sidebar.ftl | 12 +- .../main/resources/templates/link/list.ftl | 344 +- .../src/main/resources/templates/login.ftl | 92 +- .../main/resources/templates/notice/list.ftl | 228 +- .../main/resources/templates/notification.ftl | 47 + .../main/resources/templates/remover/list.ftl | 380 ++ .../resources/templates/resources/list.ftl | 164 +- .../main/resources/templates/role/list.ftl | 210 +- .../src/main/resources/templates/shiro.ftl | 5 +- .../resources/templates/template/list.ftl | 112 +- .../main/resources/templates/update/list.ftl | 146 +- .../main/resources/templates/user/list.ftl | 258 +- .../zyd/blog/BlogAdminApplicationTests.java | 106 +- blog-core/pom.xml | 126 +- .../business/aspect/BussinessLogAspect.java | 55 +- .../business/aspect/RedisCacheAspect.java | 59 +- .../blog/business/aspect}/RenderAspects.java | 10 +- .../blog/business/consts/SessionConst.java | 5 + .../zyd/blog/business/dto/BizCommentDTO.java | 15 +- .../com/zyd/blog/business/entity/Article.java | 26 + .../com/zyd/blog/business/entity/Comment.java | 2 +- .../com/zyd/blog/business/entity/Config.java | 8 + .../com/zyd/blog/business/entity/UserPwd.java | 49 + .../business/service/BizArticleService.java | 11 +- .../business/service/BizCommentService.java | 8 + .../blog/business/service/BizTypeService.java | 6 + .../blog/business/service/RedisService.java | 17 +- .../blog/business/service/RemoverService.java | 17 + .../blog/business/service/SysUserService.java | 10 + .../service/impl/BizArticleServiceImpl.java | 22 +- .../service/impl/BizCommentServiceImpl.java | 36 +- .../service/impl/BizTypeServiceImpl.java | 89 +- .../service/impl/RedisServiceImpl.java | 45 +- .../service/impl/RemoverServiceImpl.java | 117 + .../service/impl/SysUserServiceImpl.java | 27 + .../framework/config/ErrorPagesConfig.java | 28 +- .../blog/framework/config/RedisConfig.java | 16 +- .../blog/framework/config/TomcatConfig.java | 30 + .../framework/object/AbstractService.java | 80 +- .../framework/property/RedisProperties.java | 14 +- .../framework/property/ShiroProperties.java | 52 + .../framework/redis/CustomRedisManager.java | 203 + .../runner/BlogApplicationRunner.java | 48 + .../framework/tag/CustomTagDirective.java | 18 +- .../blog/persistence/beans/BizArticle.java | 3 + .../zyd/blog/persistence/beans/SysConfig.java | 1 + .../persistence/mapper/BizArticleMapper.java | 20 +- .../persistence/mapper/BizTypeMapper.java | 14 +- .../java/com/zyd/blog/util/AspectUtil.java | 101 + .../java/com/zyd/blog/util/CacheKeyUtil.java | 21 +- .../java/com/zyd/blog/util/RegexUtils.java | 67 + .../java/com/zyd/blog/util/RequestUtil.java | 78 + .../com/zyd/blog/util/RestClientUtil.java | 2 +- .../java/com/zyd/blog/util/SessionUtil.java | 7 +- .../java/com/zyd/blog/util/XssKillerUtil.java | 113 + .../resources/mybatis/BizArticleMapper.xml | 31 +- .../main/resources/mybatis/BizTypeMapper.xml | 36 + .../resources/mybatis/SysConfigMapper.xml | 1 + .../resources/mybatis/SysResourceMapper.xml | 4 +- .../main/resources/mybatis/SysRoleMapper.xml | 3 + .../main/resources/mybatis/SysUserMapper.xml | 14 +- .../java/com/zyd/blog/util/XssKillerTest.java | 62 + blog-spider/.gitignore | 25 + blog-spider/pom.xml | 57 + .../com/zyd/blog/spider/model/Article.java | 80 + .../com/zyd/blog/spider/model/BaseModel.java | 233 + .../com/zyd/blog/spider/model/Cookie.java | 30 + .../com/zyd/blog/spider/model/CsdnModel.java | 32 + .../com/zyd/blog/spider/model/ImoocModel.java | 29 + .../com/zyd/blog/spider/model/IteyeModel.java | 32 + .../processor/ArticleSpiderProcessor.java | 106 + .../blog/spider/processor/BaseProcessor.java | 75 + .../blog/spider/processor/HtmlProcessor.java | 29 + .../blog/spider/processor/JsonProcessor.java | 26 + .../zyd/blog/spider/processor/Processor.java | 9 + .../zyd/blog/spider/processor/ZydSpider.java | 21 + .../com/zyd/blog/spider/util/WriterUtil.java | 51 + .../src/main/resources/log4j.properties | 8 + blog-web/pom.xml | 83 +- .../java/com/zyd/blog/BlogWebApplication.java | 14 +- .../blog/controller/ErrorPagesController.java | 37 +- .../src/main/resources/application-dev.yml | 46 + .../src/main/resources/application-test.yml | 45 + blog-web/src/main/resources/application.yml | 77 +- blog-web/src/main/resources/banner.txt | 22 + .../src/main/resources/logback-spring.xml | 81 + blog-web/src/main/resources/logback.xml | 51 - .../resources/static/css/zhyd.comment.css | 23 +- .../main/resources/static/css/zhyd.core.css | 124 +- .../src/main/resources/static/img/author.png | Bin 0 -> 19093 bytes .../static/img/default_article_cover.jpg | Bin 56041 -> 24945 bytes .../src/main/resources/static/img/favicon.ico | Bin 4286 -> 4286 bytes .../src/main/resources/static/img/loading.gif | Bin 6285 -> 92366 bytes .../src/main/resources/static/img/mayima.jpg | Bin 0 -> 71079 bytes .../resources/static/img/notification.png | Bin 0 -> 4258 bytes .../resources/static/img/wechat_account.jpg | Bin 0 -> 27704 bytes .../main/resources/static/img/wx_300px.png | Bin 94999 -> 0 bytes .../resources/static/js/wangEditor.min.js | 4689 ----------------- .../main/resources/static/js/zhyd.comment.js | 148 +- .../src/main/resources/static/js/zhyd.core.js | 3 +- blog-web/src/main/resources/static/js/zhyd.js | 60 +- .../src/main/resources/templates/about.ftl | 30 +- .../src/main/resources/templates/article.ftl | 42 +- .../main/resources/templates/error/401.ftl | 21 +- .../main/resources/templates/error/403.ftl | 69 +- .../main/resources/templates/error/404.ftl | 19 +- .../main/resources/templates/error/500.ftl | 21 +- .../main/resources/templates/guestbook.ftl | 36 +- .../resources/templates/include/macros.ftl | 21 +- .../src/main/resources/templates/index.ftl | 44 +- .../resources/templates/layout/footer.ftl | 19 +- .../resources/templates/layout/header.ftl | 4 +- .../main/resources/templates/layout/quote.ftl | 2 +- .../resources/templates/layout/sidebar.ftl | 8 +- .../src/main/resources/templates/links.ftl | 70 +- .../test/java/com/zyd/blog/BaseJunitTest.java | 5 +- build.sh | 8 + contribution.md | 29 + demo.md | 1 + docs/db/dblog.sql | 161 +- docs/db/update.sql | 95 + docs/img/admin-article2.png | Bin 40847 -> 0 bytes docs/img/admin-articles.png | Bin 133437 -> 0 bytes docs/img/admin-index.png | Bin 99651 -> 0 bytes docs/img/admin-menu.png | Bin 40352 -> 0 bytes docs/img/admin-role.png | Bin 21515 -> 0 bytes docs/img/admin-role2.png | Bin 51159 -> 0 bytes docs/img/m.png | Bin 108262 -> 0 bytes docs/img/pc-detail.png | Bin 196214 -> 0 bytes docs/img/pc-index.png | Bin 221011 -> 0 bytes docs/yuicompressor/gzjs.sh | 87 + pom.xml | 126 +- update.md | 141 + 209 files changed, 8438 insertions(+), 9871 deletions(-) create mode 100644 blog-admin/src/main/java/com/zyd/blog/controller/RestRemoverController.java create mode 100644 blog-admin/src/main/java/com/zyd/blog/core/config/WebMvcConfig.java create mode 100644 blog-admin/src/main/java/com/zyd/blog/core/interceptor/RememberAuthenticationInterceptor.java rename {blog-web/src/main/java/com/zyd/blog/core => blog-admin/src/main/java/com/zyd/blog/core/websocket}/config/WebSocketConfig.java (90%) rename blog-web/src/main/java/com/zyd/blog/core/websocket/ZydWebSocket.java => blog-admin/src/main/java/com/zyd/blog/core/websocket/server/ZydWebsocketServer.java (76%) rename {blog-web/src/main/java/com/zyd/blog/core/websocket => blog-admin/src/main/java/com/zyd/blog/core/websocket/util}/WebSocketUtil.java (57%) create mode 100644 blog-admin/src/main/resources/application-dev.yml create mode 100644 blog-admin/src/main/resources/application-test.yml create mode 100644 blog-admin/src/main/resources/banner.txt create mode 100644 blog-admin/src/main/resources/logback-spring.xml delete mode 100644 blog-admin/src/main/resources/logback.xml delete mode 100644 blog-admin/src/main/resources/static/assets/images/back_disabled.png delete mode 100644 blog-admin/src/main/resources/static/assets/images/back_enabled.png delete mode 100644 blog-admin/src/main/resources/static/assets/images/back_enabled_hover.png delete mode 100644 blog-admin/src/main/resources/static/assets/images/favicon.png delete mode 100644 blog-admin/src/main/resources/static/assets/images/forward_disabled.png delete mode 100644 blog-admin/src/main/resources/static/assets/images/forward_enabled.png delete mode 100644 blog-admin/src/main/resources/static/assets/images/forward_enabled_hover.png delete mode 100644 blog-admin/src/main/resources/static/assets/images/picture.jpg create mode 100644 blog-admin/src/main/resources/static/assets/images/reward/wx_code.png create mode 100644 blog-admin/src/main/resources/static/assets/images/reward/wx_reward_code.png create mode 100644 blog-admin/src/main/resources/static/assets/images/reward/zfb_code.png create mode 100644 blog-admin/src/main/resources/static/assets/images/spider/cookie/cookie.png create mode 100644 blog-admin/src/main/resources/static/assets/images/spider/uid/csdn.png create mode 100644 blog-admin/src/main/resources/static/assets/images/spider/uid/imooc.png create mode 100644 blog-admin/src/main/resources/static/assets/images/spider/uid/iteye.png delete mode 100644 blog-admin/src/main/resources/static/assets/images/transparent.png create mode 100644 blog-admin/src/main/resources/static/assets/js/codemirror.inline-attachment.js create mode 100644 blog-admin/src/main/resources/static/assets/js/inline-attachment.js create mode 100644 blog-admin/src/main/resources/static/assets/js/jquery.smartWizard.js delete mode 100644 blog-admin/src/main/resources/static/assets/js/wangEditor.min.js create mode 100644 blog-admin/src/main/resources/static/assets/js/zhyd.publish-article.js create mode 100644 blog-admin/src/main/resources/templates/article/publish-md.ftl rename blog-admin/src/main/resources/templates/{layout/header.ftl => include/macros.ftl} (83%) create mode 100644 blog-admin/src/main/resources/templates/notification.ftl create mode 100644 blog-admin/src/main/resources/templates/remover/list.ftl rename {blog-web/src/main/java/com/zyd/blog/core/aspects => blog-core/src/main/java/com/zyd/blog/business/aspect}/RenderAspects.java (85%) create mode 100644 blog-core/src/main/java/com/zyd/blog/business/entity/UserPwd.java create mode 100644 blog-core/src/main/java/com/zyd/blog/business/service/RemoverService.java create mode 100644 blog-core/src/main/java/com/zyd/blog/business/service/impl/RemoverServiceImpl.java create mode 100644 blog-core/src/main/java/com/zyd/blog/framework/config/TomcatConfig.java create mode 100644 blog-core/src/main/java/com/zyd/blog/framework/property/ShiroProperties.java create mode 100644 blog-core/src/main/java/com/zyd/blog/framework/redis/CustomRedisManager.java create mode 100644 blog-core/src/main/java/com/zyd/blog/framework/runner/BlogApplicationRunner.java create mode 100644 blog-core/src/main/java/com/zyd/blog/util/AspectUtil.java create mode 100644 blog-core/src/main/java/com/zyd/blog/util/RegexUtils.java create mode 100644 blog-core/src/main/java/com/zyd/blog/util/RequestUtil.java create mode 100644 blog-core/src/main/java/com/zyd/blog/util/XssKillerUtil.java create mode 100644 blog-core/src/test/java/com/zyd/blog/util/XssKillerTest.java create mode 100644 blog-spider/.gitignore create mode 100644 blog-spider/pom.xml create mode 100644 blog-spider/src/main/java/com/zyd/blog/spider/model/Article.java create mode 100644 blog-spider/src/main/java/com/zyd/blog/spider/model/BaseModel.java create mode 100644 blog-spider/src/main/java/com/zyd/blog/spider/model/Cookie.java create mode 100644 blog-spider/src/main/java/com/zyd/blog/spider/model/CsdnModel.java create mode 100644 blog-spider/src/main/java/com/zyd/blog/spider/model/ImoocModel.java create mode 100644 blog-spider/src/main/java/com/zyd/blog/spider/model/IteyeModel.java create mode 100644 blog-spider/src/main/java/com/zyd/blog/spider/processor/ArticleSpiderProcessor.java create mode 100644 blog-spider/src/main/java/com/zyd/blog/spider/processor/BaseProcessor.java create mode 100644 blog-spider/src/main/java/com/zyd/blog/spider/processor/HtmlProcessor.java create mode 100644 blog-spider/src/main/java/com/zyd/blog/spider/processor/JsonProcessor.java create mode 100644 blog-spider/src/main/java/com/zyd/blog/spider/processor/Processor.java create mode 100644 blog-spider/src/main/java/com/zyd/blog/spider/processor/ZydSpider.java create mode 100644 blog-spider/src/main/java/com/zyd/blog/spider/util/WriterUtil.java create mode 100644 blog-spider/src/main/resources/log4j.properties create mode 100644 blog-web/src/main/resources/application-dev.yml create mode 100644 blog-web/src/main/resources/application-test.yml create mode 100644 blog-web/src/main/resources/banner.txt create mode 100644 blog-web/src/main/resources/logback-spring.xml delete mode 100644 blog-web/src/main/resources/logback.xml create mode 100644 blog-web/src/main/resources/static/img/author.png create mode 100644 blog-web/src/main/resources/static/img/mayima.jpg create mode 100644 blog-web/src/main/resources/static/img/notification.png create mode 100644 blog-web/src/main/resources/static/img/wechat_account.jpg delete mode 100644 blog-web/src/main/resources/static/img/wx_300px.png delete mode 100644 blog-web/src/main/resources/static/js/wangEditor.min.js create mode 100644 build.sh create mode 100644 contribution.md create mode 100644 demo.md delete mode 100644 docs/img/admin-article2.png delete mode 100644 docs/img/admin-articles.png delete mode 100644 docs/img/admin-index.png delete mode 100644 docs/img/admin-menu.png delete mode 100644 docs/img/admin-role.png delete mode 100644 docs/img/admin-role2.png delete mode 100644 docs/img/m.png delete mode 100644 docs/img/pc-detail.png delete mode 100644 docs/img/pc-index.png create mode 100644 docs/yuicompressor/gzjs.sh create mode 100644 update.md diff --git a/README.md b/README.md index f7c3932..aa49bb5 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,33 @@ -# 注:本项目Github版已不更新,获取最新版本请点击:[Gitee](https://gitee.com/yadong.zhang/DBlog) - -# DBlog简介 -DBlog是一款简洁美观、自适应的Java博客系统。使用springboot开发,前端使用Bootstrap。支持移动端自适应,配有完备的前台和后台管理功能。 - -**网站预览** - -[https://www.zhyd.me](https://www.zhyd.me) - -**开源地址** -1. [Gitee](https://gitee.com/yadong.zhang/DBlog) -2. [Github](https://github.com/zhangyd-c/DBlog) - -## 写在前面的话 + **DBlog** 是一款简洁美观、自适应的Java博客系统。使用springboot开发,前端使用Bootstrap。支持移动端自适应,配有完备的前台和后台管理功能。 + +![JDK](https://img.shields.io/badge/JDK-1.8-green.svg) +![Maven](https://img.shields.io/badge/Maven-3.3.1-green.svg) +![MySQL](https://img.shields.io/badge/MySQL-5.6.4-green.svg) +![Redis](https://img.shields.io/badge/Redis-3.0.503-green.svg) +[![license](https://img.shields.io/badge/license-MIT-yellow.svg)](https://gitee.com/yadong.zhang/DBlog/blob/master/LICENSE) + +---- + +# 博客新增“文章搬运工”功能(20180824) + +该功能可以将其他平台(目前支持imooc、csdn和iteye)的文章同步到本地服务器。点击下图查看视频示例 +[![输入图片说明](https://images.gitee.com/uploads/images/2018/0824/161625_250da176_784199.png "屏幕截图.png")](https://gitee.com/yadong.zhang/static/raw/master/dblog/DBlog-%E6%96%87%E7%AB%A0%E6%90%AC%E8%BF%90%E5%B7%A5%E7%A4%BA%E4%BE%8B.webm) + +---- + +# 重要声明 + +1. 本项目配有相关[帮助文档](https://gitee.com/yadong.zhang/DBlog/wikis)。文档中包括**基本的项目说明**、**shiro标签使用**、**七牛云配置**和一些常见的**异常问题解决方案**。使用时碰到问题请**优先**查阅【[帮助文档](https://gitee.com/yadong.zhang/DBlog/wikis)】。因为现在好多朋友问的问题大部分都写在【[帮助文档](https://gitee.com/yadong.zhang/DBlog/wikis)】中了,希望各位朋友能自己翻阅下相关资料,高效提问,避免重复问题! +2. **提问题**前请优先阅读【[如何向开源社区提问题](https://github.com/seajs/seajs/issues/545)】&【[提问的智慧](http://www.dianbo.org/9238/stone/tiwendezhihui.htm)】 +3. **提问题**时请优先选择[Gitee Issues](https://gitee.com/yadong.zhang/DBlog/issues)(方便问题追踪和一对一解决),其次[我的博客-留言板](https://www.zhyd.me/guestbook),再次[QQ群190886500](http://shang.qq.com/wpa/qunwpa?idkey=9f986e9b33b1de953e1ef9a96cdeec990affd0ac7855e00ff103514de2027b60)(QQ群消息较多,提问请注意节奏、时机),最次加我QQ好友直接提问(不推荐) +4. 本项目唯一官网:[https://www.zhyd.me](https://www.zhyd.me) +5. 本项目开源地址:[Gitee](https://gitee.com/yadong.zhang/DBlog) 注: **Github上的项目已不准备更新** ,因此版本较老,请Github用户移步至[Gitee](https://gitee.com/yadong.zhang/DBlog) +6. 本项目修改记录,详情请移步[这里](https://gitee.com/yadong.zhang/DBlog/blob/master/update.md) +7. 如果你想贡献代码,请先阅读[这篇文章](https://gitee.com/yadong.zhang/DBlog/blob/master/contribution.md) + +---- + +# 写在前面的话 ps: 虽然我知道,大部分人都是来了**直接下载源代码**后就潇洒的离开,并且只有等到下次**突然想到**“我天~~我得去看看DBlog这烂项目更新新功能了吗”的时候才会重新来到这儿,即使你重新来过,我估计你也只有两个选择: 发现更新代码了 --> 下载源码后重复上面的步骤 @@ -19,18 +35,24 @@ ps: 虽然我知道,大部分人都是来了**直接下载源代码**后就潇 虽然我知道现实就是如此的残酷,但我还是要以我萤虫之力对各位到来的同仁发出一声诚挚的嘶吼: -**如果喜欢,请多多分享!!多多Star!!fork可以,但还是请star一下!!** +**如果喜欢,请多多分享!!多多Star!!** + +---- + +### 已经在用DBlog的网站 ( 排名按照留言先后顺序 ) +- [张亚东博客](https://www.zhyd.me) +- [攻城狮不是猫博客](http://www.jsdblog.com) +- [刘辉辉的博客](http://www.axxo.top) +- [乐赚淘](http://www.lezhuantao.com) +- [时光号](http://www.shiguanghao.cn/) +- [大杂烩 | 好好网](https://www.haohaowang.top) +- 更多待续... +烦请各位使用DBlog已经跑起来自己的博客的朋友,能留下你的网址(没别的意思,只是看看有多少人而已) - [点这儿](https://gitee.com/yadong.zhang/DBlog/issues/ILIAQ) -### 开发环境 -| 工具 | 版本或描述 | -| ----- | -------------------- | -| OS | Windows 7 | -| JDK | 1.7+ | -| IDE | IntelliJ IDEA 2017.3 | -| Maven | 3.3.1 | -| MySQL | 5.6.4 | + +---- ### 模块划分 @@ -43,7 +65,7 @@ ps: 虽然我知道,大部分人都是来了**直接下载源代码**后就潇 ### 技术栈 -- Springboot 1.5.9 +- Springboot 2.0.1 - Apache Shiro 1.2.2 - Logback - Redis @@ -59,101 +81,83 @@ ps: 虽然我知道,大部分人都是来了**直接下载源代码**后就潇 - Qiniu - ... +### 功能简介 + +- 支持wangEditor和Markdown两种富文本编辑器,可以自行选择 +- 在线申请友情链接,无需站长手动配置,只需申请方添加完站长的连接后自行申请即可 +- 支持将文件提交到百度站长收录平台,加快百度引擎的收录 +- 自研评论系统 +- 后台配备完善的权限管理 +- 自带robots、sitemap等seo模板,实现自动生成robots和sitemap +- 集成七牛云,实现文件云存储 +- 系统配置支持快速配置。可通过后台手动修改诸如域名信息、SEO优化、赞赏码、七牛云以及更新维护通知等。 +- 管理员可向在线的用户发送实时消息(需用户授权 - 基于websocket实现,具体参考[DBlog建站之Websocket的使用](https://www.zhyd.me/article/111)) + ### 使用方法 1. 使用IDE导入本项目 2. 新建数据库`CREATE DATABASE dblog;` 3. 导入数据库`docs/db/dblog.sql` -4. 修改(`resources/application.yml`)配置文件 - 1. 数据库链接属性(可搜索`datasource`或定位到L.19) - 2. redis配置(可搜索`redis`或定位到L.69) - 3. mail配置(可搜索`mail`或定位到L.89) - 4. 【[七牛云](http://qiniu.com)】配置(见sys_config表中qiniu_*开头的字段) - 注:因为系统存在redis缓存,如果是第一次使用,可以直接修改sys_config表内容,如果不是第一次用,建议使用admin项目中的`系统配置`页面修改相关配置内容 +4. 修改配置文件 + 1. 数据库链接属性(在`resources/application-{env}.yml`配置文件中搜索`datasource`或定位到L.7) + 2. redis配置(在`resources/application.yml`配置文件中搜索`redis`或定位到L.65) + 3. mail配置(在`resources/application-{env}.yml`配置文件中搜索`mail`或定位到L.14) + 4. 【[七牛云](https://portal.qiniu.com/signup?code=3l8yx2v0f21ci)】配置(见sys_config表中qiniu_*开头的字段) + 注:因为系统存在redis缓存,如果是第一次使用,可以直接修改sys_config表内容,如果不是第一次用,建议使用admin项目中的`系统配置`页面修改相关配置内容 5. 运行项目(三种方式) - 1. 项目根目录下执行`mvn -X clean package -Dmaven.test.skip=true`编译打包,然后执行`java -jar target/blog-web.jar` + 1. 项目根目录下执行`mvn -X clean package -Dmaven.test.skip=true -Ptest`编译打包(注:-Ptest中的test为环境标识),然后cd到blog-web目录下执行`java -jar target/blog-web.jar` 2. 项目根目录下执行`mvn springboot:run` 3. 直接运行`BlogWebApplication.java` 6. 浏览器访问`http://127.0.0.1:8443` -**后台用户** +**后台默认账户** -_超级管理员_: 账号:root 密码:123456 (本地测试使用这个账号,admin没设置权限) +_超级管理员_(超级管理员): 账号:root 密码:123456 -_普通管理员_: 账号:admin 密码:123456 +_普通管理员_(普通管理员,无权限): 账号:admin 密码:123456 -_评论审核管理员_: 账号:comment-admin 密码:123456 +_评论审核管理员_(只有评论审核的权限): 账号:comment-admin 密码:123456 注:后台用户的创建,尽可能做到**权限最小化** -更多详情,请参考【[Wiki](https://gitee.com/yadong.zhang/DBlog/wikis)】 -### 更新日志 - -2018-05-25 - -**修改功能:** - -1. 修复后台标签等分页失败的问题 -2. 修复前台自动申请友链失败的问题 -3. 其他一些问题 - - -2018-05-22 - -**修改功能:** - -1. 完善shiro权限(数据库、页面)。注:需要重新执行下`sys_resources`和`sys_role_resources`两张表的`insert`语句 -2. redis配置默认不含密码(鉴于大多数朋友的redis都没有密码做此修改,不过本人 **强烈建议**设置下密码) +你能看到这儿已经很不容易了,剩下的自己先摸索摸索吧,实在不行,加QQ群[190886500](http://shang.qq.com/wpa/qunwpa?idkey=9f986e9b33b1de953e1ef9a96cdeec990affd0ac7855e00ff103514de2027b60),进群可以选择性的备注:~~欧巴群主我爱你~~(咳咳,鉴于部分群友的抗议,该备注就不用了),麻烦大家换成:`我猜群主一定很帅` -2018-05-18 -**修复bug:** +### 后续扩展 +- [x] 1. 结合websocket+notification实现管理员向在线用户实时发送消息通知(隐藏掉浏览器的情况下一样会弹出,类似windowx桌面弹窗,需要用户授权) +- [ ] 2. 页面缓存 +- [ ] 3. 数据统计 +- [ ] 4. cc防护 +... -1. web端自动申请友链后不显示的问题 -2. config表修改后不能实时刷新的问题 - -**增加功能:** -1. 网站赞赏码 -2. 百度推送功能(链接提交到百度站长平台) - -**修改功能:** -1. 百度api的ak和百度推送的token以及七牛云的配置改为通过config表管理 -3. admin模块菜单通过标签实时获取 -3. 弹窗工具类js结构调整 +### 图片预览 -你能看到这儿已经很不容易了,剩下的自己先摸索摸索吧,实在不行,加QQ群[190886500](http://shang.qq.com/wpa/qunwpa?idkey=9f986e9b33b1de953e1ef9a96cdeec990affd0ac7855e00ff103514de2027b60),进群可以选择性的备注:~~欧巴群主我爱你~~(咳咳,鉴于部分群友的抗议,该备注就不用了),麻烦大家换成:`我猜群主一定很帅` +#### 前台页面 -### 图片预览 +![PC-首页](https://gitee.com/uploads/images/2018/0627/161851_3eefd129_784199.png?v=1.0 "PC-首页") +![手机端](https://gitee.com/uploads/images/2018/0627/163121_6b6c551e_784199.png "手机端") -**前台页面** -![PC-首页](https://gitee.com/yadong.zhang/DBlog/raw/master/docs/img/pc-index.png?v=1.0) -![PC-文章详情页](https://gitee.com/yadong.zhang/DBlog/raw/master/docs/img/pc-detail.png?v=1.0) -![手机](https://gitee.com/yadong.zhang/DBlog/raw/master/docs/img/m.png?v=1.0) -**后台页面** -![首页](https://gitee.com/yadong.zhang/DBlog/raw/master/docs/img/admin-index.png) -![菜单](https://gitee.com/yadong.zhang/DBlog/raw/master/docs/img/admin-menu.png) -![文章列表](https://gitee.com/yadong.zhang/DBlog/raw/master/docs/img/admin-articles.png) -![发表文章](https://gitee.com/yadong.zhang/DBlog/raw/master/docs/img/admin-article2.png) -![角色列表](https://gitee.com/yadong.zhang/DBlog/raw/master/docs/img/admin-role.png) -![角色分配](https://gitee.com/yadong.zhang/DBlog/raw/master/docs/img/admin-role2.png) +#### 后台页面 +![PC-后台首页](https://gitee.com/uploads/images/2018/0627/162136_01f40c01_784199.png?v=1.0 "PC-后台首页") +![PC-文章列表页](https://gitee.com/uploads/images/2018/0627/162222_001e3342_784199.png?v=1.0 "PC-文章列表页") +![PC-发布文章页-markdown版](https://gitee.com/uploads/images/2018/0627/162317_5ea6c8d5_784199.png "PC-发布文章页-markdown版") +![PC-文章发布页-html版](https://gitee.com/uploads/images/2018/0627/162442_c98194c4_784199.png "PC-文章发布页-html版.png") - ### 生命不息,折腾不止! 更多信息,请关注: +### 生命不息,折腾不止! 更多信息,请关注: 1. [我的博客](https://www.zhyd.me) 2. [我的微博](http://weibo.com/211230415) 3. [我的头条号](http://www.toutiao.com/c/user/3286958681/) - 4. [我的mooc](http://www.imooc.com/u/1175248/articles) + 4. [我的imooc](http://www.imooc.com/u/1175248/articles) - ### 有任何问题可以 -- [给我留言](https://www.zhyd.me/guestbook) +### 特别感谢 +1. 广大的开源爱好者 +2. 无私的网友 ### 开源协议 - [MIT](https://gitee.com/yadong.zhang/DBlog/blob/master/LICENSE) - - - +[![license](https://img.shields.io/badge/license-MIT-yellow.svg)](https://gitee.com/yadong.zhang/DBlog/blob/master/LICENSE) \ No newline at end of file diff --git a/blog-admin/pom.xml b/blog-admin/pom.xml index 6f53b4b..761d19e 100644 --- a/blog-admin/pom.xml +++ b/blog-admin/pom.xml @@ -3,9 +3,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.zyd - blog-admin - 0.0.1-SNAPSHOT + blog-admin jar blog-admin @@ -14,36 +12,105 @@ com.zyd blog - 0.0.1-SNAPSHOT + 2.0.1.Beta - org.springframework.boot - spring-boot-starter-web + com.zyd + blog-core + org.springframework.boot - spring-boot-starter-freemarker - - - com.zyd - blog-core - 0.0.1-SNAPSHOT + spring-boot-starter-websocket + + + + org.apache.maven.plugins + maven-resources-plugin + + + @ + + false + + + + net.alchim31.maven + yuicompressor-maven-plugin + + + process-resources + + compress + + + + + + UTF-8 + + false + + false + + -1 + + true + + true + + src/main/resources/static/assets + + target/classes/static/assets + + + **/*.js + **/*.css + + + + **/*.min.js + **/*.min.css + **/jquery-form.js + + + org.springframework.boot spring-boot-maven-plugin com.zyd.blog.BlogAdminApplication JAR + + true + + diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/ErrorPagesController.java b/blog-admin/src/main/java/com/zyd/blog/controller/ErrorPagesController.java index 9389c32..a027e34 100644 --- a/blog-admin/src/main/java/com/zyd/blog/controller/ErrorPagesController.java +++ b/blog-admin/src/main/java/com/zyd/blog/controller/ErrorPagesController.java @@ -21,18 +21,17 @@ package com.zyd.blog.controller; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.web.ErrorAttributes; -import org.springframework.boot.autoconfigure.web.ErrorController; import org.springframework.boot.autoconfigure.web.ErrorProperties; import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.web.servlet.error.ErrorAttributes; +import org.springframework.boot.web.servlet.error.ErrorController; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.context.request.RequestAttributes; -import org.springframework.web.context.request.ServletRequestAttributes; +import org.springframework.web.context.request.WebRequest; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; @@ -43,8 +42,6 @@ import java.util.Map; * 重写BasicErrorController,主要负责系统的异常页面的处理以及错误信息的显示 *

* 此处指需要记录 - * @see org.springframework.boot.autoconfigure.web.BasicErrorController - * @see org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration *

* 要注意,这个类里面的代码一定不能有异常或者潜在异常发生,否则可能会让程序陷入死循环。 *

@@ -78,18 +75,18 @@ public class ErrorPagesController implements ErrorController { } @RequestMapping("/404") - public ModelAndView errorHtml404(HttpServletRequest request, HttpServletResponse response) { + public ModelAndView errorHtml404(HttpServletRequest request, HttpServletResponse response, WebRequest webRequest) { response.setStatus(HttpStatus.NOT_FOUND.value()); - Map model = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.TEXT_HTML)); + Map model = getErrorAttributes(webRequest, isIncludeStackTrace(request, MediaType.TEXT_HTML)); return new ModelAndView("error/404", model); } @RequestMapping("/403") - public ModelAndView errorHtml403(HttpServletRequest request, HttpServletResponse response) { + public ModelAndView errorHtml403(HttpServletRequest request, HttpServletResponse response, WebRequest webRequest) { response.setStatus(HttpStatus.FORBIDDEN.value()); // 404拦截规则,如果是静态文件发生的404则不记录到DB - Map model = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.TEXT_HTML)); + Map model = getErrorAttributes(webRequest, isIncludeStackTrace(request, MediaType.TEXT_HTML)); if (!String.valueOf(model.get("path")).contains(".")) { model.put("status", HttpStatus.FORBIDDEN.value()); } @@ -97,23 +94,23 @@ public class ErrorPagesController implements ErrorController { } @RequestMapping("/400") - public ModelAndView errorHtml400(HttpServletRequest request, HttpServletResponse response) { + public ModelAndView errorHtml400(HttpServletRequest request, HttpServletResponse response, WebRequest webRequest) { response.setStatus(HttpStatus.BAD_REQUEST.value()); - Map model = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.TEXT_HTML)); + Map model = getErrorAttributes(webRequest, isIncludeStackTrace(request, MediaType.TEXT_HTML)); return new ModelAndView("error/400", model); } @RequestMapping("/401") - public ModelAndView errorHtml401(HttpServletRequest request, HttpServletResponse response) { + public ModelAndView errorHtml401(HttpServletRequest request, HttpServletResponse response, WebRequest webRequest) { response.setStatus(HttpStatus.UNAUTHORIZED.value()); - Map model = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.TEXT_HTML)); + Map model = getErrorAttributes(webRequest, isIncludeStackTrace(request, MediaType.TEXT_HTML)); return new ModelAndView("error/401", model); } @RequestMapping("/500") - public ModelAndView errorHtml500(HttpServletRequest request, HttpServletResponse response) { + public ModelAndView errorHtml500(HttpServletRequest request, HttpServletResponse response, WebRequest webRequest) { response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); - Map model = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.TEXT_HTML)); + Map model = getErrorAttributes(webRequest, isIncludeStackTrace(request, MediaType.TEXT_HTML)); return new ModelAndView("error/500", model); } @@ -139,15 +136,13 @@ public class ErrorPagesController implements ErrorController { /** * 获取错误的信息 * - * @param request + * @param webRequest * @param includeStackTrace * @return */ - private Map getErrorAttributes(HttpServletRequest request, + private Map getErrorAttributes(WebRequest webRequest, boolean includeStackTrace) { - RequestAttributes requestAttributes = new ServletRequestAttributes(request); - return this.errorAttributes.getErrorAttributes(requestAttributes, - includeStackTrace); + return this.errorAttributes.getErrorAttributes(webRequest, includeStackTrace); } /** diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/ExceptionHandleController.java b/blog-admin/src/main/java/com/zyd/blog/controller/ExceptionHandleController.java index f2b5eae..0cd0126 100644 --- a/blog-admin/src/main/java/com/zyd/blog/controller/ExceptionHandleController.java +++ b/blog-admin/src/main/java/com/zyd/blog/controller/ExceptionHandleController.java @@ -21,13 +21,13 @@ package com.zyd.blog.controller; import com.zyd.blog.business.consts.CommonConst; import com.zyd.blog.business.enums.ResponseStatus; -import com.zyd.blog.framework.exception.ZhydArticleException; -import com.zyd.blog.framework.exception.ZhydCommentException; -import com.zyd.blog.framework.exception.ZhydFileException; -import com.zyd.blog.framework.exception.ZhydLinkException; +import com.zyd.blog.framework.exception.*; import com.zyd.blog.framework.object.ResponseVO; import com.zyd.blog.util.ResultUtil; import lombok.extern.slf4j.Slf4j; +import org.apache.shiro.authc.AccountException; +import org.apache.shiro.authz.UnauthorizedException; +import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; @@ -48,13 +48,27 @@ import java.lang.reflect.UndeclaredThrowableException; @ControllerAdvice public class ExceptionHandleController { + /** + * Shiro权限认证异常 + * + * @param e + * @return + */ + @ExceptionHandler(value = {UnauthorizedException.class, AccountException.class}) + @ResponseBody + public ResponseVO unauthorizedExceptionHandle(Throwable e) { + e.printStackTrace(); // 打印异常栈 + return ResultUtil.error(HttpStatus.UNAUTHORIZED.value(), e.getLocalizedMessage()); + } + @ExceptionHandler(value = Exception.class) @ResponseBody public ResponseVO handle(Throwable e) { if (e instanceof ZhydArticleException || e instanceof ZhydCommentException || e instanceof ZhydFileException - || e instanceof ZhydLinkException) { + || e instanceof ZhydLinkException + || e instanceof ZhydException) { return ResultUtil.error(e.getMessage()); } if (e instanceof UndeclaredThrowableException) { diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/PassportController.java b/blog-admin/src/main/java/com/zyd/blog/controller/PassportController.java index 9b91e36..509dc01 100644 --- a/blog-admin/src/main/java/com/zyd/blog/controller/PassportController.java +++ b/blog-admin/src/main/java/com/zyd/blog/controller/PassportController.java @@ -20,6 +20,8 @@ package com.zyd.blog.controller; import com.zyd.blog.business.annotation.BussinessLog; +import com.zyd.blog.business.entity.UserPwd; +import com.zyd.blog.business.service.SysUserService; import com.zyd.blog.framework.object.ResponseVO; import com.zyd.blog.framework.property.AppProperties; import com.zyd.blog.util.ResultUtil; @@ -32,6 +34,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.util.StringUtils; +import org.springframework.validation.BindingResult; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -55,14 +59,12 @@ public class PassportController { @Autowired private AppProperties config; + @Autowired + private SysUserService userService; @BussinessLog("进入登录页面") @GetMapping("/login") public ModelAndView login(Model model) { - Subject subject = SecurityUtils.getSubject(); - if (subject.isAuthenticated()||subject.isRemembered()){ - return ResultUtil.redirect("/index"); - } model.addAttribute("enableKaptcha", config.getEnableKaptcha()); return ResultUtil.view("/login"); } @@ -99,6 +101,22 @@ public class PassportController { } } + /** + * 修改密码 + * + * @return + */ + @PostMapping("/updatePwd") + @ResponseBody + public ResponseVO updatePwd(@Validated UserPwd userPwd, BindingResult bindingResult) throws Exception { + if (bindingResult.hasErrors()) { + return ResultUtil.error(bindingResult.getFieldError().getDefaultMessage()); + } + boolean result = userService.updatePwd(userPwd); + SessionUtil.removeAllSession(); + return ResultUtil.success(result ? "密码已修改成功,请重新登录" : "密码修改失败"); + } + /** * 使用权限管理工具进行用户的退出,跳出登录,给出提示信息 * diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/RenderController.java b/blog-admin/src/main/java/com/zyd/blog/controller/RenderController.java index 70f8904..36355d5 100644 --- a/blog-admin/src/main/java/com/zyd/blog/controller/RenderController.java +++ b/blog-admin/src/main/java/com/zyd/blog/controller/RenderController.java @@ -28,8 +28,17 @@ package com.zyd.blog.controller; * @date 2018/4/24 14:37 * @since 1.0 */ + import com.zyd.blog.business.annotation.BussinessLog; +import com.zyd.blog.business.entity.Article; +import com.zyd.blog.business.service.BizArticleService; +import com.zyd.blog.core.websocket.server.ZydWebsocketServer; import com.zyd.blog.util.ResultUtil; +import org.apache.shiro.authz.annotation.RequiresAuthentication; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.apache.shiro.authz.annotation.RequiresRoles; +import org.apache.shiro.authz.annotation.RequiresUser; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; @@ -48,122 +57,166 @@ import org.springframework.web.servlet.ModelAndView; @Controller public class RenderController { - @BussinessLog("进入首页") - @GetMapping("") - public ModelAndView home() { - return ResultUtil.view("index"); - } + @Autowired + private BizArticleService articleService; + @Autowired + private ZydWebsocketServer websocketServer; + @RequiresAuthentication @BussinessLog("进入首页") - @GetMapping("/index") - public ModelAndView index() { + @GetMapping(value = {""}) + public ModelAndView home() { return ResultUtil.view("index"); } + @RequiresPermissions("users") @BussinessLog("进入用户列表页") @GetMapping("/users") public ModelAndView user() { return ResultUtil.view("user/list"); } + @RequiresPermissions("resources") @BussinessLog("进入资源列表页") @GetMapping("/resources") public ModelAndView resources() { return ResultUtil.view("resources/list"); } + @RequiresPermissions("roles") @BussinessLog("进入角色列表页") @GetMapping("/roles") public ModelAndView roles() { return ResultUtil.view("role/list"); } + @RequiresPermissions("articles") @BussinessLog("进入文章列表页") @GetMapping("/articles") public ModelAndView articles() { return ResultUtil.view("article/list"); } - @BussinessLog("进入发表文章页") + @RequiresPermissions("article:publish") + @BussinessLog(value = "发表文章页[html]") @GetMapping("/article/publish") public ModelAndView publish() { return ResultUtil.view("article/publish"); } - @BussinessLog("进入发表文章页") + @RequiresPermissions("article:publish") + @BussinessLog(value = "发表文章页[markdown]") + @GetMapping("/article/publishMd") + public ModelAndView publishMd() { + return ResultUtil.view("article/publish-md"); + } + + @RequiresPermissions("article:publish") + @BussinessLog(value = "修改文章页[id={1}]") @GetMapping("/article/update/{id}") public ModelAndView edit(@PathVariable("id") Long id, Model model) { model.addAttribute("id", id); + Article article = articleService.getByPrimaryKey(id); + if(article.getIsMarkdown()){ + return ResultUtil.view("article/publish-md"); + } return ResultUtil.view("article/publish"); } + @RequiresPermissions("types") @BussinessLog("进入分类列表页") @GetMapping("/article/types") public ModelAndView types() { return ResultUtil.view("article/types"); } + @RequiresPermissions("tags") @BussinessLog("进入标签列表页") @GetMapping("/article/tags") public ModelAndView tags() { return ResultUtil.view("article/tags"); } + @RequiresPermissions("links") @BussinessLog("进入链接页") @GetMapping("/links") public ModelAndView links() { return ResultUtil.view("link/list"); } + @RequiresPermissions("comments") @BussinessLog("进入评论页") @GetMapping("/comments") public ModelAndView comments() { return ResultUtil.view("comment/list"); } + @RequiresPermissions("notices") @BussinessLog("进入系统通知页") @GetMapping("/notices") public ModelAndView notices() { return ResultUtil.view("notice/list"); } + @RequiresRoles("role:root") @BussinessLog("进入系统配置页") @GetMapping("/config") public ModelAndView config() { return ResultUtil.view("config"); } + @RequiresPermissions("templates") @BussinessLog("进入模板管理页") @GetMapping("/templates") public ModelAndView templates() { return ResultUtil.view("template/list"); } + @RequiresPermissions("updateLogs") @BussinessLog("进入更新记录管理页") @GetMapping("/updates") public ModelAndView updates() { return ResultUtil.view("update/list"); } + @RequiresPermissions("plays") @BussinessLog("进入歌单管理页") @GetMapping("/plays") public ModelAndView plays() { return ResultUtil.view("play/list"); } + @RequiresPermissions("sysWebpage") @BussinessLog("进入静态页面管理页") @GetMapping("/sysWebpage") public ModelAndView sysWebpage() { return ResultUtil.view("sysWebpage/list"); } + @RequiresPermissions("icons") @GetMapping("/icons") public ModelAndView icons(Model model) { return ResultUtil.view("icons"); } + @RequiresPermissions("shiro") @GetMapping("/shiro") public ModelAndView shiro(Model model) { return ResultUtil.view("shiro"); } + + @RequiresPermissions("notice") + @BussinessLog("进入通知管理页") + @GetMapping("/notice") + public ModelAndView notice(Model model) { + model.addAttribute("online", websocketServer.getOnlineUserCount()); + return ResultUtil.view("notification"); + } + + @RequiresUser + @BussinessLog("进入搬运工页面") + @GetMapping("/remover") + public ModelAndView remover(Model model) { + return ResultUtil.view("remover/list"); + } } diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/RestApiController.java b/blog-admin/src/main/java/com/zyd/blog/controller/RestApiController.java index f0dd98a..2c67f73 100644 --- a/blog-admin/src/main/java/com/zyd/blog/controller/RestApiController.java +++ b/blog-admin/src/main/java/com/zyd/blog/controller/RestApiController.java @@ -19,11 +19,16 @@ */ package com.zyd.blog.controller; +import com.zyd.blog.business.entity.Config; import com.zyd.blog.business.enums.QiniuUploadType; import com.zyd.blog.business.service.BizArticleService; +import com.zyd.blog.business.service.SysConfigService; +import com.zyd.blog.core.websocket.server.ZydWebsocketServer; +import com.zyd.blog.core.websocket.util.WebSocketUtil; import com.zyd.blog.framework.object.ResponseVO; import com.zyd.blog.util.FileUtil; import com.zyd.blog.util.ResultUtil; +import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -31,6 +36,10 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import java.io.UnsupportedEncodingException; +import java.util.HashMap; +import java.util.Map; + /** * 其他api性质的接口 * @@ -46,6 +55,10 @@ public class RestApiController { @Autowired private BizArticleService articleService; + @Autowired + private SysConfigService configService; + @Autowired + private ZydWebsocketServer websocketServer; /** * 上传文件到七牛云 @@ -53,19 +66,45 @@ public class RestApiController { * @param file * @return */ + @RequiresPermissions("article:publish") @PostMapping("/upload2Qiniu") public ResponseVO upload2Qiniu(@RequestParam("file") MultipartFile file) { String filePath = FileUtil.uploadToQiniu(file, QiniuUploadType.SIMPLE, false); return ResultUtil.success("图片上传成功", filePath); } + @RequiresPermissions("article:publish") + @PostMapping("/upload2QiniuForMd") + public Object upload2QiniuForMd(@RequestParam("file") MultipartFile file) { + String filePath = FileUtil.uploadToQiniu(file, QiniuUploadType.SIMPLE, false); + Config config = configService.get(); + Map resultMap = new HashMap<>(3); + resultMap.put("success", 1); + resultMap.put("message", "上传成功"); + resultMap.put("filename", config.getQiuniuBasePath() + filePath + "-pw"); + return resultMap; + } + /** * 发布文章选择图片时获取素材库 * * @return */ + @RequiresPermissions("article:publish") @PostMapping("/material") public ResponseVO material() { return ResultUtil.success("", articleService.listMaterial()); } + + /** + * 发送消息通知 + * + * @return + */ + @RequiresPermissions("notice") + @PostMapping("/notice") + public ResponseVO notice(String msg) throws UnsupportedEncodingException { + WebSocketUtil.sendNotificationMsg(msg, websocketServer.getOnlineUsers()); + return ResultUtil.success("消息发送成功", articleService.listMaterial()); + } } diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/RestArticleController.java b/blog-admin/src/main/java/com/zyd/blog/controller/RestArticleController.java index 0909b0d..7cae31c 100644 --- a/blog-admin/src/main/java/com/zyd/blog/controller/RestArticleController.java +++ b/blog-admin/src/main/java/com/zyd/blog/controller/RestArticleController.java @@ -23,6 +23,7 @@ import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageInfo; import com.zyd.blog.business.entity.Article; import com.zyd.blog.business.entity.Config; +import com.zyd.blog.business.enums.ArticleStatusEnum; import com.zyd.blog.business.enums.BaiduPushTypeEnum; import com.zyd.blog.business.enums.ResponseStatus; import com.zyd.blog.business.service.BizArticleService; @@ -34,6 +35,7 @@ import com.zyd.blog.framework.object.ResponseVO; import com.zyd.blog.util.ResultUtil; import com.zyd.blog.util.UrlBuildUtil; import lombok.extern.slf4j.Slf4j; +import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; @@ -67,6 +69,7 @@ public class RestArticleController { return ResultUtil.tablePage(pageInfo); } + @RequiresPermissions(value = {"article:batchDelete", "article:delete"}, logical = Logical.OR) @PostMapping(value = "/remove") public ResponseVO remove(Long[] ids) { if (null == ids) { @@ -78,23 +81,27 @@ public class RestArticleController { return ResultUtil.success("成功删除 [" + ids.length + "] 篇文章"); } + @RequiresPermissions("article:get") @PostMapping("/get/{id}") public ResponseVO get(@PathVariable Long id) { return ResultUtil.success(null, this.articleService.getByPrimaryKey(id)); } + @RequiresPermissions(value = {"article:edit", "article:publish"}, logical = Logical.OR) @PostMapping("/save") public ResponseVO edit(Article article, Long[] tags, MultipartFile file) { articleService.publish(article, tags, file); return ResultUtil.success(ResponseStatus.SUCCESS); } + @RequiresPermissions(value = {"article:top", "article:recommend"}, logical = Logical.OR) @PostMapping("/update/{type}") public ResponseVO update(@PathVariable("type") String type, Long id) { articleService.updateTopOrRecommendedById(type, id); return ResultUtil.success(ResponseStatus.SUCCESS); } + @RequiresPermissions(value = {"article:batchPush", "article:push"}, logical = Logical.OR) @PostMapping(value = "/pushToBaidu/{type}") public ResponseVO pushToBaidu(@PathVariable("type") BaiduPushTypeEnum type, Long[] ids) { if (null == ids) { @@ -129,4 +136,14 @@ public class RestArticleController { } return ResultUtil.success(null, result); } + + @RequiresPermissions(value = {"article:publish"}, logical = Logical.OR) + @PostMapping(value = "/batchPublish") + public ResponseVO batchPublish(Long[] ids) { + if (null == ids) { + return ResultUtil.error(500, "请至少选择一条记录"); + } + articleService.batchUpdateStatus(ids, true); + return ResultUtil.success("批量发布完成"); + } } diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/RestCommentController.java b/blog-admin/src/main/java/com/zyd/blog/controller/RestCommentController.java index fc44e75..e0a8bcd 100644 --- a/blog-admin/src/main/java/com/zyd/blog/controller/RestCommentController.java +++ b/blog-admin/src/main/java/com/zyd/blog/controller/RestCommentController.java @@ -21,22 +21,20 @@ package com.zyd.blog.controller; import com.github.pagehelper.PageInfo; import com.zyd.blog.business.entity.Comment; -import com.zyd.blog.business.entity.Config; -import com.zyd.blog.business.entity.User; -import com.zyd.blog.business.enums.CommentStatusEnum; import com.zyd.blog.business.enums.ResponseStatus; import com.zyd.blog.business.enums.TemplateKeyEnum; import com.zyd.blog.business.service.BizCommentService; import com.zyd.blog.business.service.MailService; -import com.zyd.blog.business.service.SysConfigService; import com.zyd.blog.business.vo.CommentConditionVO; import com.zyd.blog.framework.exception.ZhydCommentException; import com.zyd.blog.framework.object.PageResult; import com.zyd.blog.framework.object.ResponseVO; import com.zyd.blog.util.ResultUtil; -import com.zyd.blog.util.SessionUtil; +import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.apache.shiro.authz.annotation.RequiresUser; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -57,8 +55,6 @@ public class RestCommentController { @Autowired private BizCommentService commentService; @Autowired - private SysConfigService configService; - @Autowired private MailService mailService; @RequiresPermissions("comments") @@ -68,25 +64,18 @@ public class RestCommentController { return ResultUtil.tablePage(pageInfo); } + @RequiresPermissions("comment:reply") @PostMapping(value = "/reply") public ResponseVO reply(Comment comment) { try { - Config config = configService.get(); - User user = SessionUtil.getUser(); - comment.setQq(user.getQq()); - comment.setEmail(user.getEmail()); - comment.setNickname(user.getNickname()); - comment.setAvatar(user.getAvatar()); - comment.setUrl(config.getSiteUrl()); - comment.setUserId(user.getId()); - comment.setStatus(CommentStatusEnum.APPROVED.toString()); - commentService.comment(comment); - } catch (ZhydCommentException e) { + commentService.commentForAdmin(comment); + } catch (ZhydCommentException e){ return ResultUtil.error(e.getMessage()); } return ResultUtil.success("成功"); } + @RequiresPermissions(value = {"comment:batchDelete", "comment:delete"}, logical = Logical.OR) @PostMapping(value = "/remove") public ResponseVO remove(Long[] ids) { if (null == ids) { @@ -98,11 +87,13 @@ public class RestCommentController { return ResultUtil.success("成功删除 [" + ids.length + "] 条评论"); } + @RequiresPermissions("comments") @PostMapping("/get/{id}") public ResponseVO get(@PathVariable Long id) { return ResultUtil.success(null, this.commentService.getByPrimaryKey(id)); } + @RequiresPermissions("comments") @PostMapping("/edit") public ResponseVO edit(Comment comment) { try { @@ -120,11 +111,16 @@ public class RestCommentController { * @param comment * @return */ + @RequiresPermissions("comment:audit") @PostMapping("/audit") - public ResponseVO audit(Comment comment, Boolean sendEmail) { + public ResponseVO audit(Comment comment, String contentText, Boolean sendEmail) { try { commentService.updateSelective(comment); - if (null != sendEmail && sendEmail) { + if(!StringUtils.isEmpty(contentText)){ + comment.setContent(contentText); + commentService.commentForAdmin(comment); + } + if(null != sendEmail && sendEmail){ Comment commentDB = commentService.getByPrimaryKey(comment.getId()); mailService.send(commentDB, TemplateKeyEnum.TM_COMMENT_AUDIT, true); } @@ -141,6 +137,7 @@ public class RestCommentController { * @param comment * @return */ + @RequiresUser @PostMapping("/listVerifying") public ResponseVO listVerifying(Comment comment) { return ResultUtil.success(null, commentService.listVerifying(10)); diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/RestConfigController.java b/blog-admin/src/main/java/com/zyd/blog/controller/RestConfigController.java index 4d3bfec..3e21691 100644 --- a/blog-admin/src/main/java/com/zyd/blog/controller/RestConfigController.java +++ b/blog-admin/src/main/java/com/zyd/blog/controller/RestConfigController.java @@ -25,6 +25,7 @@ import com.zyd.blog.business.service.SysConfigService; import com.zyd.blog.framework.object.ResponseVO; import com.zyd.blog.util.FileUtil; import com.zyd.blog.util.ResultUtil; +import org.apache.shiro.authz.annotation.RequiresRoles; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -47,11 +48,13 @@ public class RestConfigController { @Autowired private SysConfigService sysConfigService; + @RequiresRoles("role:root") @PostMapping("/get") public ResponseVO get() { return ResultUtil.success(null, sysConfigService.get()); } + @RequiresRoles("role:root") @PostMapping("/edit") public ResponseVO edit(Config config, @RequestParam(required = false) MultipartFile wxPraiseCodeFile, diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/RestLinkController.java b/blog-admin/src/main/java/com/zyd/blog/controller/RestLinkController.java index 7d789dd..6fff99b 100644 --- a/blog-admin/src/main/java/com/zyd/blog/controller/RestLinkController.java +++ b/blog-admin/src/main/java/com/zyd/blog/controller/RestLinkController.java @@ -30,6 +30,8 @@ import com.zyd.blog.business.vo.LinkConditionVO; import com.zyd.blog.framework.object.PageResult; import com.zyd.blog.framework.object.ResponseVO; import com.zyd.blog.util.ResultUtil; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -53,12 +55,14 @@ public class RestLinkController { @Autowired private MailService mailService; + @RequiresPermissions("links") @PostMapping("/list") public PageResult list(LinkConditionVO vo) { PageInfo pageInfo = linkService.findPageBreakByCondition(vo); return ResultUtil.tablePage(pageInfo); } + @RequiresPermissions("link:add") @PostMapping(value = "/add") public ResponseVO add(Link link) { link.setSource(LinkSourceEnum.ADMIN); @@ -67,6 +71,7 @@ public class RestLinkController { return ResultUtil.success("成功"); } + @RequiresPermissions(value = {"link:batchDelete", "link:delete"}, logical = Logical.OR) @PostMapping(value = "/remove") public ResponseVO remove(Long[] ids) { if (null == ids) { @@ -78,11 +83,13 @@ public class RestLinkController { return ResultUtil.success("成功删除 [" + ids.length + "] 个友情链接"); } + @RequiresPermissions("link:get") @PostMapping("/get/{id}") public ResponseVO get(@PathVariable Long id) { return ResultUtil.success(null, this.linkService.getByPrimaryKey(id)); } + @RequiresPermissions("link:edit") @PostMapping("/edit") public ResponseVO edit(Link link) { try { diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/RestNoticeController.java b/blog-admin/src/main/java/com/zyd/blog/controller/RestNoticeController.java index 4fd78ec..17cd08f 100644 --- a/blog-admin/src/main/java/com/zyd/blog/controller/RestNoticeController.java +++ b/blog-admin/src/main/java/com/zyd/blog/controller/RestNoticeController.java @@ -30,6 +30,8 @@ import com.zyd.blog.framework.object.PageResult; import com.zyd.blog.framework.object.ResponseVO; import com.zyd.blog.util.ResultUtil; import com.zyd.blog.util.SessionUtil; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -51,12 +53,14 @@ public class RestNoticeController { @Autowired private SysNoticeService noticeService; + @RequiresPermissions("notices") @PostMapping("/list") public PageResult list(NoticeConditionVO vo) { PageInfo pageInfo = noticeService.findPageBreakByCondition(vo); return ResultUtil.tablePage(pageInfo); } + @RequiresPermissions("notice:add") @PostMapping(value = "/add") public ResponseVO add(Notice notice) { User user = SessionUtil.getUser(); @@ -67,6 +71,7 @@ public class RestNoticeController { return ResultUtil.success("系统通知添加成功"); } + @RequiresPermissions(value = {"notice:batchDelete", "notice:delete"}, logical = Logical.OR) @PostMapping(value = "/remove") public ResponseVO remove(Long[] ids) { if (null == ids) { @@ -78,11 +83,13 @@ public class RestNoticeController { return ResultUtil.success("成功删除 [" + ids.length + "] 个系统通知"); } + @RequiresPermissions("notice:get") @PostMapping("/get/{id}") public ResponseVO get(@PathVariable Long id) { return ResultUtil.success(null, this.noticeService.getByPrimaryKey(id)); } + @RequiresPermissions("notice:edit") @PostMapping("/edit") public ResponseVO edit(Notice notice) { try { @@ -94,6 +101,7 @@ public class RestNoticeController { return ResultUtil.success(ResponseStatus.SUCCESS); } + @RequiresPermissions("notice:release") @PostMapping("/release/{id}") public ResponseVO release(@PathVariable Long id) { try { @@ -108,6 +116,7 @@ public class RestNoticeController { return ResultUtil.success("该通知已发布,可去前台页面查看效果!"); } + @RequiresPermissions("notice:withdraw") @PostMapping("/withdraw/{id}") public ResponseVO withdraw(@PathVariable Long id) { try { diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/RestRemoverController.java b/blog-admin/src/main/java/com/zyd/blog/controller/RestRemoverController.java new file mode 100644 index 0000000..438212a --- /dev/null +++ b/blog-admin/src/main/java/com/zyd/blog/controller/RestRemoverController.java @@ -0,0 +1,56 @@ +/** + * MIT License + * Copyright (c) 2018 yadong.zhang + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.zyd.blog.controller; + + +import com.zyd.blog.business.service.RemoverService; +import com.zyd.blog.spider.model.BaseModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * Remover:搬运工(英语渣渣,实在想不出好玩的名字了) + * + * @author yadong.zhang (yadong.zhang0415(a)gmail.com) + * @version 1.0 + * @website https://www.zhyd.me + * @date 2018/8/14 14:37 + * @since 1.0 + */ +@RestController +@RequestMapping("/remover") +public class RestRemoverController { + + @Autowired + private RemoverService removerService; + + @PostMapping("/run") + @ResponseBody + public void run(Long typeId, BaseModel model, HttpServletResponse response) throws IOException, InterruptedException { + removerService.run(typeId, model, response.getWriter()); + } + +} diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/RestResourcesController.java b/blog-admin/src/main/java/com/zyd/blog/controller/RestResourcesController.java index 802de0b..7de29eb 100644 --- a/blog-admin/src/main/java/com/zyd/blog/controller/RestResourcesController.java +++ b/blog-admin/src/main/java/com/zyd/blog/controller/RestResourcesController.java @@ -28,6 +28,8 @@ import com.zyd.blog.core.shiro.ShiroService; import com.zyd.blog.framework.object.PageResult; import com.zyd.blog.framework.object.ResponseVO; import com.zyd.blog.util.ResultUtil; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -54,17 +56,20 @@ public class RestResourcesController { @Autowired private ShiroService shiroService; + @RequiresPermissions("resources") @PostMapping("/list") public PageResult getAll(ResourceConditionVO vo) { PageInfo pageInfo = resourcesService.findPageBreakByCondition(vo); return ResultUtil.tablePage(pageInfo); } + @RequiresPermissions("role:allotResource") @PostMapping("/resourcesWithSelected") public ResponseVO> resourcesWithSelected(Long rid) { return ResultUtil.success(null, resourcesService.queryResourcesListWithSelected(rid)); } + @RequiresPermissions("resource:add") @PostMapping(value = "/add") public ResponseVO add(Resources resources) { resourcesService.insert(resources); @@ -73,6 +78,7 @@ public class RestResourcesController { return ResultUtil.success("成功"); } + @RequiresPermissions(value = {"resource:batchDelete", "resource:delete"}, logical = Logical.OR) @PostMapping(value = "/remove") public ResponseVO remove(Long[] ids) { if (null == ids) { @@ -87,11 +93,13 @@ public class RestResourcesController { return ResultUtil.success("成功删除 [" + ids.length + "] 个资源"); } + @RequiresPermissions("resource:get") @PostMapping("/get/{id}") public ResponseVO get(@PathVariable Long id) { return ResultUtil.success(null, this.resourcesService.getByPrimaryKey(id)); } + @RequiresPermissions("resource:edit") @PostMapping("/edit") public ResponseVO edit(Resources resources) { try { diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/RestRoleController.java b/blog-admin/src/main/java/com/zyd/blog/controller/RestRoleController.java index d0d19fc..ce14b28 100644 --- a/blog-admin/src/main/java/com/zyd/blog/controller/RestRoleController.java +++ b/blog-admin/src/main/java/com/zyd/blog/controller/RestRoleController.java @@ -29,6 +29,8 @@ import com.zyd.blog.core.shiro.ShiroService; import com.zyd.blog.framework.object.PageResult; import com.zyd.blog.framework.object.ResponseVO; import com.zyd.blog.util.ResultUtil; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.PathVariable; @@ -57,17 +59,20 @@ public class RestRoleController { @Autowired private ShiroService shiroService; + @RequiresPermissions("roles") @PostMapping("/list") public PageResult getAll(RoleConditionVO vo) { PageInfo pageInfo = roleService.findPageBreakByCondition(vo); return ResultUtil.tablePage(pageInfo); } + @RequiresPermissions("user:allotRole") @PostMapping("/rolesWithSelected") public ResponseVO> rolesWithSelected(Integer uid) { return ResultUtil.success(null, roleService.queryRoleListWithSelected(uid)); } + @RequiresPermissions("role:allotResource") @PostMapping("/saveRoleResources") public ResponseVO saveRoleResources(Long roleId, String resourcesId) { if (StringUtils.isEmpty(roleId)) { @@ -79,12 +84,14 @@ public class RestRoleController { return ResultUtil.success("成功"); } + @RequiresPermissions("role:add") @PostMapping(value = "/add") public ResponseVO add(Role role) { roleService.insert(role); return ResultUtil.success("成功"); } + @RequiresPermissions(value = {"role:batchDelete", "role:delete"}, logical = Logical.OR) @PostMapping(value = "/remove") public ResponseVO remove(Long[] ids) { if (null == ids) { @@ -97,11 +104,13 @@ public class RestRoleController { return ResultUtil.success("成功删除 [" + ids.length + "] 个角色"); } + @RequiresPermissions("role:get") @PostMapping("/get/{id}") public ResponseVO get(@PathVariable Long id) { return ResultUtil.success(null, this.roleService.getByPrimaryKey(id)); } + @RequiresPermissions("role:edit") @PostMapping("/edit") public ResponseVO edit(Role role) { try { diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/RestTagController.java b/blog-admin/src/main/java/com/zyd/blog/controller/RestTagController.java index 7a715db..3b572de 100644 --- a/blog-admin/src/main/java/com/zyd/blog/controller/RestTagController.java +++ b/blog-admin/src/main/java/com/zyd/blog/controller/RestTagController.java @@ -27,6 +27,8 @@ import com.zyd.blog.business.vo.TagsConditionVO; import com.zyd.blog.framework.object.PageResult; import com.zyd.blog.framework.object.ResponseVO; import com.zyd.blog.util.ResultUtil; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -48,18 +50,21 @@ public class RestTagController { @Autowired private BizTagsService tagsService; + @RequiresPermissions("tags") @PostMapping("/list") public PageResult list(TagsConditionVO vo) { PageInfo pageInfo = tagsService.findPageBreakByCondition(vo); return ResultUtil.tablePage(pageInfo); } + @RequiresPermissions("tag:add") @PostMapping(value = "/add") public ResponseVO add(Tags tags) { tagsService.insert(tags); return ResultUtil.success("标签添加成功!新标签 - " + tags.getName()); } + @RequiresPermissions(value = {"tag:batchDelete", "tag:delete"}, logical = Logical.OR) @PostMapping(value = "/remove") public ResponseVO remove(Long[] ids) { if (null == ids) { @@ -71,11 +76,13 @@ public class RestTagController { return ResultUtil.success("成功删除 [" + ids.length + "] 个标签"); } + @RequiresPermissions("tag:get") @PostMapping("/get/{id}") public ResponseVO get(@PathVariable Long id) { return ResultUtil.success(null, this.tagsService.getByPrimaryKey(id)); } + @RequiresPermissions("tag:edit") @PostMapping("/edit") public ResponseVO edit(Tags tags) { try { diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/RestTemplateController.java b/blog-admin/src/main/java/com/zyd/blog/controller/RestTemplateController.java index 2d85be7..12e1fe4 100644 --- a/blog-admin/src/main/java/com/zyd/blog/controller/RestTemplateController.java +++ b/blog-admin/src/main/java/com/zyd/blog/controller/RestTemplateController.java @@ -27,6 +27,8 @@ import com.zyd.blog.business.vo.TemplateConditionVO; import com.zyd.blog.framework.object.PageResult; import com.zyd.blog.framework.object.ResponseVO; import com.zyd.blog.util.ResultUtil; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -48,18 +50,21 @@ public class RestTemplateController { @Autowired private SysTemplateService templateService; + @RequiresPermissions("templates") @PostMapping("/list") public PageResult list(TemplateConditionVO vo) { PageInfo