Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haoban3.0
haoban-manage3.0
Commits
587f2eeb
Commit
587f2eeb
authored
Feb 18, 2020
by
huangZW
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
溢出门店做不了分页查询,顶多手动做个分页
parent
8320d564
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
2 deletions
+82
-2
DepartmentContoller.java
...gic/haoban/manage/web/controller/DepartmentContoller.java
+31
-2
ListUtils.java
.../main/java/com/gic/haoban/manage/web/utils/ListUtils.java
+51
-0
No files found.
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/DepartmentContoller.java
View file @
587f2eeb
...
@@ -21,6 +21,7 @@ import com.gic.haoban.manage.api.service.DepartmentApiService;
...
@@ -21,6 +21,7 @@ import com.gic.haoban.manage.api.service.DepartmentApiService;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.haoban.manage.web.qo.DepartmentAddQO
;
import
com.gic.haoban.manage.web.qo.DepartmentAddQO
;
import
com.gic.haoban.manage.web.qo.DepartmentEditQO
;
import
com.gic.haoban.manage.web.qo.DepartmentEditQO
;
import
com.gic.haoban.manage.web.utils.ListUtils
;
import
com.gic.haoban.manage.web.vo.LoginVO
;
import
com.gic.haoban.manage.web.vo.LoginVO
;
@RestController
@RestController
...
@@ -316,6 +317,34 @@ public class DepartmentContoller extends WebBaseController{
...
@@ -316,6 +317,34 @@ public class DepartmentContoller extends WebBaseController{
}
}
}
}
//溢出门店列表
@RequestMapping
(
"store-full-list"
)
public
HaobanResponse
storeFullList
(
BasePageInfo
basePageInfo
)
{
LoginVO
login
=
(
LoginVO
)
AuthRequestUtil
.
getSessionUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
int
pageNum
=
basePageInfo
.
getPageNum
();
int
pageSize
=
basePageInfo
.
getPageSize
();
Page
<
DepartmentDTO
>
page
=
new
Page
<>(
pageNum
,
pageSize
,
0
);
//TODO 获取版本容量
int
maxSize
=
0
;
List
<
DepartmentDTO
>
list
=
departmentApiService
.
listStoreByWxEnterpriseId
(
wxEnterpriseId
);
if
(
list
==
null
||
list
.
size
()==
0
){
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
new
Page
<>());
}
page
.
setTotalCount
(
list
.
size
());
if
(
maxSize
!=
0
){
if
(
list
.
size
()
<=
maxSize
){
//小于版本容量(无溢出门店)
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
new
Page
<>());
}
else
{
//大于版本容量(有溢出门店)
list
=
list
.
subList
(
maxSize
,
list
.
size
()-
1
);
}
}
List
resultList
=
ListUtils
.
Pager
(
pageSize
,
pageNum
,
list
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
resultList
);
}
}
}
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/utils/ListUtils.java
0 → 100644
View file @
587f2eeb
package
com
.
gic
.
haoban
.
manage
.
web
.
utils
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* list集合工具类
*/
public
class
ListUtils
{
/**
*
* @param pageSize 当前页面大小
* @param pageIndex 当前页码
* @param list 需要分页的集合
* @return
*/
public
static
List
Pager
(
int
pageSize
,
int
pageIndex
,
List
list
){
//使用list 中的sublist方法分页
List
resultList
=
new
ArrayList
<>();
// 每页显示多少条记录
int
currentPage
;
//当前第几页数据
int
totalRecord
=
list
.
size
();
// 一共多少条记录
int
totalPage
=
totalRecord
%
pageSize
;
// 一共多少页
if
(
totalPage
>
0
)
{
totalPage
=
totalRecord
/
pageSize
+
1
;
}
else
{
totalPage
=
totalRecord
/
pageSize
;
}
System
.
out
.
println
(
"总页数:"
+
totalPage
);
// 当前第几页数据
currentPage
=
totalPage
<
pageIndex
?
totalPage
:
pageIndex
;
// 起始索引
int
fromIndex
=
pageSize
*
(
currentPage
-
1
);
// 结束索引
int
toIndex
=
pageSize
*
currentPage
>
totalRecord
?
totalRecord
:
pageSize
*
currentPage
;
try
{
resultList
=
list
.
subList
(
fromIndex
,
toIndex
);
}
catch
(
IndexOutOfBoundsException
e
){
e
.
printStackTrace
();
}
return
resultList
;
}
}
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