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 7c7f34e9
authored
Jan 05, 2021
by
18356073052
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
聊天工具侧边栏素材信息
1 parent
7bbed6c2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
116 additions
and
0 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
0 → 100644
View file @
7c7f34e
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
import
com.linkwechat.wecom.domain.WeChatItem
;
import
com.linkwechat.wecom.domain.WeChatSide
;
import
com.linkwechat.wecom.domain.WeMaterial
;
import
com.linkwechat.wecom.domain.dto.WeChatItemDto
;
import
com.linkwechat.wecom.mapper.WeChatItemMapper
;
import
com.linkwechat.wecom.mapper.WeChatSideMapper
;
import
com.linkwechat.wecom.service.IWeChatItemService
;
import
com.linkwechat.wecom.service.IWeMaterialService
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
/**
*
* 聊天工具侧边栏
* @author kewen
*/
@Service
public
class
WeChatItemServiceImpl
extends
ServiceImpl
<
WeChatItemMapper
,
WeChatItem
>
implements
IWeChatItemService
{
@Autowired
private
WeChatItemMapper
weChatItemMapper
;
@Autowired
private
IWeMaterialService
weMaterialService
;
@Autowired
private
WeChatSideMapper
weChatSideMapper
;
@Override
public
int
checkItems
(
WeChatItemDto
chatItemDto
)
{
List
<
Long
>
materialIds
=
new
ArrayList
<>();
if
(
chatItemDto
.
getCheckAll
().
equals
(
"0"
)){
List
<
WeMaterial
>
weMaterials
=
weMaterialService
.
findWeMaterials
(
null
,
null
,
chatItemDto
.
getMediaType
());
if
(
CollectionUtils
.
isNotEmpty
(
weMaterials
)){
materialIds
=
weMaterials
.
stream
().
map
(
WeMaterial:
:
getId
).
collect
(
Collectors
.
toList
());
}
}
else
{
materialIds
=
chatItemDto
.
getMaterialIds
();
}
List
<
Long
>
finalMaterialIds
=
materialIds
;
Optional
.
ofNullable
(
materialIds
).
ifPresent
(
s
->{
List
<
WeChatItem
>
items
=
new
ArrayList
<>();
finalMaterialIds
.
forEach
(
materialId
->{
WeChatItem
item
=
new
WeChatItem
();
item
.
setItemId
(
SnowFlakeUtil
.
nextId
());
item
.
setMaterialId
(
materialId
);
item
.
setSideId
(
chatItemDto
.
getSideId
());
items
.
add
(
item
);
});
weChatItemMapper
.
dropItem
(
chatItemDto
.
getSideId
());
weChatItemMapper
.
addItem
(
items
);
checkItemsTotal
(
chatItemDto
,
finalMaterialIds
);
}
);
return
1
;
}
/**
* 更新该次选择的素材数
*
* @param chatItemDto 侧边栏信息
* @param finalMaterialIds 素材id列表
*/
private
void
checkItemsTotal
(
WeChatItemDto
chatItemDto
,
List
<
Long
>
finalMaterialIds
)
{
WeChatSide
side
=
new
WeChatSide
();
side
.
setSideId
(
chatItemDto
.
getSideId
());
side
.
setTotal
(
finalMaterialIds
.
size
());
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