├── README.md ├── blog.sql ├── vueblog ├── .gitignore ├── README.md ├── babel.config.js ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ └── index.html ├── src │ ├── App.vue │ ├── assets │ │ └── logo.png │ ├── components │ │ ├── Login.vue │ │ └── blogs │ │ │ ├── BlogListCom.vue │ │ │ └── SearchBlogsCom.vue │ ├── main.js │ ├── router │ │ └── index.js │ ├── utils │ │ └── api.js │ └── views │ │ ├── Home.vue │ │ └── blogs │ │ ├── AllBlogs.vue │ │ ├── CategoryBlog.vue │ │ ├── CommentBlog.vue │ │ ├── EditBlog.vue │ │ ├── LinksBlog.vue │ │ ├── TagBlog.vue │ │ └── WriteBlog.vue └── vue.config.js ├── xlblog ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── xlblog │ │ │ └── blog │ │ │ ├── BlogApplication.java │ │ │ ├── CodeGenerator.java │ │ │ ├── config │ │ │ ├── MybatisPlusConfig.java │ │ │ ├── SecurityConfig.java │ │ │ └── SwaggerConfig.java │ │ │ ├── controller │ │ │ ├── LoginController.java │ │ │ ├── TBlogController.java │ │ │ ├── TBlogTagsController.java │ │ │ ├── TCommentController.java │ │ │ ├── TContactController.java │ │ │ ├── TLinksController.java │ │ │ ├── TRoleController.java │ │ │ ├── TTagController.java │ │ │ ├── TTrafficController.java │ │ │ ├── TTypeController.java │ │ │ ├── TUserController.java │ │ │ └── TUserRoleController.java │ │ │ ├── entity │ │ │ ├── TBlog.java │ │ │ ├── TBlogTags.java │ │ │ ├── TComment.java │ │ │ ├── TContact.java │ │ │ ├── TLinks.java │ │ │ ├── TRole.java │ │ │ ├── TTag.java │ │ │ ├── TTraffic.java │ │ │ ├── TType.java │ │ │ ├── TUser.java │ │ │ ├── TUserRole.java │ │ │ └── Tcount.java │ │ │ ├── form │ │ │ └── BlogForm.java │ │ │ ├── mapper │ │ │ ├── TBlogMapper.java │ │ │ ├── TBlogTagsMapper.java │ │ │ ├── TCommentMapper.java │ │ │ ├── TContactMapper.java │ │ │ ├── TLinksMapper.java │ │ │ ├── TRoleMapper.java │ │ │ ├── TTagMapper.java │ │ │ ├── TTrafficMapper.java │ │ │ ├── TTypeMapper.java │ │ │ ├── TUserMapper.java │ │ │ └── TUserRoleMapper.java │ │ │ ├── service │ │ │ ├── TBlogService.java │ │ │ ├── TBlogTagsService.java │ │ │ ├── TCommentService.java │ │ │ ├── TContactService.java │ │ │ ├── TLinksService.java │ │ │ ├── TRoleService.java │ │ │ ├── TTagService.java │ │ │ ├── TTrafficService.java │ │ │ ├── TTypeService.java │ │ │ ├── TUserRoleService.java │ │ │ ├── TUserService.java │ │ │ └── impl │ │ │ │ ├── CustomUserServiceImpl.java │ │ │ │ ├── TBlogServiceImpl.java │ │ │ │ ├── TBlogTagsServiceImpl.java │ │ │ │ ├── TCommentServiceImpl.java │ │ │ │ ├── TContactServiceImpl.java │ │ │ │ ├── TLinksServiceImpl.java │ │ │ │ ├── TRoleServiceImpl.java │ │ │ │ ├── TTagServiceImpl.java │ │ │ │ ├── TTrafficServiceImpl.java │ │ │ │ ├── TTypeServiceImpl.java │ │ │ │ ├── TUserRoleServiceImpl.java │ │ │ │ └── TUserServiceImpl.java │ │ │ └── utils │ │ │ ├── RespBean.java │ │ │ ├── Result.java │ │ │ └── blogQuartz.java │ └── resources │ │ ├── application.yml │ │ ├── mapper │ │ ├── TBlogMapper.xml │ │ ├── TBlogTagsMapper.xml │ │ ├── TCommentMapper.xml │ │ ├── TContactMapper.xml │ │ ├── TLinksMapper.xml │ │ ├── TRoleMapper.xml │ │ ├── TTagMapper.xml │ │ ├── TTrafficMapper.xml │ │ ├── TTypeMapper.xml │ │ ├── TUserMapper.xml │ │ └── TUserRoleMapper.xml │ │ └── static │ │ └── images │ │ └── avatar.jpg │ └── test │ └── java │ └── com │ └── xlblog │ └── blog │ └── BlogApplicationTests.java └── xlvueblog ├── .gitignore ├── README.md ├── babel.config.js ├── package-lock.json ├── package.json ├── public ├── favicon.ico └── index.html ├── src ├── App.vue ├── assets │ ├── css │ │ └── mycss.css │ ├── image │ │ ├── bg.jpg │ │ └── code.jpg │ ├── js │ │ ├── clock.js │ │ ├── mouse.js │ │ └── myjs.js │ └── logo.png ├── components │ ├── Blog.vue │ ├── Comment.vue │ ├── Foot.vue │ └── Head.vue ├── main.js ├── router │ └── index.js └── views │ ├── BlogLinks.vue │ ├── BlogSearch.vue │ ├── BlogTag.vue │ ├── BlogType.vue │ ├── Home.vue │ ├── Index.vue │ └── Message.vue └── vue.config.js /README.md: -------------------------------------------------------------------------------- 1 | ### 关注小L,为你分享更多优质文章和实用资源~ 2 | ![输入图片说明](https://images.gitee.com/uploads/images/2021/0309/110313_186aef0d_7415731.png "屏幕截图.png") 3 | 4 | ### 简介 5 | 这是一个使用 SpringBoot+Vue+Mybatis-Plus 开发的前后端分离个人博客,有配套开发教程,欢迎star学习! 6 | 7 | ### 文件介绍 8 | - vueblog:这是后台博客管理的前端 9 | - xlblog:这是后台博客管理后端 10 | - xlvueblog:这是前台博客 11 | 12 | ### 技术路线 13 | - SpringBoot 14 | - Vue 15 | - Mybatis-Plus 16 | - SpringSecurity 17 | - MySQL ... 18 | 19 | ### 项目部署 20 | 后端项目-xlblog 21 | - 1、导入sql。 22 | - 2、修改application.yml文件(配置数据库连接,修改账号密码)。 23 | - 3、启动。 24 | 25 | 前端-vueblog、xlvueblog 26 | - 1、输入 npm install 安装依赖。 27 | - 2、输入 npm run serve 启动项目即可(vueblog启动后登陆的账号:admin,密码:123)。 28 | - 3、浏览器访问:http://localhost:8080。 29 | 30 | 31 | ### 配套教程 32 | - [SpringBoot+Vue+Mybatis-plus 博客:个人博客介绍及效果展示](https://blog.csdn.net/m0_45234510/article/details/114599074) 33 | - [SpringBoot+Vue+Mybatis-plus 博客(一):完成博客后台前端登录页面、后端登录接口](https://blog.csdn.net/m0_45234510/article/details/110405346) 34 | - [SpringBoot+Vue+Mybatis-plus 博客(二):完成登录的前后端对接、完善左侧菜单栏](https://blog.csdn.net/m0_45234510/article/details/110494715) 35 | - [SpringBoot+Vue+Mybatis-plus 博客(三):完成搜索及博客列表展示功能前后端](https://blog.csdn.net/m0_45234510/article/details/110932322) 36 | - [SpringBoot+Vue+Mybatis-plus 博客(四):完成发布文章、编辑文章、删除文章及查询文章功能](https://blog.csdn.net/m0_45234510/article/details/111075386) 37 | - [SpringBoot+Vue+Mybatis-plus 博客(五):完成分类管理和标签管理前后端对接](https://blog.csdn.net/m0_45234510/article/details/112315926) 38 | - [SpringBoot+Vue+Mybatis-plus 博客(六):完成评论管理前后端交互](https://blog.csdn.net/m0_45234510/article/details/114150638) 39 | - [SpringBoot+Vue+Mybatis-plus 博客(七):完成友链管理前后端对接](https://blog.csdn.net/m0_45234510/article/details/114155484) 40 | 41 | ### 效果展示 42 | #### 前台页面 43 | - 博客首页 44 | ![输入图片说明](https://images.gitee.com/uploads/images/2021/0309/105453_c1edf8b8_7415731.png "屏幕截图.png") 45 | 46 | - 分类专栏 47 | ![输入图片说明](https://images.gitee.com/uploads/images/2021/0309/105628_27202941_7415731.png "屏幕截图.png") 48 | 49 | - 标签 50 | ![输入图片说明](https://images.gitee.com/uploads/images/2021/0309/105637_d49ec578_7415731.png "屏幕截图.png") 51 | 52 | - 留言板 53 | ![输入图片说明](https://images.gitee.com/uploads/images/2021/0309/105649_0283e236_7415731.png "屏幕截图.png") 54 | 55 | - 友链 56 | ![输入图片说明](https://images.gitee.com/uploads/images/2021/0309/105655_e73b8306_7415731.png "屏幕截图.png") 57 | 58 | - 搜索 59 | ![输入图片说明](https://images.gitee.com/uploads/images/2021/0309/105705_9a2ac88f_7415731.png "屏幕截图.png") 60 | 61 | 62 | #### 后台博客管理前端页面 63 | 64 | - 写博客 65 | ![输入图片说明](https://images.gitee.com/uploads/images/2021/0309/105854_1c937a22_7415731.png "屏幕截图.png") 66 | 67 | - 文章管理 68 | ![输入图片说明](https://images.gitee.com/uploads/images/2021/0309/105916_e6767076_7415731.png "屏幕截图.png") 69 | 70 | - 分类管理 71 | ![输入图片说明](https://images.gitee.com/uploads/images/2021/0309/105930_b0f58f72_7415731.png "屏幕截图.png") 72 | 73 | - 标签管理 74 | ![输入图片说明](https://images.gitee.com/uploads/images/2021/0309/105939_740c0bf7_7415731.png "屏幕截图.png") 75 | 76 | - 评论管理 77 | ![输入图片说明](https://images.gitee.com/uploads/images/2021/0309/105948_1a4cbee5_7415731.png "屏幕截图.png") 78 | 79 | - 友链管理 80 | ![输入图片说明](https://images.gitee.com/uploads/images/2021/0309/105958_f5046423_7415731.png "屏幕截图.png") 81 | -------------------------------------------------------------------------------- /vueblog/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /vueblog/README.md: -------------------------------------------------------------------------------- 1 | # vueblog 2 | 3 | ## Project setup 4 | ``` 5 | npm install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | npm run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | npm run build 16 | ``` 17 | 18 | ### Customize configuration 19 | See [Configuration Reference](https://cli.vuejs.org/config/). 20 | -------------------------------------------------------------------------------- /vueblog/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /vueblog/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vueblog", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build" 8 | }, 9 | "dependencies": { 10 | "axios": "^0.21.0", 11 | "core-js": "^3.6.5", 12 | "element-ui": "^2.14.1", 13 | "mavon-editor": "^2.9.0", 14 | "vue": "^2.6.11", 15 | "vue-router": "^3.2.0" 16 | }, 17 | "devDependencies": { 18 | "@vue/cli-plugin-babel": "~4.5.0", 19 | "@vue/cli-plugin-router": "~4.5.0", 20 | "@vue/cli-service": "~4.5.0", 21 | "vue-template-compiler": "^2.6.11" 22 | }, 23 | "browserslist": [ 24 | "> 1%", 25 | "last 2 versions", 26 | "not dead" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /vueblog/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdragon0/xiaoLBlog/91ed66993f8133902ffbc7f59f192abc7c40d306/vueblog/public/favicon.ico -------------------------------------------------------------------------------- /vueblog/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 12 | 13 | 18 | 19 | 20 | 23 |
24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /vueblog/src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 10 | -------------------------------------------------------------------------------- /vueblog/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdragon0/xiaoLBlog/91ed66993f8133902ffbc7f59f192abc7c40d306/vueblog/src/assets/logo.png -------------------------------------------------------------------------------- /vueblog/src/components/Login.vue: -------------------------------------------------------------------------------- 1 | 29 | 30 | 75 | 76 | -------------------------------------------------------------------------------- /vueblog/src/components/blogs/SearchBlogsCom.vue: -------------------------------------------------------------------------------- 1 | 41 | 42 | 75 | 76 | -------------------------------------------------------------------------------- /vueblog/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | import router from './router' 4 | 5 | import ElementUI from 'element-ui'; //引入Element ui 6 | import { Message } from 'element-ui' 7 | import 'element-ui/lib/theme-chalk/index.css'; 8 | 9 | import {postKeyValueRequest} from "./utils/api"; 10 | import {postPicRequest} from "./utils/api"; 11 | import {postRequest} from "./utils/api"; 12 | import {putRequest} from "./utils/api"; 13 | import {getRequest} from "./utils/api"; 14 | import {deleteRequest} from "./utils/api"; 15 | 16 | 17 | import mavonEditor from 'mavon-editor' 18 | import 'mavon-editor/dist/css/index.css' 19 | // 使用 mavonEditor 20 | Vue.use(mavonEditor) 21 | 22 | Vue.prototype.postKeyValueRequest = postKeyValueRequest; 23 | Vue.prototype.postPicRequest = postPicRequest; 24 | Vue.prototype.postRequest = postRequest; 25 | Vue.prototype.putRequest = putRequest; 26 | Vue.prototype.getRequest = getRequest; 27 | Vue.prototype.deleteRequest = deleteRequest; 28 | 29 | 30 | Vue.config.productionTip = false 31 | 32 | Vue.use(ElementUI); //使用 ElementUI 33 | 34 | router.beforeEach((to,from,next)=>{ 35 | //to: 将要去哪里 from: 从哪里来的 next: 下一步,放行 36 | //如果要去的页面是Login页,直接放行 37 | if(to.path=='/' || to.path=='/admin'){ 38 | next(); 39 | }else{ 40 | //如果有user,说明已经登录了 41 | if(window.sessionStorage.getItem("user")){ 42 | next(); 43 | }else{ 44 | //没有登录就去登录页并记录你刚才要去的路由 45 | //to.path是你刚要去的路由,但因未登录被拦截了,在登录之后就会直接去到你刚访问的路由 46 | Message.error({message: "尚未登录,请先登录"}) 47 | next('/?redirect=' + to.path); 48 | } 49 | 50 | } 51 | }) 52 | 53 | new Vue({ 54 | router, 55 | render: h => h(App) 56 | }).$mount('#app') 57 | -------------------------------------------------------------------------------- /vueblog/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import VueRouter from 'vue-router' 3 | 4 | import Login from '../components/Login.vue' 5 | import Home from '../views/Home.vue' 6 | 7 | import WriteBlog from '../views/blogs/WriteBlog' 8 | import EditBlog from '../views/blogs/EditBlog' 9 | import AllBlogs from '../views/blogs/AllBlogs' 10 | import CategoryBlog from '../views/blogs/CategoryBlog' 11 | import TagBlog from '../views/blogs/TagBlog' 12 | import CommentBlog from '../views/blogs/CommentBlog' 13 | import LinksBlog from '../views/blogs/LinksBlog' 14 | 15 | 16 | Vue.use(VueRouter) 17 | 18 | const routes = [ 19 | { path: '/',redirect: '/admin',name: 'Login', component: Login, hidden: true }, 20 | 21 | { path: '/admin', name: 'Login', component: Login, hidden: true}, 22 | 23 | { 24 | path: '/admin/home', 25 | name: '博客管理', 26 | component: Home, 27 | children:[ 28 | { path: '/admin/writeblog', name: '写博客', component: WriteBlog }, 29 | { path: '/admin/editblog/:id', name: '编辑博客', component: EditBlog, props: true, hidden: true }, 30 | { path: '/admin/allblogs', name: '文章管理', component: AllBlogs }, 31 | { path: '/admin/categoryblog', name: '分类专栏', component: CategoryBlog }, 32 | { path: '/admin/tagblog', name: '标签管理', component: TagBlog }, 33 | { path: '/admin/commentblog', name: '评论管理', component: CommentBlog }, 34 | { path: '/admin/linksblog', name: '友链管理', component: LinksBlog }, 35 | 36 | ] 37 | }, 38 | 39 | ] 40 | 41 | const router = new VueRouter({ 42 | routes 43 | }) 44 | 45 | export default router 46 | -------------------------------------------------------------------------------- /vueblog/src/utils/api.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | /* 单独引入 此时调用方法为 Message(options)。我们也为每个 type 定义了各自的方法,如 Message.success(options)。 3 | 并且可以调用 Message.closeAll() 手动关闭所有实例。*/ 4 | import { Message } from 'element-ui' 5 | //导入路由 6 | import router from '../router' 7 | 8 | //处理响应信息的响应拦截器 9 | 10 | /*上面已经导入了axios的对象了,这个对象里面有个响应的拦截器axios.interceptors.response.use(),use里面的data是服务端响应给你的数据, 11 | 该拦截器有两个回调函数,一个是success,一个是error,和jQuery里面的ajax一样请求数据的时候也有两个回调函数,一个success,一个error, 12 | 可以简单的理解为http的响应码是200的,它会进入到success方法中来,400以上的会进入到error来 13 | */ 14 | axios.interceptors.response.use(success => { 15 | //success.status: http的响应码 16 | //success.data.status == 500: 返回json的status 17 | if(success.status && success.status == 200 && success.data.status == 500 ){ 18 | //把后台的出错消息写出来 19 | Message.error({message: success.data.msg}) 20 | return; 21 | } 22 | if(success.data.msg){ 23 | //把操作成功的信息也弹出来 24 | Message.success({message: success.data.msg}) 25 | } 26 | return success.data 27 | },error =>{ //失败的处理 28 | if(error.response.status == 504 || error.response.status == 404){ 29 | Message.error({message: "服务器被吃了哦!"}) 30 | }else if(error.response.status == 403){ 31 | Message.error({message: "权限不足,请联系管理员"}) 32 | }else if(error.response.status == 401){ 33 | Message.error({message: "尚未登录"}) 34 | router.replace('/') 35 | }else{ 36 | //服务器返回的错误信息 37 | if(error.response.data.msg){ 38 | Message.error({message: error.response.data.msg}) 39 | }else{ 40 | Message.error({message: "未知错误"}) 41 | } 42 | } 43 | return; 44 | }) 45 | 46 | //封装请求 47 | let base = ''; //避免前缀要一个一个去改,太麻烦 48 | // 49 | export const postKeyValueRequest=(url,params)=>{ 50 | 51 | return axios({ 52 | method: 'post', 53 | url: `${base}${url}`, //特别注意这里是``引用变量的方式,而不是'' 54 | data: params, //直接这样以json的形式传给服务器,这是不支持的,所有还需要定义下面的transformRequest 55 | transformRequest: [function (data){ 56 | let ret = ''; 57 | for(let i in data){ 58 | //往ret上面追加变量 59 | ret+=encodeURIComponent(i) + '=' + encodeURIComponent(data[i]) + '&' 60 | } 61 | // console.log(ret); 62 | return ret; 63 | }], 64 | //定义header 65 | headers:{ 66 | 'Content-Type':'application/x-www-form-urlencoded ' 67 | } 68 | }) 69 | 70 | } 71 | 72 | export const postPicRequest=(url,params)=>{ 73 | return axios({ 74 | method: 'post', 75 | url: `${base}${url}`, //特别注意这里是``引用变量的方式,而不是'' 76 | data: params, 77 | //定义header 78 | headers:{ 79 | 'Content-Type':'multipart/form-data' 80 | } 81 | }) 82 | 83 | } 84 | 85 | export const postRequest=(url, params)=>{ 86 | return axios({ 87 | method: 'post', 88 | url: `${base}${url}`, 89 | data: params //这是用json来传递的,所以不用加transformRequest转换了 90 | }) 91 | } 92 | 93 | export const putRequest=(url, params)=>{ 94 | return axios({ 95 | method: 'put', 96 | url: `${base}${url}`, 97 | data: params //这是用json来传递的,所以不用加transformRequest转换了 98 | }) 99 | } 100 | 101 | export const getRequest=(url, params)=>{ 102 | return axios({ 103 | method: 'get', 104 | url: `${base}${url}`, 105 | data: params //这是用json来传递的,所以不用加transformRequest转换了 106 | }) 107 | } 108 | 109 | export const deleteRequest=(url, params)=>{ 110 | return axios({ 111 | method: 'delete', 112 | url: `${base}${url}`, 113 | data: params //这是用json来传递的,所以不用加transformRequest转换了 114 | }) 115 | } 116 | -------------------------------------------------------------------------------- /vueblog/src/views/Home.vue: -------------------------------------------------------------------------------- 1 | 59 | 60 | 93 | 94 | 139 | -------------------------------------------------------------------------------- /vueblog/src/views/blogs/AllBlogs.vue: -------------------------------------------------------------------------------- 1 | 41 | 42 | 91 | 92 | -------------------------------------------------------------------------------- /vueblog/src/views/blogs/CategoryBlog.vue: -------------------------------------------------------------------------------- 1 | 97 | 98 | 212 | 213 | -------------------------------------------------------------------------------- /vueblog/src/views/blogs/TagBlog.vue: -------------------------------------------------------------------------------- 1 | 96 | 97 | 209 | 210 | -------------------------------------------------------------------------------- /vueblog/vue.config.js: -------------------------------------------------------------------------------- 1 | //配置请求转发的代理 2 | 3 | //定义代理的对象 4 | let proxyObj = {}; 5 | 6 | //拦截http请求 7 | proxyObj['/'] = { 8 | ws: false, //关掉websocket 9 | target: 'http://localhost:8082', //目标转发的地址 10 | changeOrigin: true, 11 | pathRewrite:{ //请求地址重写 12 | '^/': '' //拦截到的地址不去修改它 13 | } 14 | } 15 | 16 | //把上面的导出来 17 | module.exports = { 18 | devServer:{ //配置开发环境 19 | host: 'localhost', //端口号 20 | // host: '192.168.49.27', //端口号 21 | port: 8080, 22 | proxy: proxyObj //代理对象 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /xlblog/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /xlblog/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import java.net.*; 18 | import java.io.*; 19 | import java.nio.channels.*; 20 | import java.util.Properties; 21 | 22 | public class MavenWrapperDownloader { 23 | 24 | private static final String WRAPPER_VERSION = "0.5.6"; 25 | /** 26 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 27 | */ 28 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 29 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 30 | 31 | /** 32 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 33 | * use instead of the default one. 34 | */ 35 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 36 | ".mvn/wrapper/maven-wrapper.properties"; 37 | 38 | /** 39 | * Path where the maven-wrapper.jar will be saved to. 40 | */ 41 | private static final String MAVEN_WRAPPER_JAR_PATH = 42 | ".mvn/wrapper/maven-wrapper.jar"; 43 | 44 | /** 45 | * Name of the property which should be used to override the default download url for the wrapper. 46 | */ 47 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 48 | 49 | public static void main(String args[]) { 50 | System.out.println("- Downloader started"); 51 | File baseDirectory = new File(args[0]); 52 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 53 | 54 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 55 | // wrapperUrl parameter. 56 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 57 | String url = DEFAULT_DOWNLOAD_URL; 58 | if (mavenWrapperPropertyFile.exists()) { 59 | FileInputStream mavenWrapperPropertyFileInputStream = null; 60 | try { 61 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 62 | Properties mavenWrapperProperties = new Properties(); 63 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 64 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 65 | } catch (IOException e) { 66 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 67 | } finally { 68 | try { 69 | if (mavenWrapperPropertyFileInputStream != null) { 70 | mavenWrapperPropertyFileInputStream.close(); 71 | } 72 | } catch (IOException e) { 73 | // Ignore ... 74 | } 75 | } 76 | } 77 | System.out.println("- Downloading from: " + url); 78 | 79 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 80 | if (!outputFile.getParentFile().exists()) { 81 | if (!outputFile.getParentFile().mkdirs()) { 82 | System.out.println( 83 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 84 | } 85 | } 86 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 87 | try { 88 | downloadFileFromURL(url, outputFile); 89 | System.out.println("Done"); 90 | System.exit(0); 91 | } catch (Throwable e) { 92 | System.out.println("- Error downloading"); 93 | e.printStackTrace(); 94 | System.exit(1); 95 | } 96 | } 97 | 98 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 99 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 100 | String username = System.getenv("MVNW_USERNAME"); 101 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 102 | Authenticator.setDefault(new Authenticator() { 103 | @Override 104 | protected PasswordAuthentication getPasswordAuthentication() { 105 | return new PasswordAuthentication(username, password); 106 | } 107 | }); 108 | } 109 | URL website = new URL(urlString); 110 | ReadableByteChannel rbc; 111 | rbc = Channels.newChannel(website.openStream()); 112 | FileOutputStream fos = new FileOutputStream(destination); 113 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 114 | fos.close(); 115 | rbc.close(); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /xlblog/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdragon0/xiaoLBlog/91ed66993f8133902ffbc7f59f192abc7c40d306/xlblog/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /xlblog/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /xlblog/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.4.0 9 | 10 | 11 | com.xlblog 12 | blog 13 | 0.0.1-SNAPSHOT 14 | blog 15 | myblog 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-security 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-thymeleaf 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-data-redis 36 | 37 | 38 | 39 | org.quartz-scheduler 40 | quartz 41 | 2.2.3 42 | 43 | 44 | 45 | com.baomidou 46 | mybatis-plus-boot-starter 47 | 3.2.0 48 | 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-freemarker 53 | 54 | 55 | 56 | com.baomidou 57 | mybatis-plus-generator 58 | 3.2.0 59 | 60 | 61 | 62 | org.projectlombok 63 | lombok 64 | true 65 | 66 | 67 | 68 | io.springfox 69 | springfox-swagger-ui 70 | 2.9.2 71 | 72 | 73 | 74 | 75 | io.springfox 76 | springfox-swagger2 77 | 2.9.2 78 | 79 | 80 | org.springframework.boot 81 | spring-boot-starter-web 82 | 83 | 84 | org.mybatis.spring.boot 85 | mybatis-spring-boot-starter 86 | 2.1.4 87 | 88 | 89 | 90 | org.springframework.boot 91 | spring-boot-devtools 92 | runtime 93 | true 94 | 95 | 96 | 97 | mysql 98 | mysql-connector-java 99 | runtime 100 | 101 | 102 | org.springframework.boot 103 | spring-boot-starter-test 104 | test 105 | 106 | 107 | 108 | 109 | 110 | 111 | org.springframework.boot 112 | spring-boot-maven-plugin 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/BlogApplication.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.transaction.annotation.EnableTransactionManagement; 6 | 7 | @SpringBootApplication 8 | @EnableTransactionManagement //开启事务支持 9 | public class BlogApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(BlogApplication.class, args); 13 | } 14 | 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/CodeGenerator.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog; 2 | 3 | import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException; 4 | import com.baomidou.mybatisplus.core.toolkit.StringPool; 5 | import com.baomidou.mybatisplus.core.toolkit.StringUtils; 6 | import com.baomidou.mybatisplus.generator.AutoGenerator; 7 | import com.baomidou.mybatisplus.generator.InjectionConfig; 8 | import com.baomidou.mybatisplus.generator.config.*; 9 | import com.baomidou.mybatisplus.generator.config.po.TableInfo; 10 | import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; 11 | import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | import java.util.Scanner; 16 | 17 | // 演示例子,执行 main 方法控制台输入模块表名回车自动生成对应项目目录中 18 | public class CodeGenerator { 19 | 20 | /** 21 | *

22 | * 读取控制台内容 23 | *

24 | */ 25 | public static String scanner(String tip) { 26 | Scanner scanner = new Scanner(System.in); 27 | StringBuilder help = new StringBuilder(); 28 | help.append("请输入" + tip + ":"); 29 | System.out.println(help.toString()); 30 | if (scanner.hasNext()) { 31 | String ipt = scanner.next(); 32 | if (StringUtils.isNotEmpty(ipt)) { 33 | return ipt; 34 | } 35 | } 36 | throw new MybatisPlusException("请输入正确的" + tip + "!"); 37 | } 38 | 39 | public static void main(String[] args) { 40 | // 代码生成器 41 | AutoGenerator mpg = new AutoGenerator(); 42 | 43 | // 全局配置 44 | GlobalConfig gc = new GlobalConfig(); 45 | String projectPath = System.getProperty("user.dir"); 46 | gc.setOutputDir(projectPath + "/src/main/java"); 47 | // gc.setOutputDir("D:\\test"); 48 | gc.setAuthor("关注公众号:小L星光"); 49 | gc.setOpen(false); 50 | gc.setSwagger2(true); //实体属性 Swagger2 注解 51 | gc.setServiceName("%sService"); 52 | mpg.setGlobalConfig(gc); 53 | 54 | // 数据源配置 55 | DataSourceConfig dsc = new DataSourceConfig(); 56 | dsc.setUrl("jdbc:mysql://localhost:3306/blog?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=UTC"); 57 | // dsc.setSchemaName("public"); 58 | dsc.setDriverName("com.mysql.cj.jdbc.Driver"); 59 | dsc.setUsername("root"); 60 | dsc.setPassword("xxx"); 61 | mpg.setDataSource(dsc); 62 | 63 | // 包配置 64 | PackageConfig pc = new PackageConfig(); 65 | pc.setModuleName(null); 66 | pc.setParent("com.xlblog.blog"); 67 | mpg.setPackageInfo(pc); 68 | 69 | // 自定义配置 70 | InjectionConfig cfg = new InjectionConfig() { 71 | @Override 72 | public void initMap() { 73 | // to do nothing 74 | } 75 | }; 76 | 77 | // 如果模板引擎是 freemarker 78 | String templatePath = "/templates/mapper.xml.ftl"; 79 | // 如果模板引擎是 velocity 80 | // String templatePath = "/templates/mapper.xml.vm"; 81 | 82 | // 自定义输出配置 83 | List focList = new ArrayList<>(); 84 | // 自定义配置会被优先输出 85 | focList.add(new FileOutConfig(templatePath) { 86 | @Override 87 | public String outputFile(TableInfo tableInfo) { 88 | // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!! 89 | return projectPath + "/src/main/resources/mapper/" 90 | + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML; 91 | } 92 | }); 93 | 94 | cfg.setFileOutConfigList(focList); 95 | mpg.setCfg(cfg); 96 | 97 | // 配置模板 98 | TemplateConfig templateConfig = new TemplateConfig(); 99 | 100 | templateConfig.setXml(null); 101 | mpg.setTemplate(templateConfig); 102 | 103 | // 策略配置 104 | StrategyConfig strategy = new StrategyConfig(); 105 | strategy.setNaming(NamingStrategy.underline_to_camel); 106 | strategy.setColumnNaming(NamingStrategy.underline_to_camel); 107 | strategy.setEntityLombokModel(true); 108 | strategy.setRestControllerStyle(true); 109 | strategy.setInclude(scanner("表名,多个英文逗号分割").split(",")); 110 | strategy.setControllerMappingHyphenStyle(true); 111 | strategy.setTablePrefix("m_"); 112 | mpg.setStrategy(strategy); 113 | mpg.setTemplateEngine(new FreemarkerTemplateEngine()); 114 | mpg.execute(); 115 | } 116 | } -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/config/MybatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.config; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; 4 | import org.mybatis.spring.annotation.MapperScan; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.transaction.annotation.EnableTransactionManagement; 8 | 9 | @Configuration 10 | @EnableTransactionManagement 11 | @MapperScan("com.xlblog.blog.mapper") 12 | public class MybatisPlusConfig { 13 | @Bean 14 | public PaginationInterceptor paginationInterceptor() { 15 | PaginationInterceptor paginationInterceptor = new PaginationInterceptor(); 16 | return paginationInterceptor; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/config/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.config; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import com.xlblog.blog.entity.TUser; 5 | import com.xlblog.blog.service.impl.CustomUserServiceImpl; 6 | import com.xlblog.blog.utils.RespBean; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.security.authentication.BadCredentialsException; 10 | import org.springframework.security.authentication.CredentialsExpiredException; 11 | import org.springframework.security.authentication.DisabledException; 12 | import org.springframework.security.authentication.LockedException; 13 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 14 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 15 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 16 | import org.springframework.security.core.Authentication; 17 | import org.springframework.security.core.AuthenticationException; 18 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 19 | import org.springframework.security.crypto.password.PasswordEncoder; 20 | import org.springframework.security.web.authentication.AuthenticationFailureHandler; 21 | import org.springframework.security.web.authentication.AuthenticationSuccessHandler; 22 | import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; 23 | 24 | import javax.annotation.Resource; 25 | import javax.servlet.ServletException; 26 | import javax.servlet.http.HttpServletRequest; 27 | import javax.servlet.http.HttpServletResponse; 28 | import javax.servlet.http.HttpSession; 29 | import java.io.IOException; 30 | import java.io.PrintWriter; 31 | 32 | @Configuration 33 | public class SecurityConfig extends WebSecurityConfigurerAdapter { 34 | 35 | @Resource 36 | CustomUserServiceImpl customUserService; 37 | 38 | @Bean 39 | PasswordEncoder passwordEncoder(){ 40 | return new BCryptPasswordEncoder(); 41 | } 42 | 43 | //要有一个configure方法吧hrService整进来 44 | @Override 45 | protected void configure(AuthenticationManagerBuilder auth) throws Exception{ 46 | auth.userDetailsService(customUserService); 47 | } 48 | 49 | @Override 50 | protected void configure(HttpSecurity http) throws Exception { 51 | http.authorizeRequests() 52 | .antMatchers("/blog/vuefindByPage","/blog/getByBlogId", 53 | "/type/getAllType","/tag/getAllTag","/blog/getByTitle", 54 | "/comment/comments/{blogId}","/comment/comments", 55 | "/blog/countBlog","/comment/getCommentByPage", 56 | "/links/getAllLink","/blog/vuefindHotBlog").permitAll() 57 | // .antMatchers("/blog/getByBlogId").permitAll() 58 | .anyRequest().authenticated() 59 | .and() 60 | .formLogin() 61 | .usernameParameter("username") 62 | .passwordParameter("password") 63 | .loginProcessingUrl("/doLogin") 64 | .loginPage("/login") 65 | .successHandler(new AuthenticationSuccessHandler() { 66 | @Override 67 | public void onAuthenticationSuccess(HttpServletRequest req, HttpServletResponse resp, Authentication authentication) throws IOException, ServletException { 68 | //如果登录成功就返回一段json 69 | resp.setContentType("application/json;charset=utf-8"); 70 | //这是往出写的 71 | PrintWriter out = resp.getWriter(); 72 | //登录成功的hr对象 73 | TUser user = (TUser)authentication.getPrincipal(); 74 | //为了安全,这里返回给前端时将密码设置为null 75 | user.setPassword(null); 76 | RespBean ok = RespBean.ok("登录成功!",user); 77 | //把Hr写成字符串 78 | String s = new ObjectMapper().writeValueAsString(ok); 79 | //把字符串写出去 80 | out.write(s); 81 | out.flush(); 82 | out.close(); 83 | } 84 | }) 85 | .failureHandler(new AuthenticationFailureHandler() { 86 | @Override 87 | public void onAuthenticationFailure(HttpServletRequest req, HttpServletResponse resp, 88 | AuthenticationException exception) throws IOException, ServletException { 89 | //如果登录失败也返回一段json 90 | resp.setContentType("application/json;charset=utf-8"); 91 | //设置状态码 92 | resp.setStatus(401); 93 | //这是往出写的 94 | PrintWriter out = resp.getWriter(); 95 | RespBean respBean = RespBean.error("登录失败!"); 96 | if(exception instanceof LockedException){ 97 | respBean.setMsg("账户被锁定,请联系管理员!"); 98 | }else if (exception instanceof CredentialsExpiredException){ 99 | respBean.setMsg("密码过期,请联系管理员!"); 100 | }else if (exception instanceof DisabledException){ 101 | respBean.setMsg("账户被禁用,请联系管理员!"); 102 | }else if (exception instanceof BadCredentialsException){ 103 | respBean.setMsg("用户名或者密码输入错误,请重新输入!"); 104 | } 105 | out.write(new ObjectMapper().writeValueAsString(respBean)); 106 | out.flush(); 107 | out.close(); 108 | 109 | } 110 | }) 111 | .permitAll() 112 | .and() 113 | .logout() 114 | .logoutSuccessHandler(new LogoutSuccessHandler() { 115 | @Override 116 | public void onLogoutSuccess(HttpServletRequest req, HttpServletResponse resp, 117 | Authentication authentication) throws IOException, ServletException { 118 | resp.setContentType("application/json;charset=utf-8"); 119 | PrintWriter out = resp.getWriter(); 120 | out.write(new ObjectMapper().writeValueAsString(RespBean.ok("注销成功!"))); 121 | out.flush(); 122 | out.close(); 123 | } 124 | }) 125 | .permitAll() 126 | .and() 127 | .csrf().disable(); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.RequestHandlerSelectors; 6 | import springfox.documentation.service.ApiInfo; 7 | import springfox.documentation.service.Contact; 8 | import springfox.documentation.spi.DocumentationType; 9 | import springfox.documentation.spring.web.plugins.Docket; 10 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 11 | 12 | import java.util.ArrayList; 13 | 14 | @Configuration 15 | @EnableSwagger2 //开启swagger2 16 | public class SwaggerConfig { 17 | 18 | //配置了Swagger的Docker的Bean实例 19 | @Bean 20 | public Docket docket(){ 21 | return new Docket(DocumentationType.SWAGGER_2) 22 | .apiInfo(apiInfo()) 23 | .enable(true) //配置是否启用Swagger,如果是false,在浏览器将无法访问 24 | .select()// 通过.select()方法,去配置扫描接口,RequestHandlerSelectors配置如何扫描接口 25 | .apis(RequestHandlerSelectors.basePackage("com.xlblog.blog.controller")) 26 | .build(); 27 | } 28 | 29 | //配置swagger信息 apiInfo 30 | private ApiInfo apiInfo(){ 31 | //作者信息 32 | Contact DEFAULT_CONTACT = new Contact("xl", "http://baidu.com", "xxx@qq.com"); 33 | 34 | return new ApiInfo( 35 | "api文档", 36 | "api描述信息", 37 | "v1.0", 38 | "http://localhost:8082", 39 | DEFAULT_CONTACT, 40 | "Apache 2.0", 41 | "http://www.apache.org/licenses/LICENSE-2.0", 42 | new ArrayList()); 43 | 44 | } 45 | } -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.controller; 2 | 3 | import com.xlblog.blog.utils.RespBean; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | public class LoginController { 9 | @GetMapping("/login") 10 | public RespBean login(){ 11 | return RespBean.error("尚未登录,请先登录!"); 12 | } 13 | } -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/controller/TBlogTagsController.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.controller; 2 | 3 | 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | /** 9 | *

10 | * 前端控制器 11 | *

12 | * 13 | * @author 关注公众号:小L星光 14 | * @since 2020-11-30 15 | */ 16 | @RestController 17 | @RequestMapping("/t-blog-tags") 18 | public class TBlogTagsController { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/controller/TCommentController.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 5 | import com.xlblog.blog.entity.TBlog; 6 | import com.xlblog.blog.entity.TComment; 7 | import com.xlblog.blog.entity.TUser; 8 | import com.xlblog.blog.service.TBlogService; 9 | import com.xlblog.blog.service.TCommentService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.beans.factory.annotation.Value; 12 | import org.springframework.security.core.Authentication; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | import org.springframework.web.servlet.mvc.support.RedirectAttributes; 16 | 17 | import javax.servlet.http.HttpServletRequest; 18 | import javax.servlet.http.HttpSession; 19 | import java.security.Principal; 20 | import java.util.List; 21 | 22 | /** 23 | *

24 | * 前端控制器 25 | *

26 | * 27 | * @author 关注公众号:小L星光 28 | * @since 2020-11-30 29 | */ 30 | @RestController 31 | @RequestMapping("/comment") 32 | public class TCommentController { 33 | 34 | @Autowired 35 | private TCommentService commentService; 36 | @Autowired 37 | private TBlogService tBlogService; 38 | 39 | //查询评论列表 40 | @GetMapping("/comments/{blogId}") 41 | public List comments(@PathVariable Long blogId) { 42 | return commentService.listCommentByBlogId(blogId); 43 | } 44 | 45 | //查询所有评论 46 | @GetMapping("/getCommentByPage") 47 | public Page getCommentByPage(Long current, Long size){ 48 | return commentService.getCommentByPage(current, size); 49 | } 50 | 51 | //根据评论人姓名查询评论 52 | @GetMapping("/comments") 53 | public List findCommentByNickname(String nickname){ 54 | return commentService.findCommentByNickname(nickname); 55 | } 56 | 57 | 58 | //新增评论 59 | @PostMapping("/comments") 60 | public List post(@RequestBody TComment tComment,Authentication authentication,HttpServletRequest request) { 61 | //获取评论人的ip 62 | String ip = request.getHeader("x-forwarded-for"); 63 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 64 | ip = request.getHeader("Proxy-Client-IP"); 65 | } 66 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 67 | ip = request.getHeader("WL-Proxy-Client-IP"); 68 | } 69 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 70 | ip = request.getHeader("HTTP_CLIENT_IP"); 71 | } 72 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 73 | ip = request.getHeader("HTTP_X_FORWARDED_FOR"); 74 | } 75 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 76 | ip = request.getRemoteAddr(); 77 | } 78 | Long blogId = tComment.getBlogId(); 79 | if (authentication != null){ 80 | TUser user = (TUser)authentication.getPrincipal(); 81 | tComment.setAvatar(user.getAvatar()); 82 | tComment.setAdminComment(true); 83 | tComment.setIp(ip); 84 | } 85 | else { 86 | //设置头像 87 | tComment.setAvatar("https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2070453827,1163403148&fm=26&gp=0.jpg"); 88 | tComment.setIp(ip); 89 | } 90 | if (tComment.getParentComment() != null) { 91 | tComment.setParentCommentId(tComment.getParentComment().getId()); 92 | } 93 | commentService.saveComment(tComment); 94 | TBlog tBlog = tBlogService.getById(blogId); 95 | tBlog.setCommentCount(tBlog.getCommentCount() + 1); 96 | tBlogService.updateByComment(tBlog); 97 | return commentService.listCommentByBlogId(blogId); 98 | } 99 | 100 | //删除评论 101 | @DeleteMapping("/deleteComment") 102 | public String delete(Long id){ 103 | commentService.deleteComment(id); 104 | return "OK"; 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/controller/TContactController.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.controller; 2 | 3 | 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | /** 9 | *

10 | * 前端控制器 11 | *

12 | * 13 | * @author 关注公众号:小L星光 14 | * @since 2020-11-30 15 | */ 16 | @RestController 17 | @RequestMapping("/t-contact") 18 | public class TContactController { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/controller/TLinksController.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.xlblog.blog.entity.TLinks; 6 | import com.xlblog.blog.service.TLinksService; 7 | import com.xlblog.blog.utils.RespBean; 8 | import io.swagger.annotations.ApiImplicitParam; 9 | import io.swagger.annotations.ApiImplicitParams; 10 | import io.swagger.annotations.ApiOperation; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.web.bind.annotation.*; 13 | 14 | import java.time.LocalDateTime; 15 | import java.util.List; 16 | 17 | /** 18 | *

19 | * 前端控制器 20 | *

21 | * 22 | * @author 关注公众号:小L星光 23 | * @since 2020-11-30 24 | */ 25 | @RestController 26 | @RequestMapping("/links") 27 | public class TLinksController { 28 | @Autowired 29 | TLinksService tLinksService; 30 | 31 | RespBean respBean = RespBean.build(); 32 | 33 | /** 34 | * 新增友链 35 | * @param tLinks 36 | * @return 37 | */ 38 | @PostMapping("/saveLink") 39 | public RespBean saveLink(@RequestBody TLinks tLinks){ 40 | tLinks.setCreateTime(LocalDateTime.now()); 41 | Boolean result = tLinksService.save(tLinks); 42 | if (result){ 43 | respBean.setStatus(200); 44 | respBean.setMsg("添加友链成功!"); 45 | return respBean; 46 | }else { 47 | respBean.setStatus(500); 48 | respBean.setMsg("添加友链失败!"); 49 | return respBean; 50 | } 51 | 52 | } 53 | 54 | /** 55 | * 查询所有 56 | * @return 57 | */ 58 | @GetMapping("/getAllLink") 59 | public RespBean getAllLink(){ 60 | List linksList = tLinksService.list(); 61 | return RespBean.ok("查询成功!",linksList); 62 | } 63 | 64 | /** 65 | * 友链的分页查询 66 | * @param current 67 | * @param size 68 | * @return 69 | */ 70 | @GetMapping("/getLinksByPage") 71 | @ApiOperation("友链的分页查询") 72 | @ApiImplicitParams({ 73 | @ApiImplicitParam(name = "current",value = "当前页") , 74 | @ApiImplicitParam(name = "size",value = "每页的数量"), 75 | }) 76 | public RespBean getLinksByPage(Long current, Long size){ 77 | return tLinksService.pageLinks(current, size); 78 | } 79 | 80 | /** 81 | * 通过名称查找友链 82 | * @param name 83 | * @return 84 | */ 85 | @GetMapping("/getLinksByName") 86 | public RespBean getLinksByName(String name){ 87 | return tLinksService.getLinksByName(name); 88 | } 89 | 90 | /** 91 | * 更新友链 92 | * @param tLinks 93 | * @return 94 | */ 95 | @PutMapping("/updateLink") 96 | public RespBean updateLink(@RequestBody TLinks tLinks){ 97 | return tLinksService.updateLink(tLinks); 98 | } 99 | 100 | /** 101 | * 删除友链 102 | * @param id 103 | * @return 104 | */ 105 | @DeleteMapping("deleteLinkById") 106 | public RespBean deleteLinkById(Long id){ 107 | return tLinksService.deleteLinkById(id); 108 | } 109 | 110 | /** 111 | * 根据id查询友链 112 | * @param id 113 | * @return 114 | */ 115 | @GetMapping("/getLinksById") 116 | public RespBean getLinksById(Long id){ 117 | return tLinksService.getLinksById(id); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/controller/TRoleController.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.controller; 2 | 3 | 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | /** 9 | *

10 | * 前端控制器 11 | *

12 | * 13 | * @author 关注公众号:小L星光 14 | * @since 2020-11-30 15 | */ 16 | @RestController 17 | @RequestMapping("/t-role") 18 | public class TRoleController { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/controller/TTagController.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.baomidou.mybatisplus.core.toolkit.StringUtils; 6 | import com.xlblog.blog.entity.TTag; 7 | import com.xlblog.blog.entity.TType; 8 | import com.xlblog.blog.service.TTagService; 9 | import com.xlblog.blog.service.TTypeService; 10 | import com.xlblog.blog.utils.RespBean; 11 | import io.swagger.annotations.ApiImplicitParam; 12 | import io.swagger.annotations.ApiImplicitParams; 13 | import io.swagger.annotations.ApiOperation; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.web.bind.annotation.*; 16 | 17 | import java.util.List; 18 | 19 | /** 20 | *

21 | * 前端控制器 22 | *

23 | * 24 | * @author 关注公众号:小L星光 25 | * @since 2020-11-30 26 | */ 27 | @RestController 28 | @RequestMapping("/tag") 29 | public class TTagController { 30 | 31 | @Autowired 32 | TTagService tTagService; 33 | 34 | RespBean respBean = RespBean.build(); 35 | 36 | @PostMapping("/saveTag") 37 | public RespBean saveTag(@RequestBody TTag tTag){ 38 | if (StringUtils.isEmpty(tTag.getName())){ 39 | respBean.setStatus(500); 40 | respBean.setMsg("标签名称不能为空!"); 41 | return respBean; 42 | } 43 | QueryWrapper queryWrapper = new QueryWrapper(); 44 | queryWrapper.eq("name",tTag.getName()); 45 | List tagList = tTagService.list(queryWrapper); 46 | if (tagList.size() > 0){ 47 | respBean.setStatus(500); 48 | respBean.setMsg("添加失败,已有该标签名称"); 49 | return respBean; 50 | } 51 | Boolean result = tTagService.save(tTag); 52 | if (result){ 53 | respBean.setStatus(200); 54 | respBean.setMsg("添加标签成功!"); 55 | return respBean; 56 | }else { 57 | respBean.setStatus(500); 58 | respBean.setMsg("添加标签失败!"); 59 | return respBean; 60 | } 61 | 62 | } 63 | 64 | /** 65 | * 查询所有标签 66 | * @return 67 | */ 68 | @GetMapping("/getAllTag") 69 | public RespBean getAllTag(){ 70 | return tTagService.getAllTag(); 71 | } 72 | 73 | 74 | 75 | /** 76 | * 标签的分页查询 77 | * @param current 78 | * @param size 79 | * @return 80 | */ 81 | @GetMapping("/getTagByPage") 82 | @ApiOperation("标签的分页查询") 83 | @ApiImplicitParams({ 84 | @ApiImplicitParam(name = "current",value = "当前页") , 85 | @ApiImplicitParam(name = "size",value = "每页的数量"), 86 | }) 87 | public RespBean getTagByPage(Long current, Long size){ 88 | return tTagService.pageTags(current, size); 89 | } 90 | 91 | /** 92 | * 通过名称查找标签 93 | * @param name 94 | * @return 95 | */ 96 | @GetMapping("/getTagByName") 97 | public RespBean getTagByName(String name){ 98 | return tTagService.getTagByName(name); 99 | } 100 | 101 | /** 102 | * 更新标签 103 | * @param tTag 104 | * @return 105 | */ 106 | @PutMapping("/updateTag") 107 | public RespBean updateTag(@RequestBody TTag tTag){ 108 | if (StringUtils.isEmpty(tTag.getName())){ 109 | respBean.setMsg("分类名称不能为空"); 110 | return respBean; 111 | } 112 | return tTagService.updateTag(tTag); 113 | } 114 | 115 | /** 116 | * 删除标签 117 | * @param id 118 | * @return 119 | */ 120 | @DeleteMapping("deleteTagById") 121 | public RespBean deleteTagById(Long id){ 122 | return tTagService.deleteTagById(id); 123 | } 124 | 125 | /** 126 | * 根据id查询标签 127 | * @param id 128 | * @return 129 | */ 130 | @GetMapping("/getTagById") 131 | public RespBean getTagById(Long id){ 132 | return tTagService.getTagById(id); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/controller/TTrafficController.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.controller; 2 | 3 | 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | /** 9 | *

10 | * 前端控制器 11 | *

12 | * 13 | * @author 关注公众号:小L星光 14 | * @since 2020-11-30 15 | */ 16 | @RestController 17 | @RequestMapping("/t-traffic") 18 | public class TTrafficController { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/controller/TTypeController.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.baomidou.mybatisplus.core.toolkit.StringUtils; 6 | import com.xlblog.blog.entity.TBlog; 7 | import com.xlblog.blog.entity.TType; 8 | import com.xlblog.blog.service.TTypeService; 9 | import com.xlblog.blog.utils.RespBean; 10 | import io.swagger.annotations.ApiImplicitParam; 11 | import io.swagger.annotations.ApiImplicitParams; 12 | import io.swagger.annotations.ApiOperation; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.web.bind.annotation.*; 15 | 16 | import java.util.List; 17 | 18 | /** 19 | *

20 | * 前端控制器 21 | *

22 | * 23 | * @author 关注公众号:小L星光 24 | * @since 2020-11-30 25 | */ 26 | @RestController 27 | @RequestMapping("/type") 28 | public class TTypeController { 29 | 30 | @Autowired 31 | TTypeService tTypeService; 32 | 33 | RespBean respBean = RespBean.build(); 34 | 35 | /** 36 | * 保存分类专栏 37 | * @param tType 38 | * @return 39 | */ 40 | @PostMapping("/saveType") 41 | public RespBean saveType(@RequestBody TType tType){ 42 | if (StringUtils.isEmpty(tType.getName())){ 43 | respBean.setStatus(500); 44 | respBean.setMsg("分类专栏名称不能为空!"); 45 | return respBean; 46 | } 47 | QueryWrapper queryWrapper = new QueryWrapper(); 48 | queryWrapper.eq("name",tType.getName()); 49 | List tBlogList = tTypeService.list(queryWrapper); 50 | if (tBlogList.size() > 0){ 51 | respBean.setStatus(500); 52 | respBean.setMsg("添加失败,已有该分类专栏名称"); 53 | return respBean; 54 | } 55 | Boolean result = tTypeService.save(tType); 56 | if (result){ 57 | respBean.setStatus(200); 58 | respBean.setMsg("添加成功!"); 59 | return respBean; 60 | }else { 61 | respBean.setStatus(500); 62 | respBean.setMsg("添加失败!"); 63 | return respBean; 64 | } 65 | 66 | } 67 | 68 | /** 69 | * 查询所有分类 70 | * @return 71 | */ 72 | @GetMapping("/getAllType") 73 | public RespBean getAllType(){ 74 | // List typeList = tTypeService.list(); 75 | return tTypeService.getAllType(); 76 | } 77 | 78 | /** 79 | * 分类的分页查询 80 | * @param current 81 | * @param size 82 | * @return 83 | */ 84 | @GetMapping("/getTypeByPage") 85 | @ApiOperation("分类的分页查询") 86 | @ApiImplicitParams({ 87 | @ApiImplicitParam(name = "current",value = "当前页") , 88 | @ApiImplicitParam(name = "size",value = "每页的数量"), 89 | }) 90 | public RespBean getByPage(Long current, Long size){ 91 | return tTypeService.pageTypes(current, size); 92 | } 93 | 94 | /** 95 | * 通过名称查找分类 96 | * @param name 97 | * @return 98 | */ 99 | @GetMapping("/getTypeByName") 100 | public RespBean getTypeByName(String name){ 101 | return tTypeService.getTypeByName(name); 102 | } 103 | 104 | /** 105 | * 更新分类 106 | * @param tType 107 | * @return 108 | */ 109 | @PutMapping("/updateType") 110 | public RespBean updateType(@RequestBody TType tType){ 111 | if (StringUtils.isEmpty(tType.getName())){ 112 | respBean.setMsg("分类名称不能为空"); 113 | return respBean; 114 | } 115 | return tTypeService.updateType(tType); 116 | } 117 | 118 | /** 119 | * 删除分类 120 | * @param id 121 | * @return 122 | */ 123 | @DeleteMapping("deleteTypeById") 124 | public RespBean deleteTypeById(Long id){ 125 | return tTypeService.deleteTypeById(id); 126 | } 127 | 128 | /** 129 | * 根据id查询分类 130 | * @param id 131 | * @return 132 | */ 133 | @GetMapping("/getTypeById") 134 | public RespBean getTypeById(Long id){ 135 | return tTypeService.getTypeById(id); 136 | } 137 | 138 | } 139 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/controller/TUserController.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.controller; 2 | 3 | 4 | import com.xlblog.blog.entity.TUser; 5 | import com.xlblog.blog.service.TUserService; 6 | import com.xlblog.blog.utils.RespBean; 7 | import com.xlblog.blog.utils.Result; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | /** 16 | *

17 | * 前端控制器 18 | *

19 | * 20 | * @author 关注公众号:小L星光 21 | * @since 2020-11-30 22 | */ 23 | @RestController 24 | public class TUserController { 25 | 26 | @GetMapping("/hello") 27 | public RespBean test() { 28 | return RespBean.ok("hello"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/controller/TUserRoleController.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.controller; 2 | 3 | 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | /** 9 | *

10 | * 前端控制器 11 | *

12 | * 13 | * @author 关注公众号:小L星光 14 | * @since 2020-11-30 15 | */ 16 | @RestController 17 | @RequestMapping("/t-user-role") 18 | public class TUserRoleController { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/entity/TBlog.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.entity; 2 | 3 | import java.time.LocalDateTime; 4 | import java.io.Serializable; 5 | import java.util.List; 6 | 7 | import com.baomidou.mybatisplus.annotation.TableField; 8 | import com.baomidou.mybatisplus.annotation.TableName; 9 | import com.fasterxml.jackson.annotation.JsonFormat; 10 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 11 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 12 | import io.swagger.annotations.ApiModel; 13 | import io.swagger.annotations.ApiModelProperty; 14 | import lombok.Data; 15 | import lombok.EqualsAndHashCode; 16 | import lombok.experimental.Accessors; 17 | 18 | /** 19 | *

20 | * 21 | *

22 | * 23 | * @author 关注公众号:小L星光 24 | * @since 2020-11-30 25 | */ 26 | @Data 27 | @EqualsAndHashCode(callSuper = false) 28 | @Accessors(chain = true) 29 | @ApiModel(value="TBlog对象", description="") 30 | //@TableName(value = "t_blog" ,resultMap = "MyBlogMap") 31 | public class TBlog implements Serializable { 32 | 33 | private static final long serialVersionUID = 1L; 34 | 35 | @JsonSerialize(using = ToStringSerializer.class) //系统序列化时,保留相关精度 36 | @ApiModelProperty(value = "博客id") 37 | private Long id; 38 | 39 | // @ApiModelProperty(value = "是否开启赞赏") 40 | // private Boolean appreciation; 41 | // 42 | // @ApiModelProperty(value = "是否开启评论") 43 | // private Boolean commentabled; 44 | 45 | @ApiModelProperty(value = "博客内容") 46 | private String content; 47 | 48 | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "Asia/ShangHai") 49 | @ApiModelProperty(value = "创建时间") 50 | private LocalDateTime createTime ; 51 | 52 | @ApiModelProperty(value = "描述") 53 | private String description; 54 | 55 | @ApiModelProperty(value = "首图地址") 56 | private String firstPicture; 57 | 58 | @ApiModelProperty(value = "原创") 59 | private String flag; 60 | 61 | @ApiModelProperty(value = "是否公开") 62 | private Boolean published; 63 | 64 | // @ApiModelProperty(value = "是否可以回复") 65 | // private Boolean recommend; 66 | 67 | @ApiModelProperty(value = "草稿") 68 | private Boolean shareStatement; 69 | 70 | @ApiModelProperty(value = "标题") 71 | private String title; 72 | 73 | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "Asia/ShangHai") 74 | @ApiModelProperty(value = "更新时间") 75 | private LocalDateTime updateTime; 76 | 77 | @ApiModelProperty(value = "浏览量") 78 | private Integer views; 79 | 80 | @JsonSerialize(using = ToStringSerializer.class) //系统序列化时,保留相关精度 81 | @ApiModelProperty(value = "分类id") 82 | private Long typeId; 83 | 84 | @JsonSerialize(using = ToStringSerializer.class) //系统序列化时,保留相关精度 85 | @ApiModelProperty(value = "用户id") 86 | private Long userId; 87 | 88 | @JsonSerialize(using = ToStringSerializer.class) //系统序列化时,保留相关精度 89 | @ApiModelProperty(value = "评论次数") 90 | private Long commentCount; 91 | 92 | @ApiModelProperty(value = "逻辑删除") 93 | private Boolean isDelete; 94 | 95 | @TableField(exist = false) //查询时过滤非数据库字段 96 | @ApiModelProperty(value = "博客标签集合") 97 | private List tBlogTags; 98 | 99 | @TableField(exist = false) //查询时过滤非数据库字段 100 | @ApiModelProperty(value = "分类专栏对象") 101 | private TType tType; 102 | 103 | @TableField(exist = false) //查询时过滤非数据库字段 104 | @ApiModelProperty(value = "用户对象") 105 | private TUser tUser; 106 | 107 | 108 | } 109 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/entity/TBlogTags.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.baomidou.mybatisplus.annotation.TableField; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 8 | import io.swagger.annotations.ApiModel; 9 | import io.swagger.annotations.ApiModelProperty; 10 | import lombok.Data; 11 | import lombok.EqualsAndHashCode; 12 | import lombok.experimental.Accessors; 13 | 14 | /** 15 | *

16 | * 17 | *

18 | * 19 | * @author 关注公众号:小L星光 20 | * @since 2020-11-30 21 | */ 22 | @Data 23 | @EqualsAndHashCode(callSuper = false) 24 | @Accessors(chain = true) 25 | @ApiModel(value="TBlogTags对象", description="") 26 | public class TBlogTags implements Serializable { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | @JsonSerialize(using = ToStringSerializer.class) 31 | @ApiModelProperty(value = "博客id") 32 | private Long blogsId; 33 | 34 | @JsonSerialize(using = ToStringSerializer.class) 35 | @ApiModelProperty(value = "标签id") 36 | private Long tagsId; 37 | 38 | @TableField(exist = false) 39 | @ApiModelProperty(value = "博客对象") 40 | private TBlog tBlog; 41 | 42 | @TableField(exist = false) 43 | @ApiModelProperty(value = "标签对象") 44 | private TTag tTag; 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/entity/TComment.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.entity; 2 | 3 | import java.time.LocalDateTime; 4 | import java.io.Serializable; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import com.baomidou.mybatisplus.annotation.TableField; 9 | import com.fasterxml.jackson.annotation.JsonFormat; 10 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 11 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 12 | import io.swagger.annotations.ApiModel; 13 | import io.swagger.annotations.ApiModelProperty; 14 | import lombok.Data; 15 | import lombok.EqualsAndHashCode; 16 | import lombok.experimental.Accessors; 17 | 18 | /** 19 | *

20 | * 21 | *

22 | * 23 | * @author 关注公众号:小L星光 24 | * @since 2020-11-30 25 | */ 26 | @Data 27 | @EqualsAndHashCode(callSuper = false) 28 | @Accessors(chain = true) 29 | @ApiModel(value="TComment对象", description="") 30 | public class TComment implements Serializable { 31 | 32 | private static final long serialVersionUID = 1L; 33 | 34 | @JsonSerialize(using = ToStringSerializer.class) //系统序列化时,保留相关精度 35 | @ApiModelProperty(value = "评论id") 36 | private Long id; 37 | 38 | @ApiModelProperty(value = "是否为管理员评论") 39 | private Boolean adminComment; 40 | 41 | @ApiModelProperty(value = "头像") 42 | private String avatar; 43 | 44 | @ApiModelProperty(value = "评论内容") 45 | private String content; 46 | 47 | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "Asia/ShangHai") 48 | @ApiModelProperty(value = "创建时间") 49 | private LocalDateTime createTime; 50 | 51 | @ApiModelProperty(value = "邮箱") 52 | private String email; 53 | 54 | @ApiModelProperty(value = "ip地址") 55 | private String ip; 56 | 57 | @ApiModelProperty(value = "昵称") 58 | private String nickname; 59 | 60 | @JsonSerialize(using = ToStringSerializer.class) //系统序列化时,保留相关精度 61 | @ApiModelProperty(value = "博客id") 62 | private Long blogId; 63 | 64 | @JsonSerialize(using = ToStringSerializer.class) //系统序列化时,保留相关精度 65 | @ApiModelProperty(value = "父评论id") 66 | private Long parentCommentId; 67 | 68 | //回复评论 69 | @TableField(exist = false) //查询时过滤非数据库字段 70 | private List replyComments = new ArrayList<>(); 71 | @TableField(exist = false) //查询时过滤非数据库字段 72 | private TComment parentComment; 73 | @TableField(exist = false) //查询时过滤非数据库字段 74 | private String parentNickname; 75 | 76 | } 77 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/entity/TContact.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.entity; 2 | 3 | import java.io.Serializable; 4 | import io.swagger.annotations.ApiModel; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Data; 7 | import lombok.EqualsAndHashCode; 8 | import lombok.experimental.Accessors; 9 | 10 | /** 11 | *

12 | * 13 | *

14 | * 15 | * @author 关注公众号:小L星光 16 | * @since 2020-11-30 17 | */ 18 | @Data 19 | @EqualsAndHashCode(callSuper = false) 20 | @Accessors(chain = true) 21 | @ApiModel(value="TContact对象", description="") 22 | public class TContact implements Serializable { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | @ApiModelProperty(value = "主键id") 27 | private Long id; 28 | 29 | @ApiModelProperty(value = "邮箱") 30 | private String email; 31 | 32 | @ApiModelProperty(value = "微信支付二维码") 33 | private String payByWechat; 34 | 35 | @ApiModelProperty(value = "支付宝二维码") 36 | private String payByZhi; 37 | 38 | @ApiModelProperty(value = "qq账号") 39 | private String qq; 40 | 41 | @ApiModelProperty(value = "微信号") 42 | private String wechat; 43 | 44 | @ApiModelProperty(value = "微信二维码") 45 | private String wechatCode; 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/entity/TLinks.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.entity; 2 | 3 | import java.time.LocalDateTime; 4 | import java.io.Serializable; 5 | 6 | import com.fasterxml.jackson.annotation.JsonFormat; 7 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 8 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 9 | import io.swagger.annotations.ApiModel; 10 | import io.swagger.annotations.ApiModelProperty; 11 | import lombok.Data; 12 | import lombok.EqualsAndHashCode; 13 | import lombok.experimental.Accessors; 14 | 15 | /** 16 | *

17 | * 18 | *

19 | * 20 | * @author 关注公众号:小L星光 21 | * @since 2020-11-30 22 | */ 23 | @Data 24 | @EqualsAndHashCode(callSuper = false) 25 | @Accessors(chain = true) 26 | @ApiModel(value="TLinks对象", description="") 27 | public class TLinks implements Serializable { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | @JsonSerialize(using = ToStringSerializer.class) //系统序列化时,保留相关精度 32 | @ApiModelProperty(value = "主键id") 33 | private Long id; 34 | 35 | @ApiModelProperty(value = "博客地址") 36 | private String blogAddress; 37 | 38 | @ApiModelProperty(value = "博客名称") 39 | private String blogName; 40 | 41 | @ApiModelProperty(value = "首图") 42 | private String pictureAddress; 43 | 44 | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "Asia/ShangHai") 45 | @ApiModelProperty(value = "创建时间") 46 | private LocalDateTime createTime; 47 | 48 | } 49 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/entity/TRole.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableField; 4 | import java.io.Serializable; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | import lombok.EqualsAndHashCode; 9 | import lombok.experimental.Accessors; 10 | 11 | /** 12 | *

13 | * 14 | *

15 | * 16 | * @author 关注公众号:小L星光 17 | * @since 2020-11-30 18 | */ 19 | @Data 20 | @EqualsAndHashCode(callSuper = false) 21 | @Accessors(chain = true) 22 | @ApiModel(value="TRole对象", description="") 23 | public class TRole implements Serializable { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | @ApiModelProperty(value = "角色id") 28 | private Long id; 29 | 30 | @ApiModelProperty(value = "角色名") 31 | private String name; 32 | 33 | @ApiModelProperty(value = "角色中文名") 34 | @TableField("nameZh") 35 | private String nameZh; 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/entity/TTag.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.entity; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import com.baomidou.mybatisplus.annotation.TableField; 7 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 8 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 9 | import io.swagger.annotations.ApiModel; 10 | import io.swagger.annotations.ApiModelProperty; 11 | import lombok.Data; 12 | import lombok.EqualsAndHashCode; 13 | import lombok.experimental.Accessors; 14 | 15 | /** 16 | *

17 | * 18 | *

19 | * 20 | * @author 关注公众号:小L星光 21 | * @since 2020-11-30 22 | */ 23 | @Data 24 | @EqualsAndHashCode(callSuper = false) 25 | @Accessors(chain = true) 26 | @ApiModel(value="TTag对象", description="") 27 | public class TTag implements Serializable { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | @JsonSerialize(using = ToStringSerializer.class) 32 | @ApiModelProperty(value = "主键id") 33 | private Long id; 34 | 35 | @ApiModelProperty(value = "颜色") 36 | private String color; 37 | 38 | @ApiModelProperty(value = "名称") 39 | private String name; 40 | 41 | @TableField(exist = false) //查询时过滤非数据库字段 42 | @ApiModelProperty(value = "博客标签集合") 43 | private List tBlogTags; 44 | 45 | @TableField(exist = false) //查询时过滤非数据库字段 46 | private Integer countTag; 47 | 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/entity/TTraffic.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import java.time.LocalDateTime; 6 | import java.io.Serializable; 7 | import io.swagger.annotations.ApiModel; 8 | import io.swagger.annotations.ApiModelProperty; 9 | import lombok.Data; 10 | import lombok.EqualsAndHashCode; 11 | import lombok.experimental.Accessors; 12 | 13 | /** 14 | *

15 | * 16 | *

17 | * 18 | * @author 关注公众号:小L星光 19 | * @since 2020-11-30 20 | */ 21 | @Data 22 | @EqualsAndHashCode(callSuper = false) 23 | @Accessors(chain = true) 24 | @ApiModel(value="TTraffic对象", description="") 25 | public class TTraffic implements Serializable { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | @ApiModelProperty(value = "id") 30 | @TableId(value = "id", type = IdType.AUTO) 31 | private Long id; 32 | 33 | @ApiModelProperty(value = "创建时间") 34 | private LocalDateTime createTime; 35 | 36 | @ApiModelProperty(value = "ip地址") 37 | private String ip; 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/entity/TType.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.entity; 2 | 3 | import java.io.Serializable; 4 | import java.util.UUID; 5 | 6 | import com.baomidou.mybatisplus.annotation.TableField; 7 | import com.fasterxml.jackson.annotation.JsonProperty; 8 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 9 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 10 | import io.swagger.annotations.ApiModel; 11 | import io.swagger.annotations.ApiModelProperty; 12 | import lombok.Data; 13 | import lombok.EqualsAndHashCode; 14 | import lombok.experimental.Accessors; 15 | 16 | /** 17 | *

18 | * 19 | *

20 | * 21 | * @author 关注公众号:小L星光 22 | * @since 2020-11-30 23 | */ 24 | @Data 25 | @EqualsAndHashCode(callSuper = false) 26 | @Accessors(chain = true) 27 | @ApiModel(value="TType对象", description="") 28 | public class TType implements Serializable { 29 | 30 | private static final long serialVersionUID = 1L; 31 | 32 | @JsonSerialize(using = ToStringSerializer.class) 33 | @ApiModelProperty(value = "分类id") 34 | private Long id; 35 | 36 | @ApiModelProperty(value = "分类名称") 37 | private String name; 38 | 39 | @TableField(exist = false) //查询时过滤非数据库字段 40 | private Integer countType; 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/entity/TUser.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.entity; 2 | 3 | import java.time.LocalDateTime; 4 | import java.io.Serializable; 5 | import java.util.ArrayList; 6 | import java.util.Collection; 7 | import java.util.List; 8 | 9 | import io.swagger.annotations.ApiModel; 10 | import io.swagger.annotations.ApiModelProperty; 11 | import lombok.Data; 12 | import lombok.EqualsAndHashCode; 13 | import lombok.experimental.Accessors; 14 | import org.springframework.security.core.GrantedAuthority; 15 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 16 | import org.springframework.security.core.userdetails.UserDetails; 17 | 18 | /** 19 | *

20 | * 21 | *

22 | * 23 | * @author 关注公众号:小L星光 24 | * @since 2020-11-30 25 | */ 26 | @Data 27 | @EqualsAndHashCode(callSuper = false) 28 | @Accessors(chain = true) 29 | @ApiModel(value="TUser对象", description="") 30 | public class TUser implements Serializable,UserDetails { 31 | 32 | private static final long serialVersionUID = 1L; 33 | 34 | @ApiModelProperty(value = "用户id") 35 | private Long id; 36 | 37 | @ApiModelProperty(value = "头像") 38 | private String avatar; 39 | 40 | @ApiModelProperty(value = "创建时间") 41 | private LocalDateTime createTime; 42 | 43 | @ApiModelProperty(value = "邮箱") 44 | private String email; 45 | 46 | @ApiModelProperty(value = "昵称") 47 | private String nickname; 48 | 49 | @ApiModelProperty(value = "密码") 50 | private String password; 51 | 52 | @ApiModelProperty(value = "角色") 53 | private Integer type; 54 | 55 | @ApiModelProperty(value = "更新时间") 56 | private LocalDateTime updateTime; 57 | 58 | @ApiModelProperty(value = "用户名") 59 | private String username; 60 | 61 | private List roles; 62 | 63 | 64 | @Override 65 | public Collection getAuthorities() { 66 | // List authorities = new ArrayList<>(); 67 | // for (TRole role : getRoles()){ 68 | // authorities.add(new SimpleGrantedAuthority(role.getName())); 69 | // } 70 | return null; 71 | } 72 | @Override 73 | public boolean isAccountNonExpired() { 74 | return true; 75 | } 76 | @Override 77 | public boolean isAccountNonLocked() { 78 | return true; 79 | } 80 | @Override 81 | public boolean isCredentialsNonExpired() { 82 | return true; 83 | } 84 | @Override 85 | public boolean isEnabled() { 86 | return true; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/entity/TUserRole.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.entity; 2 | 3 | import java.io.Serializable; 4 | import io.swagger.annotations.ApiModel; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Data; 7 | import lombok.EqualsAndHashCode; 8 | import lombok.experimental.Accessors; 9 | 10 | /** 11 | *

12 | * 13 | *

14 | * 15 | * @author 关注公众号:小L星光 16 | * @since 2020-11-30 17 | */ 18 | @Data 19 | @EqualsAndHashCode(callSuper = false) 20 | @Accessors(chain = true) 21 | @ApiModel(value="TUserRole对象", description="") 22 | public class TUserRole implements Serializable { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | @ApiModelProperty(value = "用户角色id") 27 | private Integer id; 28 | 29 | @ApiModelProperty(value = "用户id") 30 | private Integer uid; 31 | 32 | @ApiModelProperty(value = "角色id") 33 | private Integer rid; 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/entity/Tcount.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.entity; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | import lombok.experimental.Accessors; 6 | 7 | @Data 8 | @EqualsAndHashCode(callSuper = false) 9 | @Accessors(chain = true) 10 | public class Tcount { 11 | private static final long serialVersionUID = 1L; 12 | private Integer blogCount; 13 | private Integer viewCount; 14 | private Long commentCount; 15 | private Long messageCount; 16 | } 17 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/form/BlogForm.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.form; 2 | 3 | import com.baomidou.mybatisplus.core.toolkit.StringUtils; 4 | import com.xlblog.blog.utils.RespBean; 5 | 6 | import java.util.HashMap; 7 | import java.util.List; 8 | 9 | /** 10 | * 表单校验 11 | */ 12 | public class BlogForm { 13 | public static RespBean check(HashMap params) { 14 | String title = (String) params.get("title"); 15 | String description = (String) params.get("description"); 16 | String first_picture = (String) params.get("first_picture"); 17 | String content = (String) params.get("content"); 18 | List tags = (List) params.get("tags"); 19 | Long type_id = Long.parseLong(params.get("type_id").toString()); 20 | String flag = (String) params.get("flag"); 21 | // Boolean published = (Boolean) params.get("published"); 22 | RespBean info = new RespBean(); 23 | if (StringUtils.isEmpty(title)) { 24 | info.setStatus(500); 25 | info.setMsg("title 不能为空"); 26 | }else if (StringUtils.isEmpty(description)) { 27 | info.setStatus(500); 28 | info.setMsg("description 不能为空"); 29 | }else if (StringUtils.isEmpty(first_picture)) { 30 | info.setStatus(500); 31 | info.setMsg("first_picture 不能为空"); 32 | }else if (StringUtils.isEmpty(content)) { 33 | info.setStatus(500); 34 | info.setMsg("content 不能为空"); 35 | }else if (tags.size() == 0) { 36 | info.setStatus(500); 37 | info.setMsg("tags 不能为空"); 38 | }else if (type_id == null) { 39 | info.setStatus(500); 40 | info.setMsg("type_id 不能为空"); 41 | }else if (StringUtils.isEmpty(flag)) { 42 | info.setStatus(500); 43 | info.setMsg("flag 不能为空"); 44 | }else { 45 | info.setMsg("校验成功"); 46 | info.setStatus(200); 47 | } 48 | return info; 49 | } 50 | 51 | public static RespBean checkTemporaryBlog(HashMap params) { 52 | String title = (String) params.get("title"); 53 | String description = (String) params.get("description"); 54 | String first_picture = (String) params.get("first_picture"); 55 | String content = (String) params.get("content"); 56 | RespBean info = new RespBean(); 57 | if (StringUtils.isEmpty(title)) { 58 | info.setStatus(500); 59 | info.setMsg("title 不能为空"); 60 | }else if (StringUtils.isEmpty(description)) { 61 | info.setStatus(500); 62 | info.setMsg("description 不能为空"); 63 | }else if (StringUtils.isEmpty(first_picture)) { 64 | info.setStatus(500); 65 | info.setMsg("first_picture 不能为空"); 66 | }else if (StringUtils.isEmpty(content)) { 67 | info.setStatus(500); 68 | info.setMsg("content 不能为空"); 69 | } 70 | return info; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/mapper/TBlogMapper.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.mapper; 2 | 3 | import com.xlblog.blog.entity.TBlog; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | 8 | import java.util.List; 9 | 10 | /** 11 | *

12 | * Mapper 接口 13 | *

14 | * 15 | * @author 关注公众号:小L星光 16 | * @since 2020-11-30 17 | */ 18 | public interface TBlogMapper extends BaseMapper { 19 | //根据id查找博客 20 | TBlog getByBlogId(@Param("id") String id); 21 | //前台分页查询 22 | List vuefindByPage(@Param("current") Long current, @Param("size")Long size, 23 | @Param("typeid") Long type_id, @Param("tagsid") Long tags_id); 24 | //前台查询所有博客 25 | List findAllBlog(); 26 | //前台根据标题查找博客 27 | List getByTitle(String title); 28 | 29 | // void updateByComment(TBlog tBlog); 30 | } 31 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/mapper/TBlogTagsMapper.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.mapper; 2 | 3 | import com.xlblog.blog.entity.TBlogTags; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * Mapper 接口 9 | *

10 | * 11 | * @author 关注公众号:小L星光 12 | * @since 2020-11-30 13 | */ 14 | public interface TBlogTagsMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/mapper/TCommentMapper.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.mapper; 2 | 3 | import com.xlblog.blog.entity.TComment; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | *

11 | * Mapper 接口 12 | *

13 | * 14 | * @author 关注公众号:小L星光 15 | * @since 2020-11-30 16 | */ 17 | public interface TCommentMapper extends BaseMapper { 18 | //查询父级评论 19 | List findByBlogIdParentIdNull(@Param("blogId") Long blogId, @Param("blogParentId") Long blogParentId); 20 | 21 | //查询一级回复 22 | List findByBlogIdParentIdNotNull(@Param("blogId") Long blogId, @Param("id") Long id); 23 | 24 | //查询二级回复 25 | List findByBlogIdAndReplayId(@Param("blogId") Long blogId,@Param("childId") Long childId); 26 | 27 | //添加一个评论 28 | int saveComment(TComment comment); 29 | 30 | //删除评论 31 | void deleteComment(Long id); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/mapper/TContactMapper.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.mapper; 2 | 3 | import com.xlblog.blog.entity.TContact; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * Mapper 接口 9 | *

10 | * 11 | * @author 关注公众号:小L星光 12 | * @since 2020-11-30 13 | */ 14 | public interface TContactMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/mapper/TLinksMapper.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.mapper; 2 | 3 | import com.xlblog.blog.entity.TLinks; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * Mapper 接口 9 | *

10 | * 11 | * @author 关注公众号:小L星光 12 | * @since 2020-11-30 13 | */ 14 | public interface TLinksMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/mapper/TRoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.mapper; 2 | 3 | import com.xlblog.blog.entity.TRole; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * Mapper 接口 9 | *

10 | * 11 | * @author 关注公众号:小L星光 12 | * @since 2020-11-30 13 | */ 14 | public interface TRoleMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/mapper/TTagMapper.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.mapper; 2 | 3 | import com.xlblog.blog.entity.TTag; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | *

10 | * Mapper 接口 11 | *

12 | * 13 | * @author 关注公众号:小L星光 14 | * @since 2020-11-30 15 | */ 16 | public interface TTagMapper extends BaseMapper { 17 | 18 | List getAllTag(); 19 | } 20 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/mapper/TTrafficMapper.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.mapper; 2 | 3 | import com.xlblog.blog.entity.TTraffic; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * Mapper 接口 9 | *

10 | * 11 | * @author 关注公众号:小L星光 12 | * @since 2020-11-30 13 | */ 14 | public interface TTrafficMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/mapper/TTypeMapper.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.mapper; 2 | 3 | import com.xlblog.blog.entity.TType; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | *

10 | * Mapper 接口 11 | *

12 | * 13 | * @author 关注公众号:小L星光 14 | * @since 2020-11-30 15 | */ 16 | public interface TTypeMapper extends BaseMapper { 17 | 18 | List getAllType(); 19 | } 20 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/mapper/TUserMapper.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.mapper; 2 | 3 | import com.xlblog.blog.entity.TUser; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author 关注公众号:小L星光 13 | * @since 2020-11-30 14 | */ 15 | public interface TUserMapper extends BaseMapper { 16 | TUser loadUserByUsername(String username); 17 | } 18 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/mapper/TUserRoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.mapper; 2 | 3 | import com.xlblog.blog.entity.TUserRole; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * Mapper 接口 9 | *

10 | * 11 | * @author 关注公众号:小L星光 12 | * @since 2020-11-30 13 | */ 14 | public interface TUserRoleMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/TBlogService.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import com.xlblog.blog.entity.TBlog; 5 | import com.baomidou.mybatisplus.extension.service.IService; 6 | import com.xlblog.blog.utils.RespBean; 7 | 8 | import java.util.HashMap; 9 | 10 | /** 11 | *

12 | * 服务类 13 | *

14 | * 15 | * @author 关注公众号:小L星光 16 | * @since 2020-11-30 17 | */ 18 | public interface TBlogService extends IService { 19 | //分页查询 20 | RespBean pageBlogs(Long current, Long limit, Boolean published, String flag, Boolean share_statement, Boolean is_delete); 21 | //根据博客标题查询 22 | RespBean getByTitle(String title); 23 | //添加博客和标签 24 | RespBean saveBT(HashMap params); 25 | //暂时保存博客 26 | RespBean temporarySave(HashMap params); 27 | //更新博客 28 | RespBean updateBlog(HashMap params); 29 | //删除博客(逻辑删除) 30 | RespBean logicDeleteBlog(String id); 31 | //删除博客和标签(彻底删除) 32 | RespBean deleteBT(String id); 33 | //还原博客 34 | RespBean recoveryBlog(String id); 35 | //根据博客id查询 36 | RespBean getByBlogId(String id); 37 | //分页查询博客(前台) 38 | RespBean vuefindByPage(Long current, Long size, Long type_id, Long tags_id); 39 | //更新评论总数 40 | void updateByComment(TBlog tBlog); 41 | //统计数据 42 | RespBean countBlog(); 43 | //热门top文章 44 | RespBean vuefindHotBlog(); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/TBlogTagsService.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service; 2 | 3 | import com.xlblog.blog.entity.TBlogTags; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 服务类 9 | *

10 | * 11 | * @author 关注公众号:小L星光 12 | * @since 2020-11-30 13 | */ 14 | public interface TBlogTagsService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/TCommentService.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import com.xlblog.blog.entity.TComment; 5 | import com.baomidou.mybatisplus.extension.service.IService; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | *

11 | * 服务类 12 | *

13 | * 14 | * @author 关注公众号:小L星光 15 | * @since 2020-11-30 16 | */ 17 | public interface TCommentService extends IService { 18 | //根据博客id查询评论信息 19 | List listCommentByBlogId(Long blogId); 20 | 21 | //添加保存评论 22 | int saveComment(TComment comment); 23 | 24 | //删除评论 25 | void deleteComment(Long id); 26 | 27 | List findCommentByNickname(String nickname); 28 | 29 | Page getCommentByPage(Long current, Long size); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/TContactService.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service; 2 | 3 | import com.xlblog.blog.entity.TContact; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 服务类 9 | *

10 | * 11 | * @author 关注公众号:小L星光 12 | * @since 2020-11-30 13 | */ 14 | public interface TContactService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/TLinksService.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service; 2 | 3 | import com.xlblog.blog.entity.TLinks; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import com.xlblog.blog.utils.RespBean; 6 | 7 | /** 8 | *

9 | * 服务类 10 | *

11 | * 12 | * @author 关注公众号:小L星光 13 | * @since 2020-11-30 14 | */ 15 | public interface TLinksService extends IService { 16 | 17 | RespBean pageLinks(Long current, Long size); 18 | 19 | RespBean getLinksByName(String name); 20 | 21 | RespBean updateLink(TLinks tLinks); 22 | 23 | RespBean deleteLinkById(Long id); 24 | 25 | RespBean getLinksById(Long id); 26 | } 27 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/TRoleService.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service; 2 | 3 | import com.xlblog.blog.entity.TRole; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 服务类 9 | *

10 | * 11 | * @author 关注公众号:小L星光 12 | * @since 2020-11-30 13 | */ 14 | public interface TRoleService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/TTagService.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service; 2 | 3 | import com.xlblog.blog.entity.TTag; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import com.xlblog.blog.utils.RespBean; 6 | 7 | /** 8 | *

9 | * 服务类 10 | *

11 | * 12 | * @author 关注公众号:小L星光 13 | * @since 2020-11-30 14 | */ 15 | public interface TTagService extends IService { 16 | 17 | RespBean pageTags(Long current, Long size); 18 | 19 | RespBean getTagByName(String name); 20 | 21 | RespBean updateTag(TTag tTag); 22 | 23 | RespBean deleteTagById(Long id); 24 | 25 | RespBean getTagById(Long id); 26 | 27 | RespBean getAllTag(); 28 | } 29 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/TTrafficService.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service; 2 | 3 | import com.xlblog.blog.entity.TTraffic; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 服务类 9 | *

10 | * 11 | * @author 关注公众号:小L星光 12 | * @since 2020-11-30 13 | */ 14 | public interface TTrafficService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/TTypeService.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service; 2 | 3 | import com.xlblog.blog.entity.TType; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import com.xlblog.blog.utils.RespBean; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | *

11 | * 服务类 12 | *

13 | * 14 | * @author 关注公众号:小L星光 15 | * @since 2020-11-30 16 | */ 17 | public interface TTypeService extends IService { 18 | 19 | RespBean pageTypes(Long current, Long size); 20 | 21 | RespBean getTypeByName(String name); 22 | 23 | RespBean deleteTypeById(Long id); 24 | 25 | RespBean updateType(TType tType); 26 | 27 | RespBean getTypeById(Long id); 28 | 29 | RespBean getAllType(); 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/TUserRoleService.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service; 2 | 3 | import com.xlblog.blog.entity.TUserRole; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 服务类 9 | *

10 | * 11 | * @author 关注公众号:小L星光 12 | * @since 2020-11-30 13 | */ 14 | public interface TUserRoleService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/TUserService.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service; 2 | 3 | import com.xlblog.blog.entity.TUser; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 服务类 9 | *

10 | * 11 | * @author 关注公众号:小L星光 12 | * @since 2020-11-30 13 | */ 14 | 15 | public interface TUserService extends IService { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/impl/CustomUserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service.impl; 2 | 3 | import com.xlblog.blog.entity.TUser; 4 | import com.xlblog.blog.mapper.TUserMapper; 5 | import org.springframework.security.core.userdetails.UserDetails; 6 | import org.springframework.security.core.userdetails.UserDetailsService; 7 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 8 | import org.springframework.stereotype.Service; 9 | 10 | import javax.annotation.Resource; 11 | 12 | @Service 13 | public class CustomUserServiceImpl implements UserDetailsService { 14 | @Resource 15 | TUserMapper tUserMapper; 16 | 17 | @Override 18 | public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException { 19 | TUser tUser = tUserMapper.loadUserByUsername(s); 20 | if (s == null){ //如果用户名不存在,就抛出下面的信息 21 | throw new UsernameNotFoundException("用户名不存在!"); 22 | } 23 | //用户存在的话就返回hr对象 24 | return tUser; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/impl/TBlogTagsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service.impl; 2 | 3 | import com.xlblog.blog.entity.TBlogTags; 4 | import com.xlblog.blog.mapper.TBlogTagsMapper; 5 | import com.xlblog.blog.service.TBlogTagsService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 服务实现类 12 | *

13 | * 14 | * @author 关注公众号:小L星光 15 | * @since 2020-11-30 16 | */ 17 | @Service 18 | public class TBlogTagsServiceImpl extends ServiceImpl implements TBlogTagsService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/impl/TCommentServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 5 | import com.xlblog.blog.entity.TBlog; 6 | import com.xlblog.blog.entity.TComment; 7 | import com.xlblog.blog.entity.TTag; 8 | import com.xlblog.blog.mapper.TBlogMapper; 9 | import com.xlblog.blog.mapper.TCommentMapper; 10 | import com.xlblog.blog.service.TCommentService; 11 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Service; 14 | 15 | import java.time.LocalDateTime; 16 | import java.util.ArrayList; 17 | import java.util.Date; 18 | import java.util.List; 19 | 20 | /** 21 | *

22 | * 服务实现类 23 | *

24 | * 25 | * @author 关注公众号:小L星光 26 | * @since 2020-11-30 27 | */ 28 | @Service 29 | public class TCommentServiceImpl extends ServiceImpl implements TCommentService { 30 | 31 | @Autowired 32 | private TCommentMapper commentMapper; 33 | 34 | @Autowired 35 | private TBlogMapper blogMapper; 36 | 37 | //存放迭代找出的所有子代的集合 38 | private List tempReplys = new ArrayList<>(); 39 | 40 | /** 41 | * @Description: 查询评论 42 | * @Param: blogId:博客id 43 | * @Return: 评论消息 44 | */ 45 | @Override 46 | public List listCommentByBlogId(Long blogId) { 47 | //查询出父节点 48 | List comments = commentMapper.findByBlogIdParentIdNull(blogId, Long.parseLong("-1")); 49 | for(TComment comment : comments){ 50 | Long id = comment.getId(); 51 | String parentNickname1 = comment.getNickname(); 52 | List childComments = commentMapper.findByBlogIdParentIdNotNull(blogId,id); 53 | //查询出子评论 54 | combineChildren(blogId, childComments, parentNickname1); 55 | comment.setReplyComments(tempReplys); 56 | tempReplys = new ArrayList<>(); 57 | } 58 | return comments; 59 | } 60 | 61 | /** 62 | * @Description: 查询出子评论 63 | * @Auther: ONESTAR 64 | * @Date: 10:43 2020/6/23 65 | * @Param: childComments:所有子评论 66 | * @Param: parentNickname1:父评论姓名 67 | * @Return: 68 | */ 69 | private void combineChildren(Long blogId, List childComments, String parentNickname1) { 70 | //判断是否有一级子评论 71 | if(childComments.size() > 0){ 72 | //循环找出子评论的id 73 | for(TComment childComment : childComments){ 74 | String parentNickname = childComment.getNickname(); 75 | childComment.setParentNickname(parentNickname1); 76 | tempReplys.add(childComment); 77 | Long childId = childComment.getId(); 78 | //查询出子二级评论 79 | recursively(blogId, childId, parentNickname); 80 | } 81 | } 82 | } 83 | 84 | /** 85 | * @Description: 循环迭代找出子集回复 86 | * @Auther: ONESTAR 87 | * @Date: 10:44 2020/6/23 88 | * @Param: chileId:子评论id 89 | * @Param: parentNickname1:子评论姓名 90 | * @Return: 91 | */ 92 | private void recursively(Long blogId, Long childId, String parentNickname1) { 93 | //根据子一级评论的id找到子二级评论 94 | List replayComments = commentMapper.findByBlogIdAndReplayId(blogId,childId); 95 | 96 | if(replayComments.size() > 0){ 97 | for(TComment replayComment : replayComments){ 98 | String parentNickname = replayComment.getNickname(); 99 | replayComment.setParentNickname(parentNickname1); 100 | Long replayId = replayComment.getId(); 101 | tempReplys.add(replayComment); 102 | recursively(blogId,replayId,parentNickname); 103 | } 104 | } 105 | } 106 | 107 | //新增评论 108 | @Override 109 | public int saveComment(TComment comment) { 110 | comment.setCreateTime(LocalDateTime.now()); 111 | int comments = commentMapper.saveComment(comment); 112 | //文章评论计数 113 | // blogMapper.getCommentCountById(comment.getBlogId()); 114 | return comments; 115 | } 116 | 117 | //删除评论 118 | @Override 119 | public void deleteComment(Long id) { 120 | TComment comment = commentMapper.selectById(id); 121 | commentMapper.deleteComment(id); 122 | TBlog tBlog = blogMapper.selectById(comment.getBlogId()); 123 | tBlog.setCommentCount(tBlog.getCommentCount() - 1); 124 | blogMapper.updateById(tBlog); 125 | // blogMapper.getCommentCountById(comment.getBlogId()); 126 | } 127 | 128 | //根据昵称查询评论 129 | @Override 130 | public List findCommentByNickname(String nickname) { 131 | QueryWrapper queryWrapper = new QueryWrapper(); 132 | queryWrapper.like("nickname",nickname); 133 | //以创建时间排序(降序) 134 | queryWrapper.orderByDesc("create_time"); 135 | List tBlogList = commentMapper.selectList(queryWrapper); 136 | return tBlogList; 137 | } 138 | 139 | @Override 140 | public Page getCommentByPage(Long current, Long size) { 141 | //创建Page对象 142 | Page commentPage = new Page<>(current,size); 143 | //构建条件 144 | QueryWrapper wrapper = new QueryWrapper<>(); 145 | //排序 146 | wrapper.orderByDesc("create_time"); 147 | //调用mybatis plus分页方法进行查询 148 | commentMapper.selectPage(commentPage,wrapper); 149 | //通过Page对象获取分页信息 150 | List typeList = commentPage.getRecords(); //每页的数据 list集合 151 | long pagesize = commentPage.getSize(); //每页显示的条数 152 | long total = commentPage.getTotal(); //总记录数 153 | long pages = commentPage.getPages(); //总页数 154 | return commentPage; 155 | } 156 | 157 | 158 | } 159 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/impl/TContactServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service.impl; 2 | 3 | import com.xlblog.blog.entity.TContact; 4 | import com.xlblog.blog.mapper.TContactMapper; 5 | import com.xlblog.blog.service.TContactService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 服务实现类 12 | *

13 | * 14 | * @author 关注公众号:小L星光 15 | * @since 2020-11-30 16 | */ 17 | @Service 18 | public class TContactServiceImpl extends ServiceImpl implements TContactService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/impl/TLinksServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 5 | import com.xlblog.blog.entity.TLinks; 6 | import com.xlblog.blog.entity.TTag; 7 | import com.xlblog.blog.mapper.TLinksMapper; 8 | import com.xlblog.blog.service.TLinksService; 9 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 10 | import com.xlblog.blog.utils.RespBean; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Service; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | *

18 | * 服务实现类 19 | *

20 | * 21 | * @author 关注公众号:小L星光 22 | * @since 2020-11-30 23 | */ 24 | @Service 25 | public class TLinksServiceImpl extends ServiceImpl implements TLinksService { 26 | 27 | @Autowired 28 | TLinksMapper tLinksMapper; 29 | 30 | @Override 31 | public RespBean pageLinks(Long current, Long size) { 32 | RespBean respBean = RespBean.build(); 33 | //创建Page对象 34 | Page tLinksPage = new Page<>(current,size); 35 | //构建条件 36 | QueryWrapper wrapper = new QueryWrapper<>(); 37 | //以创建时间排序(降序) 38 | wrapper.orderByDesc("create_time"); 39 | //调用mybatis plus分页方法进行查询 40 | tLinksMapper.selectPage(tLinksPage,wrapper); 41 | //通过Page对象获取分页信息 42 | List typeList = tLinksPage.getRecords(); //每页的数据 list集合 43 | long pagesize = tLinksPage.getSize(); //每页显示的条数 44 | long total = tLinksPage.getTotal(); //总记录数 45 | long pages = tLinksPage.getPages(); //总页数 46 | 47 | respBean.setStatus(200); 48 | respBean.setObj(tLinksPage); 49 | return respBean; 50 | } 51 | 52 | @Override 53 | public RespBean getLinksByName(String name) { 54 | RespBean respBean = RespBean.build(); 55 | QueryWrapper queryWrapper = new QueryWrapper(); 56 | queryWrapper.like("blog_name",name); 57 | List tLinksList = tLinksMapper.selectList(queryWrapper); 58 | respBean.setStatus(200); 59 | respBean.setObj(tLinksList); 60 | return respBean; 61 | } 62 | 63 | @Override 64 | public RespBean updateLink(TLinks tLinks) { 65 | RespBean respBean = RespBean.build(); 66 | if (tLinksMapper.updateById(tLinks) == 1){ 67 | respBean.setMsg("更新友链成功"); 68 | respBean.setStatus(200); 69 | return respBean; 70 | } 71 | respBean.setMsg("更新友链失败"); 72 | return respBean; 73 | } 74 | 75 | @Override 76 | public RespBean deleteLinkById(Long id) { 77 | RespBean respBean = RespBean.build(); 78 | if (tLinksMapper.deleteById(id) == 1){ 79 | respBean.setStatus(200); 80 | respBean.setMsg("删除友链成功"); 81 | return respBean; 82 | } 83 | respBean.setMsg("删除友链失败"); 84 | return respBean; 85 | } 86 | 87 | @Override 88 | public RespBean getLinksById(Long id) { 89 | RespBean respBean = RespBean.build(); 90 | TLinks tLinks = tLinksMapper.selectById(id); 91 | respBean.setStatus(200); 92 | respBean.setObj(tLinks); 93 | return respBean; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/impl/TRoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service.impl; 2 | 3 | import com.xlblog.blog.entity.TRole; 4 | import com.xlblog.blog.mapper.TRoleMapper; 5 | import com.xlblog.blog.service.TRoleService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 服务实现类 12 | *

13 | * 14 | * @author 关注公众号:小L星光 15 | * @since 2020-11-30 16 | */ 17 | @Service 18 | public class TRoleServiceImpl extends ServiceImpl implements TRoleService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/impl/TTagServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 5 | import com.xlblog.blog.entity.TTag; 6 | import com.xlblog.blog.entity.TType; 7 | import com.xlblog.blog.mapper.TTagMapper; 8 | import com.xlblog.blog.service.TTagService; 9 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 10 | import com.xlblog.blog.utils.RespBean; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Service; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | *

18 | * 服务实现类 19 | *

20 | * 21 | * @author 关注公众号:小L星光 22 | * @since 2020-11-30 23 | */ 24 | @Service 25 | public class TTagServiceImpl extends ServiceImpl implements TTagService { 26 | 27 | @Autowired 28 | TTagMapper tTagMapper; 29 | 30 | @Override 31 | public RespBean pageTags(Long current, Long size) { 32 | RespBean respBean = RespBean.build(); 33 | //创建Page对象 34 | Page tagPage = new Page<>(current,size); 35 | //构建条件 36 | QueryWrapper wrapper = new QueryWrapper<>(); 37 | //调用mybatis plus分页方法进行查询 38 | tTagMapper.selectPage(tagPage,wrapper); 39 | //通过Page对象获取分页信息 40 | List typeList = tagPage.getRecords(); //每页的数据 list集合 41 | long pagesize = tagPage.getSize(); //每页显示的条数 42 | long total = tagPage.getTotal(); //总记录数 43 | long pages = tagPage.getPages(); //总页数 44 | 45 | respBean.setStatus(200); 46 | respBean.setObj(tagPage); 47 | return respBean; 48 | } 49 | 50 | @Override 51 | public RespBean getTagByName(String name) { 52 | RespBean respBean = RespBean.build(); 53 | QueryWrapper queryWrapper = new QueryWrapper(); 54 | queryWrapper.like("name",name); 55 | List tagList = tTagMapper.selectList(queryWrapper); 56 | respBean.setStatus(200); 57 | respBean.setObj(tagList); 58 | return respBean; 59 | } 60 | 61 | @Override 62 | public RespBean updateTag(TTag tTag) { 63 | RespBean respBean = RespBean.build(); 64 | if (tTagMapper.updateById(tTag) == 1){ 65 | respBean.setMsg("更新标签成功"); 66 | respBean.setStatus(200); 67 | return respBean; 68 | } 69 | respBean.setMsg("更新标签失败"); 70 | return respBean; 71 | } 72 | 73 | @Override 74 | public RespBean deleteTagById(Long id) { 75 | RespBean respBean = RespBean.build(); 76 | if (tTagMapper.deleteById(id) == 1){ 77 | respBean.setStatus(200); 78 | respBean.setMsg("删除标签成功"); 79 | return respBean; 80 | } 81 | respBean.setMsg("删除标签失败"); 82 | return respBean; 83 | } 84 | 85 | @Override 86 | public RespBean getTagById(Long id) { 87 | RespBean respBean = RespBean.build(); 88 | TTag tTag = tTagMapper.selectById(id); 89 | respBean.setStatus(200); 90 | respBean.setObj(tTag); 91 | return respBean; 92 | } 93 | 94 | @Override 95 | public RespBean getAllTag() { 96 | RespBean respBean = RespBean.build(); 97 | List tagList = tTagMapper.getAllTag(); 98 | respBean.setStatus(200); 99 | respBean.setObj(tagList); 100 | return respBean; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/impl/TTrafficServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service.impl; 2 | 3 | import com.xlblog.blog.entity.TTraffic; 4 | import com.xlblog.blog.mapper.TTrafficMapper; 5 | import com.xlblog.blog.service.TTrafficService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 服务实现类 12 | *

13 | * 14 | * @author 关注公众号:小L星光 15 | * @since 2020-11-30 16 | */ 17 | @Service 18 | public class TTrafficServiceImpl extends ServiceImpl implements TTrafficService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/impl/TTypeServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 5 | import com.xlblog.blog.entity.TBlog; 6 | import com.xlblog.blog.entity.TType; 7 | import com.xlblog.blog.mapper.TTypeMapper; 8 | import com.xlblog.blog.service.TTypeService; 9 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 10 | import com.xlblog.blog.utils.RespBean; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Service; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | *

18 | * 服务实现类 19 | *

20 | * 21 | * @author 关注公众号:小L星光 22 | * @since 2020-11-30 23 | */ 24 | @Service 25 | public class TTypeServiceImpl extends ServiceImpl implements TTypeService { 26 | 27 | @Autowired 28 | TTypeMapper tTypeMapper; 29 | 30 | @Override 31 | public RespBean pageTypes(Long current, Long size) { 32 | RespBean respBean = RespBean.build(); 33 | //创建Page对象 34 | Page typePage = new Page<>(current,size); 35 | //构建条件 36 | QueryWrapper wrapper = new QueryWrapper<>(); 37 | //调用mybatis plus分页方法进行查询 38 | tTypeMapper.selectPage(typePage,wrapper); 39 | //通过Page对象获取分页信息 40 | List typeList = typePage.getRecords(); //每页的数据 list集合 41 | long pagesize = typePage.getSize(); //每页显示的条数 42 | long total = typePage.getTotal(); //总记录数 43 | long pages = typePage.getPages(); //总页数 44 | 45 | respBean.setStatus(200); 46 | respBean.setObj(typePage); 47 | return respBean; 48 | } 49 | 50 | /** 51 | * 通过名称查询分类 52 | * @param name 53 | * @return 54 | */ 55 | @Override 56 | public RespBean getTypeByName(String name) { 57 | RespBean respBean = RespBean.build(); 58 | QueryWrapper queryWrapper = new QueryWrapper(); 59 | queryWrapper.like("name",name); 60 | List typeList = tTypeMapper.selectList(queryWrapper); 61 | respBean.setStatus(200); 62 | respBean.setObj(typeList); 63 | return respBean; 64 | } 65 | 66 | @Override 67 | public RespBean deleteTypeById(Long id) { 68 | RespBean respBean = RespBean.build(); 69 | if (tTypeMapper.deleteById(id) == 1){ 70 | respBean.setStatus(200); 71 | respBean.setMsg("删除分类成功"); 72 | return respBean; 73 | } 74 | respBean.setMsg("删除分类失败"); 75 | return respBean; 76 | } 77 | 78 | @Override 79 | public RespBean updateType(TType tType) { 80 | RespBean respBean = RespBean.build(); 81 | if (tTypeMapper.updateById(tType) == 1){ 82 | respBean.setMsg("更新分类成功"); 83 | respBean.setStatus(200); 84 | return respBean; 85 | } 86 | respBean.setMsg("更新分类失败"); 87 | return respBean; 88 | } 89 | 90 | @Override 91 | public RespBean getTypeById(Long id) { 92 | RespBean respBean = RespBean.build(); 93 | TType tType = tTypeMapper.selectById(id); 94 | respBean.setStatus(200); 95 | respBean.setObj(tType); 96 | return respBean; 97 | } 98 | 99 | @Override 100 | public RespBean getAllType() { 101 | RespBean respBean = RespBean.build(); 102 | List tType = tTypeMapper.getAllType(); 103 | respBean.setStatus(200); 104 | respBean.setObj(tType); 105 | return respBean; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/impl/TUserRoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service.impl; 2 | 3 | import com.xlblog.blog.entity.TUserRole; 4 | import com.xlblog.blog.mapper.TUserRoleMapper; 5 | import com.xlblog.blog.service.TUserRoleService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 服务实现类 12 | *

13 | * 14 | * @author 关注公众号:小L星光 15 | * @since 2020-11-30 16 | */ 17 | @Service 18 | public class TUserRoleServiceImpl extends ServiceImpl implements TUserRoleService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/service/impl/TUserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.service.impl; 2 | 3 | import com.xlblog.blog.entity.TUser; 4 | import com.xlblog.blog.mapper.TUserMapper; 5 | import com.xlblog.blog.service.TUserService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.security.core.userdetails.UserDetails; 8 | import org.springframework.security.core.userdetails.UserDetailsService; 9 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 10 | import org.springframework.stereotype.Service; 11 | 12 | import javax.annotation.Resource; 13 | 14 | /** 15 | *

16 | * 服务实现类 17 | *

18 | * 19 | * @author 关注公众号:小L星光 20 | * @since 2020-11-30 21 | */ 22 | @Service 23 | public class TUserServiceImpl extends ServiceImpl implements TUserService { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/utils/RespBean.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.utils; 2 | 3 | public class RespBean { 4 | private Integer status = 0; 5 | private String msg; 6 | private Object obj; 7 | 8 | public static RespBean build(){ 9 | return new RespBean(); 10 | } 11 | 12 | public static RespBean ok(String msg){ 13 | return new RespBean(200,msg,null); 14 | } 15 | 16 | public static RespBean ok(String msg, Object obj){ 17 | return new RespBean(200,msg,obj); 18 | } 19 | 20 | public static RespBean error(String msg){ 21 | return new RespBean(500,msg,null); 22 | } 23 | 24 | public static RespBean error(String msg, Object obj){ 25 | return new RespBean(500,msg,obj); 26 | } 27 | 28 | public Integer getStatus() { 29 | return status; 30 | } 31 | 32 | public void setStatus(Integer status) { 33 | this.status = status; 34 | } 35 | 36 | public String getMsg() { 37 | return msg; 38 | } 39 | 40 | public void setMsg(String msg) { 41 | this.msg = msg; 42 | } 43 | 44 | public Object getObj() { 45 | return obj; 46 | } 47 | 48 | public void setObj(Object obj) { 49 | this.obj = obj; 50 | } 51 | 52 | public RespBean() { 53 | } 54 | 55 | private RespBean(Integer status, String msg, Object obj) { 56 | this.status = status; 57 | this.msg = msg; 58 | this.obj = obj; 59 | } 60 | 61 | } 62 | 63 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/utils/Result.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog.utils; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | @Data 8 | public class Result implements Serializable { 9 | private String code; 10 | private String msg; 11 | private Object data; 12 | public static Result succ(Object data) { 13 | Result m = new Result(); 14 | m.setCode("0"); 15 | m.setData(data); 16 | m.setMsg("操作成功"); 17 | return m; 18 | } 19 | public static Result succ(String mess, Object data) { 20 | Result m = new Result(); 21 | m.setCode("0"); 22 | m.setData(data); 23 | m.setMsg(mess); 24 | return m; 25 | } 26 | public static Result fail(String mess) { 27 | Result m = new Result(); 28 | m.setCode("-1"); 29 | m.setData(null); 30 | m.setMsg(mess); 31 | return m; 32 | } 33 | public static Result fail(String mess, Object data) { 34 | Result m = new Result(); 35 | m.setCode("-1"); 36 | m.setData(data); 37 | m.setMsg(mess); 38 | return m; 39 | } 40 | } 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /xlblog/src/main/java/com/xlblog/blog/utils/blogQuartz.java: -------------------------------------------------------------------------------- 1 | //package com.xlblog.blog.utils; 2 | // 3 | //import com.xlblog.blog.entity.TBlog; 4 | //import com.xlblog.blog.service.TBlogService; 5 | //import org.springframework.beans.factory.annotation.Autowired; 6 | //import org.springframework.beans.factory.annotation.Configurable; 7 | //import org.springframework.data.redis.core.RedisTemplate; 8 | //import org.springframework.data.redis.core.ValueOperations; 9 | //import org.springframework.scheduling.annotation.EnableScheduling; 10 | //import org.springframework.scheduling.annotation.Scheduled; 11 | //import org.springframework.stereotype.Component; 12 | // 13 | //import java.util.List; 14 | // 15 | //@Component 16 | //@Configurable 17 | //@EnableScheduling 18 | //public class blogQuartz { 19 | // 20 | // @Autowired 21 | // RedisTemplate redisTemplate; 22 | // @Autowired 23 | // TBlogService tBlogService; 24 | // 25 | // /** 26 | // * 访问量定时器 27 | // */ 28 | // @Scheduled(cron = "0 0 * * * ?") 29 | // public void blog(){ 30 | // List blogLsit = tBlogService.list(); 31 | // ValueOperations operations = redisTemplate.opsForValue(); 32 | // for (TBlog blog: blogLsit ) { 33 | // if(blog.getId() != -1){ 34 | // String key = "blog_" + blog.getId(); 35 | // if (redisTemplate.hasKey(key)){ 36 | // //获取该缓存数据 37 | // TBlog tBlog = operations.get(key); 38 | // tBlogService.updateById(tBlog); 39 | // System.out.println("更新访问量->数据库"); 40 | // } 41 | // 42 | // } 43 | // 44 | // } 45 | // 46 | // 47 | // 48 | // } 49 | //} 50 | -------------------------------------------------------------------------------- /xlblog/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | driver-class-name: com.mysql.cj.jdbc.Driver 4 | url: jdbc:mysql://localhost:3306/blog?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai 5 | username: root 6 | password: 123456 7 | mvc: 8 | static-path-pattern: /** 9 | 10 | 11 | mybatis-plus: 12 | mapper-locations: classpath*:/mapper/**Mapper.xml 13 | server: 14 | port: 8082 15 | 16 | comment.avatar: /images/avatar.jpg 17 | message.avatar: /images/avatar.jpg 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /xlblog/src/main/resources/mapper/TBlogMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 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 | 40 | 51 | 52 | 53 | 75 | 76 | 77 | 81 | 82 | 83 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /xlblog/src/main/resources/mapper/TBlogTagsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /xlblog/src/main/resources/mapper/TCommentMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | insert into t_comment (nickname,email,content,avatar,create_time,blog_id,parent_comment_id,admin_comment,ip) 9 | values (#{nickname},#{email},#{content},#{avatar},#{createTime},#{blogId},#{parentCommentId},#{adminComment},#{ip}); 10 | 11 | 12 | 13 | 19 | 20 | 21 | 27 | 28 | 29 | 35 | 36 | 37 | 38 | delete from t_comment where id = #{id} 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /xlblog/src/main/resources/mapper/TContactMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /xlblog/src/main/resources/mapper/TLinksMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /xlblog/src/main/resources/mapper/TRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /xlblog/src/main/resources/mapper/TTagMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /xlblog/src/main/resources/mapper/TTrafficMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /xlblog/src/main/resources/mapper/TTypeMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /xlblog/src/main/resources/mapper/TUserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 21 | 22 | -------------------------------------------------------------------------------- /xlblog/src/main/resources/mapper/TUserRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /xlblog/src/main/resources/static/images/avatar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdragon0/xiaoLBlog/91ed66993f8133902ffbc7f59f192abc7c40d306/xlblog/src/main/resources/static/images/avatar.jpg -------------------------------------------------------------------------------- /xlblog/src/test/java/com/xlblog/blog/BlogApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.xlblog.blog; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class BlogApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /xlvueblog/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /xlvueblog/README.md: -------------------------------------------------------------------------------- 1 | # xlvueblog 2 | 3 | ## Project setup 4 | ``` 5 | npm install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | npm run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | npm run build 16 | ``` 17 | 18 | ### Customize configuration 19 | See [Configuration Reference](https://cli.vuejs.org/config/). 20 | -------------------------------------------------------------------------------- /xlvueblog/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /xlvueblog/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "xlvueblog", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build" 8 | }, 9 | "dependencies": { 10 | "axios": "^0.21.1", 11 | "core-js": "^3.6.5", 12 | "element-ui": "^2.14.1", 13 | "github-markdown-css": "^4.0.0", 14 | "markdown-it": "^12.0.4", 15 | "vue": "^2.6.11", 16 | "vue-router": "^3.2.0" 17 | }, 18 | "devDependencies": { 19 | "@vue/cli-plugin-babel": "~4.5.0", 20 | "@vue/cli-plugin-router": "~4.5.0", 21 | "@vue/cli-service": "~4.5.0", 22 | "vue-template-compiler": "^2.6.11" 23 | }, 24 | "browserslist": [ 25 | "> 1%", 26 | "last 2 versions", 27 | "not dead" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /xlvueblog/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdragon0/xiaoLBlog/91ed66993f8133902ffbc7f59f192abc7c40d306/xlvueblog/public/favicon.ico -------------------------------------------------------------------------------- /xlvueblog/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 17 | 18 | 19 | 20 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /xlvueblog/src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 30 | 31 | 45 | -------------------------------------------------------------------------------- /xlvueblog/src/assets/css/mycss.css: -------------------------------------------------------------------------------- 1 | 2 | a { 3 | position: relative; 4 | width: 100px; 5 | height: 60px; 6 | text-align: center; 7 | line-height: 60px; 8 | margin: 45px; 9 | text-decoration: none; 10 | color: aqua; 11 | font-size: 20px; 12 | padding: 10px 30px; 13 | text-transform: uppercase; 14 | transition: 0.5s; 15 | overflow: hidden; 16 | -webkit-box-reflect: below 1px linear-gradient(transparent, #1113); 17 | } 18 | a::before { 19 | content: ''; 20 | position: absolute; 21 | top: 0; 22 | left: 0; 23 | width: 20px; 24 | height: 20px; 25 | border-top: 2px solid aqua; 26 | border-left: 2px solid aqua; 27 | transition: 0.5s; 28 | transition-delay: 0.5s; 29 | } 30 | a::after { 31 | content: ''; 32 | position: absolute; 33 | bottom: 0; 34 | right: 0; 35 | width: 20px; 36 | height: 20px; 37 | border-bottom: 2px solid aqua; 38 | border-right: 2px solid aqua; 39 | transition: 0.5s; 40 | transition-delay: 0.5s; 41 | } 42 | a:hover::before, a:hover::after { 43 | width: 100%; 44 | height: 100%; 45 | transition-delay: 0s; 46 | } 47 | a:hover { 48 | background-color: aqua; 49 | color: #000; 50 | box-shadow: 0 0 50px #21ebff; 51 | transition-delay: 0.3s; 52 | } 53 | /* a:nth-child(1) { 54 | filter: hue-rotate(150deg); 55 | } */ 56 | /* a:nth-child(3) { 57 | filter: hue-rotate(270deg); 58 | } 59 | a:nth-child(4) { 60 | filter: hue-rotate(400deg); 61 | } 62 | a:nth-child(5) { 63 | filter: hue-rotate(70deg); 64 | } */ -------------------------------------------------------------------------------- /xlvueblog/src/assets/image/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdragon0/xiaoLBlog/91ed66993f8133902ffbc7f59f192abc7c40d306/xlvueblog/src/assets/image/bg.jpg -------------------------------------------------------------------------------- /xlvueblog/src/assets/image/code.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdragon0/xiaoLBlog/91ed66993f8133902ffbc7f59f192abc7c40d306/xlvueblog/src/assets/image/code.jpg -------------------------------------------------------------------------------- /xlvueblog/src/assets/js/clock.js: -------------------------------------------------------------------------------- 1 | //定义一个函数绘制时钟 2 | function drawClock(){ 3 | var context=document.getElementById("clock").getContext("2d"); 4 | //每次绘制新图形之前清空当前区域 5 | context.clearRect(0,0,500,500); 6 | // var hs = [" I ", "I I", "III", "I V", " V ", "V I", "VII", "VIII", "I X", " X ", "X I", "XII"]; 7 | // var hs = [" 1 ", " 2 ", " 3 ", " 4 ", " 5 ", " 6 ", " 7 ", " 8 ", " 9 ", " 10 ", " 11 ", " 12 "]; 8 | //画表盘 9 | context.beginPath(); 10 | context.arc(250,250,200,0,2*Math.PI); 11 | // context.strokeStyle="#A9A9A9"; 12 | context.strokeStyle="#bcbff7"; 13 | context.lineWidth=15; 14 | context.stroke(); 15 | context.closePath(); 16 | //循环绘制分钟刻度 17 | //重新定义画布的原点 18 | context.translate(250,250); 19 | //绘制分钟刻度 20 | for (var i=0;i<60;i++) { 21 | //每次旋转6度 22 | context.rotate(6*Math.PI/180); 23 | context.beginPath(); 24 | context.moveTo(0,-185); 25 | context.lineTo(0,-190); 26 | context.lineWidth=4; 27 | context.strokeStyle="lightgreen"; 28 | context.stroke(); 29 | context.closePath(); 30 | } 31 | //绘制小时刻度 32 | for(var i = 0; i < 12; i++) { 33 | //旋转30度 34 | context.rotate(30 * Math.PI / 180); 35 | context.beginPath(); 36 | context.moveTo(0, -180); 37 | context.lineTo(0, -190); 38 | context.strokeStyle = "#008000"; 39 | context.stroke(); 40 | context.closePath(); 41 | 42 | context.beginPath(); 43 | context.font="12px 微软雅黑"; 44 | //文字轮廓 45 | context.fillStyle = "red"; 46 | // context.fillText(hs[i], -8, -160); 47 | context.closePath(); 48 | } 49 | context.textAlign = 'center'; 50 | context.textBaseline = 'middle'; 51 | context.fillStyle = 'red'; 52 | context.font = '20px 微软雅黑'; 53 | for (var i = 1; i < 13; i++) { 54 | context.fillText(i,Math.sin(2*Math.PI/12*i)*160,Math.cos(2*Math.PI/12*i)*-160); 55 | } 56 | 57 | //获取现在的系统时间 58 | var date = new Date(); 59 | var hour = date.getHours(); 60 | var minute = date.getMinutes(); 61 | //获得的小时是一个整数,需要加上分钟代表的小数 62 | hour = hour + minute / 60; 63 | //如果是下午减去12 64 | hour = hour > 12 ? hour - 12 : hour; 65 | var second = date.getSeconds(); 66 | //画时针 67 | context.rotate(hour * 30 * Math.PI / 180); 68 | context.beginPath(); 69 | //设置线段开始点 70 | context.moveTo(0, 20); 71 | //设置线段结束点 72 | context.lineTo(0, -80); 73 | context.lineWidth = 5; 74 | context.strokeStyle = "#008000"; 75 | context.stroke(); 76 | context.closePath(); 77 | //将画布角度还原到初始状态 78 | context.rotate(-hour * 30 * Math.PI / 180); 79 | 80 | //画分针 81 | context.rotate(minute * 6 * Math.PI / 180); 82 | context.beginPath(); 83 | //设置线段开始点 84 | context.moveTo(0, 20); 85 | //设置线段结束点 86 | context.lineTo(0, -140); 87 | context.lineWidth = 4; 88 | context.strokeStyle = "lightgreen"; 89 | context.stroke(); 90 | context.closePath(); 91 | //将画布角度还原到初始状态 92 | context.rotate(-minute * 6 * Math.PI / 180); 93 | 94 | //画秒针 95 | context.rotate(second * 6 * Math.PI / 180); 96 | context.beginPath(); 97 | //设置线段开始点 98 | context.moveTo(0, 20); 99 | //设置线段结束点 100 | context.lineTo(0, -175); 101 | context.lineWidth = 3; 102 | context.strokeStyle = "crimson"; 103 | context.stroke(); 104 | context.closePath(); 105 | //在圆形的中心点绘制一个圆形 106 | context.beginPath(); 107 | context.arc(0,0,10,0,2*Math.PI); 108 | context.fillStyle="gold"; 109 | context.fill(); 110 | context.closePath(); 111 | //在秒针上端绘制一个圆形 112 | context.beginPath(); 113 | context.arc(0,-155,8,0,2*Math.PI); 114 | context.fillStyle="gold"; 115 | context.fill(); 116 | context.closePath(); 117 | //将画布角度还原到初始状态 118 | context.rotate(-second * 6 * Math.PI / 180); 119 | //将圆心的位置重置到左上角 120 | context.translate(-250, -250); 121 | } 122 | drawClock(); 123 | //每隔一秒钟重新绘制时钟 124 | setInterval("drawClock()",1000); 125 | 126 | 127 | export default{ 128 | drawClock 129 | } -------------------------------------------------------------------------------- /xlvueblog/src/assets/js/mouse.js: -------------------------------------------------------------------------------- 1 | const canvas = document.getElementById('mouse'); 2 | const ctx = canvas.getContext('2d'); 3 | const WIDTH = canvas.width = document.documentElement.clientWidth; 4 | const HEIGHT = canvas.height = document.documentElement.clientHeight; 5 | 6 | function hexColor() { 7 | let str = '#'; 8 | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F']; 9 | for (let i = 0; i < 6; i++) { 10 | let index = Number.parseInt(Math.random() * 16); 11 | str += arr[index] 12 | } 13 | return str; 14 | } 15 | 16 | let mouseX; 17 | let mouseY; 18 | let arr = []; 19 | 20 | window.onmousemove = function (e) { 21 | mouseX = e.clientX; 22 | mouseY = e.clientY; 23 | arr.push({ 24 | x: mouseX, 25 | y: mouseY, 26 | r: 0.9, 27 | s: 1 // 控制⚪消失 28 | }) 29 | 30 | }; 31 | 32 | function animate() { 33 | ctx.clearRect(0, 0, WIDTH, HEIGHT); 34 | let step=0.9; 35 | let s=0.09; 36 | for (let i = 0; i < arr.length; i++) { 37 | ctx.beginPath(); 38 | ctx.arc(arr[i].x, arr[i].y, arr[i].r, 0, 2 * Math.PI); 39 | ctx.closePath(); 40 | ctx.fillStyle = hexColor(); 41 | ctx.fill(); 42 | arr[i].r += step;//⚪半径增长步长 43 | arr[i].s -= s; 44 | 45 | if (arr[i].s <= 0) { 46 | arr.splice(i, 1); 47 | i--; 48 | } 49 | } 50 | requestAnimationFrame(animate) 51 | } 52 | 53 | animate(); 54 | 55 | -------------------------------------------------------------------------------- /xlvueblog/src/assets/js/myjs.js: -------------------------------------------------------------------------------- 1 | function aff(){ 2 | alert("222") 3 | } 4 | 5 | export default{ 6 | aff 7 | } -------------------------------------------------------------------------------- /xlvueblog/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdragon0/xiaoLBlog/91ed66993f8133902ffbc7f59f192abc7c40d306/xlvueblog/src/assets/logo.png -------------------------------------------------------------------------------- /xlvueblog/src/components/Blog.vue: -------------------------------------------------------------------------------- 1 | 41 | 42 | 76 | 77 | -------------------------------------------------------------------------------- /xlvueblog/src/components/Foot.vue: -------------------------------------------------------------------------------- 1 | 54 | 55 | 83 | 84 | -------------------------------------------------------------------------------- /xlvueblog/src/components/Head.vue: -------------------------------------------------------------------------------- 1 | 34 | 35 | 63 | 64 | -------------------------------------------------------------------------------- /xlvueblog/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | import router from './router' 4 | 5 | import ElementUI from 'element-ui'; //引入Element ui 6 | import 'element-ui/lib/theme-chalk/index.css'; 7 | import axios from 'axios'; 8 | 9 | Vue.prototype.axios = axios; 10 | // axios.defaults.baseURL = "/api" 11 | axios.defaults.withCredentials = true 12 | Vue.use(axios); 13 | 14 | 15 | Vue.use(ElementUI); //使用 ElementUI 16 | 17 | Vue.config.productionTip = false 18 | 19 | new Vue({ 20 | router, 21 | render: h => h(App) 22 | }).$mount('#app') 23 | -------------------------------------------------------------------------------- /xlvueblog/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import VueRouter from 'vue-router' 3 | 4 | Vue.use(VueRouter) 5 | 6 | const routes = [ 7 | { 8 | path: '/', 9 | name: 'Index', 10 | component: () => import('../views/Index.vue') 11 | }, 12 | { 13 | path: '/home', 14 | name: 'Home', 15 | component: () => import('../views/Home.vue') 16 | }, 17 | { 18 | path: '/blog/:id', 19 | name: 'Blog', 20 | props: true, 21 | component: () => import('../components/Blog.vue') 22 | }, 23 | { 24 | path: '/blogType', 25 | name: 'BlogType', 26 | component: () => import('../views/BlogType.vue') 27 | }, 28 | { 29 | path: '/blogTag', 30 | name: 'BlogTag', 31 | component: () => import('../views/BlogTag.vue') 32 | }, 33 | { 34 | path: '/blogSearch', 35 | name: 'BlogSearch', 36 | // props: true, 37 | component: () => import('../views/BlogSearch.vue') 38 | }, 39 | { 40 | path: '/message', 41 | name: 'Message', 42 | component: () => import('../views/Message.vue') 43 | }, 44 | { 45 | path: '/blogLinks', 46 | name: 'BlogLinks', 47 | component: () => import('../views/BlogLinks.vue') 48 | }, 49 | ] 50 | 51 | const router = new VueRouter({ 52 | routes 53 | }) 54 | 55 | export default router 56 | -------------------------------------------------------------------------------- /xlvueblog/src/views/BlogLinks.vue: -------------------------------------------------------------------------------- 1 | 76 | 77 | 105 | 106 | -------------------------------------------------------------------------------- /xlvueblog/src/views/BlogSearch.vue: -------------------------------------------------------------------------------- 1 | 93 | 94 | 153 | 154 | -------------------------------------------------------------------------------- /xlvueblog/src/views/BlogTag.vue: -------------------------------------------------------------------------------- 1 | 101 | 102 | 161 | 162 | -------------------------------------------------------------------------------- /xlvueblog/src/views/BlogType.vue: -------------------------------------------------------------------------------- 1 | 100 | 101 | 165 | 166 | -------------------------------------------------------------------------------- /xlvueblog/src/views/Message.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 26 | 27 | -------------------------------------------------------------------------------- /xlvueblog/vue.config.js: -------------------------------------------------------------------------------- 1 | //配置请求转发的代理 2 | 3 | //定义代理的对象 4 | let proxyObj = {}; 5 | 6 | //拦截http请求 7 | proxyObj['/'] = { 8 | ws: false, //关掉websocket 9 | // target: 'http://47.107.158.11:8082', //目标转发的地址 10 | target: 'http://localhost:8082', //目标转发的地址 11 | changeOrigin: true, 12 | pathRewrite:{ //请求地址重写 13 | '^/': '' //拦截到的地址不去修改它 14 | } 15 | } 16 | 17 | //把上面的导出来 18 | module.exports = { 19 | devServer:{ //配置开发环境 20 | host: 'localhost', //端口号 21 | port: 8080, 22 | proxy: proxyObj //代理对象 23 | } 24 | } 25 | --------------------------------------------------------------------------------