Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
smart_gov_platform
Commits
d03ad9e6
Commit
d03ad9e6
authored
Dec 16, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加查询缓存
parent
6b1e125a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
30 deletions
+46
-30
base-manager/src/main/java/com/mortals/xhx/module/window/service/impl/WindowBusinessServiceImpl.java
...module/window/service/impl/WindowBusinessServiceImpl.java
+45
-29
base-manager/src/test/java/com/mortals/httpclient/window/WindowBusinessController.http
...m/mortals/httpclient/window/WindowBusinessController.http
+1
-1
No files found.
base-manager/src/main/java/com/mortals/xhx/module/window/service/impl/WindowBusinessServiceImpl.java
View file @
d03ad9e6
...
...
@@ -38,8 +38,7 @@ import java.util.stream.Collectors;
import
static
com
.
mortals
.
framework
.
util
.
HttpUtil
.
HEADER_CONTENT_TYPE
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.
PARAM_SERVER_PHP_HTTP_URL
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
RedisKey
.
KEY_SEARCH_SITEBUSINESSID_CACHE
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
RedisKey
.
KEY_SEARCH_TIMEOUTT_CACHE
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
RedisKey
.*;
/**
* WindowBusinessService
...
...
@@ -68,43 +67,60 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
*/
@Override
public
Result
<
WindowBusinessEntity
>
find
(
WindowBusinessEntity
entity
,
PageInfo
pageInfo
,
Context
context
)
throws
AppException
{
WindowBusinessEntity
query
=
this
.
findBefore
(
entity
,
pageInfo
,
context
);
//判断查询结果是否用缓存
if
(!
ObjectUtils
.
isEmpty
(
query
)
&&
!
ObjectUtils
.
isEmpty
(
query
.
getSearchCache
()
==
YesNoEnum
.
YES
.
getValue
()))
{
//根据查询条件 获取缓存,如果缓存有则直接取缓存,否则读数据库后 再写入缓存
if
(!
ObjectUtils
.
isEmpty
(
query
.
getSiteBusinessId
()))
{
Long
siteBusinessId
=
query
.
getSiteBusinessId
();
String
cacheResult
=
cacheService
.
get
(
KEY_SEARCH_SITEBUSINESSID_CACHE
+
siteBusinessId
,
String
.
class
);
if
(!
ObjectUtils
.
isEmpty
(
cacheResult
))
{
Result
<
WindowBusinessEntity
>
result
=
JSON
.
parseObject
(
cacheResult
,
new
TypeReference
<
Result
<
WindowBusinessEntity
>>()
{
});
return
result
;
}
else
{
//查询数据库
Result
<
WindowBusinessEntity
>
result
=
this
.
dao
.
getList
(
query
,
pageInfo
);
this
.
findAfter
(
entity
,
pageInfo
,
context
,
result
.
getList
());
cacheService
.
set
(
KEY_SEARCH_SITEBUSINESSID_CACHE
+
siteBusinessId
,
JSON
.
toJSONString
(
result
),
KEY_SEARCH_TIMEOUTT_CACHE
);
return
result
;
}
}
else
if
(!
ObjectUtils
.
isEmpty
(
query
.
getWindowId
()))
{
//todo
return
null
;
}
else
if
(!
ObjectUtils
.
isEmpty
(
query
.
getWindowIdList
()))
{
//todo
return
null
;
}
else
{
Result
<
WindowBusinessEntity
>
result
=
this
.
dao
.
getList
(
query
,
pageInfo
);
this
.
findAfter
(
entity
,
pageInfo
,
context
,
result
.
getList
());
return
result
;
}
return
getWindowBusinessEntityCacheResult
(
entity
,
pageInfo
,
context
,
query
);
}
else
{
Result
<
WindowBusinessEntity
>
result
=
this
.
dao
.
getList
(
query
,
pageInfo
);
this
.
findAfter
(
entity
,
pageInfo
,
context
,
result
.
getList
());
return
result
;
}
}
private
Result
<
WindowBusinessEntity
>
getWindowBusinessEntityCacheResult
(
WindowBusinessEntity
entity
,
PageInfo
pageInfo
,
Context
context
,
WindowBusinessEntity
query
)
{
Result
<
WindowBusinessEntity
>
result
=
null
;
if
(!
ObjectUtils
.
isEmpty
(
query
.
getSiteBusinessId
()))
{
Long
siteBusinessId
=
query
.
getSiteBusinessId
();
String
cacheResult
=
cacheService
.
get
(
KEY_SEARCH_SITEBUSINESSID_CACHE
+
siteBusinessId
,
String
.
class
);
if
(!
ObjectUtils
.
isEmpty
(
cacheResult
))
{
result
=
JSON
.
parseObject
(
cacheResult
,
new
TypeReference
<
Result
<
WindowBusinessEntity
>>()
{});
}
else
{
//查询数据库
result
=
this
.
dao
.
getList
(
query
,
pageInfo
);
this
.
findAfter
(
entity
,
pageInfo
,
context
,
result
.
getList
());
cacheService
.
set
(
KEY_SEARCH_SITEBUSINESSID_CACHE
+
siteBusinessId
,
JSON
.
toJSONString
(
result
),
KEY_SEARCH_TIMEOUTT_CACHE
);
}
}
else
if
(!
ObjectUtils
.
isEmpty
(
query
.
getWindowId
()))
{
Long
windowId
=
query
.
getWindowId
();
String
cacheResult
=
cacheService
.
get
(
KEY_SEARCH_WINDOWID_CACHE
+
windowId
,
String
.
class
);
if
(!
ObjectUtils
.
isEmpty
(
cacheResult
))
{
result
=
JSON
.
parseObject
(
cacheResult
,
new
TypeReference
<
Result
<
WindowBusinessEntity
>>()
{
});
}
else
{
//查询数据库
result
=
this
.
dao
.
getList
(
query
,
pageInfo
);
this
.
findAfter
(
entity
,
pageInfo
,
context
,
result
.
getList
());
cacheService
.
set
(
KEY_SEARCH_WINDOWID_CACHE
+
windowId
,
JSON
.
toJSONString
(
result
),
KEY_SEARCH_TIMEOUTT_CACHE
);
}
}
else
if
(!
ObjectUtils
.
isEmpty
(
query
.
getWindowIdList
()))
{
String
windowIdlist
=
query
.
getWindowIdList
().
stream
().
map
(
String:
:
valueOf
).
collect
(
Collectors
.
joining
(
"#"
));
String
cacheResult
=
cacheService
.
get
(
KEY_SEARCH_WINDOWID_LIST_CACHE
+
windowIdlist
,
String
.
class
);
if
(!
ObjectUtils
.
isEmpty
(
cacheResult
))
{
result
=
JSON
.
parseObject
(
cacheResult
,
new
TypeReference
<
Result
<
WindowBusinessEntity
>>()
{
});
}
else
{
//查询数据库
result
=
this
.
dao
.
getList
(
query
,
pageInfo
);
this
.
findAfter
(
entity
,
pageInfo
,
context
,
result
.
getList
());
cacheService
.
set
(
KEY_SEARCH_WINDOWID_LIST_CACHE
+
windowIdlist
,
JSON
.
toJSONString
(
result
),
KEY_SEARCH_TIMEOUTT_CACHE
);
}
}
else
{
result
=
this
.
dao
.
getList
(
query
,
pageInfo
);
this
.
findAfter
(
entity
,
pageInfo
,
context
,
result
.
getList
());
}
return
result
;
}
@Override
...
...
base-manager/src/test/java/com/mortals/httpclient/window/WindowBusinessController.http
View file @
d03ad9e6
...
...
@@ -11,7 +11,7 @@ Content-Type: application/json
POST {{baseUrl}}/window/business/interlist
Content-Type: application/json
{"siteBusinessId":
1
,"size":-1,"searchCache": 1}
{"siteBusinessId":
2
,"size":-1,"searchCache": 1}
###窗口业务列表缓存2
POST {{baseUrl}}/window/business/interlist
...
...
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