From ba1840a7529072256d5d9ff5cbfa7e64b9ffc6c3 Mon Sep 17 00:00:00 2001 From: ronger Date: Tue, 3 Dec 2019 17:38:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E9=A2=98-=E6=A0=87=E7=AD=BE=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/rymcu/vertical/dto/admin/TagDTO.java | 10 +++++++ .../rymcu/vertical/dto/admin/TopicDTO.java | 29 +++++++++++++++++++ .../rymcu/vertical/mapper/TopicMapper.java | 7 +++++ .../rymcu/vertical/service/TopicService.java | 18 ++++++++++++ .../service/impl/TopicServiceImpl.java | 15 ++++++++++ .../web/api/admin/AdminController.java | 16 +++++++--- src/main/java/mapper/TopicMapper.xml | 15 ++++++++++ 7 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/rymcu/vertical/dto/admin/TagDTO.java create mode 100644 src/main/java/com/rymcu/vertical/dto/admin/TopicDTO.java diff --git a/src/main/java/com/rymcu/vertical/dto/admin/TagDTO.java b/src/main/java/com/rymcu/vertical/dto/admin/TagDTO.java new file mode 100644 index 0000000..99e7741 --- /dev/null +++ b/src/main/java/com/rymcu/vertical/dto/admin/TagDTO.java @@ -0,0 +1,10 @@ +package com.rymcu.vertical.dto.admin; + +import lombok.Data; + +/** + * @author ronger + */ +@Data +public class TagDTO { +} diff --git a/src/main/java/com/rymcu/vertical/dto/admin/TopicDTO.java b/src/main/java/com/rymcu/vertical/dto/admin/TopicDTO.java new file mode 100644 index 0000000..9ff60e5 --- /dev/null +++ b/src/main/java/com/rymcu/vertical/dto/admin/TopicDTO.java @@ -0,0 +1,29 @@ +package com.rymcu.vertical.dto.admin; + +import lombok.Data; + +import java.util.List; + +/** + * @author ronger + */ +@Data +public class TopicDTO { + + private Integer idTopic; + + private String topicTitle; + + private String topicUri; + + private String topicIconPath; + + private String topicDescription; + + private String topicStatus; + + private Integer topicTagCount; + + private List tags; + +} diff --git a/src/main/java/com/rymcu/vertical/mapper/TopicMapper.java b/src/main/java/com/rymcu/vertical/mapper/TopicMapper.java index 7c7b9ff..d36b1e7 100644 --- a/src/main/java/com/rymcu/vertical/mapper/TopicMapper.java +++ b/src/main/java/com/rymcu/vertical/mapper/TopicMapper.java @@ -1,10 +1,17 @@ package com.rymcu.vertical.mapper; import com.rymcu.vertical.core.mapper.Mapper; +import com.rymcu.vertical.dto.admin.TagDTO; +import com.rymcu.vertical.dto.admin.TopicDTO; import com.rymcu.vertical.entity.Topic; +import org.apache.ibatis.annotations.Param; import java.util.List; public interface TopicMapper extends Mapper { List selectTopicNav(); + + TopicDTO selectTopicByTopicUri(@Param("topicUri") String topicUri); + + List selectTopicTag(@Param("idTopic") Integer idTopic); } diff --git a/src/main/java/com/rymcu/vertical/service/TopicService.java b/src/main/java/com/rymcu/vertical/service/TopicService.java index e957844..3fb4825 100644 --- a/src/main/java/com/rymcu/vertical/service/TopicService.java +++ b/src/main/java/com/rymcu/vertical/service/TopicService.java @@ -1,10 +1,28 @@ 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; +/** + * @author ronger + */ public interface TopicService extends Service { + + /** + * 获取导航主题数据 + * @return + * */ List findTopicNav(); + + /** + * 根据 topicUri 获取主题信息及旗下标签数据 + * @param topicUri 主题 URI + * @param page + * @param rows + * @return + * */ + TopicDTO 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 66a7888..d98cbdb 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/TopicServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/TopicServiceImpl.java @@ -1,6 +1,8 @@ package com.rymcu.vertical.service.impl; import com.rymcu.vertical.core.service.AbstractService; +import com.rymcu.vertical.dto.admin.TagDTO; +import com.rymcu.vertical.dto.admin.TopicDTO; import com.rymcu.vertical.entity.Topic; import com.rymcu.vertical.mapper.TopicMapper; import com.rymcu.vertical.service.TopicService; @@ -9,6 +11,9 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; +/** + * @author ronger + */ @Service public class TopicServiceImpl extends AbstractService implements TopicService { @@ -20,4 +25,14 @@ public class TopicServiceImpl extends AbstractService implements TopicSer List topics = topicMapper.selectTopicNav(); return topics; } + + @Override + public TopicDTO findTopicByTopicUri(String topicUri, Integer page, Integer rows) { + TopicDTO topic = topicMapper.selectTopicByTopicUri(topicUri); + if (topic == null) { + return new TopicDTO(); + } + List list = topicMapper.selectTopicTag(topic.getIdTopic()); + return topic; + } } diff --git a/src/main/java/com/rymcu/vertical/web/api/admin/AdminController.java b/src/main/java/com/rymcu/vertical/web/api/admin/AdminController.java index a575e96..e509e71 100644 --- a/src/main/java/com/rymcu/vertical/web/api/admin/AdminController.java +++ b/src/main/java/com/rymcu/vertical/web/api/admin/AdminController.java @@ -4,14 +4,13 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.rymcu.vertical.core.result.GlobalResult; import com.rymcu.vertical.core.result.GlobalResultGenerator; +import com.rymcu.vertical.dto.admin.TopicDTO; import com.rymcu.vertical.entity.Topic; import com.rymcu.vertical.entity.User; import com.rymcu.vertical.service.TopicService; import com.rymcu.vertical.service.UserService; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.apache.commons.lang.StringUtils; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.HashMap; @@ -60,4 +59,13 @@ public class AdminController { return GlobalResultGenerator.genSuccessResult(map); } + @GetMapping("/topic/{topicUri}") + public GlobalResult topic(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows,@PathVariable String topicUri){ + if (StringUtils.isBlank(topicUri)) { + return GlobalResultGenerator.genErrorResult("数据异常!"); + } + TopicDTO topic = topicService.findTopicByTopicUri(topicUri,page,rows); + return GlobalResultGenerator.genSuccessResult(); + } + } diff --git a/src/main/java/mapper/TopicMapper.xml b/src/main/java/mapper/TopicMapper.xml index 4b1c83f..d7a219c 100644 --- a/src/main/java/mapper/TopicMapper.xml +++ b/src/main/java/mapper/TopicMapper.xml @@ -18,7 +18,22 @@ + + + + + + + + + + + \ No newline at end of file