package com.gkhy.huataiFourierSpecialGasMonitor.application.account.converter;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
import com.gkhy.huataiFourierSpecialGasMonitor.application.account.dto.respDto.UserIdentityBindAppRespDTO;
|
import com.gkhy.huataiFourierSpecialGasMonitor.application.account.dto.respDto.UserInfoAppRespDTO;
|
import com.gkhy.huataiFourierSpecialGasMonitor.application.account.dto.respDto.UserRoleBindAppRespDTO;
|
import com.gkhy.huataiFourierSpecialGasMonitor.application.attachment.service.dto.resp.AttachmentAppRespDTO;
|
import com.gkhy.huataiFourierSpecialGasMonitor.commons.utils.BeanCopyUtils;
|
import com.gkhy.huataiFourierSpecialGasMonitor.domain.account.model.dto.SysUserRoleBindDomainDTO;
|
import com.gkhy.huataiFourierSpecialGasMonitor.domain.account.model.dto.UserInfoDomainDTO;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.stereotype.Service;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
@Service
|
public class UserInfoAppConverter {
|
|
public List<UserInfoAppRespDTO> toAppDtoList(List<UserInfoDomainDTO> domainDtoList){
|
if(domainDtoList == null || domainDtoList.isEmpty())
|
return null;
|
List<UserInfoAppRespDTO> appRespDTOList = new ArrayList<>();
|
domainDtoList.forEach(d -> {
|
appRespDTOList.add(toAppDto(d));
|
});
|
return appRespDTOList;
|
}
|
|
public UserInfoAppRespDTO toAppDto(UserInfoDomainDTO domainDto){
|
if(domainDto == null)
|
return null;
|
UserInfoAppRespDTO appDto = new UserInfoAppRespDTO();
|
BeanUtils.copyProperties(domainDto,appDto);
|
List<UserRoleBindAppRespDTO> userRoleBindAppRespDTOS = new ArrayList<>();
|
if(ObjectUtil.isNotEmpty(domainDto.getRoles())){
|
domainDto.getRoles().forEach(role -> {
|
userRoleBindAppRespDTOS.add(toUserRoleAppRestDTO(role));
|
});
|
}
|
appDto.setRoles(userRoleBindAppRespDTOS);
|
//身份
|
List<UserIdentityBindAppRespDTO> userIdentityBindAppDTOS = new ArrayList<>();
|
if(domainDto.getUserIdentities() != null){
|
userIdentityBindAppDTOS = BeanCopyUtils.copyBeanList(domainDto.getUserIdentities(), UserIdentityBindAppRespDTO.class);
|
}
|
//资质附件
|
if(domainDto.getQualificationAttDomainDTO() != null){
|
AttachmentAppRespDTO attachmentAppRespDTO = new AttachmentAppRespDTO();
|
BeanUtils.copyProperties(domainDto.getQualificationAttDomainDTO(),attachmentAppRespDTO);
|
appDto.setQualificationAttaAppRespDTO(attachmentAppRespDTO);
|
}
|
appDto.setUserIdentities(userIdentityBindAppDTOS);
|
return appDto;
|
}
|
|
private UserRoleBindAppRespDTO toUserRoleAppRestDTO(SysUserRoleBindDomainDTO role) {
|
if(role == null){
|
return null;
|
}
|
UserRoleBindAppRespDTO userRoleBindAppRespDTO = new UserRoleBindAppRespDTO();
|
BeanUtils.copyProperties(role,userRoleBindAppRespDTO);
|
return userRoleBindAppRespDTO;
|
}
|
|
}
|