ny
昨天 b6f169fe43a2b13f351aefc152374fc7f0bc8cb7
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package jnpf.message.service.impl;
 
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import jnpf.base.service.SuperServiceImpl;
import jnpf.message.entity.MessageMonitorEntity;
import jnpf.message.mapper.MessageMonitorMapper;
import jnpf.message.model.messagemonitor.MessageMonitorForm;
import jnpf.message.model.messagemonitor.MessageMonitorPagination;
import jnpf.message.service.MessageMonitorService;
import jnpf.permission.UserApi;
import jnpf.permission.entity.UserEntity;
import jnpf.util.JsonUtil;
import jnpf.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
 
/**
 * 消息监控
 * 版本: V3.2.0
 * 版权: 引迈信息技术有限公司(https://www.jnpfsoft.com)
 * 作者: JNPF开发平台组
 * 日期: 2022-08-22
 */
@Service
public class MessageMonitorServiceImpl extends SuperServiceImpl<MessageMonitorMapper, MessageMonitorEntity> implements MessageMonitorService {
 
    @Autowired
    private UserApi userApi;
 
    @Override
    public List<MessageMonitorEntity> getList(MessageMonitorPagination messageMonitorPagination) {
        return this.baseMapper.getList(messageMonitorPagination);
    }
 
    @Override
    public List<MessageMonitorEntity> getTypeList(MessageMonitorPagination messageMonitorPagination, String dataType) {
        return this.baseMapper.getTypeList(messageMonitorPagination, dataType);
    }
 
 
    @Override
    public MessageMonitorEntity getInfo(String id) {
        return this.baseMapper.getInfo(id);
    }
 
    @Override
    public void create(MessageMonitorEntity entity) {
        this.save(entity);
    }
 
    @Override
    public boolean update(String id, MessageMonitorEntity entity) {
        entity.setId(id);
        return this.updateById(entity);
    }
 
    @Override
    public void delete(MessageMonitorEntity entity) {
        if (entity != null) {
            this.removeById(entity.getId());
        }
    }
 
    @Override
    public boolean checkForm(MessageMonitorForm form, int i) {
        int total = 0;
        if (total > 0) {
            return true;
        }
        return false;
    }
 
    @Override
    public void emptyMonitor() {
        this.baseMapper.emptyMonitor();
    }
 
    @Override
    @DSTransactional
    public boolean delete(String[] ids) {
        this.baseMapper.delete(ids);
        return true;
    }
 
    /**
     * 用户id转名称(多选)
     *
     * @param ids
     * @return
     */
    @Override
    public String userSelectValues(String ids) {
        if (StringUtil.isEmpty(ids)) {
            return ids;
        }
        if (ids.contains("[")) {
            List<String> nameList = new ArrayList<>();
            List<String> jsonToList = JsonUtil.getJsonToList(ids, String.class);
            for (String userId : jsonToList) {
                UserEntity info = userApi.getInfoById(userId);
                nameList.add(Objects.nonNull(info) ? info.getRealName() + "/" + info.getAccount() : userId);
            }
            return String.join(";", nameList);
        } else {
            List<String> userInfoList = new ArrayList<>();
            String[] idList = ids.split(",");
            if (idList.length > 0) {
                for (String id : idList) {
                    UserEntity userEntity = userApi.getInfoById(id);
                    if (ObjectUtil.isNotEmpty(userEntity)) {
                        String info = userEntity.getRealName() + "/" + userEntity.getAccount();
                        userInfoList.add(info);
                    }
                }
            }
            return String.join("-", userInfoList);
        }
    }
}