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);
|
}
|
|
}
|