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
18bdfe40
Commit
18bdfe40
authored
Mar 08, 2019
by
gechengyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AA
parent
e7d54cd1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
117 additions
and
6 deletions
+117
-6
NoUiRequest.java
...va/org/sss/presentation/noui/api/request/NoUiRequest.java
+12
-0
Constants.java
...main/java/org/sss/presentation/noui/common/Constants.java
+4
-0
NoUiContextManager.java
...org/sss/presentation/noui/context/NoUiContextManager.java
+4
-4
NoUiPresentation.java
...a/org/sss/presentation/noui/context/NoUiPresentation.java
+27
-1
AbstractCommonController.java
...resentation/noui/controller/AbstractCommonController.java
+2
-1
ShowDisplayController.java
...s/presentation/noui/controller/ShowDisplayController.java
+48
-0
GsonTest.java
.../java/org/sss/presentation/noui/api/servlet/GsonTest.java
+20
-0
No files found.
src/main/java/org/sss/presentation/noui/api/request/NoUiRequest.java
View file @
18bdfe40
...
@@ -16,6 +16,7 @@ public class NoUiRequest {
...
@@ -16,6 +16,7 @@ public class NoUiRequest {
private
String
mappingUrl
;
private
String
mappingUrl
;
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
>();
public
NoUiRequest
(
HttpServletRequest
request
,
String
mappingUrl
,
Map
<
String
,
?>
requestData
)
{
public
NoUiRequest
(
HttpServletRequest
request
,
String
mappingUrl
,
Map
<
String
,
?>
requestData
)
{
String
tokenId
=
request
.
getHeader
(
"token"
);
String
tokenId
=
request
.
getHeader
(
"token"
);
...
@@ -28,10 +29,13 @@ public class NoUiRequest {
...
@@ -28,10 +29,13 @@ public class NoUiRequest {
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
);
this
.
saveDisplayMap
=
(
Map
<
String
,
?>)
requestData
.
get
(
Constants
.
DISPLAY
);
if
(
this
.
paramsMap
==
null
)
if
(
this
.
paramsMap
==
null
)
this
.
paramsMap
=
new
HashMap
<
String
,
Object
>();
this
.
paramsMap
=
new
HashMap
<
String
,
Object
>();
if
(
this
.
dataMap
==
null
)
if
(
this
.
dataMap
==
null
)
this
.
dataMap
=
new
HashMap
<
String
,
Object
>();
this
.
dataMap
=
new
HashMap
<
String
,
Object
>();
if
(
this
.
saveDisplayMap
==
null
)
this
.
saveDisplayMap
=
new
HashMap
<
String
,
Object
>();
}
}
}
}
...
@@ -91,4 +95,12 @@ public class NoUiRequest {
...
@@ -91,4 +95,12 @@ public class NoUiRequest {
this
.
dataMap
=
dataMap
;
this
.
dataMap
=
dataMap
;
}
}
public
Map
<
String
,
?>
getSaveDisplayMap
()
{
return
saveDisplayMap
;
}
public
void
setSaveDisplayMap
(
Map
<
String
,
?>
saveDisplayMap
)
{
this
.
saveDisplayMap
=
saveDisplayMap
;
}
}
}
src/main/java/org/sss/presentation/noui/common/Constants.java
View file @
18bdfe40
...
@@ -3,9 +3,13 @@ package org.sss.presentation.noui.common;
...
@@ -3,9 +3,13 @@ package org.sss.presentation.noui.common;
public
class
Constants
{
public
class
Constants
{
public
final
static
String
PARAMS
=
"params"
;
public
final
static
String
PARAMS
=
"params"
;
public
final
static
String
DATA
=
"data"
;
public
final
static
String
DATA
=
"data"
;
public
final
static
String
DISPLAY
=
"display"
;
public
final
static
String
ENCODING
=
"UTF-8"
;
public
final
static
String
USERNAME
=
"username"
;
public
final
static
String
USERNAME
=
"username"
;
public
final
static
String
PASSWORD
=
"password"
;
public
final
static
String
PASSWORD
=
"password"
;
public
final
static
String
DISPLAY_FILE_NAME
=
"fileName"
;
public
final
static
String
MAPPING_PRE
=
"_"
;
public
final
static
String
MAPPING_PRE
=
"_"
;
}
}
src/main/java/org/sss/presentation/noui/context/NoUiContextManager.java
View file @
18bdfe40
...
@@ -19,10 +19,10 @@ public class NoUiContextManager {
...
@@ -19,10 +19,10 @@ public class NoUiContextManager {
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
NoUiContext
createNoUiContext
(
NoUiRequest
r
equest
)
{
public
static
NoUiContext
createNoUiContext
(
NoUiRequest
noUiR
equest
)
{
NoUiContext
noUiContext
=
new
NoUiContext
();
NoUiContext
noUiContext
=
new
NoUiContext
();
ILoginContext
loginContext
=
null
;
ILoginContext
loginContext
=
null
;
if
(
StringUtils
.
isEmpty
(
r
equest
.
getToken
()))
{
if
(
StringUtils
.
isEmpty
(
noUiR
equest
.
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
)
{
...
@@ -31,7 +31,7 @@ public class NoUiContextManager {
...
@@ -31,7 +31,7 @@ public class NoUiContextManager {
}
}
else
else
loginContext
=
new
EmptyLoginContext
(
r
equest
.
getUserId
());
loginContext
=
new
EmptyLoginContext
(
noUiR
equest
.
getUserId
());
loginContext
.
setContext
(
noUiContext
);
loginContext
.
setContext
(
noUiContext
);
noUiContext
.
setAuth
(
loginContext
);
noUiContext
.
setAuth
(
loginContext
);
noUiContext
.
setSessionId
(
UUID
.
randomUUID
().
toString
());
noUiContext
.
setSessionId
(
UUID
.
randomUUID
().
toString
());
...
@@ -42,7 +42,7 @@ public class NoUiContextManager {
...
@@ -42,7 +42,7 @@ public class NoUiContextManager {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
NoUiException
(
"Constructs NoUiContext error"
);
throw
new
NoUiException
(
"Constructs NoUiContext error"
);
}
}
noUiContext
.
setGui
(
new
NoUiPresentation
(
noUiContext
));
noUiContext
.
setGui
(
new
NoUiPresentation
(
noUiContext
,
noUiRequest
));
noUiContext
.
setSession
(
session
);
noUiContext
.
setSession
(
session
);
log
.
debug
(
"Build context finished"
);
log
.
debug
(
"Build context finished"
);
...
...
src/main/java/org/sss/presentation/noui/context/NoUiPresentation.java
View file @
18bdfe40
...
@@ -2,6 +2,7 @@ package org.sss.presentation.noui.context;
...
@@ -2,6 +2,7 @@ package org.sss.presentation.noui.context;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.PrintStream
;
import
java.io.PrintStream
;
import
java.text.MessageFormat
;
import
java.text.MessageFormat
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
...
@@ -13,6 +14,7 @@ import java.util.Map;
...
@@ -13,6 +14,7 @@ import java.util.Map;
import
log.Log
;
import
log.Log
;
import
log.LogFactory
;
import
log.LogFactory
;
import
org.apache.commons.io.FileUtils
;
import
org.sss.common.impl.AbstractNullPresentation
;
import
org.sss.common.impl.AbstractNullPresentation
;
import
org.sss.common.model.CodetableItem
;
import
org.sss.common.model.CodetableItem
;
import
org.sss.common.model.IAttribute
;
import
org.sss.common.model.IAttribute
;
...
@@ -28,9 +30,13 @@ import org.sss.common.model.MessageType;
...
@@ -28,9 +30,13 @@ import org.sss.common.model.MessageType;
import
org.sss.common.model.RowOpType
;
import
org.sss.common.model.RowOpType
;
import
org.sss.common.model.ViewType
;
import
org.sss.common.model.ViewType
;
import
org.sss.exception.ContainerException
;
import
org.sss.exception.ContainerException
;
import
org.sss.presentation.noui.api.request.NoUiRequest
;
import
org.sss.presentation.noui.common.Constants
;
import
org.sss.presentation.noui.util.NoUiUtils
;
import
org.sss.presentation.noui.util.NoUiUtils
;
import
org.sss.util.ContainerUtils
;
import
org.sss.util.ContainerUtils
;
import
com.google.gson.Gson
;
public
class
NoUiPresentation
extends
AbstractNullPresentation
{
public
class
NoUiPresentation
extends
AbstractNullPresentation
{
private
static
final
Log
log
=
LogFactory
.
getLog
(
NoUiPresentation
.
class
);
private
static
final
Log
log
=
LogFactory
.
getLog
(
NoUiPresentation
.
class
);
// public final Map<IModuleList<?>, List<RowOpItem>> tableRowMap = new
// public final Map<IModuleList<?>, List<RowOpItem>> tableRowMap = new
...
@@ -51,6 +57,8 @@ public class NoUiPresentation extends AbstractNullPresentation {
...
@@ -51,6 +57,8 @@ public class NoUiPresentation extends AbstractNullPresentation {
// ArrayList<IAttribute<?>>();
// ArrayList<IAttribute<?>>();
private
Map
<
String
,
Object
>
codetable
=
new
HashMap
<>();
private
Map
<
String
,
Object
>
codetable
=
new
HashMap
<>();
private
NoUiRequest
noUiRequest
;
private
Map
<
String
,
Object
>
error
=
new
HashMap
<>();
private
Map
<
String
,
Object
>
error
=
new
HashMap
<>();
private
Map
<
String
,
Object
>
modifyMap
=
new
HashMap
<>();
private
Map
<
String
,
Object
>
modifyMap
=
new
HashMap
<>();
...
@@ -74,8 +82,9 @@ public class NoUiPresentation extends AbstractNullPresentation {
...
@@ -74,8 +82,9 @@ public class NoUiPresentation extends AbstractNullPresentation {
return
isChain
;
return
isChain
;
}
}
public
NoUiPresentation
(
NoUiContext
context
)
{
public
NoUiPresentation
(
NoUiContext
context
,
NoUiRequest
noUiRequest
)
{
this
.
ctx
=
context
;
this
.
ctx
=
context
;
this
.
noUiRequest
=
noUiRequest
;
}
}
public
synchronized
void
dispose
()
{
public
synchronized
void
dispose
()
{
...
@@ -452,6 +461,23 @@ public class NoUiPresentation extends AbstractNullPresentation {
...
@@ -452,6 +461,23 @@ public class NoUiPresentation extends AbstractNullPresentation {
return
NoUiUtils
.
debugMode
;
return
NoUiUtils
.
debugMode
;
}
}
@Override
public
void
saveDisplay
(
IPanel
[]
panels
,
String
fileName
,
String
cssUrl
)
throws
ContainerException
{
saveDisplay
(
panels
,
fileName
);
}
@Override
public
void
saveDisplay
(
IPanel
[]
panels
,
String
fileName
)
throws
ContainerException
{
try
{
Map
<
String
,
?>
map
=
noUiRequest
.
getSaveDisplayMap
();
String
data
=
new
Gson
().
toJson
(
map
);
FileUtils
.
write
(
new
File
(
fileName
),
data
,
Constants
.
ENCODING
);
}
catch
(
IOException
e
)
{
log
.
error
(
"save dispaly error"
,
e
);
}
}
public
Map
<
String
,
Object
>
getCodetable
()
{
public
Map
<
String
,
Object
>
getCodetable
()
{
return
codetable
;
return
codetable
;
}
}
...
...
src/main/java/org/sss/presentation/noui/controller/AbstractCommonController.java
View file @
18bdfe40
...
@@ -115,8 +115,9 @@ public class AbstractCommonController {
...
@@ -115,8 +115,9 @@ public class AbstractCommonController {
NoUiPresentationUtil
.
handleErrorReturnData
(
context
,
alias
),
NoUiPresentationUtil
.
handleCodeTableReturnData
(
context
,
alias
));
NoUiPresentationUtil
.
handleErrorReturnData
(
context
,
alias
),
NoUiPresentationUtil
.
handleCodeTableReturnData
(
context
,
alias
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"OnClick command error"
,
e
);
log
.
error
(
"OnClick command error"
,
e
);
return
ResultUtil
.
result
(
ErrorCodes
.
ERROR
,
"hander error"
,
e
.
getMessage
());
}
}
return
ResultUtil
.
result
(
ErrorCodes
.
ERROR
,
"提交处理异常"
,
null
);
}
}
private
IBaseObject
baseObject
(
NoUiContext
context
,
NoUiRequest
noUiRequest
,
Alias
alias
)
{
private
IBaseObject
baseObject
(
NoUiContext
context
,
NoUiRequest
noUiRequest
,
Alias
alias
)
{
...
...
src/main/java/org/sss/presentation/noui/controller/ShowDisplayController.java
0 → 100644
View file @
18bdfe40
package
org
.
sss
.
presentation
.
noui
.
controller
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpSession
;
import
log.Log
;
import
log.LogFactory
;
import
org.apache.commons.io.IOUtils
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.sss.presentation.noui.api.response.ErrorCodes
;
import
org.sss.presentation.noui.api.response.ResultUtil
;
import
org.sss.presentation.noui.common.Constants
;
import
com.google.gson.Gson
;
@Controller
public
class
ShowDisplayController
{
private
static
final
Log
log
=
LogFactory
.
getLog
(
ShowDisplayController
.
class
);
@ResponseBody
@RequestMapping
(
value
=
"/showDisplay"
,
method
=
RequestMethod
.
POST
)
public
Object
showDisplay
(
@RequestBody
Map
<
String
,
Object
>
dataMap
,
HttpServletRequest
request
,
HttpSession
session
)
{
System
.
out
.
println
(
dataMap
);
try
{
String
fileName
=
(
String
)
dataMap
.
get
(
Constants
.
DISPLAY_FILE_NAME
);
FileInputStream
fis
=
new
FileInputStream
(
new
File
(
fileName
));
String
jsonData
=
IOUtils
.
toString
(
fis
,
Constants
.
ENCODING
);
Map
mapData
=
new
Gson
().
fromJson
(
jsonData
,
Map
.
class
);
return
ResultUtil
.
result
(
ErrorCodes
.
SUCCESS
,
ErrorCodes
.
SUCCESS_INFO
,
mapData
);
}
catch
(
Exception
e
)
{
log
.
error
(
"showDisplay error"
,
e
);
return
ResultUtil
.
result
(
ErrorCodes
.
ERROR
,
"showDisplay error"
,
e
.
getMessage
());
}
}
}
src/test/java/org/sss/presentation/noui/api/servlet/GsonTest.java
0 → 100644
View file @
18bdfe40
package
org
.
sss
.
presentation
.
noui
.
api
.
servlet
;
import
java.util.HashMap
;
import
java.util.Map
;
import
com.google.gson.Gson
;
public
class
GsonTest
{
public
static
void
main
(
String
[]
args
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
.
put
(
"username"
,
"tst1"
);
map
.
put
(
"password"
,
"1"
);
Map
<
String
,
Object
>
map2
=
new
HashMap
<
String
,
Object
>();
map2
.
put
(
"data"
,
map
);
// System.out.println(JSON.toJSON(student));
System
.
out
.
println
(
new
Gson
().
toJson
(
map2
));
}
}
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