From d91507e2255957c28543e7cf6cb32dcbd3af1499 Mon Sep 17 00:00:00 2001 From: "Yangkai.Shen" <237497819@qq.com> Date: Sat, 14 Sep 2019 15:02:01 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=96=B0=E5=A2=9E=20ActiveRecord?= =?UTF-8?q?=20=E6=A8=A1=E5=BC=8F=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spring-boot-demo-orm-mybatis-plus/README.md | 117 ++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/spring-boot-demo-orm-mybatis-plus/README.md b/spring-boot-demo-orm-mybatis-plus/README.md index 3bfc74dd3..658fd2052 100644 --- a/spring-boot-demo-orm-mybatis-plus/README.md +++ b/spring-boot-demo-orm-mybatis-plus/README.md @@ -1,6 +1,8 @@ # spring-boot-demo-orm-mybatis-plus > 此 demo 演示了 Spring Boot 如何集成 mybatis-plus,简化Mybatis开发,带给你难以置信的开发体验。 +> +> - 2019-09-14 新增:ActiveRecord 模式操作 ## pom.xml @@ -420,6 +422,121 @@ public class UserServiceTest extends SpringBootDemoOrmMybatisPlusApplicationTest } ``` +## 2019-09-14新增 + +### ActiveRecord 模式 + +- Role.java + +```java +/** + *
+ * 角色实体类 + *
+ * + * @author yangkai.shen + * @date Created in 2019/9/16 14:04 + */ +@Data +@TableName("orm_role") +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class Role extends Model+ * RoleMapper + *
+ * + * @author yangkai.shen + * @date Created in 2019/9/16 14:06 + */ +public interface RoleMapper extends BaseMapper+ * Role + *
+ * + * @author yangkai.shen + * @date Created in 2019/9/16 14:19 + */ +@Slf4j +public class ActiveRecordTest extends SpringBootDemoOrmMybatisPlusApplicationTests { + /** + * 测试 ActiveRecord 插入数据 + */ + @Test + public void testActiveRecordInsert() { + Role role = new Role(); + role.setName("VIP"); + Assert.assertTrue(role.insert()); + // 成功直接拿会写的 ID + log.debug("【role】= {}", role); + } + + /** + * 测试 ActiveRecord 更新数据 + */ + @Test + public void testActiveRecordUpdate() { + Assert.assertTrue(new Role().setId(1L).setName("管理员-1").updateById()); + Assert.assertTrue(new Role().update(new UpdateWrapper