| | |
| | | import com.moral.api.entity.ManageRole; |
| | | import com.moral.api.pojo.dto.account.AccountDTO; |
| | | import lombok.Data; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | public class AccountVO { |
| | | |
| | | private String code; |
| | | |
| | | private Integer id; |
| | | |
| | | private String userName; |
| | |
| | | |
| | | private List<String> roleNames; |
| | | |
| | | public static AccountVO convert(AccountDTO dto){ |
| | | if(dto.getAccount()==null) |
| | | public static AccountVO convert(AccountDTO dto) { |
| | | if (dto.getAccount() == null) |
| | | return null; |
| | | AccountVO vo = new AccountVO(); |
| | | ManageAccount account = dto.getAccount(); |
| | | List<ManageRole> roles = dto.getRoles(); |
| | | List<String> roleNames = new ArrayList<>(); |
| | | roles.forEach(role->roleNames.add(role.getName())); |
| | | if (!ObjectUtils.isEmpty(roles)) { |
| | | roles.forEach(role -> roleNames.add(role.getName())); |
| | | } |
| | | vo.setId(account.getId()); |
| | | vo.setUserName(account.getUserName()); |
| | | vo.setEmail(account.getEmail()); |