From 16c5bca1a11205372d1d03c627dd759c5b4dc1b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=B8=85?= <1474983351@qq.com> Date: Thu, 3 Oct 2024 20:24:36 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E6=B5=8B=E8=AF=95=20IAU28L=20=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/mapper/MyAccountMapper.java | 6 ++- .../mybatisflex/test/model/AccountView.java | 54 +++++++++++++++++++ .../main/resources/mapper/accountMapper.xml | 15 ++++++ .../test/mapper/MyAccountMapperTest.java | 8 +++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/AccountView.java diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/mapper/MyAccountMapper.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/mapper/MyAccountMapper.java index 5f5ad57a..45cafd2f 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/mapper/MyAccountMapper.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/mapper/MyAccountMapper.java @@ -17,6 +17,8 @@ package com.mybatisflex.test.mapper; import com.mybatisflex.test.model.Account; +import com.mybatisflex.test.model.AccountDto; +import com.mybatisflex.test.model.AccountView; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -25,7 +27,9 @@ import java.util.Map; public interface MyAccountMapper extends AccountMapper { -// AccountDto selectByName(@Param("name") String name); + AccountDto selectByName(@Param("name") String name); + + AccountView selectViewObject(); @Select("select * from tb_account where id = #{id} and id =#{id}") Account selectById(@Param("id") Object id); diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/AccountView.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/AccountView.java new file mode 100644 index 00000000..ed722e42 --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/AccountView.java @@ -0,0 +1,54 @@ +package com.mybatisflex.test.model; + +import java.util.Date; +import java.util.List; + +/** + * 复杂查询接收类 + * 演示问题。 + * + * @author 王帅 + * @since 2024-10-03 + */ +@SuppressWarnings({"LombokGetterMayBeUsed", "LombokSetterMayBeUsed"}) +public class AccountView { + + private Long id; + private String userName; + private Date birthday; + + private List accountList; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public Date getBirthday() { + return birthday; + } + + public void setBirthday(Date birthday) { + this.birthday = birthday; + } + + public List getAccountList() { + return accountList; + } + + public void setAccountList(List accountList) { + this.accountList = accountList; + } + +} diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/mapper/accountMapper.xml b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/mapper/accountMapper.xml index 43229d97..7cdea25c 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/mapper/accountMapper.xml +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/mapper/accountMapper.xml @@ -26,4 +26,19 @@ select count(*) from `tb_account` ${qwSql} + + + + + + + + + + + diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/MyAccountMapperTest.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/MyAccountMapperTest.java index b943336e..e5e67a2f 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/MyAccountMapperTest.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/MyAccountMapperTest.java @@ -17,6 +17,8 @@ package com.mybatisflex.test.mapper; import com.mybatisflex.test.model.Account; +import com.mybatisflex.test.model.AccountView; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -37,6 +39,12 @@ class MyAccountMapperTest { @Autowired private MyAccountMapper mapper; + @Test + void complexSelect() { + AccountView accountView = Assertions.assertDoesNotThrow(() -> mapper.selectViewObject()); + System.out.println(accountView); + } + @Test void insertBatch() { List accounts = new ArrayList<>();