lizijie
2021-03-18 f1c3c5f0b840df7fa5fe08a69186c9f2b52ce243
screen-manage/src/main/java/com/moral/api/pojo/vo/account/AccountVO.java
@@ -5,6 +5,7 @@
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;
@@ -18,8 +19,8 @@
 **/
@Data
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class AccountVO {
    private Integer id;
    private String userName;
@@ -30,24 +31,23 @@
    private String wechat;
    private String isDelete;
    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());
        vo.setMobile(account.getMobile());
        vo.setWechat(account.getWechat());
        vo.setIsDelete(account.getIsDelete());
        vo.setRoleNames(roleNames);
        return vo;
    }