package com.moral.api.pojo.vo.account;
|
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.moral.api.entity.ManageAccount;
|
import com.moral.api.entity.ManageRole;
|
import com.moral.api.pojo.dto.account.AccountDTO;
|
import lombok.Data;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* @ClassName AccountVO
|
* @Description TODO
|
* @Author 陈凯裕
|
* @Date 2021/3/15 14:42
|
* @Version TODO
|
**/
|
@Data
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
public class AccountVO {
|
|
private String code;
|
|
private Integer id;
|
|
private String userName;
|
|
private String email;
|
|
private String mobile;
|
|
private String wechat;
|
|
private List<String> roleNames;
|
|
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()));
|
vo.setId(account.getId());
|
vo.setUserName(account.getUserName());
|
vo.setEmail(account.getEmail());
|
vo.setMobile(account.getMobile());
|
vo.setWechat(account.getWechat());
|
vo.setRoleNames(roleNames);
|
return vo;
|
}
|
}
|