diff --git a/pom.xml b/pom.xml index a45a587..3769d6e 100644 --- a/pom.xml +++ b/pom.xml @@ -108,6 +108,11 @@ org.springframework.boot spring-boot-starter-jdbc + + com.baomidou + mybatis-plus-spring-boot3-starter + 3.5.7 + diff --git a/src/main/java/edu/cmipt/gcs/GcsApplication.java b/src/main/java/edu/cmipt/gcs/GcsApplication.java index d2c8096..7788609 100644 --- a/src/main/java/edu/cmipt/gcs/GcsApplication.java +++ b/src/main/java/edu/cmipt/gcs/GcsApplication.java @@ -1,9 +1,11 @@ package edu.cmipt.gcs; +import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication +@MapperScan("edu.cmipt.gcs.dao") public class GcsApplication { public static void main(String[] args) { diff --git a/src/main/java/edu/cmipt/gcs/dao/UserMapper.java b/src/main/java/edu/cmipt/gcs/dao/UserMapper.java new file mode 100644 index 0000000..d9e648f --- /dev/null +++ b/src/main/java/edu/cmipt/gcs/dao/UserMapper.java @@ -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 { +} diff --git a/src/main/java/edu/cmipt/gcs/pojo/UserPO.java b/src/main/java/edu/cmipt/gcs/pojo/UserPO.java new file mode 100644 index 0000000..f38aff8 --- /dev/null +++ b/src/main/java/edu/cmipt/gcs/pojo/UserPO.java @@ -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) { +} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index f8dd622..2ea84be 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,4 +1,3 @@ -debug: true spring: datasource: druid: diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index f8dd622..2ea84be 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -1,4 +1,3 @@ -debug: true spring: datasource: druid: diff --git a/src/test/java/edu/cmipt/gcs/controller/dao/UserMapperTest.java b/src/test/java/edu/cmipt/gcs/controller/dao/UserMapperTest.java new file mode 100644 index 0000000..09bbe61 --- /dev/null +++ b/src/test/java/edu/cmipt/gcs/controller/dao/UserMapperTest.java @@ -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 userList = userMapper.selectList(null); + Assert.isTrue(1 == userList.size(), ""); + userList.forEach(System.out::println); + } +}