Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
test
Project
Project
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
邬友楠
test
Commits
539d4a6f
Commit
539d4a6f
authored
Oct 16, 2020
by
雍欢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
grid中也可以使用基于非SQL的easysearch
parent
45d2eb47
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
138 additions
and
16 deletions
+138
-16
EasySearch.java
...ava/com/huigou/uasp/bmp/common/easysearch/EasySearch.java
+22
-0
EasySearchDispatcher.java
...mp/common/easysearch/controller/EasySearchDispatcher.java
+89
-0
IconController.java
...va/com/huigou/uasp/bmp/opm/controller/IconController.java
+11
-6
LinkController.java
...va/com/huigou/uasp/bmp/opm/controller/LinkController.java
+10
-6
application.properties
huigou-xt/src/main/resources/application.properties
+3
-1
Function.js
huigou-xt/src/main/webapp/system/opm/permission/Function.js
+3
-3
No files found.
huigou-uasp/src/main/java/com/huigou/uasp/bmp/common/easysearch/EasySearch.java
0 → 100644
View file @
539d4a6f
package
com
.
huigou
.
uasp
.
bmp
.
common
.
easysearch
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
/**
* easysearch执行器。
*
* @author yonghuan
*/
@Target
({
ElementType
.
METHOD
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
EasySearch
{
String
configType
()
default
"system"
;
String
queryName
();
}
huigou-uasp/src/main/java/com/huigou/uasp/bmp/common/easysearch/controller/EasySearchDispatcher.java
0 → 100644
View file @
539d4a6f
package
com
.
huigou
.
uasp
.
bmp
.
common
.
easysearch
.
controller
;
import
com.huigou.uasp.bmp.common.easysearch.EasySearch
;
import
com.huigou.uasp.client.CommonController
;
import
com.huigou.util.SDO
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.web.context.WebApplicationContext
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
org.springframework.web.servlet.DispatcherServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.lang.reflect.Method
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
* @author yonghuan
*/
@Component
@Aspect
public
class
EasySearchDispatcher
{
private
final
Map
<
String
,
Object
[]>
easySearchCache
=
new
ConcurrentHashMap
<>(
16
);
private
final
static
Object
[]
EMPTY_EASY_SEARCH
=
new
Object
[
0
];
private
static
Method
getSDOMethod
;
static
{
try
{
getSDOMethod
=
CommonController
.
class
.
getDeclaredMethod
(
"getSDO"
);
getSDOMethod
.
setAccessible
(
true
);
}
catch
(
NoSuchMethodException
e
)
{
}
}
@Around
(
"execution(* com.huigou.uasp.bmp.common.easysearch.controller.EasySearchController.execute(..))"
)
public
String
intercept
(
ProceedingJoinPoint
pjp
)
throws
Throwable
{
SDO
sdo
=
(
SDO
)
getSDOMethod
.
invoke
(
pjp
.
getTarget
());
String
configType
=
sdo
.
getProperty
(
"configType"
,
String
.
class
,
"system"
);
String
queryName
=
sdo
.
getString
(
"queryName"
);
Object
[]
config
=
getConfig
(
configType
,
queryName
);
if
(
config
!=
EMPTY_EASY_SEARCH
)
{
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
Object
bean
=
config
[
0
];
Method
method
=
(
Method
)
config
[
1
];
Object
model
=
method
.
invoke
(
bean
,
sdo
);
HttpServletResponse
response
=
((
ServletRequestAttributes
)
(
RequestContextHolder
.
currentRequestAttributes
())).
getResponse
();
request
.
setAttribute
(
"EASY_SEARCH_DATA"
,
model
);
request
.
getRequestDispatcher
(
"/common/easySearch.jsp"
).
forward
(
request
,
response
);
return
null
;
}
return
(
String
)
pjp
.
proceed
();
}
public
Object
[]
getConfig
(
String
configType
,
String
queryName
)
{
String
cacheKey
=
String
.
format
(
"%s.%s"
,
configType
,
queryName
);
Object
[]
config
=
easySearchCache
.
get
(
cacheKey
);
if
(
config
!=
null
)
{
return
config
;
}
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
// 获取到Servlet WebApplicationContext(不是Root WebApplicationContext)
WebApplicationContext
wac
=
((
WebApplicationContext
)
request
.
getAttribute
(
DispatcherServlet
.
WEB_APPLICATION_CONTEXT_ATTRIBUTE
));
for
(
String
beanName
:
wac
.
getBeanDefinitionNames
())
{
Object
bean
=
wac
.
getBean
(
beanName
);
for
(
Method
method
:
ReflectionUtils
.
getAllDeclaredMethods
(
bean
.
getClass
()))
{
EasySearch
easySearch
=
method
.
getAnnotation
(
EasySearch
.
class
);
if
(
easySearch
!=
null
&&
easySearch
.
configType
().
equals
(
configType
)
&&
easySearch
.
queryName
().
equals
(
queryName
))
{
config
=
new
Object
[]{
bean
,
method
};
break
;
}
}
if
(
config
!=
null
)
{
break
;
}
}
if
(
config
==
null
)
{
config
=
EMPTY_EASY_SEARCH
;
}
easySearchCache
.
put
(
cacheKey
,
config
);
return
config
;
}
}
huigou-uasp/src/main/java/com/huigou/uasp/bmp/opm/controller/IconController.java
View file @
539d4a6f
package
com
.
huigou
.
uasp
.
bmp
.
opm
.
controller
;
package
com
.
huigou
.
uasp
.
bmp
.
opm
.
controller
;
import
com.huigou.uasp.annotation.ControllerMapping
;
import
com.huigou.uasp.annotation.ControllerMapping
;
import
com.huigou.uasp.bmp.common.easysearch.EasySearch
;
import
com.huigou.uasp.bmp.common.easysearch.domain.model.EasySearchParse
;
import
com.huigou.uasp.bmp.common.easysearch.domain.model.EasySearchParse
;
import
com.huigou.uasp.bmp.common.easysearch.domain.model.QuerySchemeField
;
import
com.huigou.uasp.bmp.common.easysearch.domain.model.QuerySchemeField
;
import
com.huigou.uasp.bmp.opm.application.CssIconParser
;
import
com.huigou.uasp.bmp.opm.application.CssIconParser
;
...
@@ -45,7 +46,6 @@ public class IconController extends CommonController implements ApplicationListe
...
@@ -45,7 +46,6 @@ public class IconController extends CommonController implements ApplicationListe
private
MemEasySearcher
<
Icon
>
memEasySearcher
;
private
MemEasySearcher
<
Icon
>
memEasySearcher
;
private
List
<
String
>
iconCssFiles
=
Collections
.
emptyList
();
private
List
<
String
>
iconCssFiles
=
Collections
.
emptyList
();
private
Collection
<
Icon
>
icons
=
Collections
.
emptyList
();
private
Collection
<
Icon
>
icons
=
Collections
.
emptyList
();
private
WebApplicationContext
webApplicationContext
;
private
ServletContext
servletContext
;
private
ServletContext
servletContext
;
@Value
(
"${icon.cssFile}"
)
@Value
(
"${icon.cssFile}"
)
...
@@ -60,8 +60,7 @@ public class IconController extends CommonController implements ApplicationListe
...
@@ -60,8 +60,7 @@ public class IconController extends CommonController implements ApplicationListe
@Override
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
webApplicationContext
=
(
WebApplicationContext
)
applicationContext
;
servletContext
=
((
WebApplicationContext
)
applicationContext
).
getServletContext
();
servletContext
=
webApplicationContext
.
getServletContext
();
}
}
/**
/**
...
@@ -75,8 +74,16 @@ public class IconController extends CommonController implements ApplicationListe
...
@@ -75,8 +74,16 @@ public class IconController extends CommonController implements ApplicationListe
/**
/**
* 搜索图标。
* 搜索图标。
*/
*/
@Deprecated
public
String
easySearch
()
{
public
String
easySearch
()
{
SDO
sdo
=
getSDO
();
SDO
sdo
=
getSDO
();
Object
model
=
executeEasySearch
(
sdo
);
putAttribute
(
EASY_SEARCH_DATA
,
model
);
return
forward
(
"/common/easySearch.jsp"
);
}
@EasySearch
(
queryName
=
"icon"
)
public
Object
executeEasySearch
(
SDO
sdo
)
{
Integer
intPage
=
sdo
.
getInteger
(
"intPage"
,
1
);
Integer
intPage
=
sdo
.
getInteger
(
"intPage"
,
1
);
Integer
pageSize
=
sdo
.
getInteger
(
"pageSize"
);
Integer
pageSize
=
sdo
.
getInteger
(
"pageSize"
);
PageRequest
pageRequest
=
new
PageRequest
(
intPage
-
1
,
pageSize
);
PageRequest
pageRequest
=
new
PageRequest
(
intPage
-
1
,
pageSize
);
...
@@ -86,9 +93,7 @@ public class IconController extends CommonController implements ApplicationListe
...
@@ -86,9 +93,7 @@ public class IconController extends CommonController implements ApplicationListe
EasySearchParse
easySearchParse
=
new
EasySearchParse
();
EasySearchParse
easySearchParse
=
new
EasySearchParse
();
easySearchParse
.
setFields
(
fields
);
easySearchParse
.
setFields
(
fields
);
easySearchParse
.
setWidth
(
200L
);
easySearchParse
.
setWidth
(
200L
);
Map
<
String
,
Object
>
model
=
memEasySearcher
.
search
(
icons
,
easySearchParse
,
pageRequest
,
(
icon
->
StringUtils
.
isBlank
(
paramValue
)
||
icon
.
getCode
().
contains
(
paramValue
)));
return
memEasySearcher
.
search
(
icons
,
easySearchParse
,
pageRequest
,
(
icon
->
StringUtils
.
isBlank
(
paramValue
)
||
icon
.
getCode
().
contains
(
paramValue
)));
putAttribute
(
EASY_SEARCH_DATA
,
model
);
return
forward
(
"/common/easySearch.jsp"
);
}
}
private
void
syncIconsInternal
()
{
private
void
syncIconsInternal
()
{
...
...
huigou-uasp/src/main/java/com/huigou/uasp/bmp/opm/controller/LinkController.java
View file @
539d4a6f
package
com
.
huigou
.
uasp
.
bmp
.
opm
.
controller
;
package
com
.
huigou
.
uasp
.
bmp
.
opm
.
controller
;
import
com.huigou.uasp.annotation.ControllerMapping
;
import
com.huigou.uasp.annotation.ControllerMapping
;
import
com.huigou.uasp.bmp.common.easysearch.EasySearch
;
import
com.huigou.uasp.bmp.common.easysearch.domain.model.EasySearchParse
;
import
com.huigou.uasp.bmp.common.easysearch.domain.model.EasySearchParse
;
import
com.huigou.uasp.bmp.common.easysearch.domain.model.QuerySchemeField
;
import
com.huigou.uasp.bmp.common.easysearch.domain.model.QuerySchemeField
;
import
com.huigou.uasp.bmp.opm.application.MemEasySearcher
;
import
com.huigou.uasp.bmp.opm.application.MemEasySearcher
;
...
@@ -20,7 +21,6 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
...
@@ -20,7 +21,6 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
static
com
.
huigou
.
util
.
Constants
.
EASY_SEARCH_DATA
;
import
static
com
.
huigou
.
util
.
Constants
.
EASY_SEARCH_DATA
;
...
@@ -55,8 +55,15 @@ public class LinkController extends CommonController implements ApplicationListe
...
@@ -55,8 +55,15 @@ public class LinkController extends CommonController implements ApplicationListe
/**
/**
* 搜索链接
* 搜索链接
*/
*/
@Deprecated
public
String
easySearch
()
{
public
String
easySearch
()
{
SDO
sdo
=
getSDO
();
Object
model
=
executeEasySearch
(
getSDO
());
putAttribute
(
EASY_SEARCH_DATA
,
model
);
return
forward
(
"/common/easySearch.jsp"
);
}
@EasySearch
(
queryName
=
"link"
)
public
Object
executeEasySearch
(
SDO
sdo
)
{
Integer
intPage
=
sdo
.
getInteger
(
"intPage"
,
1
);
Integer
intPage
=
sdo
.
getInteger
(
"intPage"
,
1
);
Integer
pageSize
=
sdo
.
getInteger
(
"pageSize"
);
Integer
pageSize
=
sdo
.
getInteger
(
"pageSize"
);
PageRequest
pageRequest
=
new
PageRequest
(
intPage
-
1
,
pageSize
);
PageRequest
pageRequest
=
new
PageRequest
(
intPage
-
1
,
pageSize
);
...
@@ -65,10 +72,7 @@ public class LinkController extends CommonController implements ApplicationListe
...
@@ -65,10 +72,7 @@ public class LinkController extends CommonController implements ApplicationListe
List
<
QuerySchemeField
>
fields
=
Collections
.
singletonList
(
new
QuerySchemeField
(
"地址"
,
"url"
,
"string"
,
400L
));
List
<
QuerySchemeField
>
fields
=
Collections
.
singletonList
(
new
QuerySchemeField
(
"地址"
,
"url"
,
"string"
,
400L
));
easySearchParse
.
setFields
(
fields
);
easySearchParse
.
setFields
(
fields
);
easySearchParse
.
setWidth
(
400L
);
easySearchParse
.
setWidth
(
400L
);
Map
<
String
,
Object
>
model
=
memSearcher
.
search
(
links
,
easySearchParse
,
pageRequest
,
(
link
->
StringUtils
.
isBlank
(
paramValue
)
||
StringUtils
.
containsIgnoreCase
(
link
.
getUrl
(),
paramValue
)));
return
memSearcher
.
search
(
links
,
easySearchParse
,
pageRequest
,
(
link
->
StringUtils
.
isBlank
(
paramValue
)
||
StringUtils
.
containsIgnoreCase
(
link
.
getUrl
(),
paramValue
)));
putAttribute
(
EASY_SEARCH_DATA
,
model
);
return
forward
(
"/common/easySearch.jsp"
);
}
}
private
void
syncLinksInternal
()
{
private
void
syncLinksInternal
()
{
...
...
huigou-xt/src/main/resources/application.properties
View file @
539d4a6f
...
@@ -42,4 +42,6 @@ email.host=https://mail.topsunit.com/EWS/Exchange.asmx
...
@@ -42,4 +42,6 @@ email.host=https://mail.topsunit.com/EWS/Exchange.asmx
email.username
=
portal@topsunit.com
email.username
=
portal@topsunit.com
email.password
=
20180101
email.password
=
20180101
icon.cssFile
=
themes/fontawesome/css/font-awesome.min.css
icon.cssFile
=
themes/fontawesome/css/font-awesome.min.css
\ No newline at end of file
org.forceGenerateIdentifier
=
false
huigou-xt/src/main/webapp/system/opm/permission/Function.js
View file @
539d4a6f
...
@@ -188,7 +188,7 @@ function initDetail(div) {
...
@@ -188,7 +188,7 @@ function initDetail(div) {
_showIcon
(
$
(
this
).
val
());
_showIcon
(
$
(
this
).
val
());
});
});
_icon
.
searchbox
({
_icon
.
searchbox
({
url
:
'/icon/easySearch.load
'
,
name
:
'icon
'
,
getParam
:
function
()
{
getParam
:
function
()
{
return
{};
return
{};
},
},
...
@@ -219,7 +219,7 @@ function initDetail(div) {
...
@@ -219,7 +219,7 @@ function initDetail(div) {
$
(
'#url-selector-container'
).
remove
();
$
(
'#url-selector-container'
).
remove
();
$
(
'<div id="url-selector-container"><input id="urlSelector" name="urlSelector" /></div>'
).
insertBefore
(
'#url_click'
);
$
(
'<div id="url-selector-container"><input id="urlSelector" name="urlSelector" /></div>'
).
insertBefore
(
'#url_click'
);
$
(
'#urlSelector'
).
searchbox
({
$
(
'#urlSelector'
).
searchbox
({
url
:
'/link/easySearch.load
'
,
name
:
'link
'
,
getParam
:
function
()
{
getParam
:
function
()
{
return
{};
return
{};
},
},
...
@@ -382,4 +382,4 @@ function syncLinks() {
...
@@ -382,4 +382,4 @@ function syncLinks() {
null
,
null
,
function
(
data
)
{
function
(
data
)
{
});
});
}
}
\ No newline at end of file
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