-
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.
In this commit, we add the `mybatis-plus` dependency to the `pom.xml` file, and configure the `mybatis-plus` in the `application-dev.yml` file. We also add the `UserMapper` interface and `UserPO` class to the project for testing. The `UserMapper` interface is used to define the database operations (the real operations will generated by `mybatis-plus`), and the `UserPO` class is used to define the user entity. We use `spring-boot-test` to test this function (I've add one item in the `t_user` table). This solved #28.
- Loading branch information
1 parent
a486dfa
commit 157992a
Showing
7 changed files
with
53 additions
and
2 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
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,8 @@ | ||
package edu.cmipt.gcs.dao; | ||
|
||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
|
||
import edu.cmipt.gcs.pojo.UserPO; | ||
|
||
public interface UserMapper extends BaseMapper<UserPO> { | ||
} |
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,11 @@ | ||
package edu.cmipt.gcs.pojo; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import com.baomidou.mybatisplus.annotation.TableId; | ||
import com.baomidou.mybatisplus.annotation.TableName; | ||
|
||
@TableName("t_user") | ||
public record UserPO(@TableId Long pkUserId, String username, String email, String userPassword, LocalDateTime gmtCreated, | ||
LocalDateTime gmtUpdated, LocalDateTime gmtDeleted) { | ||
} |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
debug: true | ||
spring: | ||
datasource: | ||
druid: | ||
|
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
debug: true | ||
spring: | ||
datasource: | ||
druid: | ||
|
27 changes: 27 additions & 0 deletions
27
src/test/java/edu/cmipt/gcs/controller/dao/UserMapperTest.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,27 @@ | ||
package edu.cmipt.gcs.controller.dao; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
import com.baomidou.mybatisplus.core.toolkit.Assert; | ||
|
||
import edu.cmipt.gcs.dao.UserMapper; | ||
import edu.cmipt.gcs.pojo.UserPO; | ||
|
||
@SpringBootTest | ||
public class UserMapperTest { | ||
|
||
@Autowired | ||
private UserMapper userMapper; | ||
|
||
@Test | ||
public void testSelect() { | ||
System.out.println(("----- selectAll method test ------")); | ||
List<UserPO> userList = userMapper.selectList(null); | ||
Assert.isTrue(1 == userList.size(), ""); | ||
userList.forEach(System.out::println); | ||
} | ||
} |