mail_yanpeng@163.com пре 4 година
родитељ
комит
8ed4b88b10
  1. 5
      src/main/java/com/aiprose/mbp/controller/UserController.java
  2. 2
      src/main/java/com/aiprose/mbp/mapper/UserMapper.java
  3. 8
      src/main/java/com/aiprose/mbp/service/UserService.java
  4. 5
      src/main/resources/application.yml
  5. 11
      src/main/resources/mapper/UserMapper.xml

5
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<User> save(String name) {
return userService.fingByName(name,11);
}
@GetMapping("list")
public List<User> user() {
return userService.list();

2
src/main/java/com/aiprose/mbp/mapper/UserMapper.java

@ -12,4 +12,6 @@ public interface UserMapper extends BaseMapper<User> {
@Select("select * from mbp_user")
public List<User> queryList();
public List<User> selectByName(String name,Integer age);
}

8
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<UserMapper,User> {
return userList;
}
public List<User> fingByName(String name,Integer age){
List<User> userList = userMapper.selectByName(name,age);
return userList;
}
public Page<User> page(){
Page<User> page = userMapper.selectPage(new Page<User>(1, 2), new QueryWrapper<User>().eq("name","nelson"));
return page;
}
}

5
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

11
src/main/resources/mapper/UserMapper.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.aiprose.mbp.mapper.UserMapper">
<select id="selectByName" resultType="com.aiprose.mbp.entity.User">
select * from mbp_user where name = #{name} and age = #{age}
</select>
</mapper>
Loading…
Откажи
Сачувај