test: 枚举属性测试。

This commit is contained in:
Suomm 2023-06-14 10:10:24 +08:00
parent 4d2778e836
commit 41524440c9
4 changed files with 60 additions and 6 deletions

View File

@ -28,23 +28,31 @@ public class Account extends BaseEntity<String, Long> {
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;

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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;
}*/
}

View File

@ -35,8 +35,6 @@ class FieldTest {
void test() {
String genericString = BaseEntity.class.toGenericString();
System.out.println(genericString);
// List<String> genericParameters = StringUtil.getGenericParameters(genericString);
// System.out.println(genericParameters);
}
@Test

View File

@ -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);
}
}