package com.nova.sankuai.service.impl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.nova.sankuai.domain.dto.MechanismDto;
|
import com.nova.sankuai.domain.entity.ChannelMechanismConfig;
|
import com.nova.sankuai.infra.mapper.ChannelMechanismConfigMapper;
|
import com.nova.sankuai.service.IChannelMechanismConfigService;
|
import lombok.AllArgsConstructor;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
/**
|
* @author weikangdi
|
* @create 2022/3/31
|
*/
|
@AllArgsConstructor
|
@Service
|
public class ChannelMechanismConfigServiceImpl extends ServiceImpl<ChannelMechanismConfigMapper, ChannelMechanismConfig> implements IChannelMechanismConfigService {
|
|
private final ChannelMechanismConfigMapper channelMechanismConfigMapper;
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void updateConfig(MechanismDto mechanismDto) {
|
channelMechanismConfigMapper.removeByMechanismId(mechanismDto.getId());
|
if (mechanismDto.getChannelIds() != null && mechanismDto.getChannelIds().size() > 0) {
|
List<Long> channelIds = mechanismDto.getChannelIds().stream().distinct().collect(Collectors.toList());
|
channelMechanismConfigMapper.updateConfig(channelIds, mechanismDto.getId());
|
}
|
}
|
|
@Override
|
public List<Long> getChannelsByMechanismId(Long mechanismId) {
|
List<Long> result = channelMechanismConfigMapper.getChannelsByMechanismId(mechanismId);
|
return result;
|
}
|
}
|