wuguanghui 2 weeks ago
parent
commit
871eb4794a
  1. 92
      .idea/shelf/在变基之前未提交的更改_[更改]2/shelved.patch
  2. BIN
      孙维宁学习笔记/11.8孙维宁学习笔记.docx
  3. BIN
      孙维宁学习笔记/孙维宁-双十一机器人项目方案学习笔记-11.8.docx
  4. BIN
      尹顺宇学习笔记/尹顺宇11.08作业/尹顺宇11.08学习总结.docx
  5. 379
      尹顺宇学习笔记/尹顺宇11.08作业/尹顺宇11.08学习笔记.md
  6. BIN
      尹顺宇学习笔记/尹顺宇11.08作业/尹顺宇11.08学习笔记.pdf
  7. BIN
      尹顺宇学习笔记/尹顺宇11.08作业/尹顺宇11.08股票知识学习.docx
  8. BIN
      李延霜学习笔记/李延霜11.8学习总结.docx

92
.idea/shelf/在变基之前未提交的更改_[更改]2/shelved.patch

@ -0,0 +1,92 @@
Index: .idea/workspace.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+><?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project version=\"4\">\r\n <component name=\"AutoImportSettings\">\r\n <option name=\"autoReloadType\" value=\"SELECTIVE\" />\r\n </component>\r\n <component name=\"ChangeListManager\">\r\n <list default=\"true\" id=\"1250a154-aa13-4278-9e87-904a86c4dbd2\" name=\"更改\" comment=\"11.5\">\r\n <change beforePath=\"$PROJECT_DIR$/.idea/workspace.xml\" beforeDir=\"false\" afterPath=\"$PROJECT_DIR$/.idea/workspace.xml\" afterDir=\"false\" />\r\n </list>\r\n <option name=\"SHOW_DIALOG\" value=\"false\" />\r\n <option name=\"HIGHLIGHT_CONFLICTS\" value=\"true\" />\r\n <option name=\"HIGHLIGHT_NON_ACTIVE_CHANGELIST\" value=\"false\" />\r\n <option name=\"LAST_RESOLUTION\" value=\"IGNORE\" />\r\n </component>\r\n <component name=\"Git.Settings\">\r\n <option name=\"RECENT_BRANCH_BY_REPOSITORY\">\r\n <map>\r\n <entry key=\"$PROJECT_DIR$\" value=\"dev\" />\r\n </map>\r\n </option>\r\n <option name=\"RECENT_GIT_ROOT_PATH\" value=\"$PROJECT_DIR$\" />\r\n </component>\r\n <component name=\"ProjectColorInfo\">{\r\n &quot;associatedIndex&quot;: 0\r\n}</component>\r\n <component name=\"ProjectId\" id=\"353KyGCnYJFbynSTGPtdrLF9Edm\" />\r\n <component name=\"ProjectViewState\">\r\n <option name=\"hideEmptyMiddlePackages\" value=\"true\" />\r\n <option name=\"showLibraryContents\" value=\"true\" />\r\n </component>\r\n <component name=\"PropertiesComponent\"><![CDATA[{\r\n \"keyToString\": {\r\n \"ModuleVcsDetector.initialDetectionPerformed\": \"true\",\r\n \"RunOnceActivity.ShowReadmeOnStart\": \"true\",\r\n \"RunOnceActivity.git.unshallow\": \"true\",\r\n \"git-widget-placeholder\": \"sunweining/feature-20251028175924-学习\",\r\n \"last_opened_file_path\": \"D:/study_dbqb/Dbqb_Study/孙维宁学习笔记\",\r\n \"node.js.detected.package.eslint\": \"true\",\r\n \"node.js.selected.package.eslint\": \"(autodetect)\",\r\n \"node.js.selected.package.tslint\": \"(autodetect)\",\r\n \"nodejs_package_manager_path\": \"npm\",\r\n \"vue.rearranger.settings.migration\": \"true\"\r\n }\r\n}]]></component>\r\n <component name=\"RecentsManager\">\r\n <key name=\"CopyFile.RECENT_KEYS\">\r\n <recent name=\"D:\\study_dbqb\\Dbqb_Study\\孙维宁学习笔记\" />\r\n </key>\r\n </component>\r\n <component name=\"SharedIndexes\">\r\n <attachedChunks>\r\n <set>\r\n <option value=\"bundled-jdk-9823dce3aa75-fbdcb00ec9e3-intellij.indexing.shared.core-IU-251.26927.53\" />\r\n <option value=\"bundled-js-predefined-d6986cc7102b-09060db00ec0-JavaScript-IU-251.26927.53\" />\r\n </set>\r\n </attachedChunks>\r\n </component>\r\n <component name=\"TaskManager\">\r\n <task id=\"LOCAL-00001\" summary=\"11.1\">\r\n <option name=\"closed\" value=\"true\" />\r\n <created>1761983013107</created>\r\n <option name=\"number\" value=\"00001\" />\r\n <option name=\"presentableId\" value=\"LOCAL-00001\" />\r\n <option name=\"project\" value=\"LOCAL\" />\r\n <updated>1761983013107</updated>\r\n </task>\r\n <task id=\"LOCAL-00002\" summary=\"11.1\">\r\n <option name=\"closed\" value=\"true\" />\r\n <created>1761983018907</created>\r\n <option name=\"number\" value=\"00002\" />\r\n <option name=\"presentableId\" value=\"LOCAL-00002\" />\r\n <option name=\"project\" value=\"LOCAL\" />\r\n <updated>1761983018907</updated>\r\n </task>\r\n <task id=\"LOCAL-00003\" summary=\"11.5\">\r\n <option name=\"closed\" value=\"true\" />\r\n <created>1762333284024</created>\r\n <option name=\"number\" value=\"00003\" />\r\n <option name=\"presentableId\" value=\"LOCAL-00003\" />\r\n <option name=\"project\" value=\"LOCAL\" />\r\n <updated>1762333284024</updated>\r\n </task>\r\n <task active=\"true\" id=\"Default\" summary=\"默认任务\">\r\n <changelist id=\"1250a154-aa13-4278-9e87-904a86c4dbd2\" name=\"更改\" comment=\"11.5\" />\r\n <created>1762333567204</created>\r\n <option name=\"number\" value=\"Default\" />\r\n <option name=\"presentableId\" value=\"Default\" />\r\n <updated>1762333567204</updated>\r\n <workItem from=\"1762333568292\" duration=\"691000\" />\r\n <workItem from=\"1762390006167\" duration=\"599000\" />\r\n <workItem from=\"1762421259945\" duration=\"616000\" />\r\n </task>\r\n <option name=\"localTasksCounter\" value=\"4\" />\r\n <servers />\r\n </component>\r\n <component name=\"TypeScriptGeneratedFilesManager\">\r\n <option name=\"version\" value=\"3\" />\r\n </component>\r\n <component name=\"VcsManagerConfiguration\">\r\n <MESSAGE value=\"11.1\" />\r\n <MESSAGE value=\"11.5\" />\r\n <option name=\"LAST_COMMIT_MESSAGE\" value=\"11.5\" />\r\n </component>\r\n</project>
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
--- a/.idea/workspace.xml (revision c455a0312d16e71a9a58ec4f162e0e7463461374)
+++ b/.idea/workspace.xml (date 1762515114727)
@@ -4,7 +4,7 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
- <list default="true" id="1250a154-aa13-4278-9e87-904a86c4dbd2" name="更改" comment="11.5">
+ <list default="true" id="1250a154-aa13-4278-9e87-904a86c4dbd2" name="更改" comment="11.6">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@@ -15,7 +15,7 @@
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
- <entry key="$PROJECT_DIR$" value="dev" />
+ <entry key="$PROJECT_DIR$" value="sunweining/feature-20251028175924-学习" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
@@ -28,20 +28,20 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
- <component name="PropertiesComponent"><![CDATA[{
- "keyToString": {
- "ModuleVcsDetector.initialDetectionPerformed": "true",
- "RunOnceActivity.ShowReadmeOnStart": "true",
- "RunOnceActivity.git.unshallow": "true",
- "git-widget-placeholder": "sunweining/feature-20251028175924-学习",
- "last_opened_file_path": "D:/study_dbqb/Dbqb_Study/孙维宁学习笔记",
- "node.js.detected.package.eslint": "true",
- "node.js.selected.package.eslint": "(autodetect)",
- "node.js.selected.package.tslint": "(autodetect)",
- "nodejs_package_manager_path": "npm",
- "vue.rearranger.settings.migration": "true"
+ <component name="PropertiesComponent">{
+ &quot;keyToString&quot;: {
+ &quot;ModuleVcsDetector.initialDetectionPerformed&quot;: &quot;true&quot;,
+ &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
+ &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
+ &quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
+ &quot;last_opened_file_path&quot;: &quot;D:/study_dbqb/Dbqb_Study/孙维宁学习笔记&quot;,
+ &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
+ &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
+ &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
+ &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
+ &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
-}]]></component>
+}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="D:\study_dbqb\Dbqb_Study\孙维宁学习笔记" />
@@ -89,8 +89,18 @@
<workItem from="1762333568292" duration="691000" />
<workItem from="1762390006167" duration="599000" />
<workItem from="1762421259945" duration="616000" />
+ <workItem from="1762492519774" duration="992000" />
+ <workItem from="1762515015836" duration="99000" />
+ </task>
+ <task id="LOCAL-00004" summary="11.6">
+ <option name="closed" value="true" />
+ <created>1762514905809</created>
+ <option name="number" value="00004" />
+ <option name="presentableId" value="LOCAL-00004" />
+ <option name="project" value="LOCAL" />
+ <updated>1762514905809</updated>
</task>
- <option name="localTasksCounter" value="4" />
+ <option name="localTasksCounter" value="5" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -99,6 +109,7 @@
<component name="VcsManagerConfiguration">
<MESSAGE value="11.1" />
<MESSAGE value="11.5" />
- <option name="LAST_COMMIT_MESSAGE" value="11.5" />
+ <MESSAGE value="11.6" />
+ <option name="LAST_COMMIT_MESSAGE" value="11.6" />
</component>
</project>
\ No newline at end of file

BIN
孙维宁学习笔记/11.8孙维宁学习笔记.docx

BIN
孙维宁学习笔记/孙维宁-双十一机器人项目方案学习笔记-11.8.docx

BIN
尹顺宇学习笔记/尹顺宇11.08作业/尹顺宇11.08学习总结.docx

379
尹顺宇学习笔记/尹顺宇11.08作业/尹顺宇11.08学习笔记.md

@ -0,0 +1,379 @@
# Mybatis初步复习
## 1.SpringBoot整合Mybatis
## 1.1第一步添加依赖
```
<!-- mybatis启动器-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.5</version>
</dependency>
```
### 1.2进行配置
```
#配置Mybatis
mybatis:
configuration:
#在映射为java对象,将表中的下划线命名自动转换成驼峰式命名
map-underscore-to-camel-case: true
#日志前缀 可选
log-prefix: mybatis.
#日志实现类 可选
log-impl: org.apache.ibatis.logging.commons.JakartaCommonsLoggingImpl
#动态sql文件存储位置
mapper-locations: classpath:/mapper/**/*.xml
#配置日志显示sql
logging:
level:
#指定日志前缀
mybatis: debug
```
### 1.3 在Dao层编写的mapper接口,添加@Mapper注解
![1762578862653](C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\1762578862653.png)
### 1.4 编写动态sql文件(xx.xml文件)
![1762578878514](C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\1762578878514.png)
### 1.5 安装mybatisx插件
![1762578934144](C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\1762578934144.png)
安装之后在mapper和动态SQL文件对应代码左边有一个小鸟图标,方便直接跳转
![1762578917583](C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\1762578917583.png)
## 2.自动映射
当开启驼峰命名自动映射
```yaml
mybatis:
configuration:
map-underscore-to-camel-case: true
```
## 3.手动映射
当自动映射无法满足需求时,可以使用 `<resultMap>` 进行精确的手动映射。
```xml
<resultMap id="唯一标识" type="要映射的Java类型">
<!-- 主键映射 -->
<id property="Java属性名" column="数据库列名"/>
<!-- 普通字段映射 -->
<result property="Java属性名" column="数据库列名"/>
<!-- 关联关系映射 -->
<association property="关联对象属性" javaType="关联对象类型"/>
<collection property="集合属性" ofType="集合元素类型"/>
</resultMap>
```
举例:
### 3.1基础字段映射
```java
实体类
public class User {
private Long userId; // 与数据库字段名不同
private String userName; // 需要手动映射
private String email;
private Integer status;
private LocalDateTime createTime;
private LocalDateTime updateTime;
// 构造函数、getter、setter...
}
```
```sql
数据库表结构:
CREATE TABLE t_user (
id BIGINT PRIMARY KEY,
name VARCHAR(50),
email VARCHAR(100),
status TINYINT,
created_at DATETIME,
updated_at DATETIME
);
```
```xml
<!-- 基础手动映射示例 -->
<resultMap id="BaseUserMap" type="User">
<!-- 主键字段,使用 id 标签 -->
<id property="userId" column="id"/>
<!-- 普通字段,使用 result 标签 -->
<result property="userName" column="name"/>
<result property="email" column="email"/>
<result property="status" column="status"/>
<result property="createTime" column="created_at"/>
<result property="updateTime" column="updated_at"/>
</resultMap>
<!-- 使用 resultMap -->
<select id="selectUserById" resultMap="BaseUserMap">
SELECT id, name, email, status, created_at, updated_at
FROM t_user
WHERE id = #{id}
</select>
```
说明:
![1762581420222](C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\1762581420222.png)
### 3.2一对一关联映射
#### 3.2.1单次查询嵌套结果映射
举例:
```java
实体类
public class User {
private Long userId;
private String userName;
private UserProfile userProfile; // 一对一关联
// getter/setter...
}
public class UserProfile {
private Long profileId;
private Long userId;
private String realName;
private Integer age;
private String address;
private String phone;
// getter/setter...
}
```
```xml
手动映射配置:
<!-- 用户和用户详情的一对一映射 -->
<resultMap id="UserWithProfileMap" type="User">
<id property="userId" column="id"/>
<result property="userName" column="name"/>
<!-- association: 一对一关联映射 -->
<association property="userProfile" javaType="UserProfile">
<id property="profileId" column="profile_id"/>
<result property="userId" column="id"/> <!-- 注意:这里复用外层查询的id -->
<result property="realName" column="real_name"/>
<result property="age" column="age"/>
<result property="address" column="address"/>
<result property="phone" column="phone"/>
</association>
</resultMap>
<!-- 关联查询SQL -->
<select id="selectUserWithProfile" resultMap="UserWithProfileMap">
SELECT
u.id, u.name,
up.id as profile_id, up.real_name, up.age, up.address, up.phone
FROM t_user u
LEFT JOIN t_user_profile up ON u.id = up.user_id
WHERE u.id = #{userId}
</select>
```
#### 3.2.2 多次查询嵌套查询映射
```xml
<!-- 主结果映射 -->
<resultMap id="UserWithProfileNestedMap" type="User">
<id property="userId" column="id"/>
<result property="userName" column="name"/>
<!-- 嵌套查询:通过 select 属性引用另一个查询 -->
<association property="userProfile" column="id"
select="selectUserProfileByUserId"/>
</resultMap>
<!-- 主查询 -->
<select id="selectUserWithProfileNested" resultMap="UserWithProfileNestedMap">
SELECT id, name
FROM t_user
WHERE id = #{userId}
</select>
<!-- 嵌套查询 -->
<select id="selectUserProfileByUserId" resultType="UserProfile">
SELECT
id as profileId,
user_id as userId,
real_name as realName,
age, address, phone
FROM t_user_profile`
WHERE user_id = #{userId}
</select>
```
### 3.3一对多集合映射
```java
实体类:
public class User {
private Long userId;
private String userName;
private List<Order> orders; // 一对多关联
// getter/setter...
}
public class Order {
private Long orderId;
private Long userId;
private String orderNumber;
private BigDecimal amount;
private LocalDateTime orderTime;
// getter/setter...
}
```
```xml
<!-- 用户和订单的一对多映射 -->
<resultMap id="UserWithOrdersMap" type="User">
<id property="userId" column="id"/>
<result property="userName" column="name"/>
<!-- collection: 一对多关联映射 -->
<collection property="orders" ofType="Order">
<id property="orderId" column="order_id"/>
<result property="userId" column="id"/> <!-- 注意:这里复用外层查询的id -->
<result property="orderNumber" column="order_number"/>
<result property="amount" column="amount"/>
<result property="orderTime" column="order_time"/>
</collection>
</resultMap>
<!-- 关联查询SQL -->
<select id="selectUserWithOrders" resultMap="UserWithOrdersMap">
SELECT
u.id, u.name,
o.id as order_id, o.order_number, o.amount, o.order_time
FROM t_user u
LEFT JOIN t_order o ON u.id = o.user_id
WHERE u.id = #{userId}
</select>
```
### 3.4复杂的多层嵌套
```java
public class User {
private Long userId;
private String userName;
private List<Order> orders;
}
public class Order {
private Long orderId;
private String orderNumber;
private List<OrderItem> orderItems;
}
public class OrderItem {
private Long itemId;
private Long productId;
private Integer quantity;
private Product product; // 关联商品
}
public class Product {
private Long productId;
private String productName;
private BigDecimal price;
}
```
```xml
<!-- 完整的多层嵌套映射 -->
<resultMap id="CompleteUserMap" type="User">
<id property="userId" column="user_id"/>
<result property="userName" column="user_name"/>
<!-- 第一层嵌套:订单集合 -->
<collection property="orders" ofType="Order" resultMap="OrderWithItemsMap"/>
</resultMap>
<resultMap id="OrderWithItemsMap" type="Order">
<id property="orderId" column="order_id"/>
<result property="orderNumber" column="order_number"/>
<!-- 第二层嵌套:订单项集合 -->
<collection property="orderItems" ofType="OrderItem" resultMap="OrderItemMap"/>
</resultMap>
<resultMap id="OrderItemMap" type="OrderItem">
<id property="itemId" column="item_id"/>
<result property="quantity" column="quantity"/>
<!-- 第三层嵌套:商品信息 -->
<association property="product" javaType="Product">
<id property="productId" column="product_id"/>
<result property="productName" column="product_name"/>
<result property="price" column="price"/>
</association>
</resultMap>
<!-- 复杂查询SQL -->
<select id="selectUserWithOrderDetails" resultMap="CompleteUserMap">
SELECT
u.id as user_id, u.name as user_name,
o.id as order_id, o.order_number,
oi.id as item_id, oi.quantity,
p.id as product_id, p.name as product_name, p.price
FROM t_user u
LEFT JOIN t_order o ON u.id = o.user_id
LEFT JOIN t_order_item oi ON o.id = oi.order_id
LEFT JOIN t_product p ON oi.product_id = p.id
WHERE u.id = #{userId}
ORDER BY o.order_time DESC, oi.id
</select>
```
### 3.5.注意
1.可以 自动映射与手动映射结合
```xml
<!-- 混合映射:autoMapping="true" 开启自动映射 -->
<resultMap id="HybridUserMap" type="User" autoMapping="true">
<!-- 只手动映射名称不匹配的字段 -->
<id property="userId" column="id"/>
<result property="userName" column="name"/>
<result property="createTime" column="created_at"/>
<!-- 关联对象也可以使用自动映射 -->
<association property="userProfile" javaType="UserProfile" autoMapping="true">
<id property="profileId" column="profile_id"/>
<!-- 只覆盖需要特殊处理的字段 -->
<result property="realName" column="real_name"/>
</association>
</resultMap>
```
##

BIN
尹顺宇学习笔记/尹顺宇11.08作业/尹顺宇11.08学习笔记.pdf

BIN
尹顺宇学习笔记/尹顺宇11.08作业/尹顺宇11.08股票知识学习.docx

BIN
李延霜学习笔记/李延霜11.8学习总结.docx

Loading…
Cancel
Save