myjf007
2024-11-04 627b61d17da1dbf02c0363c659b728627dd42890
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
package com.nova.sankuai.service.impl;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nova.sankuai.domain.entity.SyncChannelConfig;
import com.nova.sankuai.domain.entity.SyncConfig;
import com.nova.sankuai.infra.mapper.SyncChannelConfigMapper;
import com.nova.sankuai.service.ISyncChannelConfigService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
 
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * @author weikangdi
 * @create 2022/2/21
 */
@AllArgsConstructor
@Service
public class SyncChannelConfigServiceImpl extends ServiceImpl<SyncChannelConfigMapper, SyncChannelConfig> implements ISyncChannelConfigService {
 
    private final SyncChannelConfigMapper syncChannelConfigMapper;
 
    @Override
    public void updateConfig(SyncConfig syncConfig) {
        syncChannelConfigMapper.removeByConfigId(syncConfig.getId());
        if (SyncConfig.CHANNEL_NONE == syncConfig.getChannelConfig()) {
            syncConfig.setChannelIds(null);
        }
        if (syncConfig.getChannelIds() != null && syncConfig.getChannelIds().size() > 0) {
            List<Long> channelIds = syncConfig.getChannelIds().stream().distinct().collect(Collectors.toList());
            syncChannelConfigMapper.updateConfig(channelIds, syncConfig.getId());
        }
    }
 
    @Override
    public List<Long> getChannelsByConfigId(Long configId) {
        List<Long> result = syncChannelConfigMapper.getChannelsByConfigId(configId);
        return result;
    }
}