Administrator
2024-07-29 a053811c774ac07340e46561f5d2ab4d892282a0
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
package com.taoke.autopay.service.impl.agent;
 
import com.taoke.autopay.dao.agent.ChannelAgentSettingsMapper;
import com.taoke.autopay.entity.agent.ChannelAgentSettings;
import com.taoke.autopay.service.agent.ChannelAgentSettingService;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
 
@Service
public class ChannelAgentSettingServiceImpl implements ChannelAgentSettingService {
 
    @Resource
    private ChannelAgentSettingsMapper channelAgentSettingsMapper;
 
 
    @Override
    public ChannelAgentSettings selectByAgentId(Long agentId) {
        return channelAgentSettingsMapper.selectByPrimaryKey(agentId);
    }
 
    @Override
    public void update(ChannelAgentSettings settings) {
        if(settings.getUpdateTime()==null){
            settings.setUpdateTime(new Date());
        }
        channelAgentSettingsMapper.updateByPrimaryKeySelective(settings);
    }
 
    @Override
    public void add(ChannelAgentSettings settings) {
        // 如果存在就修改
        ChannelAgentSettings old=   selectByAgentId(settings.getId());
        if(old==null){
            if(settings.getCreateTime()==null){
                settings.setCreateTime(new Date());
 
            }
            channelAgentSettingsMapper.insertSelective(settings);
        }else{
            update(settings);
        }
    }
 
    @Override
    public List<ChannelAgentSettings> listByIds(List<Long> agentIds) {
        return channelAgentSettingsMapper.listByIds(agentIds);
    }
}