| | |
| | | package cn.lili.modules.lmk.service.impl; |
| | | |
| | | import cn.lili.common.enums.CollectTypeEnum; |
| | | import cn.lili.common.security.context.UserContext; |
| | | import cn.lili.modules.lmk.domain.vo.SimpleMyCollectVO; |
| | | import cn.lili.modules.lmk.domain.vo.CollectTypeNumVO; |
| | | import cn.lili.modules.goods.entity.vos.GoodsVO; |
| | | import cn.lili.modules.lmk.domain.vo.*; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import cn.lili.modules.lmk.domain.entity.MyCollect; |
| | | import cn.lili.modules.lmk.mapper.MyCollectMapper; |
| | |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import cn.lili.modules.lmk.domain.form.MyCollectForm; |
| | | import cn.lili.modules.lmk.domain.vo.MyCollectVO; |
| | | import cn.lili.modules.lmk.domain.query.MyCollectQuery; |
| | | import org.springframework.stereotype.Service; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | |
| | | private final MyCollectMapper myCollectMapper; |
| | | |
| | | private final LmkFileServiceImpl fileService; |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | |
| | | public List<CollectTypeNumVO> countNumGroupByType(String type) { |
| | | return baseMapper.countNumGroupByType(type); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Result getMyCollectList(MyCollectQuery query) { |
| | | String userId = UserContext.getCurrentUserId(); |
| | | IPage<Object> page = PageUtil.getPage(query, Object.class); |
| | | if (CollectTypeEnum.activity.getType().equals(query.getType())){ |
| | | baseMapper.getActivityCollectPage(page, userId); |
| | | List<ActivityVO> activityVOS = page.getRecords().stream() |
| | | .filter(obj -> obj instanceof ActivityVO) |
| | | .map(obj -> (ActivityVO) obj) |
| | | .collect(Collectors.toList()); |
| | | for (ActivityVO activityVO : activityVOS) { |
| | | activityVO.setUrl(fileService.getPreviewUrl(activityVO.getCover())); |
| | | } |
| | | }else if (CollectTypeEnum.video.getType().equals(query.getType())) { |
| | | baseMapper.getVideoCollectPage(page, userId); |
| | | List<VideoVO> videoList = page.getRecords().stream() |
| | | .filter(obj -> obj instanceof VideoVO) |
| | | .map(obj -> (VideoVO) obj) |
| | | .collect(Collectors.toList()); |
| | | for (VideoVO video : videoList) { |
| | | video.setCoverUrl(fileService.getPreviewUrl(video.getCoverUrl())); |
| | | } |
| | | }else if (CollectTypeEnum.goods.getType().equals(query.getType())) { |
| | | baseMapper.getGoodsCollectPage(page, userId); |
| | | |
| | | } |
| | | |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | | } |