Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nouiWithSpringMVC
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
gechengyang
nouiWithSpringMVC
Commits
3ca1d187
Commit
3ca1d187
authored
Aug 09, 2022
by
WeiCong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化简单分页查询请求
优化分页查询响应返回页号处理:由noui层记录和返回页号
parent
a1e20ac0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
28 deletions
+59
-28
Alias.java
src/main/java/org/sss/presentation/noui/api/model/Alias.java
+2
-6
AbstractCache.java
...n/java/org/sss/presentation/noui/cache/AbstractCache.java
+32
-5
AbstractCommonController.java
...resentation/noui/controller/AbstractCommonController.java
+9
-3
NoUiPresentationUtil.java
.../org/sss/presentation/noui/util/NoUiPresentationUtil.java
+16
-14
No files found.
src/main/java/org/sss/presentation/noui/api/model/Alias.java
View file @
3ca1d187
...
...
@@ -80,12 +80,8 @@ public class Alias {
this
.
revertRel
=
revertRel
;
}
public
String
getPrimaryLstPth
()
{
if
(
lstPths
.
isEmpty
())
{
return
null
;
}
else
{
return
lstPths
.
get
(
0
);
}
public
List
<
String
>
getLstPth
()
{
return
lstPths
;
}
public
boolean
isSingleLst
()
{
...
...
src/main/java/org/sss/presentation/noui/cache/AbstractCache.java
View file @
3ca1d187
...
...
@@ -12,6 +12,7 @@ import org.sss.presentation.noui.api.exception.NoUiException;
import
org.sss.presentation.noui.common.Constants
;
import
java.sql.SQLException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -139,18 +140,44 @@ public abstract class AbstractCache implements CacheController {
@Override
public
void
prepareReadset
(
IModuleList
moduleList
)
{
Map
<
String
,
Map
<
String
,
Integer
>>
paginationCache
=
(
Map
<
String
,
Map
<
String
,
Integer
>>)
paginationMap
.
get
();
if
(
paginationCache
==
null
)
if
(
paginationCache
==
null
||
paginationCache
.
isEmpty
()){
return
;
Map
<
String
,
Integer
>
paginationItem
=
paginationCache
.
remove
(
moduleList
.
getUrl
());
if
(
paginationCache
.
size
()
==
0
)
paginationMap
.
remove
();
if
(
paginationItem
==
null
)
}
Map
<
String
,
Integer
>
paginationItem
=
paginationCache
.
get
(
moduleList
.
getUrl
());
if
(
paginationItem
==
null
||
paginationItem
.
isEmpty
()){
return
;
}
moduleList
.
setPageSize
(
paginationItem
.
get
(
Constants
.
PAGINATION_PAGESIZE
));
moduleList
.
setPage
(
paginationItem
.
get
(
Constants
.
PAGINATION_INDEX
));
}
protected
abstract
Object
doCacheRead
(
String
key
);
protected
abstract
void
doCacheWrite
(
String
key
,
Object
lst
,
long
keepAlive
);
public
static
Map
<
String
,
Object
>
getPageInfo
(
IModuleList
moduleList
)
{
Map
<
String
,
Map
<
String
,
Integer
>>
paginationCache
=
(
Map
<
String
,
Map
<
String
,
Integer
>>)
paginationMap
.
get
();
if
(
paginationCache
==
null
||
paginationCache
.
isEmpty
()){
return
null
;
}
Map
<
String
,
Integer
>
paginationItem
=
paginationCache
.
remove
(
moduleList
.
getUrl
());
if
(
paginationCache
.
size
()
==
0
){
paginationMap
.
remove
();
}
if
(
paginationItem
==
null
||
paginationItem
.
isEmpty
()){
return
null
;
}
Map
<
String
,
Object
>
paginationInfo
=
new
HashMap
<>();
int
total
=
moduleList
.
fullSize
();
int
index
=
paginationItem
.
get
(
Constants
.
PAGINATION_INDEX
);
int
pageSize
=
paginationItem
.
get
(
Constants
.
PAGINATION_PAGESIZE
);
if
(
total
<
pageSize
*
index
)
{
index
=
(
total
%
pageSize
!=
0
)
?
(
total
/
pageSize
+
1
)
:
total
/
pageSize
;
}
paginationInfo
.
put
(
Constants
.
PAGINATION_TOTAL
,
total
);
paginationInfo
.
put
(
Constants
.
PAGINATION_INDEX
,
index
);
return
paginationInfo
;
}
}
src/main/java/org/sss/presentation/noui/controller/AbstractCommonController.java
View file @
3ca1d187
...
...
@@ -19,6 +19,7 @@ import org.sss.presentation.noui.api.response.ErrorCodes;
import
org.sss.presentation.noui.api.response.NoUiVersion
;
import
org.sss.presentation.noui.api.response.Result
;
import
org.sss.presentation.noui.api.response.ResultUtil
;
import
org.sss.presentation.noui.cache.AbstractCache
;
import
org.sss.presentation.noui.common.Constants
;
import
org.sss.presentation.noui.context.NoUiContext
;
import
org.sss.presentation.noui.context.NoUiContextManager
;
...
...
@@ -223,8 +224,9 @@ public abstract class AbstractCommonController {
String
aliasActionUrl
=
alias
.
getAliasActionUrl
();
String
actionUrl
=
alias
.
getRel
().
get
(
aliasActionUrl
);
IBaseObject
baseObject
=
context
.
getSession
().
getBaseObject
(
context
.
getRoot
(),
actionUrl
);
if
(
null
==
baseObject
)
if
(
null
==
baseObject
)
{
throw
new
NoUiException
(
"onClickUrl :"
+
actionUrl
+
" is not exsit"
);
}
return
baseObject
;
}
...
...
@@ -234,12 +236,16 @@ public abstract class AbstractCommonController {
item
.
put
(
Constants
.
DATA
,
lst
);
if
(
noUiRequest
.
isSelByPagination
())
{
//分页信息
int
total
=
moduleList
.
fullSize
();
/*
int total = moduleList.fullSize();
int index = moduleList.getPage();
Map<String, Object> pagination = new HashMap<>();
pagination.put(Constants.PAGINATION_TOTAL, total);
pagination.put(Constants.PAGINATION_INDEX, index);
item
.
put
(
Constants
.
PAGINATION
,
pagination
);
item.put(Constants.PAGINATION, pagination);*/
Map
<
String
,
Object
>
paginationInfo
=
AbstractCache
.
getPageInfo
(
moduleList
);
if
(
paginationInfo
!=
null
){
item
.
put
(
Constants
.
PAGINATION
,
paginationInfo
);
}
}
if
(
alias
.
isSingleLst
())
{
dataMap
.
put
(
Constants
.
SIGNLE_LST
,
item
);
...
...
src/main/java/org/sss/presentation/noui/util/NoUiPresentationUtil.java
View file @
3ca1d187
...
...
@@ -4,7 +4,6 @@ import log.Log;
import
log.LogFactory
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.util.Assert
;
import
org.sss.common.impl.StreamImpl
;
import
org.sss.common.model.*
;
import
org.sss.module.pojo.AbstractPOJOModuleSession
;
...
...
@@ -76,20 +75,23 @@ public class NoUiPresentationUtil {
//处理分页信息
Map
<
String
,
?>
paginationMap
=
request
.
getPaginationMap
();
if
(
paginationMap
.
containsKey
(
Constants
.
PAGINATION_INDEX
)
&&
paginationMap
.
containsKey
(
Constants
.
PAGINATION_PAGESIZE
))
{
String
primaryLstPth
=
alias
.
getPrimaryLstPth
();
Assert
.
hasText
(
primaryLstPth
,
alias
.
getAliasActionUrl
()
+
"请求的list模型路径未知"
);
IBaseObject
baseObject
=
context
.
getSession
().
getBaseObject
(
context
.
getRoot
(),
primaryLstPth
);
if
(
null
==
baseObject
)
{
throw
new
NoUiException
(
"not found url :"
+
primaryLstPth
);
}
if
(!(
baseObject
instanceof
IModuleList
))
{
throw
new
NoUiException
(
primaryLstPth
+
" is not a moduleList"
);
String
index
=
paginationMap
.
get
(
Constants
.
PAGINATION_INDEX
)
+
""
;
String
pageSize
=
paginationMap
.
get
(
Constants
.
PAGINATION_PAGESIZE
)
+
""
;
List
<
String
>
lstPth
=
alias
.
getLstPth
();
for
(
String
primaryLstPth
:
lstPth
)
{
IBaseObject
baseObject
=
context
.
getSession
().
getBaseObject
(
context
.
getRoot
(),
primaryLstPth
);
if
(
null
==
baseObject
)
{
throw
new
NoUiException
(
"not found url :"
+
primaryLstPth
);
}
if
(!(
baseObject
instanceof
IModuleList
))
{
throw
new
NoUiException
(
primaryLstPth
+
" is not a moduleList"
);
}
IModuleList
moduleList
=
(
IModuleList
)
baseObject
;
HashMap
<
String
,
Integer
>
tmp
=
new
HashMap
<
String
,
Integer
>();
tmp
.
put
(
Constants
.
PAGINATION_INDEX
,
Integer
.
parseInt
(
index
));
tmp
.
put
(
Constants
.
PAGINATION_PAGESIZE
,
Integer
.
parseInt
(
pageSize
));
putPaginationCache
(
tmp
,
moduleList
);
}
IModuleList
moduleList
=
(
IModuleList
)
baseObject
;
HashMap
<
String
,
Integer
>
tmp
=
new
HashMap
<
String
,
Integer
>();
tmp
.
put
(
Constants
.
PAGINATION_INDEX
,
Integer
.
parseInt
(
paginationMap
.
get
(
Constants
.
PAGINATION_INDEX
)
+
""
));
tmp
.
put
(
Constants
.
PAGINATION_PAGESIZE
,
Integer
.
parseInt
(
paginationMap
.
get
(
Constants
.
PAGINATION_PAGESIZE
)
+
""
));
putPaginationCache
(
tmp
,
moduleList
);
}
else
{
for
(
String
aliasKey
:
paginationMap
.
keySet
())
{
String
url
=
alias
.
getRelPath
(
aliasKey
);
...
...
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