优化:文章目录结构(某分类/YYYY/MM/dd/xxx.md)

This commit is contained in:
2022-08-02 21:51:39 +08:00
parent ab4d8e680a
commit 992ad0127c
49 changed files with 57 additions and 52 deletions

View File

@@ -9,9 +9,9 @@ export const sidebar: DefaultTheme.Config['sidebar'] = {
}
/**
* 根据 年/月/日.xxmd 的目录格式, 获取侧边栏分组及分组下标题
* 根据 某分类/YYYY/MM/dd/xxx.md 的目录格式, 获取侧边栏分组及分组下标题
*
* /repos/issues/2022/07/20.xxx.md
* /categories/issues/2022/07/20/xxx.md
*
* @param path 扫描基础路径
* @returns {DefaultTheme.SidebarGroup[]}
@@ -34,24 +34,31 @@ function getItemsByDate (path: string) {
objectMode: true
}).forEach(({ name }) => {
let month = name
// 3.获取月份目录下的所有文章
// 3.获取所有日期目录
sync(`repos/${path}/${year}/${month}/*`, {
onlyFiles: true,
onlyDirectories: true,
objectMode: true
}).forEach(({ name }) => {
// 向前追加标题
items.unshift({
text: name,
link: `/${path}/${year}/${month}/${name}`
let day = name
// 4.获取日期目录下的所有文章
sync(`repos/${path}/${year}/${month}/${day}/*`, {
onlyFiles: true,
objectMode: true
}).forEach(({ name }) => {
// 向前追加标题
items.unshift({
text: name,
link: `/${path}/${year}/${month}/${day}/${name}`
})
})
})
// 4.向前追加到分组
// 5.向前追加到分组
if (items.length > 0) {
// 去除标题名中的日期前缀和扩展名
// 去除标题名中的扩展名
for (let i = 0; i < items.length; i++) {
let text = items[i].text
items[i].text = text.replace('.md', '').substring(text.indexOf('.') + 1)
items[i].text = text.replace('.md', '')
}
groups.unshift({
text: `${year}${month}月 (${items.length}篇)`,
@@ -61,20 +68,20 @@ function getItemsByDate (path: string) {
})
}
// 5.清空侧边栏分组下标题数组
// 6.清空侧边栏分组下标题数组
items = []
})
})
// 6.将第一个侧边栏分组的标题展开
// 7.将第一个侧边栏分组的标题展开
groups[0].collapsed = false
return groups
}
/**
* 根据 分组/序号.xxmd 的目录格式, 获取侧边栏分组及分组下标题
* 根据 某小课/序号-分组/序号-xxx.md 的目录格式, 获取侧边栏分组及分组下标题
*
* /repos/courses/mybatis/MyBatis基础/20.xxx.md
* courses/mybatis/01-MyBatis基础/01-xxx.md
*
* @param path 扫描基础路径
* @returns {DefaultTheme.SidebarGroup[]}
@@ -105,13 +112,13 @@ function getItems (path: string) {
// 3.向前追加到分组
if (items.length > 0) {
// 去除标题名中的日期前缀和扩展名
// 去除标题名中的前缀和扩展名
for (let i = 0; i < items.length; i++) {
let text = items[i].text
items[i].text = text.replace('.md', '').substring(text.indexOf('.') + 1)
items[i].text = text.replace('.md', '').substring(text.indexOf('-') + 1)
}
groups.push({
text: `${groupName.substring(groupName.indexOf('.') + 1)} (${items.length}篇)`,
text: `${groupName.substring(groupName.indexOf('-') + 1)} (${items.length}篇)`,
collapsible: true,
collapsed: true,
items: items

View File

@@ -45,7 +45,7 @@ tags:
cd eladminx
```
![202203252252923](../../../../public/img/2022/03/202203252252923.png)
![202203252252923](../../../../../public/img/2022/03/25/202203252252923.png)
2. 将前端仓库作为后端仓库的远程仓库,起别名为 frontend这个随便起
@@ -53,7 +53,7 @@ tags:
git remote add -f frontend https://gitee.com/Charles7c/eladminx-web.git
```
![202203252252926](../../../../public/img/2022/03/202203252252926.png)
![202203252252926](../../../../../public/img/2022/03/25/202203252252926.png)
3. 将前端仓库的 master 分支(自己选择哪个分支)合并到后端仓库
@@ -61,7 +61,7 @@ tags:
git merge --strategy ours --no-commit frontend/master
```
![202203252252929](../../../../public/img/2022/03/202203252252929.png)
![202203252252929](../../../../../public/img/2022/03/25/202203252252929.png)
想法很美,但是报错了:
@@ -75,7 +75,7 @@ tags:
git merge --strategy ours --allow-unrelated-histories --no-commit frontend/master
```
![202203252252931](../../../../public/img/2022/03/202203252252931.png)
![202203252252931](../../../../../public/img/2022/03/25/202203252252931.png)
4. 将前端仓库的 master 分支内容放到在后端仓库内刚建好的 eladminx-web 文件夹中

View File

@@ -14,7 +14,7 @@ tags:
近期打开移动硬盘时,经常弹出一个提示框,提示内容是:**F:\ 上的"回收站"已损坏。是否清空该驱动器上的"回收站"?**
![202112012236800](../../../../public/img/2021/12/202112012236800.png)
![202112012236800](../../../../../public/img/2021/12/01/202112012236800.png)
这个提示框出现过好多回了,除了第一次见到时担心数据丢失,所以比较重视,后来次数多了,点过 “是”,也点过 “否”,只要当下不再影响我就先忽略了。
@@ -38,7 +38,7 @@ tags:
我又考虑是不是电脑本次出了点故障,于是我重启了电脑。
![202112012236805](../../../../public/img/2021/12/202112012236805.jpeg)
![202112012236805](../../../../../public/img/2021/12/01/202112012236805.jpeg)
果然,问题还是没解决了。
@@ -66,6 +66,6 @@ tags:
rd /s f:\$RECYCLE.BIN
```
![202112012236810](../../../../public/img/2021/12/202112012236810.png)
![202112012236810](../../../../../public/img/2021/12/01/202112012236810.png)
问题解决了。

View File

@@ -17,7 +17,7 @@ tags:
结果,刚握住水杯,就看到 IntelliJ IDEA 在左下角弹出了一个错误提示框,如下:
![202112102211700](../../../../public/img/2021/12/202112102211700.jpg)
![202112102211700](../../../../../public/img/2021/12/10/202112102211700.jpg)
看提示的意思是命令行太长了让缩短一下命令行。又点了两下【Debug】运行按钮依然不依不饶的弹出这个提示那就放下水杯解决吧。
@@ -46,7 +46,7 @@ tags:
双击打开项目根目录下的 `.idea` 目录,这个目录下都是 IntelliJ IDEA 自动保存的项目配置内容,一般情况下我们不需要关注它,但这次我们需要找到其中的 `workspace.xml` 配置文件,手动修改一下配置。
![202112102211705](../../../../public/img/2021/12/202112102211705.png)
![202112102211705](../../../../../public/img/2021/12/10/202112102211705.png)
按下 【Ctrl + F】在弹出的搜索框中输入【PropertiesComponent】回车定位到该项配置后在其所在的 `<component>` 标签内最后部分添加一条属性配置,如下:
@@ -54,6 +54,6 @@ tags:
<property name="dynamic.classpath" value="true" />
```
![202112102211710](../../../../public/img/2021/12/202112102211710.png)
![202112102211710](../../../../../public/img/2021/12/10/202112102211710.png)
添加完后关闭该配置文件即可再次点击【Debug】运行按钮项目正常启动了笔者也该去接水了。

View File

@@ -18,7 +18,7 @@ tags:
不过好在最后问题解决了,跟笔者来一起看看解决方法吧。
![202112132257200](../../../../public/img/2021/12/202112132257200.png)
![202112132257200](../../../../../public/img/2021/12/13/202112132257200.png)
## 解决方案
@@ -26,15 +26,15 @@ tags:
首先,在出现问题的磁盘上【右键】单击,然后选择【属性】。
![202112132257205](../../../../public/img/2021/12/202112132257205.png)
![202112132257205](../../../../../public/img/2021/12/13/202112132257205.png)
在弹出的【属性】对话框中,选择【工具】选项卡,然后点击【检查】按钮。这个功能是用来检查磁盘文件系统错误的,检查完还会有个错误修复的环节。
![202112132257210](../../../../public/img/2021/12/202112132257210.png)
![202112132257210](../../../../../public/img/2021/12/13/202112132257210.png)
可惜的是,不知道是笔者这台电脑登录的账号权限问题,还是系统错误,这项修复手段,笔者用不了。
![202112132257215](../../../../public/img/2021/12/202112132257215.png)
![202112132257215](../../../../../public/img/2021/12/13/202112132257215.png)
### 尝试2命令行修复
@@ -42,7 +42,7 @@ tags:
按下【Windows】键弹出【开始】菜单直接输入【cmd】来在菜单中搜索。搜索出来后在【cmd.exe/命令行】上【右键】单击,选择【以管理员身份运行】。
![202112132257220](../../../../public/img/2021/12/202112132257220.png)
![202112132257220](../../../../../public/img/2021/12/13/202112132257220.png)
在弹出的 CMD 命令行窗口中,输入以下命令:
@@ -51,10 +51,10 @@ tags:
chkdsk f: /f
```
![202112132257225](../../../../public/img/2021/12/202112132257225.png)
![202112132257225](../../../../../public/img/2021/12/13/202112132257225.png)
![202112132257230](../../../../public/img/2021/12/202112132257230.png)
![202112132257230](../../../../../public/img/2021/12/13/202112132257230.png)
等待检查修复结束,笔者的 F 盘又回来了。
![202112132257235](../../../../public/img/2021/12/202112132257235.png)
![202112132257235](../../../../../public/img/2021/12/13/202112132257235.png)

View File

@@ -66,7 +66,7 @@ tags:
在前端表单中的展示效果大概如下:
![202201260941889](../../../../public/img/2022/01/202201260941889.png)
![202201260941889](../../../../../public/img/2022/01/26/202201260941889.png)
## 原因分析
@@ -78,7 +78,7 @@ tags:
最终,配合前端开发定位这个问题的原因是因为: JavaScript 中无法存储 Java 中的 Long 类型数据,当位数超过 JavaScript 整数存储的范围就会以0来代替了。
![202201260942561](../../../../public/img/2022/01/202201260942561.png)
![202201260942561](../../../../../public/img/2022/01/26/202201260942561.png)
## 解决方案

View File

@@ -64,15 +64,15 @@ INSERT INTO `user` VALUES (5, 'Billie', 24, 'Billie@126.com');
要使用 MyBatis 框架,第一步就是下载好 MyBatis 的 jar 包,我们可以从 [MyBatis](https://github.com/mybatis/mybatis-3/releases) 在 GitHub 上的开源地址下载。
![202111232222518](../../../public/img/2021/11/202111232222518.png)
![202012252222518](../../../public/img/2020/12/25/202012252222518.png)
笔者下载了 MyBatis 的核心压缩包mybatis-x.x.x.zip及其源码包mybatis-x-mybatis-x.x.x.zip
![202111232222812](../../../public/img/2021/11/202111232222812.png)
![202012252222738](../../../public/img/2020/12/25/202012252222738.png)
解压开 **mybatis-3.5.6.zip** 压缩包,目录结构如下:
![202111232222738](../../../public/img/2021/11/202111232222738.png)
![202012252222812](../../../public/img/2020/12/25/202012252222812.png)
::: tip 笔者说
如果 GitHub 下载太慢,可以前往 [FastGit](https://hub.fastgit.org/mybatis/mybatis-3/releases/tag/mybatis-3.5.6) 进行下载,它是 GitHub 的镜像地址,网站界面等各方面与 GitHub 几乎一模一样。
@@ -83,7 +83,7 @@ INSERT INTO `user` VALUES (5, 'Billie', 24, 'Billie@126.com');
下载好依赖之后,我们通过 Eclipse创建一个动态 Web 项目,并将刚才下载的 jar 包和指定数据库驱动包添加到 WebConent\WEB-INF\lib 目录,效果如下:
![202111232223708](../../../public/img/2021/11/202111232223708.png)
![202012252223067](../../../public/img/2020/12/25/202012252223067.png)
::: tip 笔者说
本次我们不会使用到 Servlet API所以创建一个普通 Java 工程也没问题。
@@ -202,7 +202,7 @@ log4j.appender.CONSOLE.layout.ConversionPattern=[demo] %d{yyyy-MM-dd HH:mm:ss,SS
当一切准备好之后,完整的项目目录结构如下:
![202111232223067](../../../public/img/2021/11/202111232223067.png)
![202012252223708](../../../public/img/2020/12/25/202012252223708.png)
创建好一个单元测试类,测试一下:

View File

@@ -17,7 +17,7 @@ tags:
在 API 使用层面MyBatis 的核心类型有三个分别是SqlSessionFactoryBuilder、SqlSessionFactory、SqlSession。
![202111242243280](../../../public/img/2021/11/202111242243280.png)
![202012252243280](../../../public/img/2020/12/25/202012252243280.png)
## SqlSessionFactoryBuilder
@@ -179,8 +179,6 @@ void testSelectList() throws IOException {
}
```
![202111242245992](../../../public/img/2021/11/202111242245992.jpg)
::: info 笔者说
对于技术的学习,笔者一贯遵循的步骤是:先用最最简单的 demo 让它跑起来,然后学学它的最最常用 API 和 配置让自己能用起来,最后熟练使用的基础上,在空闲时尝试阅读它的源码让自己能够洞彻它的运行机制,部分问题出现的原因,同时借鉴这些技术实现来提升自己的代码高度。
所以在笔者的文章中,前期基本都是小白文,仅仅穿插很少量的源码研究。当然等小白文更新多了,你们还依然喜欢,后期会不定时专门对部分技术的源码进行解析。

View File

@@ -38,7 +38,7 @@ configuration 根节点
::: tip 笔者说
这些标签在使用时一定要注意标签的顺序和允许使用次数。Eclipse 中可以通过在标签上按 F2 查看该标签下的内容模型,即标签的顺序和允许使用次数。你看下图中画圈处就是各个标签的顺序,后面的 ?号 代表指定标签最多允许使用一次。
:::
![202111242251170](../../../public/img/2021/11/202111242251170.png)
![202012262251170](../../../public/img/2020/12/26/202012262251170.png)
## properties元素
@@ -352,7 +352,7 @@ mappers 元素的作用就是用来告诉 MyBatis 去哪找我们编写的 SQL
### 指定映射文件
这类方式主要是告诉 MyBatis 我们所编写的 SQL 映射文件的地址,我们之前在 [《快速入门》](./01.快速入门) 中使用的就是属于这类方式。它有两种实现:
这类方式主要是告诉 MyBatis 我们所编写的 SQL 映射文件的地址,我们之前在 [《快速入门》](./01-快速入门) 中使用的就是属于这类方式。它有两种实现:
```xml
<!-- 使用相对于类路径的资源引用,有多少 SQL 映射文件就写多少个 mapper 配置 -->
@@ -395,7 +395,7 @@ public interface UserMapper {
}
```
![202111242252221](../../../public/img/2021/11/202111242252221.png)
![202012262252221](../../../public/img/2020/12/26/202012262252221.png)
**第二步:将 SQL 映射文件的 namespace 值改为对应 Mapper 接口的全限定类名。**

View File

@@ -72,7 +72,7 @@ public class UserDaoImpl extends BaseDao implements UserDao {
有问题存在就不缺解决问题的人。在行业内随之诞生了大量的持久层解决方案除了各自公司自研的方案之外比较有名的通用开源方案有Hibernate、MyBatis等各有各的优劣势在此我先不谈论它们的区别只说一个现象在国内来讲MyBatis应用相对广泛。
![202111232219533](../../public/img/2021/11/202111232219533.png)
![202012252219533](../../public/img/2020/12/25/202012252219533.png)
所以那没什么好说的了,直接学吧?
@@ -86,14 +86,14 @@ MyBatis读音是:[mai'bətɪs](买杯涕死),原是 Apache 软件基金会
MyBatis 是一款优秀的 **半自动的持久层ORM框架** ,它支持自定义 SQL、存储过程以及高级映射。MyBatis 免除了几乎所有的 JDBC 代码以及设置参数和获取结果集的工作。MyBatis 可以通过简单的 XML 或注解来配置和映射原始类型、接口和 Java POJOPlain Old Java Objects普通老式 Java 对象)为数据库中的记录。
当前最新版本是MyBatis 3.5.6 其发布时间是2020年10月6日。[1]
![202111232221059](../../public/img/2021/11/202111232221059.png)
![202012252221059](../../public/img/2020/12/25/202012252221059.png)
:::
::: details **1.什么是 ORM ** [2]
ORM对象关系映射Object Relation Mapping简称ORM或O/RM或O/R Mapping它是随着面向对象的软件开发方法发展而产生的。
面向对象的开发方法是当今企业级应用开发环境中的主流开发方法,关系数据库是企业级应用环境中永久存放数据的主流数据存储系统。对象和关系数据是业务实体的两种表现形式,业务实体在内存中表现为对象,在数据库中表现为关系数据。内存中的对象之间存在关联和继承关系,而在数据库中,关系数据无法直接表达多对多关联和继承关系。因此,对象-关系映射( ORM )系统一般以中间件的形式存在,主要实现程序对象到关系数据库数据的映射。
![202111232221734](../../public/img/2021/11/202111232221734.png)
![202012252221734](../../public/img/2020/12/25/202012252221734.png)
面向对象是从软件工程基本原则(如耦合、聚合、封装)的基础上发展起来的,而关系数据库则是从数学理论发展而来的,两套理论存在显著的区别。为了解决这个不匹配的现象,对象关系映射技术应运而生。

View File

Before

Width:  |  Height:  |  Size: 113 KiB

After

Width:  |  Height:  |  Size: 113 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 99 KiB

View File

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

Before

Width:  |  Height:  |  Size: 217 KiB

After

Width:  |  Height:  |  Size: 217 KiB

View File

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 88 KiB

View File

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 83 KiB

View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 164 KiB

After

Width:  |  Height:  |  Size: 164 KiB

View File

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 79 KiB

View File

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 93 KiB

View File

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 82 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 87 KiB

View File

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

View File

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB