From 37c81c5b606272a43e0d1ab4e5e80912b8f39ee4 Mon Sep 17 00:00:00 2001 From: x ronger Date: Thu, 5 Dec 2019 17:30:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E9=A2=98=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/rymcu/vertical/dto/admin/TagDTO.java | 16 +++++++++++++++ .../rymcu/vertical/dto/admin/TopicDTO.java | 1 + .../rymcu/vertical/service/TopicService.java | 4 ++-- .../service/impl/TopicServiceImpl.java | 20 ++++++++++++++++--- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/rymcu/vertical/dto/admin/TagDTO.java b/src/main/java/com/rymcu/vertical/dto/admin/TagDTO.java index 99e7741..27960bf 100644 --- a/src/main/java/com/rymcu/vertical/dto/admin/TagDTO.java +++ b/src/main/java/com/rymcu/vertical/dto/admin/TagDTO.java @@ -1,5 +1,6 @@ package com.rymcu.vertical.dto.admin; +import com.rymcu.vertical.dto.Author; import lombok.Data; /** @@ -7,4 +8,19 @@ import lombok.Data; */ @Data public class TagDTO { + + private Integer idTag; + + private String tagTitle; + + private String tagUri; + + private String tagDescription; + + private String tagIconPath; + + private Integer tagAuthorId; + + private Author tagAuthor; + } diff --git a/src/main/java/com/rymcu/vertical/dto/admin/TopicDTO.java b/src/main/java/com/rymcu/vertical/dto/admin/TopicDTO.java index 9ff60e5..ec73a6c 100644 --- a/src/main/java/com/rymcu/vertical/dto/admin/TopicDTO.java +++ b/src/main/java/com/rymcu/vertical/dto/admin/TopicDTO.java @@ -1,5 +1,6 @@ package com.rymcu.vertical.dto.admin; +import com.rymcu.vertical.dto.Author; import lombok.Data; import java.util.List; diff --git a/src/main/java/com/rymcu/vertical/service/TopicService.java b/src/main/java/com/rymcu/vertical/service/TopicService.java index 3fb4825..bfcf84b 100644 --- a/src/main/java/com/rymcu/vertical/service/TopicService.java +++ b/src/main/java/com/rymcu/vertical/service/TopicService.java @@ -1,10 +1,10 @@ package com.rymcu.vertical.service; import com.rymcu.vertical.core.service.Service; -import com.rymcu.vertical.dto.admin.TopicDTO; import com.rymcu.vertical.entity.Topic; import java.util.List; +import java.util.Map; /** * @author ronger @@ -24,5 +24,5 @@ public interface TopicService extends Service { * @param rows * @return * */ - TopicDTO findTopicByTopicUri(String topicUri, Integer page, Integer rows); + Map findTopicByTopicUri(String topicUri, Integer page, Integer rows); } diff --git a/src/main/java/com/rymcu/vertical/service/impl/TopicServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/TopicServiceImpl.java index d98cbdb..932c804 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/TopicServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/TopicServiceImpl.java @@ -1,5 +1,7 @@ package com.rymcu.vertical.service.impl; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import com.rymcu.vertical.core.service.AbstractService; import com.rymcu.vertical.dto.admin.TagDTO; import com.rymcu.vertical.dto.admin.TopicDTO; @@ -9,7 +11,9 @@ import com.rymcu.vertical.service.TopicService; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @author ronger @@ -27,12 +31,22 @@ public class TopicServiceImpl extends AbstractService implements TopicSer } @Override - public TopicDTO findTopicByTopicUri(String topicUri, Integer page, Integer rows) { + public Map findTopicByTopicUri(String topicUri, Integer page, Integer rows) { + Map map = new HashMap(2); TopicDTO topic = topicMapper.selectTopicByTopicUri(topicUri); if (topic == null) { - return new TopicDTO(); + return map; } + PageHelper.startPage(page, rows); List list = topicMapper.selectTopicTag(topic.getIdTopic()); - return topic; + PageInfo pageInfo = new PageInfo(list); + topic.setTags(pageInfo.getList()); + map.put("topic", topic); + Map pagination = new HashMap(3); + pagination.put("pageSize",pageInfo.getPageSize()); + pagination.put("total",pageInfo.getTotal()); + pagination.put("currentPage",pageInfo.getPageNum()); + map.put("pagination", pagination); + return map; } }