admin
2025-08-08 035edfa382d349ba66240fbfef68c14c7cfc95d1
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package com.taoke.autopay.service.impl;
 
import com.taoke.autopay.dao.ClientAdditionalInfoMapper;
import com.taoke.autopay.entity.ClientAdditionalInfo;
import com.taoke.autopay.entity.SystemConfigKeyEnum;
import com.taoke.autopay.exception.LoginException;
import com.taoke.autopay.service.ClientAdditionalInfoService;
import com.taoke.autopay.service.SystemConfigService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
/**
 * 客户端附加信息服务
 */
@Service
public class ClientAdditionalInfoServiceImpl implements ClientAdditionalInfoService {
    @Resource
    private ClientAdditionalInfoMapper clientAdditionalInfoMapper;
 
    @Resource
    private SystemConfigService systemConfigService;
 
    /**
     * 增加客户端附加信息
     *
     * @param clientAdditionalInfo 客户端附加信息
     * @return 是否添加成功
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean addClientAdditionalInfo(ClientAdditionalInfo clientAdditionalInfo) {
        if (clientAdditionalInfo == null) {
            return false;
        }
        clientAdditionalInfo.setCreateTime(new Date());
        clientAdditionalInfo.setUpdateTime(new Date());
        return clientAdditionalInfoMapper.insert(clientAdditionalInfo) > 0;
    }
 
    /**
     * 更新客户端附加信息
     *
     * @param clientAdditionalInfo 客户端附加信息
     * @return 是否更新成功
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateClientAdditionalInfo(ClientAdditionalInfo clientAdditionalInfo) {
        if (clientAdditionalInfo == null || clientAdditionalInfo.getId() == null) {
            return false;
        }
        clientAdditionalInfo.setUpdateTime(new Date());
        return clientAdditionalInfoMapper.updateByPrimaryKey(clientAdditionalInfo) > 0;
    }
 
    /**
     * 根据设备ID列表获取信息的map
     *
     * @param clientIds 设备ID列表
     * @return 客户端附加信息映射Map,key为客户端ID,value为客户端附加信息
     */
    @Override
    public Map<Long, ClientAdditionalInfo> getClientAdditionalInfoMap(List<Long> clientIds) {
        if (clientIds == null || clientIds.isEmpty()) {
            return new HashMap<>();
        }
        List<ClientAdditionalInfo> clientAdditionalInfos = clientAdditionalInfoMapper.listByIds(clientIds);
        return clientAdditionalInfos.stream()
                .collect(Collectors.toMap(ClientAdditionalInfo::getId, info -> info));
    }
 
    /**
     * 根据设备ID获取信息
     *
     * @param clientId 设备ID
     * @return 客户端附加信息
     */
    @Override
    public ClientAdditionalInfo getClientAdditionalInfoByClientId(Long clientId) {
        if (clientId == null) {
            return null;
        }
        return clientAdditionalInfoMapper.selectByPrimaryKey(clientId);
    }
}