Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
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
youjj
cloud-platform
Commits
a42e4708
Commit
a42e4708
authored
Aug 03, 2019
by
libin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
随车物品
parent
8c345442
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
6 deletions
+35
-6
AccompanyingItemBiz.java
...va/com/xxfc/platform/vehicle/biz/AccompanyingItemBiz.java
+35
-6
No files found.
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/AccompanyingItemBiz.java
View file @
a42e4708
...
...
@@ -2,6 +2,8 @@ package com.xxfc.platform.vehicle.biz;
import
com.ace.cache.annotation.Cache
;
import
com.ace.cache.annotation.CacheClear
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
...
...
@@ -16,20 +18,30 @@ import com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.beanutils.BeanUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.HashOperations
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.ValueOperations
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
tk.mybatis.mapper.entity.Example
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Map
;
import
javax.annotation.Resource
;
import
java.lang.reflect.Array
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
@Slf4j
public
class
AccompanyingItemBiz
extends
BaseBiz
<
AccompanyingItemMapper
,
AccompanyingItem
>
{
@Autowired
private
RedisTemplate
redisTemplate
;
@Resource
(
name
=
"redisTemplate"
)
HashOperations
itemHashOperations
;
private
static
final
String
ACCOMPANY_ITEM
=
"accompany:item"
;
@Cache
(
key
=
RedisKey
.
ACCOMPANYING_ITEM_CACHE_ALL
)
public
List
<
AccompanyingItem
>
getAll
(){
...
...
@@ -75,6 +87,7 @@ public class AccompanyingItemBiz extends BaseBiz<AccompanyingItemMapper, Accompa
accompanyingItem
.
setId
(
null
);
BeanUtils
.
copyProperties
(
accompanyingItem
,
addOrUpdateAccompanyingItem
);
Integer
effected
=
mapper
.
insertSelective
(
accompanyingItem
);
redisTemplate
.
delete
(
ACCOMPANY_ITEM
);
return
RestResponse
.
suc
();
}
...
...
@@ -83,17 +96,33 @@ public class AccompanyingItemBiz extends BaseBiz<AccompanyingItemMapper, Accompa
AccompanyingItem
accompanyingItem
=
new
AccompanyingItem
();
BeanUtils
.
copyProperties
(
accompanyingItem
,
addOrUpdateAccompanyingItem
);
Integer
effected
=
mapper
.
updateByPrimaryKeySelective
(
accompanyingItem
);
redisTemplate
.
delete
(
ACCOMPANY_ITEM
);
return
RestResponse
.
suc
();
}
@CacheClear
(
key
=
RedisKey
.
ACCOMPANYING_ITEM_CACHE_ALL
)
public
RestResponse
<
Integer
>
del
(
Integer
id
){
Integer
effected
=
mapper
.
deleteByPrimaryKey
(
id
);
redisTemplate
.
delete
(
ACCOMPANY_ITEM
);
return
RestResponse
.
suc
();
}
public
List
<
AccompanyingItemVo
>
listAllItem
(
List
<
Integer
>
types
){
String
typeKey
=
null
;
if
(
CollectionUtils
.
isNotEmpty
(
types
)){
typeKey
=
types
.
stream
().
sorted
(
Integer:
:
compareTo
).
map
(
String:
:
valueOf
).
reduce
(
""
,(
x
,
y
)->
x
+
":"
+
y
);
String
itemJson
=
(
String
)
itemHashOperations
.
get
(
ACCOMPANY_ITEM
,
typeKey
);
if
(!
StringUtils
.
isEmpty
(
itemJson
)){
return
JSON
.
parseObject
(
itemJson
,
new
TypeReference
<
List
<
AccompanyingItemVo
>>(){});
}
}
if
(
CollectionUtils
.
isEmpty
(
types
)){
typeKey
=
"all"
;
String
itemJson
=
(
String
)
itemHashOperations
.
get
(
ACCOMPANY_ITEM
,
typeKey
);
if
(!
StringUtils
.
isEmpty
(
itemJson
)){
return
JSON
.
parseObject
(
itemJson
,
new
TypeReference
<
List
<
AccompanyingItemVo
>>(){});
}
}
List
<
AccompanyingItemVo
>
accompanyingItemVos
=
new
ArrayList
<>();
Example
example
=
new
Example
(
AccompanyingItem
.
class
);
...
...
@@ -112,7 +141,7 @@ public class AccompanyingItemBiz extends BaseBiz<AccompanyingItemMapper, Accompa
org
.
springframework
.
beans
.
BeanUtils
.
copyProperties
(
item
,
accompanyingItemVo
);
return
accompanyingItemVo
;
}).
sorted
(
Comparator
.
comparing
(
AccompanyingItemVo:
:
getType
).
thenComparing
(
AccompanyingItemVo:
:
getRank
)).
collect
(
Collectors
.
toList
());
itemHashOperations
.
put
(
ACCOMPANY_ITEM
,
typeKey
,
JSON
.
toJSONString
(
accompanyingItemVoList
));
return
accompanyingItemVoList
;
}
...
...
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