diff --git a/src/main/java/com/rymcu/vertical/service/TopicService.java b/src/main/java/com/rymcu/vertical/service/TopicService.java index cffce69..60bbd27 100644 --- a/src/main/java/com/rymcu/vertical/service/TopicService.java +++ b/src/main/java/com/rymcu/vertical/service/TopicService.java @@ -22,11 +22,9 @@ public interface TopicService extends Service { /** * 根据 topicUri 获取主题信息及旗下标签数据 * @param topicUri 主题 URI - * @param page - * @param rows * @return * */ - Map findTopicByTopicUri(String topicUri, Integer page, Integer rows); + Topic findTopicByTopicUri(String topicUri); /** * 新增/更新主题信息 @@ -56,4 +54,13 @@ public interface TopicService extends Service { * @return */ Map unbindTopicTag(TopicTagDTO topicTag); + + /** + * 获取主题下标签列表 + * @param topicUri + * @param page + * @param rows + * @return + */ + Map findTagsByTopicUri(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 84f51f8..64af131 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/TopicServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/TopicServiceImpl.java @@ -37,23 +37,10 @@ public class TopicServiceImpl extends AbstractService implements TopicSer } @Override - public Map findTopicByTopicUri(String topicUri, Integer page, Integer rows) { - Map map = new HashMap(2); - TopicDTO topic = topicMapper.selectTopicByTopicUri(topicUri); - if (topic == null) { - return map; - } - PageHelper.startPage(page, rows); - List list = topicMapper.selectTopicTag(topic.getIdTopic()); - 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; + public Topic findTopicByTopicUri(String topicUri) { + Topic searchTopic = new Topic(); + searchTopic.setTopicUri(topicUri); + return topicMapper.selectOne(searchTopic); } @Override @@ -133,4 +120,23 @@ public class TopicServiceImpl extends AbstractService implements TopicSer } return map; } + + @Override + public Map findTagsByTopicUri(String topicUri, Integer page, Integer rows) { + Map map = new HashMap(2); + TopicDTO topic = topicMapper.selectTopicByTopicUri(topicUri); + if (topic == null) { + return map; + } + PageHelper.startPage(page, rows); + List list = topicMapper.selectTopicTag(topic.getIdTopic()); + PageInfo pageInfo = new PageInfo(list); + map.put("tags", pageInfo.getList()); + 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; + } } 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 643dc9b..d2ca280 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 @@ -109,11 +109,20 @@ public class AdminController { } @GetMapping("/topic/{topicUri}") - public GlobalResult topic(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows,@PathVariable String topicUri){ + public GlobalResult topic(@PathVariable String topicUri){ if (StringUtils.isBlank(topicUri)) { return GlobalResultGenerator.genErrorResult("数据异常!"); } - Map map = topicService.findTopicByTopicUri(topicUri,page,rows); + Topic topic = topicService.findTopicByTopicUri(topicUri); + return GlobalResultGenerator.genSuccessResult(topic); + } + + @GetMapping("/topic/{topicUri}/tags") + public GlobalResult topicTags(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows,@PathVariable String topicUri){ + if (StringUtils.isBlank(topicUri)) { + return GlobalResultGenerator.genErrorResult("数据异常!"); + } + Map map = topicService.findTagsByTopicUri(topicUri,page,rows); return GlobalResultGenerator.genSuccessResult(map); } diff --git a/src/main/java/mapper/TopicMapper.xml b/src/main/java/mapper/TopicMapper.xml index 59996f0..6aad7ed 100644 --- a/src/main/java/mapper/TopicMapper.xml +++ b/src/main/java/mapper/TopicMapper.xml @@ -73,7 +73,7 @@ diff --git a/src/main/resources/static/jetbrains.png b/src/main/resources/static/jetbrains.png new file mode 100644 index 0000000..ccceb95 Binary files /dev/null and b/src/main/resources/static/jetbrains.png differ