GroupOneConvert.java
4.35 KB
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
package cn.com.glsx.entmicro.converter;
import cn.com.glsx.entmicro.dto.DracScrmWelcomeConfigDTO;
import cn.com.glsx.entmicro.entity.GroupOne;
import cn.com.glsx.entmicro.entity.GroupOneTemplate;
import cn.com.glsx.entmicro.entity.GroupTemplateUser;
import cn.com.glsx.entmicro.model.response.*;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author wangxw
* @version 1.0.0
* @ClassName GroupOneConvert.java
* @description: ${description}
* @createTime 2021年11月12日 13:08:00
*/
public class GroupOneConvert {
public static GroupOneTemplateResponse convertGroupOneTemplateEntity(GroupOneTemplate groupOneTemplate) {
GroupOneTemplateResponse groupOneTemplateResponse = new GroupOneTemplateResponse();
BeanUtils.copyProperties(groupOneTemplate, groupOneTemplateResponse);
return groupOneTemplateResponse;
}
public static List<GroupTemplateUserResponse> convertGroupOneTemplateUserList(List<GroupTemplateUser> staffList, Map<Integer, EntmicroStaffResponse> staffMapper, Map<Integer, EntmicroStaffResponse> staffDepartmentMapper) {
if (CollectionUtils.isEmpty(staffList)) {
return null;
}
List<GroupTemplateUserResponse> templateUserResponseList = new ArrayList<>();
for (GroupTemplateUser templateUser : staffList) {
templateUserResponseList.add(convertGroupOneTemplateUser(templateUser, staffMapper.get(templateUser.getStaffId()), staffDepartmentMapper.get(templateUser.getStaffId())));
}
return templateUserResponseList;
}
private static GroupTemplateUserResponse convertGroupOneTemplateUser(GroupTemplateUser templateUser, EntmicroStaffResponse entmicroStaffResponse, EntmicroStaffResponse staffDepartment) {
GroupTemplateUserResponse groupTemplateUserResponse = new GroupTemplateUserResponse();
BeanUtils.copyProperties(templateUser, groupTemplateUserResponse);
if (entmicroStaffResponse!=null) {
groupTemplateUserResponse.setStaffName(entmicroStaffResponse.getStaffName());
groupTemplateUserResponse.setUserId(entmicroStaffResponse.getUserId());
groupTemplateUserResponse.setAvatar(entmicroStaffResponse.getThumbAvatar());
}
if (staffDepartment!=null) {
groupTemplateUserResponse.setDepartmentName(staffDepartment.getDepartmentName());
}
return groupTemplateUserResponse;
}
public static List<GroupTemplateAttachmentResponse> convertWelcomeConfigList(List<DracScrmWelcomeConfigDTO> welcomeConfigList) {
if (CollectionUtils.isEmpty(welcomeConfigList)) {
return null;
}
List<GroupTemplateAttachmentResponse> attachmentResponseList = new ArrayList<>();
for (DracScrmWelcomeConfigDTO welcomeConfig:welcomeConfigList) {
attachmentResponseList.add(convertWelcomeConfig(welcomeConfig));
}
return attachmentResponseList;
}
private static GroupTemplateAttachmentResponse convertWelcomeConfig(DracScrmWelcomeConfigDTO welcomeConfig) {
GroupTemplateAttachmentResponse attachmentResponse = new GroupTemplateAttachmentResponse();
attachmentResponse.setId(welcomeConfig.getId());
attachmentResponse.setAttType(welcomeConfig.getAttType());
attachmentResponse.setAttContent(welcomeConfig.getAttContent());
attachmentResponse.setMediaId(welcomeConfig.getMediaId());
attachmentResponse.setDelFlag(welcomeConfig.getDelFlag());
attachmentResponse.setCreatedTime(welcomeConfig.getCreatedTime());
return attachmentResponse;
}
public static List<GroupOneResponse> convertGroupOneEntityList(List<GroupOne> groupOneList) {
if (CollectionUtils.isEmpty(groupOneList)) {
return null;
}
List<GroupOneResponse> convertList = new ArrayList<>();
for (GroupOne groupOne : groupOneList) {
convertList.add(convertGroupOneEntity(groupOne));
}
return convertList;
}
public static GroupOneResponse convertGroupOneEntity(GroupOne groupOne) {
if (groupOne==null) {
return null;
}
GroupOneResponse groupOneResponse = new GroupOneResponse();
BeanUtils.copyProperties(groupOne, groupOneResponse);
return groupOneResponse;
}
}