-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
591 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...in-demo-allservices/src/main/java/me/ningpp/mmegp/demo/mybatisplus/MybatisPlusEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright 2021-2023 the original author or authors. | ||
* | ||
* 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 me.ningpp.mmegp.demo.mybatisplus; | ||
|
||
import com.baomidou.mybatisplus.annotation.IdType; | ||
import com.baomidou.mybatisplus.annotation.TableField; | ||
import com.baomidou.mybatisplus.annotation.TableId; | ||
import com.baomidou.mybatisplus.annotation.TableName; | ||
|
||
@TableName | ||
public class MybatisPlusEntity { | ||
|
||
@TableId(type = IdType.AUTO) | ||
private Integer id; | ||
|
||
private String title; | ||
|
||
@TableField("mp_content") | ||
private String content; | ||
|
||
@TableField(exist = false) | ||
private String notExistColumn; | ||
|
||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Integer id) { | ||
this.id = id; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
public String getContent() { | ||
return content; | ||
} | ||
|
||
public void setContent(String content) { | ||
this.content = content; | ||
} | ||
|
||
public String getNotExistColumn() { | ||
return notExistColumn; | ||
} | ||
|
||
public void setNotExistColumn(String notExistColumn) { | ||
this.notExistColumn = notExistColumn; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...emo-allservices/src/test/java/me/ningpp/mmegp/demo/mybatisplus/MybatisPlusEntityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2021-2023 the original author or authors. | ||
* | ||
* 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 me.ningpp.mmegp.demo.mybatisplus; | ||
|
||
import me.ningpp.mmegp.demo.mybatisplusmapper.MybatisPlusEntityDynamicSqlSupport; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
import static me.ningpp.mmegp.demo.mybatisplusmapper.MybatisPlusEntityDynamicSqlSupport.content; | ||
import static me.ningpp.mmegp.demo.mybatisplusmapper.MybatisPlusEntityDynamicSqlSupport.id; | ||
import static me.ningpp.mmegp.demo.mybatisplusmapper.MybatisPlusEntityDynamicSqlSupport.mybatisPlusEntity; | ||
import static me.ningpp.mmegp.demo.mybatisplusmapper.MybatisPlusEntityDynamicSqlSupport.title; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class MybatisPlusEntityTest { | ||
|
||
@Test | ||
void parseTest() { | ||
assertEquals("id", id.name()); | ||
assertEquals("title", title.name()); | ||
assertEquals("mp_content", content.name()); | ||
assertEquals("mybatis_plus_entity", mybatisPlusEntity.tableNameAtRuntime()); | ||
Field[] fields = MybatisPlusEntityDynamicSqlSupport.MybatisPlusEntity.class.getFields(); | ||
// 需要禁止掉jacoco | ||
assertEquals("id,title,content", | ||
Stream.of(fields).map(Field::getName).collect(Collectors.joining(","))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.