zhanghua
2023-12-12 bc2da7908a227c09e5cc7b6d8dab3e9c94b784a1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.ycl.service.resources.impl;
 
 
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycl.entity.resources.ImageResources;
import com.ycl.mapper.resources.ImageResourcesMapper;
import com.ycl.service.resources.IImageResourcesService;
import com.ycl.vo.resources.MediaVO;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author lyq
 * @since 2022-11-08
 */
@Service
public class ImageResourcesServiceImpl extends ServiceImpl<ImageResourcesMapper, ImageResources> implements IImageResourcesService {
 
    @Resource
    ImageResourcesMapper imageResourcesMapper;
 
    @Override
    public Page<MediaVO> selectImages(String type, String startTime, String endTime, Long size, Long current) {
        Page<MediaVO> imagesVOPage = new Page<>();
        imagesVOPage.setCurrent(current);
        imagesVOPage.setSize(size);
        return imageResourcesMapper.selectImagePage(imagesVOPage, type, startTime, endTime);
    }
 
    @Override
    public Map<Long, String> getUrlMap(Collection<Long> ids, String type) {
        LambdaQueryWrapper<ImageResources> wrapper = new QueryWrapper<ImageResources>().lambda().in(ImageResources::getBelongToId, ids).eq(ImageResources::getType, type);
        List<ImageResources> list = imageResourcesMapper.selectList(wrapper);
        if (CollUtil.isEmpty(list)) {
            return new HashMap<>();
        }
        return list.stream().collect(Collectors.toMap(ImageResources::getBelongToId, ImageResources::getUrl, (v1, v2) -> v1));
    }
 
}