Commit 742e543a by daijie

修改优化分页配置

parent 6d4961be
......@@ -19,74 +19,49 @@ import java.util.List;
public class PageRequest implements Pageable, Serializable {
@Serial
private static final long serialVersionUID = 8280485938848398236L;
private static final long DEFAULT_CURRENT = 1L;
private static final long DEFAULT_SIZE = 50L;
private long current;
private long size;
private boolean isSearchCount;
public PageRequest() {
this(DEFAULT_CURRENT, DEFAULT_SIZE);
}
/**
* 默认当前页码
*/
private static final long DEFAULT_CURRENT = 1L;
public PageRequest(long current, long size) {
this.current = current > 0 ? current : DEFAULT_CURRENT;
this.size = size > 0 ? size : DEFAULT_SIZE;
this.isSearchCount = true;
}
/**
* 默认分页大小
*/
private static final long DEFAULT_SIZE = 10L;
/**
* 获取当前页码,默认值为 1
* 当前页码
*/
public long getCurrent() {
return current > 0 ? current : DEFAULT_CURRENT;
}
private long current;
/**
* 获取每页大小,默认值为 10
* 分页大小
*/
public long getSize() {
return size > 0 ? size : DEFAULT_SIZE;
}
private long size;
public boolean equals(Object o) {
if (o == this) {
return true;
} else if (!(o instanceof PageRequest)) {
return false;
}
/**
* 是否需要统计总条数
*/
private boolean searchCount;
PageRequest other = (PageRequest) o;
if (!other.canEqual(this)) {
return false;
}
if (this.getCurrent() != other.getCurrent()) {
return false;
}
if (this.getSize() != other.getSize()) {
return false;
}
return this.isSearchCount() == other.isSearchCount();
public PageRequest() {
this(DEFAULT_CURRENT, DEFAULT_SIZE);
}
protected boolean canEqual(Object other) {
return (other instanceof PageRequest);
public PageRequest(long current, long size) {
this.current = current;
this.size = size;
searchCount = true;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
long current = this.getCurrent();
result = result * PRIME + Long.hashCode(current);
long size = this.getSize();
result = result * PRIME + Long.hashCode(size);
result = result * PRIME + Boolean.hashCode(this.isSearchCount());
return result;
@Override
public long getCurrent() {
return current;
}
public String toString() {
return "PageRequest(current=" + this.getCurrent() + ", size=" + this.getSize() + ", isSearchCount=" + this.isSearchCount() + ")";
@Override
public boolean isSearchCount() {
return searchCount;
}
}
\ No newline at end of file
......@@ -7,9 +7,21 @@ package com.jomalls.custom.page;
* @Version: 1.0
*/
public interface Pageable {
/**
* 返回分页大小
* @return 分页大小
*/
long getSize();
/**
* 返回当前页码
* @return 当前页码
*/
long getCurrent();
/**
* 是否需要汇总
* @return true or false
*/
boolean isSearchCount();
}
package com.jomalls.custom.page;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.util.Map;
......@@ -11,6 +12,7 @@ import java.util.Map;
* @Description:
* @Version: 1.0
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class QueryCondition extends PageRequest {
@Serial
......@@ -19,50 +21,4 @@ public class QueryCondition extends PageRequest {
* 查询条件
*/
private Map<String, Object> condition;
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof QueryCondition)) {
return false;
}
QueryCondition other = (QueryCondition)o;
if (other.canEqual(this)) {
return false;
}
if (!super.equals(o)) {
return false;
}
Object thisCondition = this.getCondition();
Object otherCondition = other.getCondition();
if (thisCondition == null) {
if (otherCondition != null) {
return false;
}
}
if (thisCondition != null) {
return thisCondition.equals(otherCondition);
}
return true;
}
protected boolean canEqual(Object other) {
return !(other instanceof QueryCondition);
}
public int hashCode() {
int PRIME = 59;
int result = super.hashCode();
Object $condition = this.getCondition();
result = result * PRIME + ($condition == null ? 43 : $condition.hashCode());
return result;
}
public QueryCondition() {
}
public String toString() {
return "QueryCondition(condition=" + this.getCondition() + ")";
}
}
......@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.core.config.GlobalConfig;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
......@@ -31,7 +32,7 @@ public class MybatisPlusConfig {
@Bean(name = "sqlSessionFactory")
@Primary
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
public SqlSessionFactory sqlSessionFactory(DataSource dataSource, MybatisPlusInterceptor mybatisPlusInterceptor) throws Exception {
MybatisSqlSessionFactoryBean factory = new MybatisSqlSessionFactoryBean();
factory.setDataSource(dataSource);
......@@ -42,6 +43,8 @@ public class MybatisPlusConfig {
globalConfig.setSqlInjector(new DefaultSqlInjector());
factory.setGlobalConfig(globalConfig);
factory.setPlugins(new Interceptor[]{mybatisPlusInterceptor});
Resource[] resources = new PathMatchingResourcePatternResolver()
.getResources("classpath*:mapper/**/*.xml");
factory.setMapperLocations(resources);
......
## 数据库连接配置
spring.datasource.url=jdbc:mysql://172.16.19.99:3306/foxpsd_lizh?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.username=root
spring.datasource.password=joshine
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
## Hikari连接池配置
#最小空闲连接数
spring.datasource.hikari.minimum-idle=5
#最大连接池大小
spring.datasource.hikari.maximum-pool-size=20
#连接超时时间(60秒)
spring.datasource.hikari.connection-timeout=60000
#空闲连接超时时间(600秒)
spring.datasource.hikari.idle-timeout=600000
#最大连接生命周期(900秒)
spring.datasource.hikari.max-lifetime=900000
#验证超时时间(3000秒)
spring.datasource.hikari.validation-timeout=3000
## MyBatis-Plus SQL日志(可选开启)
#mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment