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 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 channelIds = mechanismDto.getChannelIds().stream().distinct().collect(Collectors.toList()); channelMechanismConfigMapper.updateConfig(channelIds, mechanismDto.getId()); } } @Override public List getChannelsByMechanismId(Long mechanismId) { List result = channelMechanismConfigMapper.getChannelsByMechanismId(mechanismId); return result; } }