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
69e4d0ae
Commit
69e4d0ae
authored
Jun 24, 2019
by
fukai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持无会话访问交易
parent
2f926f92
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
257 additions
and
44 deletions
+257
-44
NoUiRequest.java
...va/org/sss/presentation/noui/api/request/NoUiRequest.java
+9
-1
ErrorCodes.java
...va/org/sss/presentation/noui/api/response/ErrorCodes.java
+5
-0
NoUiContext.java
...n/java/org/sss/presentation/noui/context/NoUiContext.java
+11
-0
NoUiContextManager.java
...org/sss/presentation/noui/context/NoUiContextManager.java
+10
-2
NoUiPresentation.java
...a/org/sss/presentation/noui/context/NoUiPresentation.java
+33
-0
AbstractCommonController.java
...resentation/noui/controller/AbstractCommonController.java
+33
-36
LoginController.java
...org/sss/presentation/noui/controller/LoginController.java
+10
-0
OpenTransInterceptor.java
...a/org/sss/presentation/noui/jwt/OpenTransInterceptor.java
+90
-0
RedisLoginInfo.java
...in/java/org/sss/presentation/noui/jwt/RedisLoginInfo.java
+12
-0
NoUiApiInitListener.java
...g/sss/presentation/noui/listener/NoUiApiInitListener.java
+23
-0
NoUiPresentationUtil.java
.../org/sss/presentation/noui/util/NoUiPresentationUtil.java
+21
-5
No files found.
src/main/java/org/sss/presentation/noui/api/request/NoUiRequest.java
View file @
69e4d0ae
...
@@ -6,14 +6,15 @@ import java.util.Map;
...
@@ -6,14 +6,15 @@ import java.util.Map;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
org.sss.presentation.noui.common.Constants
;
import
org.sss.presentation.noui.common.Constants
;
import
org.sss.presentation.noui.context.NoUiContextManager
;
public
class
NoUiRequest
{
public
class
NoUiRequest
{
private
HttpServletRequest
httpRequest
;
private
HttpServletRequest
httpRequest
;
private
String
token
;
private
String
token
;
private
String
userId
;
private
String
userId
;
private
String
terminalType
;
// WEB APP
private
String
terminalType
;
// WEB APP
private
String
mappingUrl
;
private
String
mappingUrl
;
private
boolean
openSource
;
private
Map
<
String
,
?>
paramsMap
=
new
HashMap
<
String
,
Object
>();
private
Map
<
String
,
?>
paramsMap
=
new
HashMap
<
String
,
Object
>();
private
Map
<
String
,
?>
dataMap
=
new
HashMap
<
String
,
Object
>();
private
Map
<
String
,
?>
dataMap
=
new
HashMap
<
String
,
Object
>();
private
Map
<
String
,
?>
saveDisplayMap
=
new
HashMap
<
String
,
Object
>();
private
Map
<
String
,
?>
saveDisplayMap
=
new
HashMap
<
String
,
Object
>();
...
@@ -30,6 +31,10 @@ public class NoUiRequest {
...
@@ -30,6 +31,10 @@ public class NoUiRequest {
this
.
userId
=
userId
;
this
.
userId
=
userId
;
this
.
terminalType
=
terminalType
;
this
.
terminalType
=
terminalType
;
this
.
mappingUrl
=
mappingUrl
;
this
.
mappingUrl
=
mappingUrl
;
if
(
request
.
getRequestURI
().
startsWith
(
NoUiContextManager
.
openSourcePrefix
))
{
this
.
openSource
=
true
;
//开放访问路径
}
if
(
requestData
!=
null
)
{
if
(
requestData
!=
null
)
{
this
.
paramsMap
=
(
Map
<
String
,
?>)
requestData
.
get
(
Constants
.
PARAMS
);
this
.
paramsMap
=
(
Map
<
String
,
?>)
requestData
.
get
(
Constants
.
PARAMS
);
this
.
dataMap
=
(
Map
<
String
,
?>)
requestData
.
get
(
Constants
.
DATA
);
this
.
dataMap
=
(
Map
<
String
,
?>)
requestData
.
get
(
Constants
.
DATA
);
...
@@ -43,6 +48,9 @@ public class NoUiRequest {
...
@@ -43,6 +48,9 @@ public class NoUiRequest {
}
}
}
}
public
boolean
isOpenSource
(){
return
this
.
openSource
;
}
public
String
getUserId
()
{
public
String
getUserId
()
{
return
userId
;
return
userId
;
}
}
...
...
src/main/java/org/sss/presentation/noui/api/response/ErrorCodes.java
View file @
69e4d0ae
...
@@ -26,9 +26,14 @@ public class ErrorCodes {
...
@@ -26,9 +26,14 @@ public class ErrorCodes {
public
static
final
String
DISPLAY_ERROR
=
"R0014"
;
public
static
final
String
DISPLAY_ERROR
=
"R0014"
;
public
static
final
String
UNCORRECT_DATA_FORMAT
=
"R0015"
;
public
static
final
String
UNCORRECT_DATA_FORMAT
=
"R0015"
;
public
static
final
String
UNSUPPORTED_DATA_TYPE
=
"R0016"
;
public
static
final
String
UNSUPPORTED_DATA_TYPE
=
"R0016"
;
public
static
final
String
UNKNOEW_TRANS
=
"R0017"
;
public
static
final
String
FORBIDDEN_TRANS
=
"R0018"
;
public
static
final
String
INTERRUPTED_ERROR
=
"R9997"
;
public
static
final
String
INTERRUPTED_ERROR
=
"R9997"
;
public
static
final
String
REDIS_CONNECTION_ERROR
=
"R9998"
;
public
static
final
String
REDIS_CONNECTION_ERROR
=
"R9998"
;
public
static
final
String
ERROR
=
"R9999"
;
public
static
final
String
ERROR
=
"R9999"
;
public
static
final
String
BUSINESS_ERROR
=
"E0001"
;
public
static
final
String
BUSINESS_ERROR
=
"E0001"
;
}
}
src/main/java/org/sss/presentation/noui/context/NoUiContext.java
View file @
69e4d0ae
package
org
.
sss
.
presentation
.
noui
.
context
;
package
org
.
sss
.
presentation
.
noui
.
context
;
import
org.sss.common.impl.AbstractContext
;
import
org.sss.common.impl.AbstractContext
;
import
org.sss.presentation.noui.jwt.RedisLoginInfo
;
public
class
NoUiContext
extends
AbstractContext
{
public
class
NoUiContext
extends
AbstractContext
{
...
@@ -22,4 +23,14 @@ public class NoUiContext extends AbstractContext {
...
@@ -22,4 +23,14 @@ public class NoUiContext extends AbstractContext {
return
null
;
return
null
;
}
}
private
RedisLoginInfo
redisLoginInfo
;
public
RedisLoginInfo
getRedisLoginInfo
()
{
return
this
.
redisLoginInfo
;
}
public
void
setRedisLoginInfo
(
RedisLoginInfo
redisLoginInfo
)
{
this
.
redisLoginInfo
=
redisLoginInfo
;
}
}
}
src/main/java/org/sss/presentation/noui/context/NoUiContextManager.java
View file @
69e4d0ae
package
org
.
sss
.
presentation
.
noui
.
context
;
package
org
.
sss
.
presentation
.
noui
.
context
;
import
java.util.UUID
;
import
java.util.UUID
;
import
java.util.ArrayList
;
import
java.util.List
;
import
log.Log
;
import
log.Log
;
import
log.LogFactory
;
import
log.LogFactory
;
...
@@ -18,11 +19,18 @@ public class NoUiContextManager {
...
@@ -18,11 +19,18 @@ public class NoUiContextManager {
private
static
final
Log
log
=
LogFactory
.
getLog
(
NoUiContextManager
.
class
);
private
static
final
Log
log
=
LogFactory
.
getLog
(
NoUiContextManager
.
class
);
public
static
String
dbType
=
"hibernate"
;
public
static
String
dbType
=
"hibernate"
;
public
static
String
loginContextName
=
"cn.com.brilliance.eibs.auth.DatabaseLoginContext"
;
public
static
String
loginContextName
=
"cn.com.brilliance.eibs.auth.DatabaseLoginContext"
;
public
static
String
openSourcePrefix
=
"openservice"
;
public
static
String
everybody
=
"#Everybody#"
;
public
static
List
<
String
>
openTransactions
=
new
ArrayList
<
String
>();
public
static
NoUiContext
createNoUiContext
(
NoUiRequest
noUiRequest
)
{
public
static
NoUiContext
createNoUiContext
(
NoUiRequest
noUiRequest
)
{
NoUiContext
noUiContext
=
new
NoUiContext
();
NoUiContext
noUiContext
=
new
NoUiContext
();
ILoginContext
loginContext
=
null
;
ILoginContext
loginContext
=
null
;
if
(
StringUtils
.
isEmpty
(
noUiRequest
.
getToken
()))
{
if
(
noUiRequest
.
isOpenSource
())
{
loginContext
=
new
EmptyLoginContext
(
everybody
);
}
else
if
(
StringUtils
.
isEmpty
(
noUiRequest
.
getToken
()))
{
try
{
try
{
loginContext
=
(
ILoginContext
)
Class
.
forName
(
loginContextName
).
newInstance
();
loginContext
=
(
ILoginContext
)
Class
.
forName
(
loginContextName
).
newInstance
();
}
catch
(
InstantiationException
|
IllegalAccessException
|
ClassNotFoundException
e
)
{
}
catch
(
InstantiationException
|
IllegalAccessException
|
ClassNotFoundException
e
)
{
...
...
src/main/java/org/sss/presentation/noui/context/NoUiPresentation.java
View file @
69e4d0ae
...
@@ -36,6 +36,7 @@ import org.sss.presentation.noui.api.request.NoUiRequest;
...
@@ -36,6 +36,7 @@ import org.sss.presentation.noui.api.request.NoUiRequest;
import
org.sss.presentation.noui.api.response.ErrorCodes
;
import
org.sss.presentation.noui.api.response.ErrorCodes
;
import
org.sss.presentation.noui.common.Constants
;
import
org.sss.presentation.noui.common.Constants
;
import
org.sss.presentation.noui.util.NoUiUtils
;
import
org.sss.presentation.noui.util.NoUiUtils
;
import
org.sss.presentation.noui.util.RedisUtil
;
import
org.sss.util.ContainerUtils
;
import
org.sss.util.ContainerUtils
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
...
@@ -72,6 +73,38 @@ public class NoUiPresentation extends AbstractNullPresentation {
...
@@ -72,6 +73,38 @@ public class NoUiPresentation extends AbstractNullPresentation {
private
String
message
=
null
;
// 弹出的message
private
String
message
=
null
;
// 弹出的message
private
String
message_code
=
ErrorCodes
.
SUCCESS
;
private
String
message_code
=
ErrorCodes
.
SUCCESS
;
public
IPanel
popupPanel
=
null
;
public
IPanel
popupPanel
=
null
;
@Override
public
void
close
(
IPanel
panel
)
throws
ContainerException
{
// TODO Auto-generated method stub
super
.
close
(
panel
);
}
@Override
public
void
popupOnly
(
IPanel
panel
)
throws
ContainerException
{
// TODO Auto-generated method stub
super
.
popupOnly
(
panel
);
}
@Override
public
Object
readFromSession
(
String
name
)
{
return
((
NoUiContext
)
this
.
ctx
).
getRedisLoginInfo
().
getContextMap
().
get
(
name
);
}
@Override
public
void
showMainPanel
()
throws
ContainerException
{
}
@Override
public
void
showPanel
(
IPanel
panel
)
throws
ContainerException
{
super
.
showPanel
(
panel
);
}
@Override
public
void
writeToSession
(
String
name
,
Object
value
)
{
((
NoUiContext
)
this
.
ctx
).
getRedisLoginInfo
().
getContextMap
().
put
(
name
,
value
);
}
public
String
transactionName
=
null
;
public
String
transactionName
=
null
;
public
boolean
clearFlag
=
false
;
public
boolean
clearFlag
=
false
;
public
boolean
newTabFlag
=
false
;
public
boolean
newTabFlag
=
false
;
...
...
src/main/java/org/sss/presentation/noui/controller/AbstractCommonController.java
View file @
69e4d0ae
...
@@ -9,12 +9,14 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -9,12 +9,14 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.sss.common.model.EventType
;
import
org.sss.common.model.EventType
;
import
org.sss.common.model.IBaseObject
;
import
org.sss.common.model.IBaseObject
;
import
org.sss.common.model.IDatafield
;
import
org.sss.common.model.IDatafield
;
import
org.sss.common.model.IModule
;
import
org.sss.common.model.IModule
;
import
org.sss.common.model.IModuleList
;
import
org.sss.common.model.IModuleList
;
import
org.sss.common.model.IPanel
;
import
org.sss.common.model.IStream
;
import
org.sss.common.model.IStream
;
import
org.sss.presentation.noui.api.exception.NoUiException
;
import
org.sss.presentation.noui.api.exception.NoUiException
;
import
org.sss.presentation.noui.api.model.Alias
;
import
org.sss.presentation.noui.api.model.Alias
;
...
@@ -34,7 +36,7 @@ import org.sss.presentation.noui.util.StringUtil;
...
@@ -34,7 +36,7 @@ import org.sss.presentation.noui.util.StringUtil;
import
log.Log
;
import
log.Log
;
import
log.LogFactory
;
import
log.LogFactory
;
public
class
AbstractCommonController
{
public
abstract
class
AbstractCommonController
{
protected
static
final
Log
log
=
LogFactory
.
getLog
(
AbstractCommonController
.
class
);
protected
static
final
Log
log
=
LogFactory
.
getLog
(
AbstractCommonController
.
class
);
protected
static
String
ON_CLICK
=
"ON_CLICK"
;
protected
static
String
ON_CLICK
=
"ON_CLICK"
;
protected
static
String
INIT
=
"INIT"
;
protected
static
String
INIT
=
"INIT"
;
...
@@ -43,38 +45,17 @@ public class AbstractCommonController {
...
@@ -43,38 +45,17 @@ public class AbstractCommonController {
protected
static
String
ON_STREAM_UPLOAD
=
"ON_STREAM_UPLOAD"
;
protected
static
String
ON_STREAM_UPLOAD
=
"ON_STREAM_UPLOAD"
;
protected
static
String
ON_STREAM_DOWNLOAD
=
"ON_STREAM_DOWNLOAD"
;
protected
static
String
ON_STREAM_DOWNLOAD
=
"ON_STREAM_DOWNLOAD"
;
public
String
getMainPanel
(){
return
""
;
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
Object
event
(
String
mappingUrl
,
String
eventType
,
MultipartFile
file
,
Map
<
String
,
Object
>
dataMap
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
Object
event
(
String
mappingUrl
,
String
eventType
,
Map
<
String
,
Object
>
dataMap
,
MultipartFile
file
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
NoUiContext
context
=
null
;
NoUiContext
context
=
null
;
Result
ret
=
null
;
Result
ret
=
null
;
try
{
try
{
// isMultipart = ServletFileUpload.isMultipartContent(request);
// if (isMultipart) {
//
// ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
// // Parse the request
// List<FileItem> items = upload.parseRequest(request);
// Iterator<FileItem> iter = items.iterator();
//
// while (iter.hasNext()) {
// FileItem item = iter.next();
// // 普通表单域
// if (item.isFormField()) {
// String itemName = item.getFieldName();
// String itemValue = item.getString();
// log.info("文件表单 key:" + itemName + ",Value:" + itemValue);
// // 给dataMap赋值
// Map<String, ?> itemMap = new Gson().fromJson(itemValue, Map.class);
// dataMap.put(itemName, itemMap);
// } else { // 文件域
// lastFileItem = item;
// }
// }
// } else {
// log.info("普通表单key-Value:" + dataMap);
// }
NoUiRequest
noUiRequest
=
new
NoUiRequest
(
request
,
mappingUrl
,
dataMap
);
NoUiRequest
noUiRequest
=
new
NoUiRequest
(
request
,
mappingUrl
,
dataMap
);
context
=
NoUiContextManager
.
createNoUiContext
(
noUiRequest
);
context
=
NoUiContextManager
.
createNoUiContext
(
noUiRequest
);
Alias
alias
=
new
Alias
(
mappingUrl
);
Alias
alias
=
new
Alias
(
mappingUrl
);
...
@@ -85,12 +66,24 @@ public class AbstractCommonController {
...
@@ -85,12 +66,24 @@ public class AbstractCommonController {
context
.
getSession
().
storeData
(
key
,
paramsMap
.
get
(
key
));
context
.
getSession
().
storeData
(
key
,
paramsMap
.
get
(
key
));
}
}
// 设置old sysmod
// 设置old sysmod
RedisLoginInfo
redisLoginInfo
=
(
RedisLoginInfo
)
RedisUtil
.
get
(
StringUtil
.
userUniqueId
(
noUiRequest
));
RedisLoginInfo
redisLoginInfo
=
null
;
NoUiPresentationUtil
.
setSysmod
(
context
,
(
byte
[])
redisLoginInfo
.
getSysmod
());
if
(
!
StringUtils
.
isEmpty
(
noUiRequest
.
getUserId
())
)
//开放模式下
redisLoginInfo
=
(
RedisLoginInfo
)
RedisUtil
.
get
(
StringUtil
.
userUniqueId
(
noUiRequest
));
if
(
redisLoginInfo
!=
null
)
{
NoUiPresentationUtil
.
setSysmod
(
context
,
(
byte
[])
redisLoginInfo
.
getSysmod
());
context
.
setRedisLoginInfo
(
redisLoginInfo
);
}
// 交易跳转
// 交易跳转
context
.
getSession
().
chain
(
true
,
trnName
);
context
.
getSession
().
chain
(
true
,
trnName
);
//执行可能存在的主面板的初始化
if
(
this
.
getMainPanel
().
length
()
>
0
)
{
IPanel
mainPanel
=
(
IPanel
)
context
.
getSession
().
getBaseObject
(
null
,
this
.
getMainPanel
());
mainPanel
.
invokeDefaultRules
(
context
);
}
// 模型赋值
// 模型赋值
NoUiPresentationUtil
.
hanleInput
(
context
,
noUiRequest
,
alias
);
NoUiPresentationUtil
.
hanleInput
(
context
,
noUiRequest
,
alias
);
...
@@ -115,9 +108,9 @@ public class AbstractCommonController {
...
@@ -115,9 +108,9 @@ public class AbstractCommonController {
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
IDatafield
dataField
=
(
IDatafield
)
baseObject
(
context
,
noUiRequest
,
alias
);
IDatafield
dataField
=
(
IDatafield
)
baseObject
(
context
,
noUiRequest
,
alias
);
IStream
stream
=
(
IStream
)
dataField
.
getValue
();
IStream
stream
=
(
IStream
)
dataField
.
getValue
();
stream
.
setName
(
file
.
get
N
ame
());
stream
.
setName
(
file
.
get
OriginalFilen
ame
());
stream
.
setType
(
file
.
getContentType
());
stream
.
setType
(
file
.
getContentType
());
log
.
info
(
"文件表单 key:"
+
file
.
get
N
ame
()
+
",size:"
+
file
.
getSize
());
log
.
info
(
"文件表单 key:"
+
file
.
get
OriginalFilen
ame
()
+
",size:"
+
file
.
getSize
());
IOUtils
.
copy
(
file
.
getInputStream
(),
stream
.
getOutputStream
(),
1024
);
IOUtils
.
copy
(
file
.
getInputStream
(),
stream
.
getOutputStream
(),
1024
);
dataField
.
invokeEventRules
(
context
,
EventType
.
ON_STREAM_UPLOAD
,
null
);
dataField
.
invokeEventRules
(
context
,
EventType
.
ON_STREAM_UPLOAD
,
null
);
}
else
if
(
eventType
.
equals
(
ON_STREAM_DOWNLOAD
))
{
}
else
if
(
eventType
.
equals
(
ON_STREAM_DOWNLOAD
))
{
...
@@ -130,9 +123,13 @@ public class AbstractCommonController {
...
@@ -130,9 +123,13 @@ public class AbstractCommonController {
}
}
// 保存新的RedisLoginInfo
// 保存新的RedisLoginInfo
byte
[]
sysmodBytes
=
NoUiPresentationUtil
.
sysmodToBytes
(
context
);
if
(
redisLoginInfo
!=
null
)
//当为开放模式下,redisLoginInfo 为空
redisLoginInfo
.
setSysmod
(
sysmodBytes
);
{
RedisUtil
.
set
(
StringUtil
.
userUniqueId
(
noUiRequest
),
redisLoginInfo
);
byte
[]
sysmodBytes
=
NoUiPresentationUtil
.
sysmodToBytes
(
context
);
redisLoginInfo
.
setSysmod
(
sysmodBytes
);
RedisUtil
.
set
(
StringUtil
.
userUniqueId
(
noUiRequest
),
redisLoginInfo
);
}
Map
<
String
,
Object
>
afterReturnData
=
handleReturnData
(
eventType
,
context
,
noUiRequest
,
alias
);
Map
<
String
,
Object
>
afterReturnData
=
handleReturnData
(
eventType
,
context
,
noUiRequest
,
alias
);
...
...
src/main/java/org/sss/presentation/noui/controller/LoginController.java
View file @
69e4d0ae
...
@@ -112,4 +112,14 @@ public class LoginController {
...
@@ -112,4 +112,14 @@ public class LoginController {
getMenus
(
item
,
subMenuList
);
getMenus
(
item
,
subMenuList
);
}
}
}
}
@ResponseBody
@RequestMapping
(
value
=
"/logout"
,
method
=
RequestMethod
.
POST
)
public
Object
logout
(
@RequestBody
Map
<
String
,
Object
>
dataMap
,
HttpServletRequest
request
,
HttpSession
session
)
{
return
"ok"
;
}
}
}
src/main/java/org/sss/presentation/noui/jwt/OpenTransInterceptor.java
0 → 100644
View file @
69e4d0ae
package
org
.
sss
.
presentation
.
noui
.
jwt
;
import
java.io.PrintWriter
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.sss.presentation.noui.api.request.NoUiRequest
;
import
org.sss.presentation.noui.api.response.ErrorCodes
;
import
org.sss.presentation.noui.api.response.Result
;
import
org.sss.presentation.noui.context.NoUiContextManager
;
import
org.sss.presentation.noui.util.NumericUtil
;
import
org.sss.presentation.noui.util.RedisUtil
;
import
org.sss.presentation.noui.util.StringUtil
;
import
com.google.gson.Gson
;
import
log.Log
;
import
log.LogFactory
;
public
class
OpenTransInterceptor
implements
HandlerInterceptor
{
protected
static
final
Log
log
=
LogFactory
.
getLog
(
OpenTransInterceptor
.
class
);
public
void
afterCompletion
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
Exception
arg3
)
throws
Exception
{
}
public
void
postHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
ModelAndView
model
)
throws
Exception
{
}
// 拦截每个请求
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
response
.
setCharacterEncoding
(
"utf-8"
);
NoUiRequest
noUiRequest
=
new
NoUiRequest
(
request
,
""
,
null
);
String
token
=
noUiRequest
.
getToken
();
String
userId
=
noUiRequest
.
getUserId
();
String
terminalType
=
noUiRequest
.
getTerminalType
();
// APP WEB
RedisLoginInfo
redisLoginInfo
=
null
;
if
(
!
StringUtils
.
isEmpty
(
noUiRequest
.
getUserId
()))
//开放模式下
redisLoginInfo
=
(
RedisLoginInfo
)
RedisUtil
.
get
(
StringUtil
.
userUniqueId
(
noUiRequest
));
//如果是已登录状态,要刷新超时时间
if
(
redisLoginInfo
!=
null
&&
System
.
currentTimeMillis
()
<=
redisLoginInfo
.
getExpiredTime
())
{
// 重新刷入登陆时间
RedisLoginInfo
nweRedisLoginInfo
=
new
RedisLoginInfo
(
userId
,
token
,
NumericUtil
.
sessionTimeOut
(),
redisLoginInfo
.
getSysmod
());
RedisUtil
.
set
(
userId
+
"."
+
terminalType
,
nweRedisLoginInfo
);
}
String
url
=
request
.
getRequestURI
();
String
trnnam
=
null
;
int
idx1
=
url
.
indexOf
(
NoUiContextManager
.
openSourcePrefix
);
int
begpos
=
idx1
+
NoUiContextManager
.
openSourcePrefix
.
length
()+
1
;
int
idx2
=
url
.
indexOf
(
"/"
,
begpos
);
if
(
idx2
>
0
)
trnnam
=
url
.
substring
(
begpos
,
idx2
);
if
(
trnnam
==
null
)
{
Result
rt
=
new
Result
(
ErrorCodes
.
UNKNOEW_TRANS
,
"未知的交易"
,
null
);
responseMessage
(
response
,
response
.
getWriter
(),
rt
);
return
false
;
}
//交易必须是配置允许开放的交易
log
.
debug
(
"开放访问交易名:"
+
trnnam
);
if
(!
NoUiContextManager
.
openTransactions
.
contains
(
trnnam
))
{
Result
rt
=
new
Result
(
ErrorCodes
.
FORBIDDEN_TRANS
,
"非法访问"
,
null
);
responseMessage
(
response
,
response
.
getWriter
(),
rt
);
return
false
;
}
return
true
;
}
// 请求不通过,返回错误信息给客户端
private
void
responseMessage
(
HttpServletResponse
response
,
PrintWriter
out
,
Result
result
)
{
response
.
setContentType
(
"application/json; charset=utf-8"
);
String
json
=
new
Gson
().
toJson
(
result
);
out
.
print
(
json
);
out
.
flush
();
out
.
close
();
}
}
\ No newline at end of file
src/main/java/org/sss/presentation/noui/jwt/RedisLoginInfo.java
View file @
69e4d0ae
package
org
.
sss
.
presentation
.
noui
.
jwt
;
package
org
.
sss
.
presentation
.
noui
.
jwt
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
RedisLoginInfo
implements
Serializable
{
public
class
RedisLoginInfo
implements
Serializable
{
/**
/**
...
@@ -24,6 +26,16 @@ public class RedisLoginInfo implements Serializable {
...
@@ -24,6 +26,16 @@ public class RedisLoginInfo implements Serializable {
private
long
expiredTime
;
private
long
expiredTime
;
private
Object
sysmod
;
private
Object
sysmod
;
private
Map
<
String
,
Object
>
contextMap
=
new
HashMap
<
String
,
Object
>();
public
Map
<
String
,
Object
>
getContextMap
()
{
return
contextMap
;
}
public
void
setContextMap
(
Map
<
String
,
Object
>
contextMap
)
{
this
.
contextMap
=
contextMap
;
}
public
RedisLoginInfo
()
{
public
RedisLoginInfo
()
{
...
...
src/main/java/org/sss/presentation/noui/listener/NoUiApiInitListener.java
View file @
69e4d0ae
package
org
.
sss
.
presentation
.
noui
.
listener
;
package
org
.
sss
.
presentation
.
noui
.
listener
;
import
java.util.Arrays
;
import
java.util.List
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletContextEvent
;
import
javax.servlet.ServletContextEvent
;
import
javax.servlet.ServletContextListener
;
import
javax.servlet.ServletContextListener
;
import
org.apache.commons.lang.StringUtils
;
import
org.sss.presentation.noui.context.NoUiContextManager
;
import
org.sss.presentation.noui.context.NoUiContextManager
;
import
log.Log
;
import
log.LogFactory
;
public
class
NoUiApiInitListener
implements
ServletContextListener
{
public
class
NoUiApiInitListener
implements
ServletContextListener
{
protected
static
final
Log
log
=
LogFactory
.
getLog
(
NoUiApiInitListener
.
class
);
private
static
final
String
DATABASE_SUPPORT_TYPE
=
"DbSupportType"
;
private
static
final
String
DATABASE_SUPPORT_TYPE
=
"DbSupportType"
;
private
static
final
String
NOUI_TIMEOUT
=
"nouiTimeout"
;
private
static
final
String
NOUI_TIMEOUT
=
"nouiTimeout"
;
private
static
final
String
LOGIN_CONTEXT_NAME
=
"loginContextName"
;
private
static
final
String
LOGIN_CONTEXT_NAME
=
"loginContextName"
;
private
static
final
String
OPEN_PREFIX
=
"openPrefix"
;
private
static
final
String
OPEN_TRANS
=
"openTrans"
;
@Override
@Override
public
void
contextDestroyed
(
ServletContextEvent
arg0
)
{
public
void
contextDestroyed
(
ServletContextEvent
arg0
)
{
...
@@ -24,5 +36,16 @@ public class NoUiApiInitListener implements ServletContextListener {
...
@@ -24,5 +36,16 @@ public class NoUiApiInitListener implements ServletContextListener {
int
timeout
=
Integer
.
valueOf
(
context
.
getInitParameter
(
NOUI_TIMEOUT
));
int
timeout
=
Integer
.
valueOf
(
context
.
getInitParameter
(
NOUI_TIMEOUT
));
NoUiContextManager
.
dbType
=
dbType
;
NoUiContextManager
.
dbType
=
dbType
;
NoUiContextManager
.
loginContextName
=
context
.
getInitParameter
(
LOGIN_CONTEXT_NAME
);
NoUiContextManager
.
loginContextName
=
context
.
getInitParameter
(
LOGIN_CONTEXT_NAME
);
String
openSource
=
context
.
getInitParameter
(
OPEN_PREFIX
);
if
(
openSource
!=
null
)
NoUiContextManager
.
openSourcePrefix
=
openSource
;
String
trans
=
context
.
getInitParameter
(
OPEN_TRANS
);
if
(!
StringUtils
.
isEmpty
(
trans
))
{
List
<
String
>
openTrans
=
Arrays
.
asList
(
trans
.
split
(
","
));
NoUiContextManager
.
openTransactions
.
addAll
(
openTrans
);
log
.
debug
(
"开放的交易:"
+
trans
+
";"
+
openTrans
);
}
}
}
}
}
src/main/java/org/sss/presentation/noui/util/NoUiPresentationUtil.java
View file @
69e4d0ae
...
@@ -244,7 +244,7 @@ public class NoUiPresentationUtil {
...
@@ -244,7 +244,7 @@ public class NoUiPresentationUtil {
return
null
;
return
null
;
}
}
public
static
Object
handIBaseObject
(
NoUi
Context
context
,
Object
val
,
String
path
)
{
public
static
Object
handIBaseObject
(
I
Context
context
,
Object
val
,
String
path
)
{
if
(
val
==
null
)
if
(
val
==
null
)
return
null
;
return
null
;
if
(
val
instanceof
IModuleList
<?>)
{
if
(
val
instanceof
IModuleList
<?>)
{
...
@@ -269,19 +269,35 @@ public class NoUiPresentationUtil {
...
@@ -269,19 +269,35 @@ public class NoUiPresentationUtil {
}
}
return
null
;
return
null
;
}
}
public
static
Map
<
String
,
Object
>
getWholeAliasData
(
IContext
context
,
String
mappingUrl
)
{
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
Alias
alias
=
new
Alias
(
mappingUrl
);
for
(
String
aliasKey
:
alias
.
getRel
().
keySet
())
{
if
(
aliasKey
.
startsWith
(
Constants
.
MAPPING_PRE
))
{
continue
;
}
String
realPath
=
alias
.
getRelPath
(
aliasKey
);
IBaseObject
baseObject
=
context
.
getSession
().
getBaseObject
(
context
.
getRoot
(),
realPath
);
data
.
put
(
aliasKey
,
NoUiPresentationUtil
.
handIBaseObject
(
context
,
baseObject
,
realPath
));
}
return
data
;
}
public
static
Map
<
String
,
Object
>
handleErrorReturnData
(
NoUiContext
context
,
Alias
alias
)
{
public
static
Map
<
String
,
Object
>
handleErrorReturnData
(
NoUiContext
context
,
Alias
alias
)
{
NoUiPresentation
gui
=
(
NoUiPresentation
)
context
.
getGui
();
NoUiPresentation
gui
=
(
NoUiPresentation
)
context
.
getGui
();
Map
<
String
,
Object
>
errorMap
=
gui
.
getError
();
Map
<
String
,
Object
>
errorMap
=
gui
.
getError
();
Map
<
String
,
Object
>
n_errorMap
=
new
HashMap
<
String
,
Object
>();
for
(
Map
.
Entry
<
String
,
Object
>
errorEntity
:
errorMap
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Object
>
errorEntity
:
errorMap
.
entrySet
())
{
String
key
=
errorEntity
.
getKey
();
String
key
=
errorEntity
.
getKey
();
String
realKey
=
alias
.
getRevertRel
().
get
(
key
);
String
realKey
=
alias
.
getRevertRel
().
get
(
key
);
if
(!
StringUtils
.
isEmpty
(
realKey
))
if
(!
StringUtils
.
isEmpty
(
realKey
))
errorMap
.
put
(
realKey
,
errorEntity
.
getValue
());
n_
errorMap
.
put
(
realKey
,
errorEntity
.
getValue
());
else
else
errorMap
.
put
(
key
,
errorEntity
.
getValue
());
n_
errorMap
.
put
(
key
,
errorEntity
.
getValue
());
}
}
return
errorMap
;
return
n_
errorMap
;
}
}
public
static
Map
<
String
,
Object
>
handleCodeTableReturnData
(
NoUiContext
context
,
Alias
alias
)
{
public
static
Map
<
String
,
Object
>
handleCodeTableReturnData
(
NoUiContext
context
,
Alias
alias
)
{
...
...
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