diff --git a/luoo_music/src/main/java/com/luoo/music/dto/mapper/JournalMapper.java b/luoo_music/src/main/java/com/luoo/music/dto/mapper/JournalMapper.java index 76ec2cd..49b6b51 100644 --- a/luoo_music/src/main/java/com/luoo/music/dto/mapper/JournalMapper.java +++ b/luoo_music/src/main/java/com/luoo/music/dto/mapper/JournalMapper.java @@ -28,29 +28,6 @@ import util.DateUtil; import util.StringTools; public class JournalMapper { - // mock data - private static final String JOURNAL_TAG_FILE_PATH = "journalTags.txt"; - private static final Map> journalTagMap = new HashMap<>(); - private static final String[] EDITOR = new String[] { "左岸以西", "落在低处" }; - - static { - getLines(JOURNAL_TAG_FILE_PATH).forEach(s -> { - String[] segs = s.split("\\|"); - List tags = Arrays.stream(segs[1].split(",")).collect(Collectors.toList()); - journalTagMap.put(segs[0], tags); - }); - } - - private static List getLines(String filePath) { - try (InputStream is = new ClassPathResource(filePath).getInputStream(); - BufferedReader reader = new BufferedReader(new InputStreamReader(is));) { - return reader.lines().collect(Collectors.toList()); - } catch (IOException e) { - e.printStackTrace(); - } - return Collections.emptyList(); - } - public static JournalRespDTO getJournalRespDTO(Journal journal) { return getJournalRespDTO(journal, Collections.emptySet()); } @@ -70,17 +47,9 @@ public class JournalMapper { List tags=Arrays.stream(nameChTags.split(",")).collect(Collectors.toList()); journalRespDTO.setTags(tags); } - String content = journal.getContent(); - if (StringTools.isEmpty(content)) { - Poem poem = RandomSource.languageSource().randomTangPoem(); - journalRespDTO.setEditor(poem.getAuthor()); - journalRespDTO.setContent(Arrays.stream(poem.getContent()).collect(Collectors.joining("\r\n"))); - journalRespDTO.setSummary(journalRespDTO.getContent()); - } else { - journalRespDTO.setContent(content); - journalRespDTO.setSummary(journal.getSummary()); - journalRespDTO.setEditor(getEditor(journal.getUserName())); - } + journalRespDTO.setContent(journal.getContent()); + journalRespDTO.setSummary(journal.getSummary()); + journalRespDTO.setEditor(journal.getUserName()); return journalRespDTO; } @@ -96,15 +65,6 @@ public class JournalMapper { return journalRespDTO; } - private static String getEditor(String userName) { - return StringTools.isEmpty(userName) ? EDITOR[RandomSource.numberSource().randomInt(0, EDITOR.length)] - : userName; - } - - public static List getTags(String journalNo) { - return journalTagMap.getOrDefault(journalNo, Collections.emptyList()); - } - private static String getPublishDate(Journal journal) { LocalDateTime date = null == journal.getPubTime() ? journal.getCreateTime() : journal.getPubTime(); return DateUtil.format(date, DateTimePatternEnum.YYYY_DOT_MM_DOT_DD.getPattern());