Skip to content

Commit

Permalink
调优
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkerHub committed May 25, 2020
1 parent 59e5ea5 commit d596260
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public Result blogs(Integer currentPage) {

if(currentPage == null || currentPage < 1) currentPage = 1;

Page page = new Page(currentPage, 10);
Page page = new Page(currentPage, 5);
IPage pageData = blogService.page(page, new QueryWrapper<Blog>().orderByDesc("created"));

return Result.succ(pageData);
Expand Down
14 changes: 9 additions & 5 deletions vueblog-java/src/main/resources/vueblog.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Target Server Type : MYSQL
Target Server Version : 50717
File Encoding : 65001
Date: 2020-05-14 11:09:07
Date: 2020-05-23 00:49:51
*/

SET FOREIGN_KEY_CHECKS=0;
Expand All @@ -21,20 +21,24 @@ SET FOREIGN_KEY_CHECKS=0;
DROP TABLE IF EXISTS `m_blog`;
CREATE TABLE `m_blog` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) NOT NULL,
`title` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
`content` longtext,
`created` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP,
`status` tinyint(4) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4;
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Records of m_blog
-- ----------------------------
INSERT INTO `m_blog` VALUES ('1', '生活就像海洋,只有意志坚强的人才能到达彼岸', '这里是摘要哈哈哈', '内容???', '2020-05-14 09:41:15', '0');
INSERT INTO `m_blog` VALUES ('2', '最值得学习的博客项目eblog', 'eblog是一个基于Springboot2.1.2开发的博客学习项目,为了让项目融合更多的知识点,达到学习目的,编写了详细的从0到1开发文档。主要学习包括:自定义Freemarker标签,使用shiro+redis完成了会话共享,redis的zset结构完成本周热议排行榜,t-io+websocket完成即时消息通知和群聊,rabbitmq+elasticsearch完成博客内容搜索引擎等。值得学习的地方很多!', null, '2020-05-14 10:20:05', '0');
INSERT INTO `m_blog` VALUES ('3', '公众号MarkerHub文章索引', '梳理Java知识,解析开源项目! 公众号【MarkerHub】的文章分类索引,直联公众号文章链接!https://github.com/MarkerHub/JavaIndex', null, '2020-05-14 10:20:55', '0');
INSERT INTO `m_blog` VALUES ('1', '1', '生活就像海洋,只有意志坚强的人才能到达彼岸', '这里是摘要哈哈哈', '内容???', '2020-05-21 22:08:42', '0');
INSERT INTO `m_blog` VALUES ('2', '1', '最值得学习的博客项目eblog', 'eblog是一个基于Springboot2.1.2开发的博客学习项目,为了让项目融合更多的知识点,达到学习目的,编写了详细的从0到1开发文档。主要学习包括:自定义Freemarker标签,使用shiro+redis完成了会话共享,redis的zset结构完成本周热议排行榜,t-io+websocket完成即时消息通知和群聊,rabbitmq+elasticsearch完成博客内容搜索引擎等。值得学习的地方很多!', null, '2020-05-21 22:08:42', '0');
INSERT INTO `m_blog` VALUES ('3', '1', '公众号MarkerHub文章索引', '梳理Java知识,解析开源项目! 公众号【MarkerHub】的文章分类索引,直联公众号文章链接!https://github.com/MarkerHub/JavaIndex', null, '2020-05-21 22:08:42', '0');
INSERT INTO `m_blog` VALUES ('7', '1', '你真的会写单例模式吗?', '单例模式可能是代码最少的模式了,但是少不一定意味着简单,想要用好、用对单例模式,还真得费一番脑筋。本文对 Java 中常见的单例模式写法做了一个总结,如有错漏之处,恳请读者指正。', '> 作者:吃桔子的攻城狮 来源:http://www.tekbroaden.com/singleton-java.html\n\n\n单例模式可能是代码最少的模式了,但是少不一定意味着简单,想要用好、用对单例模式,还真得费一番脑筋。本文对 Java 中常见的单例模式写法做了一个总结,如有错漏之处,恳请读者指正。\n\n饿汉法\n===\n\n顾名思义,饿汉法就是在第一次引用该类的时候就创建对象实例,而不管实际是否需要创建。代码如下:\n\n```\npublic class Singleton { \n private static Singleton = new Singleton();\n private Singleton() {}\n public static getSignleton(){\n return singleton;\n }\n}\n\n```\n\n这样做的好处是编写简单,但是无法做到延迟创建对象。但是我们很多时候都希望对象可以尽可能地延迟加载,从而减小负载,所以就需要下面的懒汉法:\n', '2020-05-22 00:42:44', '0');
INSERT INTO `m_blog` VALUES ('9', '1', '真正理解Mysql的四种隔离级别@', '事务是应用程序中一系列严密的操作,所有操作必须成功完成,否则在每个操作中所作的所有更改都会被撤消。也就是事务具有原子性,一个事务中的一系列的操作要么全部成功,要么一个都不做。\n\n事务的结束有两种,当事务中的所以步骤全部成功执行时,事务提交。如果其中一个步骤失败,将发生回滚操作,撤消撤消之前到事务开始时的所以操作。', '### 什么是事务 \n\n> 事务是应用程序中一系列严密的操作,所有操作必须成功完成,否则在每个操作中所作的所有更改都会被撤消。也就是事务具有原子性,一个事务中的一系列的操作要么全部成功,要么一个都不做。\n> \n> 事务的结束有两种,当事务中的所以步骤全部成功执行时,事务提交。如果其中一个步骤失败,将发生回滚操作,撤消撤消之前到事务开始时的所以操作。\n\n**事务的 ACID**\n\n事务具有四个特征:原子性( Atomicity )、一致性( Consistency )、隔离性( Isolation )和持续性( Durability )。这四个特性简称为 ACID 特性。\n\n> 1 、原子性。事务是数据库的逻辑工作单位,事务中包含的各操作要么都做,要么都不做\n> \n> 2 、一致性。事 务执行的结果必须是使数据库从一个一致性状态变到另一个一致性状态。因此当数据库只包含成功事务提交的结果时,就说数据库处于一致性状态。如果数据库系统 运行中发生故障,有些事务尚未完成就被迫中断,这些未完成事务对数据库所做的修改有一部分已写入物理数据库,这时数据库就处于一种不正确的状态,或者说是 不一致的状态。', '2020-05-22 22:04:46', '0');
INSERT INTO `m_blog` VALUES ('10', '1', '博客项目eblog讲解视频上线啦,长达17个小时!!', '1. 慕课网免费资源好久都没更新了,新教程大都付费\n2. B站上的视频繁多,通过收藏和弹幕数量通常很容易判断出视频是否优质\n3. 讲真,B站的弹幕文化,让我觉得,我不是一个在学习,自古人才出评论。哈哈哈\n4. B站视频通常广告少,up主的用心录制,通常只为了你关注他', 'ok,再回到我们的eblog项目,源码、文档、视频我都开源出来了。来些基本操作:github上给个star,B站视频给个三连支持咧。\n\neblog源码:https://github.com/MarkerHub/eblog\n\n点击这里:[10+篇完整开发文档](https://mp.weixin.qq.com/mp/homepage?__biz=MzIwODkzOTc1MQ==&hid=1&sn=8e512316c3dfe140e636d0c996951166)\n\n![](//image-1300566513.cos.ap-guangzhou.myqcloud.com/upload/images/20200508/c290d945b7d24c79b172759bdb5b94e0.png)\n\n视频讲解:(记得关注我噢!)\n\nhttps://www.bilibili.com/video/BV1ri4y1x71A\n\n![](//image-1300566513.cos.ap-guangzhou.myqcloud.com/upload/images/20200508/983b5abc1c934360a1a1362347a275f7.png)\n\n项目其实还很多bug的,哈哈,我还需要进行二次迭代,到时候再发迭代文档出来。\n\n关注下我的B站,作为一个自媒体的自由职业者,没有什么比涨粉更让我开心的了,嘻嘻。\n\n近期即将推出的视频教程:\n\n1. 搭建脚手架,前后端分离首秀\n2. Shiro入门到精通教程\n3. SpringBoot2.2.6最新入门教程', '2020-05-22 22:05:49', '0');

-- ----------------------------
-- Table structure for m_user
Expand Down
2 changes: 1 addition & 1 deletion vueblog-vue/src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
methods: {
logout() {
const _this = this
this.$axios.get('http://localhost:8081/logout', {
this.$axios.get('/logout', {
headers: {
"Authorization": localStorage.getItem("token")
}
Expand Down
5 changes: 3 additions & 2 deletions vueblog-vue/src/views/BlogDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
getBlog() {
const blogId = this.$route.params.blogId
const _this = this
this.$axios.get('http://localhost:8081/blog/' + blogId).then((res) => {
this.$axios.get('/blog/' + blogId).then((res) => {
console.log(res)
console.log(res.data.data)
_this.blog = res.data.data
Expand All @@ -46,7 +46,8 @@
var result = md.render(_this.blog.content);
_this.blog.content = result
_this.ownBlog = true
// 判断是否是自己的文章,能否编辑
_this.ownBlog = (_this.blog.userId === _this.$store.getters.getUser.id)
});
}
},
Expand Down
12 changes: 5 additions & 7 deletions vueblog-vue/src/views/BlogEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@
return {
editForm: {
id: null,
title: '测试标题',
description: '测试内容',
content: '> [更多引入方式点击这里...](/mavonEditor/doc/cn/use.html)\n' +
'\n' +
'> [如何获取并设置markdown-it对象...](/mavonEditor/doc/cn/markdown.html)'
title: '',
description: '',
content: ''
},
rules: {
title: [
Expand All @@ -58,7 +56,7 @@
const blogId = this.$route.params.blogId
const _this = this
if(blogId) {
this.$axios.get('http://localhost:8081/blog/' + blogId).then((res) => {
this.$axios.get('/blog/' + blogId).then((res) => {
const blog = res.data.data
_this.editForm.id = blog.id
_this.editForm.title = blog.title
Expand All @@ -75,7 +73,7 @@
this.$refs.editForm.validate((valid) => {
if (valid) {
this.$axios.post('http://localhost:8081/blog/edit', this.editForm, {
this.$axios.post('/blog/edit', this.editForm, {
headers: {
"Authorization": localStorage.getItem("token")
}
Expand Down
7 changes: 5 additions & 2 deletions vueblog-vue/src/views/Blogs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
background
layout="prev, pager, next"
:current-page=currentPage
:page-size=pageSize
@current-change=page
:total="total">
</el-pagination>
Expand All @@ -36,17 +37,19 @@
return {
blogs: {},
currentPage: 1,
total: 0
total: 0,
pageSize: 5
}
},
methods: {
page(currentPage) {
const _this = this
this.$axios.get('http://localhost:8081/blogs?currentPage=' + currentPage).then((res) => {
this.$axios.get('/blogs?currentPage=' + currentPage).then((res) => {
console.log(res.data.data.records)
_this.blogs = res.data.data.records
_this.currentPage = res.data.data.current
_this.total = res.data.data.total
_this.pageSize = res.data.data.size
})
}
},
Expand Down

0 comments on commit d596260

Please sign in to comment.