| Total Complexity | 2 |
| Total Lines | 23 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | package com.dawn.jat.illuminati.core.convert; |
||
| 12 | @Service |
||
| 13 | public class Converter { |
||
| 14 | private <T> List<String> convertMapKeysToArray(Map<String, T> map) { |
||
| 15 | List<String> list = new ArrayList<>(); |
||
| 16 | map.forEach((key, value) -> { |
||
| 17 | list.add(key); |
||
| 18 | }); |
||
| 19 | return list; |
||
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Convert a PostDto to PostEntity. |
||
| 24 | */ |
||
| 25 | public PostEntity convertPostDtoToEntity(PostDto post, PostEntity postEntity) { |
||
| 26 | postEntity.setSlug(post.getSlug()); |
||
| 27 | postEntity.setAuthor(post.getAuthor()); |
||
| 28 | postEntity.setBrief(post.getBrief()); |
||
| 29 | postEntity.setTitle(post.getTitle()); |
||
| 30 | postEntity.setTime(post.getTime()); |
||
| 31 | postEntity.setContent(post.getContent()); |
||
| 32 | Map<String, Boolean> tagMap = post.getTag(); |
||
| 33 | postEntity.setTag(convertMapKeysToArray(tagMap)); |
||
| 34 | return postEntity; |
||
| 35 | } |
||
| 37 |