Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
custom-server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lizhonghong
custom-server
Commits
742e543a
Commit
742e543a
authored
May 29, 2026
by
daijie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改优化分页配置
parent
6d4961be
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
122 deletions
+46
-122
custom-server-core/src/main/java/com/jomalls/custom/page/PageRequest.java
+28
-52
custom-server-core/src/main/java/com/jomalls/custom/page/Pageable.java
+12
-0
custom-server-core/src/main/java/com/jomalls/custom/page/QueryCondition.java
+2
-46
custom-server-starter/src/main/java/com/jomalls/custom/config/MybatisPlusConfig.java
+4
-1
custom-server-starter/src/main/resources/application-dev.properties
+0
-23
No files found.
custom-server-core/src/main/java/com/jomalls/custom/page/PageRequest.java
View file @
742e543a
...
@@ -20,73 +20,48 @@ public class PageRequest implements Pageable, Serializable {
...
@@ -20,73 +20,48 @@ public class PageRequest implements Pageable, Serializable {
@Serial
@Serial
private
static
final
long
serialVersionUID
=
8280485938848398236L
;
private
static
final
long
serialVersionUID
=
8280485938848398236L
;
/**
* 默认当前页码
*/
private
static
final
long
DEFAULT_CURRENT
=
1L
;
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
);
}
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
()
{
private
long
current
;
return
current
>
0
?
current
:
DEFAULT_CURRENT
;
}
/**
/**
*
获取每页大小,默认值为 10
*
分页大小
*/
*/
public
long
getSize
()
{
private
long
size
;
return
size
>
0
?
size
:
DEFAULT_SIZE
;
}
public
boolean
equals
(
Object
o
)
{
/**
if
(
o
==
this
)
{
* 是否需要统计总条数
return
true
;
*/
}
else
if
(!(
o
instanceof
PageRequest
))
{
private
boolean
searchCount
;
return
false
;
}
PageRequest
other
=
(
PageRequest
)
o
;
public
PageRequest
()
{
if
(!
other
.
canEqual
(
this
))
{
this
(
DEFAULT_CURRENT
,
DEFAULT_SIZE
);
return
false
;
}
if
(
this
.
getCurrent
()
!=
other
.
getCurrent
())
{
return
false
;
}
if
(
this
.
getSize
()
!=
other
.
getSize
())
{
return
false
;
}
return
this
.
isSearchCount
()
==
other
.
isSearchCount
();
}
}
protected
boolean
canEqual
(
Object
other
)
{
public
PageRequest
(
long
current
,
long
size
)
{
return
(
other
instanceof
PageRequest
);
this
.
current
=
current
;
this
.
size
=
size
;
searchCount
=
true
;
}
}
public
int
hashCode
()
{
@Override
final
int
PRIME
=
59
;
public
long
getCurrent
()
{
int
result
=
1
;
return
current
;
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
;
}
}
public
String
toString
()
{
@Override
return
"PageRequest(current="
+
this
.
getCurrent
()
+
", size="
+
this
.
getSize
()
+
", isSearchCount="
+
this
.
isSearchCount
()
+
")"
;
public
boolean
isSearchCount
()
{
return
searchCount
;
}
}
}
}
\ No newline at end of file
custom-server-core/src/main/java/com/jomalls/custom/page/Pageable.java
View file @
742e543a
...
@@ -7,9 +7,21 @@ package com.jomalls.custom.page;
...
@@ -7,9 +7,21 @@ package com.jomalls.custom.page;
* @Version: 1.0
* @Version: 1.0
*/
*/
public
interface
Pageable
{
public
interface
Pageable
{
/**
* 返回分页大小
* @return 分页大小
*/
long
getSize
();
long
getSize
();
/**
* 返回当前页码
* @return 当前页码
*/
long
getCurrent
();
long
getCurrent
();
/**
* 是否需要汇总
* @return true or false
*/
boolean
isSearchCount
();
boolean
isSearchCount
();
}
}
custom-server-core/src/main/java/com/jomalls/custom/page/QueryCondition.java
View file @
742e543a
package
com
.
jomalls
.
custom
.
page
;
package
com
.
jomalls
.
custom
.
page
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
java.io.Serial
;
import
java.io.Serial
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -11,6 +12,7 @@ import java.util.Map;
...
@@ -11,6 +12,7 @@ import java.util.Map;
* @Description:
* @Description:
* @Version: 1.0
* @Version: 1.0
*/
*/
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
@Data
public
class
QueryCondition
extends
PageRequest
{
public
class
QueryCondition
extends
PageRequest
{
@Serial
@Serial
...
@@ -19,50 +21,4 @@ public class QueryCondition extends PageRequest {
...
@@ -19,50 +21,4 @@ public class QueryCondition extends PageRequest {
* 查询条件
* 查询条件
*/
*/
private
Map
<
String
,
Object
>
condition
;
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
()
+
")"
;
}
}
}
custom-server-starter/src/main/java/com/jomalls/custom/config/MybatisPlusConfig.java
View file @
742e543a
...
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
...
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.core.config.GlobalConfig
;
import
com.baomidou.mybatisplus.core.config.GlobalConfig
;
import
com.baomidou.mybatisplus.core.injector.DefaultSqlInjector
;
import
com.baomidou.mybatisplus.core.injector.DefaultSqlInjector
;
import
org.apache.ibatis.plugin.Interceptor
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.mybatis.spring.annotation.MapperScan
;
...
@@ -31,7 +32,7 @@ public class MybatisPlusConfig {
...
@@ -31,7 +32,7 @@ public class MybatisPlusConfig {
@Bean
(
name
=
"sqlSessionFactory"
)
@Bean
(
name
=
"sqlSessionFactory"
)
@Primary
@Primary
public
SqlSessionFactory
sqlSessionFactory
(
DataSource
dataSource
)
throws
Exception
{
public
SqlSessionFactory
sqlSessionFactory
(
DataSource
dataSource
,
MybatisPlusInterceptor
mybatisPlusInterceptor
)
throws
Exception
{
MybatisSqlSessionFactoryBean
factory
=
new
MybatisSqlSessionFactoryBean
();
MybatisSqlSessionFactoryBean
factory
=
new
MybatisSqlSessionFactoryBean
();
factory
.
setDataSource
(
dataSource
);
factory
.
setDataSource
(
dataSource
);
...
@@ -42,6 +43,8 @@ public class MybatisPlusConfig {
...
@@ -42,6 +43,8 @@ public class MybatisPlusConfig {
globalConfig
.
setSqlInjector
(
new
DefaultSqlInjector
());
globalConfig
.
setSqlInjector
(
new
DefaultSqlInjector
());
factory
.
setGlobalConfig
(
globalConfig
);
factory
.
setGlobalConfig
(
globalConfig
);
factory
.
setPlugins
(
new
Interceptor
[]{
mybatisPlusInterceptor
});
Resource
[]
resources
=
new
PathMatchingResourcePatternResolver
()
Resource
[]
resources
=
new
PathMatchingResourcePatternResolver
()
.
getResources
(
"classpath*:mapper/**/*.xml"
);
.
getResources
(
"classpath*:mapper/**/*.xml"
);
factory
.
setMapperLocations
(
resources
);
factory
.
setMapperLocations
(
resources
);
...
...
custom-server-starter/src/main/resources/application-dev.properties
deleted
100644 → 0
View file @
6d4961be
## 数据库连接配置
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment