diff --git a/pom.xml b/pom.xml
index 38e8f91eccb481c745d1c3757c22cf3e562f1be6..7442469c239198bad5388fb1451a142752150ea5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,6 @@
4.3.10.RELEASE
1.3.1
3.4.5
- 4.1.6
1.4
5.1.32
@@ -163,11 +162,6 @@
mysql-connector-java
${mysql-connector-java.version}
-
- com.github.pagehelper
- pagehelper
- ${pagehelper.version}
-
diff --git a/whatsmars-spring-boot/pom.xml b/whatsmars-spring-boot/pom.xml
index 6595852f1cb26921d8324fa8e3b9d247960f55fc..e44b6e18c0d37d77d689adb2d2b20f921e9d9a09 100644
--- a/whatsmars-spring-boot/pom.xml
+++ b/whatsmars-spring-boot/pom.xml
@@ -70,7 +70,8 @@
com.github.pagehelper
- pagehelper
+ pagehelper-spring-boot-starter
+ 1.2.3
diff --git a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/config/MybatisConfig.java b/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/config/MybatisConfig.java
deleted file mode 100644
index 6cdf3118d559f48d3c376236bb2690671a06aa0e..0000000000000000000000000000000000000000
--- a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/config/MybatisConfig.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.hongxi.whatsmars.spring.boot.config;
-
-import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.SqlUtilConfig;
-import org.apache.ibatis.plugin.Interceptor;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class MybatisConfig {
-
- @Bean
- public Interceptor pageHelper() {
- PageHelper pageHelper = new PageHelper();
- SqlUtilConfig sqlUtilConfig = new SqlUtilConfig();
- sqlUtilConfig.setDialect("mysql");
- sqlUtilConfig.setOffsetAsPageNum(true);
- sqlUtilConfig.setRowBoundsWithCount(true);
- sqlUtilConfig.setPageSizeZero(true);
- sqlUtilConfig.setReasonable(false);
- sqlUtilConfig.setSupportMethodsArguments(false);
- pageHelper.setSqlUtilConfig(sqlUtilConfig);
- return pageHelper;
- }
-}
diff --git a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/controller/NewController.java b/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/controller/NewController.java
index e9bf4bab48c4c2a68ee7d19b052bb4fb877ae12d..6d944bb6cd645db541af43829a07d768e261e422 100644
--- a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/controller/NewController.java
+++ b/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/controller/NewController.java
@@ -9,8 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
/**
* Created by shenhongxi on 2017/11/16.
@@ -71,4 +70,40 @@ public class NewController {
returnItems.setStatus(200);
return returnItems;
}
+
+ @GetMapping("/findByNicknameAndGender")
+ public ReturnItems findByNicknameAndGender(@RequestParam String nickname,
+ @RequestParam Integer gender) {
+ ReturnItems returnItems = new ReturnItems<>();
+ List users = userService.findByNicknameAndGender(nickname, gender);
+ returnItems.setItems(users);
+ returnItems.setTotal(users == null ? 0 : users.size());
+ returnItems.setStatus(200);
+ return returnItems;
+ }
+
+ @PostMapping("/addUsers")
+ public HttpStatus addUsers() {
+ List users = new ArrayList<>();
+ Date now = new Date();
+ long t = now.getTime();
+ User user = new User();
+ user.setUsername("tb" + t++);
+ user.setNickname("hongxi");
+ user.setGender(1);
+ user.setAge(28);
+ user.setCreateDate(now);
+ user.setUpdateDate(now);
+ users.add(user);
+ user = new User();
+ user.setUsername("tb" + t++);
+ user.setNickname("lilei");
+ user.setGender(1);
+ user.setAge(27);
+ user.setCreateDate(now);
+ user.setUpdateDate(now);
+ users.add(user);
+ userService.insertBatch(users);
+ return HttpStatus.OK;
+ }
}
diff --git a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/dao/UserMapper.java b/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/dao/UserMapper.java
index 0a9a6379312472bdffb13f949656081345473141..20274ca222f6ac7d8b9ac8f2050ea100d001a4d9 100644
--- a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/dao/UserMapper.java
+++ b/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/dao/UserMapper.java
@@ -1,5 +1,6 @@
package org.hongxi.whatsmars.spring.boot.dao;
+import org.apache.ibatis.annotations.Param;
import org.hongxi.whatsmars.spring.boot.model.User;
import org.apache.ibatis.annotations.Mapper;
@@ -24,4 +25,7 @@ public interface UserMapper {
void update(User user);
void delete(Long id);
+
+ List findByNicknameAndGender(@Param("nickname") String nickname, @Param("gender") Integer gender);
+
}
diff --git a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/service/UserService.java b/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/service/UserService.java
index 5c5f7c2350a30fed49be275ebbfa6dc0fcaba554..927966623da61b63ef15017fd3c0c3ff9be75db4 100644
--- a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/service/UserService.java
+++ b/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/service/UserService.java
@@ -24,4 +24,6 @@ public interface UserService {
void add(List users);
+ List findByNicknameAndGender(String nickname, Integer gender);
+
}
diff --git a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/service/impl/UserServiceImpl.java b/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/service/impl/UserServiceImpl.java
index 876233cd0c845bde2bcdec8fb9977e7afe1177b9..eff005f6fd738f853061c0e0bc795ab714220a24 100644
--- a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/service/impl/UserServiceImpl.java
+++ b/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/service/impl/UserServiceImpl.java
@@ -62,4 +62,9 @@ public class UserServiceImpl implements UserService {
userMapper.insert(user);
}
}
+
+ @Override
+ public List findByNicknameAndGender(String nickname, Integer gender) {
+ return userMapper.findByNicknameAndGender(nickname, gender);
+ }
}
diff --git a/whatsmars-spring-boot/src/main/resources/application.yml b/whatsmars-spring-boot/src/main/resources/application.yml
index 7a602ddc2e875fd07fe0b8af16d0e7a4dec66b85..2a4397875d123101ba6dc663ea4177966ae9c98a 100644
--- a/whatsmars-spring-boot/src/main/resources/application.yml
+++ b/whatsmars-spring-boot/src/main/resources/application.yml
@@ -31,6 +31,12 @@ user:
welcome: Hello, World!
noFilterUrl: /,/login
+logging.level.tk.mybatis.pagehelper.mapper: WARN
+pagehelper:
+ closeConn: true
+ offset-as-page-num: false
+ autoDialect: true
+
---
spring:
profiles: dev
diff --git a/whatsmars-spring-boot/src/main/resources/mapper/UserMapper.xml b/whatsmars-spring-boot/src/main/resources/mapper/UserMapper.xml
index 801265b48d6a4418e5e5c3771247568ea4b9689f..d75c88d731b9524d00384f3f45de3d654c327762 100644
--- a/whatsmars-spring-boot/src/main/resources/mapper/UserMapper.xml
+++ b/whatsmars-spring-boot/src/main/resources/mapper/UserMapper.xml
@@ -18,7 +18,7 @@
insert into user(username, nickname, gender, age, create_date, update_date) values
- (#{username}, #{nickname}, #{gender}, #{age}, #{createDate}, #{updateDate})
+ (#{item.username}, #{item.nickname}, #{item.gender}, #{item.age}, #{item.createDate}, #{item.updateDate})
@@ -38,4 +38,8 @@
delete from user where id = #{id}
+
+
\ No newline at end of file
diff --git a/whatsmars-spring-boot/src/main/resources/mybatis-config.xml b/whatsmars-spring-boot/src/main/resources/mybatis-config.xml
index 1d5e260be053965fc2f92aa50c33acf7bd74a916..730b36507de2d24c09462401505981a19421e510 100644
--- a/whatsmars-spring-boot/src/main/resources/mybatis-config.xml
+++ b/whatsmars-spring-boot/src/main/resources/mybatis-config.xml
@@ -30,37 +30,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-