Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
wangxiaolu-sfa-common-core
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
sfa
wangxiaolu-sfa-common-core
Commits
8aba91c0
提交
8aba91c0
authored
11月 08, 2024
作者:
李秋林
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改时间管理;分页管理
上级
15543a7e
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
72 行增加
和
20 行删除
+72
-20
pom.xml
pom.xml
+5
-0
DateUtils.java
src/main/java/com/sfa/common/core/utils/DateUtils.java
+25
-0
BaseController.java
...va/com/sfa/common/core/web/controller/BaseController.java
+8
-8
PageInfo.java
src/main/java/com/sfa/common/core/web/domain/PageInfo.java
+17
-6
TableSupport.java
src/main/java/com/sfa/common/core/web/page/TableSupport.java
+17
-6
没有找到文件。
pom.xml
浏览文件 @
8aba91c0
...
...
@@ -119,6 +119,11 @@
<artifactId>
mybatis-plus-core
</artifactId>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-extension
</artifactId>
</dependency>
</dependencies>
</project>
src/main/java/com/sfa/common/core/utils/DateUtils.java
浏览文件 @
8aba91c0
...
...
@@ -8,6 +8,7 @@ import java.time.LocalDateTime;
import
java.time.LocalTime
;
import
java.time.ZoneId
;
import
java.time.ZonedDateTime
;
import
java.util.Calendar
;
import
java.util.Date
;
import
org.apache.commons.lang3.time.DateFormatUtils
;
...
...
@@ -18,6 +19,7 @@ import org.apache.commons.lang3.time.DateFormatUtils;
*/
public
class
DateUtils
extends
org
.
apache
.
commons
.
lang3
.
time
.
DateUtils
{
public
static
String
HH_MM_SS_0
=
"yyyy-MM-dd 00:00:00"
;
public
static
String
YYYY
=
"yyyy"
;
public
static
String
YYYY_MM
=
"yyyy-MM"
;
...
...
@@ -180,4 +182,27 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
ZonedDateTime
zdt
=
localDateTime
.
atZone
(
ZoneId
.
systemDefault
());
return
Date
.
from
(
zdt
.
toInstant
());
}
/**
* 获取今天开始时间00:00:00
* @return
*/
public
static
Date
dateStart
(
Date
date
){
Calendar
start
=
Calendar
.
getInstance
();
start
.
setTime
(
date
);
start
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
start
.
set
(
Calendar
.
MINUTE
,
0
);
start
.
set
(
Calendar
.
SECOND
,
0
);
start
.
set
(
Calendar
.
MILLISECOND
,
0
);
return
start
.
getTime
();
}
/**
* 获取今天增加天数后的结束时间23:59:59
* @return
*/
public
static
Date
dateStart
(
int
day
){
Date
date
=
dateStart
(
new
Date
());
return
DateUtils
.
addMilliseconds
(
DateUtils
.
addDays
(
date
,
day
),-
1000
);
}
}
src/main/java/com/sfa/common/core/web/controller/BaseController.java
浏览文件 @
8aba91c0
package
com
.
sfa
.
common
.
core
.
web
.
controller
;
import
java.beans.PropertyEditorSupport
;
import
java.util.Date
;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.bind.WebDataBinder
;
import
org.springframework.web.bind.annotation.InitBinder
;
import
com.github.pagehelper.PageInfo
;
import
com.sfa.common.core.constant.HttpStatus
;
import
com.sfa.common.core.utils.DateUtils
;
import
com.sfa.common.core.utils.PageUtils
;
import
com.sfa.common.core.web.domain.AjaxResult
;
import
com.sfa.common.core.web.page.TableDataInfo
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.bind.WebDataBinder
;
import
org.springframework.web.bind.annotation.InitBinder
;
import
java.beans.PropertyEditorSupport
;
import
java.util.Date
;
import
java.util.List
;
/**
* web层通用数据处理
...
...
src/main/java/com/sfa/common/core/web/domain/PageInfo.java
浏览文件 @
8aba91c0
...
...
@@ -22,12 +22,12 @@ public class PageInfo<T> implements Serializable {
/**
* 当前页数,第1页开始
*/
private
int
pageNum
=
1
;
private
int
pageNum
;
/**
* 每页条数
*/
private
int
pageSize
=
1
;
private
int
pageSize
;
/**
* 总条数
...
...
@@ -41,10 +41,9 @@ public class PageInfo<T> implements Serializable {
private
List
<
T
>
rows
;
private
Map
<
String
,
Object
>
queryParams
;
private
Map
<
String
,
Object
>
queryParams
;
/**
*
* current:当前页数,必须大于等于 1,默认值为 1。
* size:每页条数,默认值为 10。
* total:总条数,默认值为 0。
...
...
@@ -55,6 +54,7 @@ public class PageInfo<T> implements Serializable {
* hitCount:是否对 count 进行 limit 优化,默认值为 false。
* countId:count 查询的列名,默认为 null,表示所有列。
* maxLimit:设置最大的 limit 查询限制,默认值为 -1,表示不限制。
*
* @param iPage 查询出的分页对象
* @param t 需要转换的对象(用于返回前端,不能直接返回DO)
* @param <P> 分页对象中的类型
...
...
@@ -83,12 +83,20 @@ public class PageInfo<T> implements Serializable {
}
}
public
<
P
>
void
pageCovert
(
IPage
<
P
>
iPage
)
{
/**
* 当前方法直接返回DO数据,在Service层无需再次处理DO数据时使用
* @param iPage DB中的DO数据
* PS:如需在Service层对DO数据二次处理时,请使用IPage<P> iPage, Class<T> t,返回DTO数据,将DO数据与业务隔离
*/
public
PageInfo
(
IPage
<
T
>
iPage
)
{
this
.
pageNum
=
(
int
)
iPage
.
getCurrent
();
this
.
pageSize
=
(
int
)
iPage
.
getSize
();
this
.
total
=
(
int
)
iPage
.
getTotal
();
this
.
totalPage
=
(
int
)
iPage
.
getPages
();
this
.
rows
=
iPage
.
getRecords
();
}
public
int
getSkipNum
(){
public
int
getSkipNum
()
{
return
this
.
pageSize
*
(
this
.
pageNum
-
1
);
}
...
...
@@ -139,4 +147,7 @@ public class PageInfo<T> implements Serializable {
public
void
setTotal
(
int
total
)
{
this
.
total
=
total
;
}
public
PageInfo
()
{
}
}
src/main/java/com/sfa/common/core/web/page/TableSupport.java
浏览文件 @
8aba91c0
package
com
.
sfa
.
common
.
core
.
web
.
page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.sfa.common.core.text.Convert
;
import
com.sfa.common.core.utils.ServletUtils
;
import
com.sfa.common.core.web.domain.PageInfo
;
/**
* 表格数据处理
*
* @author ruoyi
*/
public
class
TableSupport
{
public
class
TableSupport
{
/**
* 当前记录起始索引
*/
...
...
@@ -38,8 +39,7 @@ public class TableSupport
/**
* 封装分页对象
*/
public
static
PageDomain
getPageDomain
()
{
public
static
PageDomain
getPageDomain
()
{
PageDomain
pageDomain
=
new
PageDomain
();
pageDomain
.
setPageNum
(
Convert
.
toInt
(
ServletUtils
.
getParameter
(
PAGE_NUM
),
1
));
pageDomain
.
setPageSize
(
Convert
.
toInt
(
ServletUtils
.
getParameter
(
PAGE_SIZE
),
10
));
...
...
@@ -49,8 +49,19 @@ public class TableSupport
return
pageDomain
;
}
public
static
PageDomain
buildPageRequest
()
{
public
static
PageDomain
buildPageRequest
()
{
return
getPageDomain
();
}
public
static
<
T
>
Page
<
T
>
pageI
()
{
Page
<
T
>
page
=
new
Page
<
T
>(
Convert
.
toInt
(
ServletUtils
.
getParameter
(
PAGE_NUM
),
1
),
Convert
.
toInt
(
ServletUtils
.
getParameter
(
PAGE_SIZE
),
10
));
return
page
;
}
public
static
<
T
>
PageInfo
<
T
>
pageInfo
()
{
PageInfo
<
T
>
pageInfo
=
new
PageInfo
<>();
pageInfo
.
setPageNum
(
Convert
.
toInt
(
ServletUtils
.
getParameter
(
PAGE_NUM
),
1
));
pageInfo
.
setPageSize
(
Convert
.
toInt
(
ServletUtils
.
getParameter
(
PAGE_SIZE
),
10
));
return
pageInfo
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论