Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 9bf520c8
authored
Mar 29, 2021
by
leejoker
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
🐛
修复当items列表为空时,sql执行错误
1 parent
fe302ca3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
51 deletions
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeChatItemServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeChatItemServiceImpl.java
View file @
9bf520c
...
@@ -21,8 +21,8 @@ import java.util.Optional;
...
@@ -21,8 +21,8 @@ import java.util.Optional;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
*
* 聊天工具侧边栏
* 聊天工具侧边栏
*
* @author kewen
* @author kewen
*/
*/
@Service
@Service
...
@@ -39,84 +39,51 @@ public class WeChatItemServiceImpl extends ServiceImpl<WeChatItemMapper, WeChatI
...
@@ -39,84 +39,51 @@ public class WeChatItemServiceImpl extends ServiceImpl<WeChatItemMapper, WeChatI
@Override
@Override
public
int
checkItems
(
WeChatItemDto
chatItemDto
)
{
public
int
checkItems
(
WeChatItemDto
chatItemDto
)
{
List
<
Long
>
materialIds
=
new
ArrayList
<>();
if
(
"0"
.
equals
(
chatItemDto
.
getCheckAll
()))
{
List
<
Long
>
materialIds
=
new
ArrayList
<>();
if
(
"0"
.
equals
(
chatItemDto
.
getCheckAll
())){
List
<
WeMaterial
>
weMaterials
=
weMaterialService
.
findWeMaterials
(
null
,
null
,
chatItemDto
.
getMediaType
());
List
<
WeMaterial
>
weMaterials
=
weMaterialService
.
findWeMaterials
(
null
,
null
,
chatItemDto
.
getMediaType
());
if
(
CollectionUtils
.
isNotEmpty
(
weMaterials
))
{
if
(
CollectionUtils
.
isNotEmpty
(
weMaterials
)){
materialIds
=
weMaterials
.
stream
().
map
(
WeMaterial:
:
getId
).
collect
(
Collectors
.
toList
());
materialIds
=
weMaterials
.
stream
().
map
(
WeMaterial:
:
getId
).
collect
(
Collectors
.
toList
());
}
}
}
else
{
}
else
{
materialIds
=
chatItemDto
.
getMaterialIds
();
materialIds
=
chatItemDto
.
getMaterialIds
();
}
}
List
<
Long
>
finalMaterialIds
=
materialIds
;
List
<
Long
>
finalMaterialIds
=
materialIds
;
Optional
.
ofNullable
(
materialIds
).
ifPresent
(
Optional
.
ofNullable
(
materialIds
).
ifPresent
(
s
->
{
s
->{
List
<
WeChatItem
>
items
=
new
ArrayList
<>();
finalMaterialIds
.
forEach
(
materialId
->
{
List
<
WeChatItem
>
items
=
new
ArrayList
<>();
WeChatItem
item
=
new
WeChatItem
();
finalMaterialIds
.
forEach
(
materialId
->{
WeChatItem
item
=
new
WeChatItem
();
item
.
setItemId
(
SnowFlakeUtil
.
nextId
());
item
.
setItemId
(
SnowFlakeUtil
.
nextId
());
item
.
setMaterialId
(
materialId
);
item
.
setMaterialId
(
materialId
);
item
.
setSideId
(
chatItemDto
.
getSideId
());
item
.
setSideId
(
chatItemDto
.
getSideId
());
items
.
add
(
item
);
items
.
add
(
item
);
});
});
weChatItemMapper
.
dropItem
(
chatItemDto
.
getSideId
());
weChatItemMapper
.
dropItem
(
chatItemDto
.
getSideId
());
if
(
CollectionUtils
.
isNotEmpty
(
items
))
{
weChatItemMapper
.
addItem
(
items
);
weChatItemMapper
.
addItem
(
items
);
}
checkItemsTotal
(
chatItemDto
,
finalMaterialIds
);
checkItemsTotal
(
chatItemDto
,
finalMaterialIds
);
}
}
);
);
return
1
;
return
1
;
}
}
@Override
@Override
public
List
<
WeChatSideVo
>
chatItems
(
Long
sideId
,
String
keyword
,
String
mediaType
,
String
userId
)
{
public
List
<
WeChatSideVo
>
chatItems
(
Long
sideId
,
String
keyword
,
String
mediaType
,
String
userId
)
{
return
weChatItemMapper
.
findChatItems
(
sideId
,
keyword
,
mediaType
,
userId
);
return
weChatItemMapper
.
findChatItems
(
sideId
,
keyword
,
mediaType
,
userId
);
}
}
/**
/**
* 更新该次选择的素材数
* 更新该次选择的素材数
*
*
* @param chatItemDto 侧边栏信息
* @param chatItemDto
侧边栏信息
* @param finalMaterialIds 素材id列表
* @param finalMaterialIds 素材id列表
*/
*/
private
void
checkItemsTotal
(
WeChatItemDto
chatItemDto
,
List
<
Long
>
finalMaterialIds
)
{
private
void
checkItemsTotal
(
WeChatItemDto
chatItemDto
,
List
<
Long
>
finalMaterialIds
)
{
WeChatSide
side
=
new
WeChatSide
();
WeChatSide
side
=
new
WeChatSide
();
side
.
setSideId
(
chatItemDto
.
getSideId
());
side
.
setSideId
(
chatItemDto
.
getSideId
());
side
.
setTotal
(
finalMaterialIds
.
size
());
side
.
setTotal
(
finalMaterialIds
.
size
());
weChatSideMapper
.
updateWeChatSideById
(
side
);
weChatSideMapper
.
updateWeChatSideById
(
side
);
}
}
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment