diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Account.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Account.java index d5b8dcde..3d7fa200 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Account.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Account.java @@ -1,23 +1,23 @@ -/** - * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.mybatisflex.test.model; import com.mybatisflex.annotation.Id; -import com.mybatisflex.annotation.Table; import com.mybatisflex.annotation.KeyType; +import com.mybatisflex.annotation.Table; import java.util.Date; diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Good.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Good.java new file mode 100644 index 00000000..57e7f31d --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Good.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mybatisflex.test.model; + +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.Table; + +/** + * 商品。 + * + * @author 王帅 + * @since 2023-06-07 + */ +@Table("tb_good") +public class Good { + + @Id + private Integer goodId; + private String name; + private double price; + + public Integer getGoodId() { + return goodId; + } + + public void setGoodId(Integer goodId) { + this.goodId = goodId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + + @Override + public String toString() { + return "Good{" + + "goodId=" + goodId + + ", name='" + name + '\'' + + ", price=" + price + + '}'; + } +} \ No newline at end of file diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Order.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Order.java new file mode 100644 index 00000000..5e59747b --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Order.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mybatisflex.test.model; + +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.Table; + +import java.time.LocalDateTime; + +/** + * 订单。 + * + * @author 王帅 + * @since 2023-06-07 + */ +@Table("tb_order") +public class Order { + + @Id + private int orderId; + private LocalDateTime createTime; + + public int getOrderId() { + return orderId; + } + + public void setOrderId(int orderId) { + this.orderId = orderId; + } + + public LocalDateTime getCreateTime() { + return createTime; + } + + public void setCreateTime(LocalDateTime createTime) { + this.createTime = createTime; + } + + @Override + public String toString() { + return "Order{" + + "orderId=" + orderId + + ", createTime=" + createTime + + '}'; + } +} \ No newline at end of file diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/OrderGood.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/OrderGood.java new file mode 100644 index 00000000..8999a10c --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/OrderGood.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mybatisflex.test.model; + +import com.mybatisflex.annotation.Table; + +/** + * 订单与商品连接表。 + * + * @author 王帅 + * @since 2023-06-07 + */ +@Table("tb_order_good") +public class OrderGood { + + private Integer orderId; + private Integer goodId; + + public Integer getOrderId() { + return orderId; + } + + public void setOrderId(Integer orderId) { + this.orderId = orderId; + } + + public Integer getGoodId() { + return goodId; + } + + public void setGoodId(Integer goodId) { + this.goodId = goodId; + } +} \ No newline at end of file diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/OrderInfo.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/OrderInfo.java new file mode 100644 index 00000000..510f9f33 --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/OrderInfo.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mybatisflex.test.model; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * 订单信息。 + * + * @author 王帅 + * @since 2023-06-07 + */ +public class OrderInfo { + + private Integer orderId; + private LocalDateTime createTime; + + private List goodList; + + public Integer getOrderId() { + return orderId; + } + + public void setOrderId(Integer orderId) { + this.orderId = orderId; + } + + public LocalDateTime getCreateTime() { + return createTime; + } + + public void setCreateTime(LocalDateTime createTime) { + this.createTime = createTime; + } + + public List getGoodList() { + return goodList; + } + + public void setGoodList(List goodList) { + this.goodList = goodList; + } + + @Override + public String toString() { + return "OrderInfo{" + + "orderId=" + orderId + + ", createTime=" + createTime + + ", goodList=" + goodList + + '}'; + } +} \ No newline at end of file diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Role.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Role.java index f3dbca0e..88d3a109 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Role.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Role.java @@ -19,13 +19,13 @@ package com.mybatisflex.test.model; import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Table; -import java.util.Objects; - /** + * 角色。 + * * @author 王帅 - * @since 2.0 + * @since 2023-06-07 */ -@Table("sys_role") +@Table("tb_role") public class Role { @Id @@ -57,26 +57,6 @@ public class Role { this.roleName = roleName; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Role role = (Role) o; - - if (!Objects.equals(roleId, role.roleId)) return false; - if (!Objects.equals(roleKey, role.roleKey)) return false; - return Objects.equals(roleName, role.roleName); - } - - @Override - public int hashCode() { - int result = roleId != null ? roleId.hashCode() : 0; - result = 31 * result + (roleKey != null ? roleKey.hashCode() : 0); - result = 31 * result + (roleName != null ? roleName.hashCode() : 0); - return result; - } - @Override public String toString() { return "Role{" + diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/User.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/User.java index df93f45b..1ff8f244 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/User.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/User.java @@ -19,19 +19,20 @@ package com.mybatisflex.test.model; import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Table; -import java.util.Objects; - /** + * 用户。 + * * @author 王帅 - * @since 2.0 + * @since 2023-06-07 */ -@Table("sys_user") +@Table("tb_user") public class User { @Id private Integer userId; private String userName; + private String password; public Integer getUserId() { return userId; @@ -49,22 +50,12 @@ public class User { this.userName = userName; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - User user = (User) o; - - if (!Objects.equals(userId, user.userId)) return false; - return Objects.equals(userName, user.userName); + public String getPassword() { + return password; } - @Override - public int hashCode() { - int result = userId != null ? userId.hashCode() : 0; - result = 31 * result + (userName != null ? userName.hashCode() : 0); - return result; + public void setPassword(String password) { + this.password = password; } @Override @@ -72,6 +63,7 @@ public class User { return "User{" + "userId=" + userId + ", userName='" + userName + '\'' + + ", password='" + password + '\'' + '}'; } } \ No newline at end of file diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserInfo.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserInfo.java new file mode 100644 index 00000000..b1e48d1d --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserInfo.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mybatisflex.test.model; + +import java.util.List; + +/** + * 用户信息。 + * + * @author 王帅 + * @since 2023-06-07 + */ +public class UserInfo { + + private Integer userId; + private String userName; + private String password; + + private List roleList; + private List orderInfoList; + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public List getRoleList() { + return roleList; + } + + public void setRoleList(List roleList) { + this.roleList = roleList; + } + + public List getOrderInfoList() { + return orderInfoList; + } + + public void setOrderInfoList(List orderInfoList) { + this.orderInfoList = orderInfoList; + } + + @Override + public String toString() { + return "UserInfo{" + + "userId=" + userId + + ", userName='" + userName + '\'' + + ", password='" + password + '\'' + + ", roleList=" + roleList + + ", orderInfoList=" + orderInfoList + + '}'; + } +} \ No newline at end of file diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserOrder.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserOrder.java new file mode 100644 index 00000000..71defc00 --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserOrder.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mybatisflex.test.model; + +import com.mybatisflex.annotation.Table; + +/** + * 用户订单映射。 + * + * @author 王帅 + * @since 2023-06-07 + */ +@Table("tb_user_order") +public class UserOrder { + + private Integer userId; + private Integer orderId; + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public Integer getOrderId() { + return orderId; + } + + public void setOrderId(Integer orderId) { + this.orderId = orderId; + } +} \ No newline at end of file diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserRole.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserRole.java index ae2f9b8c..4ae2bb28 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserRole.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserRole.java @@ -18,13 +18,13 @@ package com.mybatisflex.test.model; import com.mybatisflex.annotation.Table; -import java.util.Objects; - /** + * 用户与角色连接表。 + * * @author 王帅 - * @since 2.0 + * @since 2023-06-07 */ -@Table("sys_user_role") +@Table("tb_user_role") public class UserRole { private Integer userId; @@ -45,23 +45,4 @@ public class UserRole { public void setRoleId(Integer roleId) { this.roleId = roleId; } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - UserRole userRole = (UserRole) o; - - if (!Objects.equals(userId, userRole.userId)) return false; - return Objects.equals(roleId, userRole.roleId); - } - - @Override - public int hashCode() { - int result = userId != null ? userId.hashCode() : 0; - result = 31 * result + (roleId != null ? roleId.hashCode() : 0); - return result; - } } \ No newline at end of file diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserVO.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserVO.java index 98c3ce4a..e3f8cf59 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserVO.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserVO.java @@ -17,11 +17,12 @@ package com.mybatisflex.test.model; import java.util.List; -import java.util.Objects; /** + * 用户 VO 对象。 + * * @author 王帅 - * @since 2.0 + * @since 2023-06-07 */ public class UserVO { @@ -29,7 +30,6 @@ public class UserVO { private String userId; private String userName; private List roleList; - private Role role; public String getUserId() { return userId; @@ -55,43 +55,12 @@ public class UserVO { this.roleList = roleList; } - public Role getRole() { - return role; - } - - public void setRole(Role role) { - this.role = role; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - UserVO userVO = (UserVO) o; - - if (!Objects.equals(userId, userVO.userId)) return false; - if (!Objects.equals(userName, userVO.userName)) return false; - if (!Objects.equals(roleList, userVO.roleList)) return false; - return Objects.equals(role, userVO.role); - } - - @Override - public int hashCode() { - int result = userId != null ? userId.hashCode() : 0; - result = 31 * result + (userName != null ? userName.hashCode() : 0); - result = 31 * result + (roleList != null ? roleList.hashCode() : 0); - result = 31 * result + (role != null ? role.hashCode() : 0); - return result; - } - @Override public String toString() { return "UserVO{" + "userId='" + userId + '\'' + ", userName='" + userName + '\'' + ", roleList=" + roleList + - ", role=" + role + '}'; } } \ No newline at end of file diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserVO1.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserVO1.java index 5ebd5271..26a60d2b 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserVO1.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserVO1.java @@ -17,11 +17,10 @@ package com.mybatisflex.test.model; import java.util.List; -import java.util.Objects; /** * @author 王帅 - * @since 2.0 + * @since 2023-06-07 */ public class UserVO1 { @@ -29,6 +28,7 @@ public class UserVO1 { private String userId; private String userName; private List roleList; + private Role role; public String getUserId() { return userId; @@ -54,32 +54,21 @@ public class UserVO1 { this.roleList = roleList; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - UserVO1 userVO1 = (UserVO1) o; - - if (!Objects.equals(userId, userVO1.userId)) return false; - if (!Objects.equals(userName, userVO1.userName)) return false; - return Objects.equals(roleList, userVO1.roleList); + public Role getRole() { + return role; } - @Override - public int hashCode() { - int result = userId != null ? userId.hashCode() : 0; - result = 31 * result + (userName != null ? userName.hashCode() : 0); - result = 31 * result + (roleList != null ? roleList.hashCode() : 0); - return result; + public void setRole(Role role) { + this.role = role; } @Override public String toString() { - return "UserVO{" + + return "UserVO1{" + "userId='" + userId + '\'' + ", userName='" + userName + '\'' + ", roleList=" + roleList + + ", role=" + role + '}'; } } \ No newline at end of file diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserVO2.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserVO2.java index 46682763..10da2c24 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserVO2.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserVO2.java @@ -16,11 +16,9 @@ package com.mybatisflex.test.model; -import java.util.Objects; - /** * @author 王帅 - * @since 2.0 + * @since 2023-06-07 */ public class UserVO2 { @@ -45,7 +43,6 @@ public class UserVO2 { this.userName = userName; } - public Role getRole() { return role; } @@ -54,29 +51,9 @@ public class UserVO2 { this.role = role; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - UserVO2 userVO = (UserVO2) o; - - if (!Objects.equals(userId, userVO.userId)) return false; - if (!Objects.equals(userName, userVO.userName)) return false; - return Objects.equals(role, userVO.role); - } - - @Override - public int hashCode() { - int result = userId != null ? userId.hashCode() : 0; - result = 31 * result + (userName != null ? userName.hashCode() : 0); - result = 31 * result + (role != null ? role.hashCode() : 0); - return result; - } - @Override public String toString() { - return "UserVO{" + + return "UserVO2{" + "userId='" + userId + '\'' + ", userName='" + userName + '\'' + ", role=" + role + diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserVO3.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserVO3.java index 6e36df50..16d97b3c 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserVO3.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/UserVO3.java @@ -16,11 +16,9 @@ package com.mybatisflex.test.model; -import java.util.Objects; - /** * @author 王帅 - * @since 2.0 + * @since 2023-06-07 */ public class UserVO3 { @@ -71,30 +69,6 @@ public class UserVO3 { this.roleName = roleName; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - UserVO3 userVO3 = (UserVO3) o; - - if (!Objects.equals(userId, userVO3.userId)) return false; - if (!Objects.equals(userName, userVO3.userName)) return false; - if (!Objects.equals(roleId, userVO3.roleId)) return false; - if (!Objects.equals(roleKey, userVO3.roleKey)) return false; - return Objects.equals(roleName, userVO3.roleName); - } - - @Override - public int hashCode() { - int result = userId != null ? userId.hashCode() : 0; - result = 31 * result + (userName != null ? userName.hashCode() : 0); - result = 31 * result + (roleId != null ? roleId.hashCode() : 0); - result = 31 * result + (roleKey != null ? roleKey.hashCode() : 0); - result = 31 * result + (roleName != null ? roleName.hashCode() : 0); - return result; - } - @Override public String toString() { return "UserVO3{" + diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml index 03ce12f1..abbcedf7 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml @@ -5,7 +5,7 @@ spring: # enabled: true datasource: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/test?characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true + url: jdbc:mysql://localhost:3306/mp_test username: root password: 12345678 # sql: diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/UserMapperTest.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/UserMapperTest.java index f082d94e..55fd2e34 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/UserMapperTest.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/UserMapperTest.java @@ -17,21 +17,25 @@ package com.mybatisflex.test.mapper; import com.mybatisflex.core.query.QueryWrapper; +import com.mybatisflex.test.model.UserInfo; import com.mybatisflex.test.model.UserVO1; -import com.mybatisflex.test.model.UserVO3; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import java.util.List; +import static com.mybatisflex.test.model.table.GoodTableDef.GOOD; +import static com.mybatisflex.test.model.table.OrderGoodTableDef.ORDER_GOOD; +import static com.mybatisflex.test.model.table.OrderTableDef.ORDER; import static com.mybatisflex.test.model.table.RoleTableDef.ROLE; +import static com.mybatisflex.test.model.table.UserOrderTableDef.USER_ORDER; import static com.mybatisflex.test.model.table.UserRoleTableDef.USER_ROLE; import static com.mybatisflex.test.model.table.UserTableDef.USER; /** * @author 王帅 - * @since 2.0 + * @since 2023-06-07 */ @SpringBootTest class UserMapperTest { @@ -59,15 +63,32 @@ class UserMapperTest { void testSelectList() { QueryWrapper queryWrapper = QueryWrapper.create() .select(USER.USER_ID, USER.USER_NAME, ROLE.ALL_COLUMNS) - .from(USER) - .leftJoin(USER_ROLE).on(USER_ROLE.USER_ID.eq(USER.USER_ID)) - .leftJoin(ROLE).on(USER_ROLE.ROLE_ID.eq(ROLE.ROLE_ID)); -// System.out.println(queryWrapper.toSQL()); + .from(USER.as("u")) + .leftJoin(USER_ROLE).as("ur").on(USER_ROLE.USER_ID.eq(USER.USER_ID)) + .leftJoin(ROLE).as("r").on(USER_ROLE.ROLE_ID.eq(ROLE.ROLE_ID)) + .where(USER.USER_ID.ge(2)); + System.out.println(queryWrapper.toSQL()); // List userVOS = userMapper.selectListByQueryAs(queryWrapper, UserVO.class); -// List userVOS = userMapper.selectListByQueryAs(queryWrapper, UserVO1.class); + List userVOS = userMapper.selectListByQueryAs(queryWrapper, UserVO1.class); // List userVOS = userMapper.selectListByQueryAs(queryWrapper, UserVO2.class); - List userVOS = userMapper.selectListByQueryAs(queryWrapper, UserVO3.class); +// List userVOS = userMapper.selectListByQueryAs(queryWrapper, UserVO3.class); userVOS.forEach(System.err::println); } + @Test + void testComplexSelectList() { + QueryWrapper queryWrapper = QueryWrapper.create() + .select(USER.ALL_COLUMNS, ROLE.ALL_COLUMNS, ORDER.ALL_COLUMNS, GOOD.ALL_COLUMNS) + .from(USER.as("u")) + .leftJoin(USER_ROLE).as("ur").on(USER.USER_ID.eq(USER_ROLE.USER_ID)) + .leftJoin(ROLE).as("r").on(ROLE.ROLE_ID.eq(USER_ROLE.ROLE_ID)) + .leftJoin(USER_ORDER).as("uo").on(USER.USER_ID.eq(USER_ORDER.USER_ID)) + .leftJoin(ORDER).as("o").on(ORDER.ORDER_ID.eq(USER_ORDER.ORDER_ID)) + .leftJoin(ORDER_GOOD).as("og").on(ORDER.ORDER_ID.eq(ORDER_GOOD.ORDER_ID)) + .leftJoin(GOOD).as("g").on(GOOD.GOOD_ID.eq(ORDER_GOOD.GOOD_ID)); + System.err.println(queryWrapper.toSQL()); + List userInfos = userMapper.selectListByQueryAs(queryWrapper, UserInfo.class); + userInfos.forEach(System.err::println); + } + } \ No newline at end of file