|
@@ -80,7 +80,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
private CommunityUserInfoMapper communityUserInfoMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- private ICommunityArticleCircleService communityArticleCircleService;
|
|
|
+ private ICommunityArticleClassService communityArticleClassService;
|
|
|
|
|
|
@Autowired
|
|
|
private CommunityCollectionArticleMapper communityCollectionArticleMapper;
|
|
@@ -111,9 +111,8 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
@Override
|
|
|
public List<CommunityArticleVo> selectCommunityArticleList(TableDataInfo rspData, CommunityArticle communityArticle, int pageNum, int pageSize, int searchType) {
|
|
|
//找出板块下的分类
|
|
|
- Long classId = communityArticle.getClassId();
|
|
|
+ List<Long> classIds = communityArticle.getClassIds();
|
|
|
Long id = communityArticle.getId();
|
|
|
- Long circleId = communityArticle.getCircleId();
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
List<CommunityArticleVo> communityArticleVos = null;
|
|
|
if (Objects.nonNull(id)) {
|
|
@@ -123,34 +122,14 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
communityArticleMapper.updateById(article);
|
|
|
}
|
|
|
|
|
|
- List<Long> circleIds = null;
|
|
|
- if (Objects.nonNull(classId)) {
|
|
|
- List<CommunityClassCircle> classCircles = communityClassCircleMapper.selectList(new QueryWrapper<CommunityClassCircle>().eq("class_id", classId));
|
|
|
- circleIds = new ArrayList<>();
|
|
|
- for (CommunityClassCircle classCircle : classCircles) {
|
|
|
- circleIds.add(classCircle.getCircleId());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //如果有圈子id,则按照传递的圈子id取文章数据
|
|
|
- if (Objects.nonNull(circleId)) {
|
|
|
- circleIds = new ArrayList<>();
|
|
|
- circleIds.add(circleId);
|
|
|
- }
|
|
|
-
|
|
|
- //如果没有圈子,则返回null数据
|
|
|
- if (Objects.isNull(circleIds) || circleIds.isEmpty()) {
|
|
|
- communityArticleVos = new ArrayList<>();
|
|
|
- }
|
|
|
-
|
|
|
//根据分类查找文章
|
|
|
int offset = (pageNum - 1) * pageSize;
|
|
|
- communityArticleVos = communityArticleMapper.selectCommunityArticleList(communityArticle, circleIds, offset, pageSize, searchType);
|
|
|
- rspData.setTotal(communityArticleMapper.selectCommunityArticleCount(communityArticle, circleIds, searchType));
|
|
|
+ communityArticleVos = communityArticleMapper.selectCommunityArticleList(communityArticle, classIds, offset, pageSize, searchType);
|
|
|
+ rspData.setTotal(communityArticleMapper.selectCommunityArticleCount(communityArticle, classIds, searchType));
|
|
|
List<CommunityArticleVo> communityArticleVos_copy = new ArrayList<>(communityArticleVos);
|
|
|
for (CommunityArticleVo articleVo : communityArticleVos_copy) {
|
|
|
List<Map<String, Object>> imageList = articleVo.getImageList();
|
|
|
- articleVo.setCircleIds(circleIds);
|
|
|
+ articleVo.setClassIds(classIds);
|
|
|
List<CommunityArticleImages> videoList = new ArrayList<>();
|
|
|
CommunityArticleImages videos = null;
|
|
|
for (Map<String, Object> image : imageList) {
|
|
@@ -297,26 +276,26 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
articleImages = new CommunityArticleImages();
|
|
|
articleImages.setArticleId(communityArticle.getId());
|
|
|
articleImages.setImageUrl(image);
|
|
|
- articleImages.setUpdateBy(userId);
|
|
|
- articleImages.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
articleImages.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
articleImages.setCreateBy(userId);
|
|
|
communityArticleImagesMapper.insert(articleImages);
|
|
|
}
|
|
|
|
|
|
- //插入圈子
|
|
|
- List<String> circleIds = communityArticle.getCircleIds();
|
|
|
- List<CommunityArticleCircle> articleCircles = new ArrayList<>();
|
|
|
- CommunityArticleCircle articleCircle = null;
|
|
|
- for (String circleId : circleIds) {
|
|
|
- articleCircle = new CommunityArticleCircle();
|
|
|
- articleCircle.setCircleId(Long.parseLong(circleId));
|
|
|
- articleCircle.setArticleId(communityArticle.getId());
|
|
|
- articleCircle.setCreateBy(userId);
|
|
|
- articleCircle.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
- articleCircles.add(articleCircle);
|
|
|
+ //插入板块
|
|
|
+ List<Long> classIds = communityArticle.getClassIds();
|
|
|
+ if (!classIds.isEmpty()) {
|
|
|
+ List<CommunityArticleClass> articleClasses = new ArrayList<>();
|
|
|
+ CommunityArticleClass articleClass = null;
|
|
|
+ for (Long classId : classIds) {
|
|
|
+ articleClass = new CommunityArticleClass();
|
|
|
+ articleClass.setClassId(classId);
|
|
|
+ articleClass.setArticleId(communityArticle.getId());
|
|
|
+ articleClass.setCreateBy(userId);
|
|
|
+ articleClass.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
+ articleClasses.add(articleClass);
|
|
|
+ }
|
|
|
+ communityArticleClassService.saveBatch(articleClasses);
|
|
|
}
|
|
|
- communityArticleCircleService.saveBatch(articleCircles);
|
|
|
|
|
|
//插入合集
|
|
|
List<String> collectionIds = communityArticle.getCollectionIds();
|