主题-标签功能开发
This commit is contained in:
parent
9859879e17
commit
ba1840a752
10
src/main/java/com/rymcu/vertical/dto/admin/TagDTO.java
Normal file
10
src/main/java/com/rymcu/vertical/dto/admin/TagDTO.java
Normal file
@ -0,0 +1,10 @@
|
||||
package com.rymcu.vertical.dto.admin;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author ronger
|
||||
*/
|
||||
@Data
|
||||
public class TagDTO {
|
||||
}
|
29
src/main/java/com/rymcu/vertical/dto/admin/TopicDTO.java
Normal file
29
src/main/java/com/rymcu/vertical/dto/admin/TopicDTO.java
Normal file
@ -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<TagDTO> tags;
|
||||
|
||||
}
|
@ -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<Topic> {
|
||||
List<Topic> selectTopicNav();
|
||||
|
||||
TopicDTO selectTopicByTopicUri(@Param("topicUri") String topicUri);
|
||||
|
||||
List<TagDTO> selectTopicTag(@Param("idTopic") Integer idTopic);
|
||||
}
|
||||
|
@ -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<Topic> {
|
||||
|
||||
/**
|
||||
* 获取导航主题数据
|
||||
* @return
|
||||
* */
|
||||
List<Topic> findTopicNav();
|
||||
|
||||
/**
|
||||
* 根据 topicUri 获取主题信息及旗下标签数据
|
||||
* @param topicUri 主题 URI
|
||||
* @param page
|
||||
* @param rows
|
||||
* @return
|
||||
* */
|
||||
TopicDTO findTopicByTopicUri(String topicUri, Integer page, Integer rows);
|
||||
}
|
||||
|
@ -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<Topic> implements TopicService {
|
||||
|
||||
@ -20,4 +25,14 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
|
||||
List<Topic> 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<TagDTO> list = topicMapper.selectTopicTag(topic.getIdTopic());
|
||||
return topic;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,22 @@
|
||||
<id column="created_time" property="createdTime"/>
|
||||
<id column="updated_time" property="updatedTime"/>
|
||||
</resultMap>
|
||||
<resultMap id="DTOResultMap" type="com.rymcu.vertical.dto.admin.TopicDTO">
|
||||
<id column="id" property="idTopic"/>
|
||||
<id column="topic_title" property="topicTitle"/>
|
||||
<id column="topic_uri" property="topicUri"/>
|
||||
<id column="topic_description" property="topicDescription"/>
|
||||
<id column="topic_icon_path" property="topicIconPath"/>
|
||||
<id column="topic_tag_count" property="topicTagCount"/>
|
||||
<id column="topic_status" property="topicStatus"/>
|
||||
</resultMap>
|
||||
<select id="selectTopicNav" resultMap="BaseResultMap">
|
||||
select id,topic_title,topic_uri,topic_icon_path from vertical_topic where topic_nva = 0 and topic_status = 0 order by topic_sort
|
||||
</select>
|
||||
<select id="selectTopicByTopicUri" resultMap="DTOResultMap">
|
||||
select id,topic_title,topic_uri,topic_icon_path,topic_description,topic_tag_count,topic_status from vertical_topic where topic_uri = #{topicUri}
|
||||
</select>
|
||||
<select id="selectTopicTag" resultType="com.rymcu.vertical.dto.admin.TagDTO">
|
||||
select * from vertical_tag vt left join vertical_topic_tag vtt on vt.id = vtt.id_tag where vtt.id_topic = #{idTopic}
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user