luodangjia
2024-12-10 ee7ce5d1cbf80bee0a15c1e5bc5eaa30858d812b
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.hollywood.manage.service.impl;
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hollywood.common.basic.PageInfo;
import com.hollywood.common.model.*;
import com.hollywood.manage.dto.TShortPlayDTO;
import com.hollywood.manage.mapper.TShortPlayMapper;
import com.hollywood.manage.mapper.TShortPlayToTypeMapper;
import com.hollywood.manage.mapper.TShortPlayTypeMapper;
import com.hollywood.manage.mapper.TShortPlayVideoMapper;
import com.hollywood.manage.query.TShortPlayQuery;
import com.hollywood.manage.service.TShortPlayService;
import com.hollywood.manage.service.TShortPlayToTypeService;
import com.hollywood.manage.vo.TShortPlayVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
 
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 短剧管理 服务实现类
 * </p>
 *
 * @author xiaochen
 * @since 2024-02-29
 */
@Service
public class TShortPlayServiceImpl extends ServiceImpl<TShortPlayMapper, TShortPlay> implements TShortPlayService {
 
    @Autowired
    private TShortPlayToTypeMapper shortPlayToTypeMapper;
    @Autowired
    private TShortPlayTypeMapper shortPlayTypeMapper;
    @Autowired
    private TShortPlayVideoMapper shortPlayVideoMapper;
 
    @Override
    public PageInfo<TShortPlayVO> pageList(TShortPlayQuery query) {
        PageInfo<TShortPlayVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TShortPlayVO> list = this.baseMapper.pageList(query,pageInfo);
        List<TShortPlayToType> tShortPlayToTypes = shortPlayToTypeMapper.selectList(Wrappers.lambdaQuery(TShortPlayToType.class));
        for (TShortPlayVO tShortPlayVO : list) {
            List<TShortPlayToType> shortPlayToTypes = tShortPlayToTypes.stream().filter(e -> tShortPlayVO.getId().equals(e.getShortPlayId())).collect(Collectors.toList());
            List<Long> typeIds = shortPlayToTypes.stream().map(TShortPlayToType::getTypeId).collect(Collectors.toList());
            tShortPlayVO.setTypeIds(typeIds);
            // 封装类型名称
            if(!CollectionUtils.isEmpty(typeIds)){
                List<TShortPlayType> tShortPlayTypes = shortPlayTypeMapper.selectList(Wrappers.lambdaQuery(TShortPlayType.class)
                        .in(TShortPlayType::getId, typeIds));
                String typeName = tShortPlayTypes.stream().map(TShortPlayType::getTypeName).collect(Collectors.joining(","));
                tShortPlayVO.setTypeName(typeName);
            }
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
 
    @Override
    public int upAndDown(Long id, Integer status) {
        TShortPlay shortPlay = this.baseMapper.selectById(id);
        shortPlay.setStatus(status);
        return this.baseMapper.updateById(shortPlay);
    }
 
}