screen-manage/src/main/java/com/moral/api/pojo/vo/account/AccountQueryVO.java
@@ -1,11 +1,17 @@
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 com.moral.api.pojo.dto.account.AccountQueryDTO;
import com.moral.constant.ResponseCodeEnum;
import lombok.Data;
import org.springframework.util.ObjectUtils;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@@ -29,16 +35,21 @@
    private List<AccountVO> accountVOs;
    public static AccountQueryVO convert(AccountQueryDTO dto){
    public static AccountQueryVO convert(AccountQueryDTO dto) {
        if (dto.getCode() != ResponseCodeEnum.SUCCESS.getCode())
            return null;
        long total = dto.getTotal();
        long current = dto.getCurrent();
        long pages = dto.getPages();
        long size = dto.getSize();
        List<AccountVO> accountVOs = new ArrayList<>();
        List<AccountDTO> accountDTOs = dto.getAccountDTOS();
        for (AccountDTO accountDTO : accountDTOs) {
            AccountVO vo = AccountVO.convert(accountDTO);
            accountVOs.add(vo);
        if (!ObjectUtils.isEmpty(accountDTOs)) {
            for (AccountDTO accountDTO : accountDTOs) {
                AccountVO vo = convertToQueryPage(accountDTO);
                accountVOs.add(vo);
            }
        }
        AccountQueryVO vo = new AccountQueryVO();
        vo.setTotal(total);
@@ -48,4 +59,28 @@
        vo.setSize(size);
        return vo;
    }
    public static AccountVO convertToQueryPage(AccountDTO dto) {
        if (dto.getAccount() == null)
            return null;
        AccountInsertVO vo = new AccountInsertVO();
        ManageAccount account = dto.getAccount();
        List<ManageRole> roles = dto.getRoles();
        List<String> roleNames = new ArrayList<>();
        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.setRoleNames(roleNames);
        //Date转换String
        Date createTime = account.getCreateTime();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String createTimeStr = sdf.format(createTime);
        vo.setCreateTime(createTimeStr);
        return vo;
    }
}