| | |
| | | import com.moral.api.entity.ManageRole; |
| | | import com.moral.api.pojo.dto.login.AccountInfoDTO; |
| | | import lombok.Data; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | private List<ManageMenu> menus; |
| | | |
| | | /** |
| | | * @Description: DTO转换VO |
| | | * @Param: [dto] |
| | | * @return: com.moral.api.pojo.vo.login.AccountInfoVO |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/13 |
| | | */ |
| | | public static AccountInfoVO convert(AccountInfoDTO dto){ |
| | | * @Description: DTO转换VO |
| | | * @Param: [dto] |
| | | * @return: com.moral.api.pojo.vo.login.AccountInfoVO |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/13 |
| | | */ |
| | | public static AccountInfoVO convert(AccountInfoDTO dto) { |
| | | AccountInfoVO vo = new AccountInfoVO(); |
| | | ManageAccount account = dto.getAccount(); |
| | | List<ManageMenu> menus = dto.getMenus(); |
| | | List<ManageRole> roles = dto.getRoles(); |
| | | //封装roleNames |
| | | ArrayList<String> roleNames = new ArrayList<>(); |
| | | roles.forEach(role->roleNames.add(role.getName())); |
| | | if (!ObjectUtils.isEmpty(roles)) { |
| | | roles.forEach(role -> roleNames.add(role.getName())); |
| | | } |
| | | /*过滤menu无用属性*/ |
| | | for (ManageMenu menu : menus) { |
| | | menu.setCreateTime(null); |
| | | menu.setIsDelete(null); |
| | | menu.setUpdateTime(null); |
| | | menu.setParentId(null); |
| | | List<ManageMenu> children = menu.getChildren(); |
| | | for (ManageMenu child : children) { |
| | | child.setCreateTime(null); |
| | | child.setIsDelete(null); |
| | | child.setUpdateTime(null); |
| | | child.setParentId(null); |
| | | if (!ObjectUtils.isEmpty(menus)) { |
| | | for (ManageMenu menu : menus) { |
| | | menu.setCreateTime(null); |
| | | menu.setIsDelete(null); |
| | | menu.setUpdateTime(null); |
| | | menu.setParentId(null); |
| | | List<ManageMenu> children = menu.getChildren(); |
| | | for (ManageMenu child : children) { |
| | | child.setCreateTime(null); |
| | | child.setIsDelete(null); |
| | | child.setUpdateTime(null); |
| | | child.setParentId(null); |
| | | } |
| | | } |
| | | } |
| | | vo.setAccountId(account.getId()); |