| package com.moral.api.pojo.vo.user; | 
|   | 
| import com.fasterxml.jackson.annotation.JsonInclude; | 
| import com.moral.api.entity.Organization; | 
| import com.moral.api.entity.User; | 
| import com.moral.api.pojo.dto.user.UserDTO; | 
| import com.moral.api.pojo.dto.user.UserQueryDTO; | 
| import com.moral.constant.ResponseCodeEnum; | 
| import com.moral.util.DateUtils; | 
| import lombok.Data; | 
| import org.springframework.util.ObjectUtils; | 
|   | 
| import java.util.ArrayList; | 
| import java.util.List; | 
|   | 
| /** | 
|  * @ClassName UserQueryVO | 
|  * @Description TODO | 
|  * @Author 陈凯裕 | 
|  * @Date 2021/4/28 14:58 | 
|  * @Version TODO | 
|  **/ | 
| @Data | 
| @JsonInclude(JsonInclude.Include.NON_EMPTY) | 
| public class UserQueryVO { | 
|   | 
|     private long pages; | 
|   | 
|     private long total; | 
|   | 
|     private long current; | 
|   | 
|     private long size; | 
|   | 
|     private List<UserVO> userVOs; | 
|   | 
|     public static UserQueryVO convert(UserQueryDTO dto) { | 
|         if (dto.getCode() != ResponseCodeEnum.SUCCESS.getCode()) | 
|             return null; | 
|         UserQueryVO vo = new UserQueryVO(); | 
|         long pages = dto.getPages(); | 
|         long total = dto.getTotal(); | 
|         long current = dto.getCurrent(); | 
|         long size = dto.getSize(); | 
|         List<UserDTO> dtos = dto.getUserDTOS(); | 
|         List<UserVO>  userVOs = new ArrayList<>(); | 
|         if(!ObjectUtils.isEmpty(dtos)){ | 
|             for (UserDTO userDTO : dtos) { | 
|                 UserVO userVO = convertToQueryPage(userDTO); | 
|                 userVOs.add(userVO); | 
|             } | 
|         } | 
|         vo.setPages(pages); | 
|         vo.setTotal(total); | 
|         vo.setCurrent(current); | 
|         vo.setSize(size); | 
|         vo.setUserVOs(userVOs); | 
|         return vo; | 
|     } | 
|   | 
|     private static UserVO convertToQueryPage(UserDTO dto){ | 
|         UserVO vo = new UserVO(); | 
|         User user = dto.getUser(); | 
|         Organization organization = dto.getOrganization(); | 
|         vo.setAccount(user.getAccount()); | 
|         vo.setOrganizationName(organization.getName()); | 
|         vo.setId(user.getId()); | 
|         vo.setCreateTime(DateUtils.dateToDateString(user.getCreateTime(),"yyyy-MM-dd")); | 
|         vo.setExpireTime(DateUtils.dateToDateString(user.getExpireTime(),"yyyy-MM-dd")); | 
|         vo.setEmail(user.getEmail()); | 
|         vo.setMobile(user.getMobile()); | 
|         return vo; | 
|     } | 
| } |