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 6f0d21f9..abc5116c 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 @@ -28,23 +28,31 @@ public class Account extends BaseEntity { private Integer age; private Date birthday; + private Gender gender; + public Gender getGender() { + return gender; + } - public Long getId() { + public void setGender(Gender gender) { + this.gender = gender; + } + + /*public Long getId() { return id; } public void setId(Long id) { this.id = id; - } + }*/ - public String getUserName() { + /*public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; - } + }*/ public Integer getAge() { return age; diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Gender.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Gender.java new file mode 100644 index 00000000..6d2e2738 --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Gender.java @@ -0,0 +1,39 @@ +/* + * 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; + +/** + * @author 王帅 + * @since 2023-06-14 + */ +public enum Gender { + + MALE, FEMALE; + /*MALE(1), FEMALE(0); + + public int getCode() { + return code; + } + + @EnumValue + private final int code; + + Gender(int code) { + this.code = code; + }*/ + +} \ No newline at end of file diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/common/FieldTest.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/common/FieldTest.java index a378a9ef..c3ef93c3 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/common/FieldTest.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/common/FieldTest.java @@ -35,8 +35,6 @@ class FieldTest { void test() { String genericString = BaseEntity.class.toGenericString(); System.out.println(genericString); -// List genericParameters = StringUtil.getGenericParameters(genericString); -// System.out.println(genericParameters); } @Test diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/AccountMapperTest.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/AccountMapperTest.java index 84ed06ed..340121e7 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/AccountMapperTest.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/AccountMapperTest.java @@ -18,6 +18,7 @@ package com.mybatisflex.test.mapper; import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.test.model.Account; +import com.mybatisflex.test.model.Gender; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -62,4 +63,12 @@ class AccountMapperTest { accountMapper.selectListByQuery(QueryWrapper.create()).forEach(System.err::println); } + @Test + void testEnum() { + Account account = new Account(); + account.setId(1L); + account.setGender(Gender.MALE); + accountMapper.update(account); + } + } \ No newline at end of file