From 8ed4b88b109d505e4fdd98876af56b531b33c259 Mon Sep 17 00:00:00 2001 From: "mail_yanpeng@163.com" Date: Tue, 25 Aug 2020 16:22:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/aiprose/mbp/controller/UserController.java | 5 +++++ src/main/java/com/aiprose/mbp/mapper/UserMapper.java | 2 ++ .../java/com/aiprose/mbp/service/UserService.java | 8 +++++++- src/main/resources/application.yml | 5 +++-- src/main/resources/mapper/UserMapper.xml | 11 +++++++++++ 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/mapper/UserMapper.xml diff --git a/src/main/java/com/aiprose/mbp/controller/UserController.java b/src/main/java/com/aiprose/mbp/controller/UserController.java index c219380..510d8f5 100644 --- a/src/main/java/com/aiprose/mbp/controller/UserController.java +++ b/src/main/java/com/aiprose/mbp/controller/UserController.java @@ -24,6 +24,11 @@ public class UserController { System.out.println(userService.save(user)); } + @GetMapping("find/name") + public List save(String name) { + return userService.fingByName(name,11); + } + @GetMapping("list") public List user() { return userService.list(); diff --git a/src/main/java/com/aiprose/mbp/mapper/UserMapper.java b/src/main/java/com/aiprose/mbp/mapper/UserMapper.java index ad885c8..b1e4927 100644 --- a/src/main/java/com/aiprose/mbp/mapper/UserMapper.java +++ b/src/main/java/com/aiprose/mbp/mapper/UserMapper.java @@ -12,4 +12,6 @@ public interface UserMapper extends BaseMapper { @Select("select * from mbp_user") public List queryList(); + + public List selectByName(String name,Integer age); } diff --git a/src/main/java/com/aiprose/mbp/service/UserService.java b/src/main/java/com/aiprose/mbp/service/UserService.java index 9179782..3d39d0b 100644 --- a/src/main/java/com/aiprose/mbp/service/UserService.java +++ b/src/main/java/com/aiprose/mbp/service/UserService.java @@ -4,7 +4,6 @@ import com.aiprose.mbp.entity.User; import com.aiprose.mbp.mapper.UserMapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -24,9 +23,16 @@ public class UserService extends ServiceImpl { return userList; } + public List fingByName(String name,Integer age){ + List userList = userMapper.selectByName(name,age); + return userList; + } + public Page page(){ Page page = userMapper.selectPage(new Page(1, 2), new QueryWrapper().eq("name","nelson")); return page; } + + } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 5c56288..774522d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -19,7 +19,8 @@ actable: database: type: mysql mybatis-plus: - mapper-locations: classpath*:com/gitee/sunchenbin/mybatis/actable/mapping/*/*.xml -# mapper-locations: classpath*:xxxxxx/*.xml,classpath*:com/gitee/sunchenbin/mybatis/actable/mapping/*/*.xml +# mapper-locations: classpath*:com/gitee/sunchenbin/mybatis/actable/mapping/*/*.xml + mapper-locations: classpath*:mapper/*.xml,classpath*:com/gitee/sunchenbin/mybatis/actable/mapping/*/*.xml + type-aliases-package: com.aiprose.mbp.entity configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl \ No newline at end of file diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml new file mode 100644 index 0000000..26c7047 --- /dev/null +++ b/src/main/resources/mapper/UserMapper.xml @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file