WangHan
2024-09-12 d5855a4926926698b740bc6c7ba489de47adb68b
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
package tech.powerjob.server.core.alarm;
 
import org.springframework.beans.BeanUtils;
import tech.powerjob.common.utils.CollectionUtils;
import tech.powerjob.server.extension.alarm.AlarmTarget;
import tech.powerjob.server.persistence.remote.model.UserInfoDO;
 
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * AlarmUtils
 *
 * @author tjq
 * @since 2023/7/31
 */
public class AlarmUtils {
 
    public static List<AlarmTarget> convertUserInfoList2AlarmTargetList(List<UserInfoDO> userInfoDOS) {
        if (CollectionUtils.isEmpty(userInfoDOS)) {
            return Collections.emptyList();
        }
        return userInfoDOS.stream().map(AlarmUtils::convertUserInfo2AlarmTarget).collect(Collectors.toList());
    }
 
    public static AlarmTarget convertUserInfo2AlarmTarget(UserInfoDO userInfoDO) {
        AlarmTarget alarmTarget = new AlarmTarget();
        BeanUtils.copyProperties(userInfoDO, alarmTarget);
 
        alarmTarget.setName(userInfoDO.getUsername());
        return alarmTarget;
    }
 
}