“djh”
2024-12-05 eee41a5fb58e6547a43929430f4b72908119db6e
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
package com.gkhy.testFourierSpecialGasMonitor.domain.account.converter;
 
import com.gkhy.testFourierSpecialGasMonitor.application.account.dto.respDto.SysDepartmentAppDTO;
import com.gkhy.testFourierSpecialGasMonitor.domain.account.entity.SysDepartment;
import com.gkhy.testFourierSpecialGasMonitor.domain.account.model.dto.SysDepartmentDomainDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * @email 1603559716@qq.com
 * @author: zf
 * @date: 2023/3/9
 * @time: 8:55
 */
@Component
public class SysDeparmentConverter {
    public SysDepartmentDomainDTO sysDepDomainDTOConverter(SysDepartment sysDepartment){
        if (sysDepartment == null){
            return null;
        }
        SysDepartmentDomainDTO sysDepartmentDomainDTO = new SysDepartmentDomainDTO();
        BeanUtils.copyProperties(sysDepartment,sysDepartmentDomainDTO);
        return sysDepartmentDomainDTO;
    }
 
    public List<SysDepartmentAppDTO> sysDepAppDTOListConverter(List<SysDepartmentDomainDTO> list) {
        List<SysDepartmentAppDTO> appDTOList = new ArrayList<>();
        if(!CollectionUtils.isEmpty(list)){
            for (SysDepartmentDomainDTO sysDepartmentDomainDTO : list){
                SysDepartmentAppDTO sysDepartmentAppDTO = new SysDepartmentAppDTO();
                BeanUtils.copyProperties(sysDepartmentDomainDTO,sysDepartmentAppDTO);
                sysDepartmentAppDTO.setChildren(sysDepAppDTOListConverter(sysDepartmentDomainDTO.getChildren()));
                appDTOList.add(sysDepartmentAppDTO);
            }
        }
        return appDTOList;
    }
}