主题管理

This commit is contained in:
x ronger 2019-12-05 20:01:39 +08:00
parent d6f5d1ef85
commit 2798408108
5 changed files with 50 additions and 0 deletions

View File

@ -14,4 +14,6 @@ public interface TopicMapper extends Mapper<Topic> {
TopicDTO selectTopicByTopicUri(@Param("topicUri") String topicUri);
List<TagDTO> selectTopicTag(@Param("idTopic") Integer idTopic);
Integer update(@Param("idTopic") Integer idTopic, @Param("topicTitle") String topicTitle, @Param("topicUri") String topicUri, @Param("topicIconPath") String topicIconPath, @Param("topicNva") String topicNva, @Param("topicStatus") String topicStatus, @Param("topicSort") Integer topicSort, @Param("topicDescription") String topicDescription);
}

View File

@ -25,4 +25,6 @@ public interface TopicService extends Service<Topic> {
* @return
* */
Map findTopicByTopicUri(String topicUri, Integer page, Integer rows);
Map saveTopic(Topic topic);
}

View File

@ -11,6 +11,7 @@ import com.rymcu.vertical.service.TopicService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -49,4 +50,26 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
map.put("pagination", pagination);
return map;
}
@Override
public Map saveTopic(Topic topic) {
Integer result = 0;
if (topic.getIdTopic() == null) {
topic.setCreatedTime(new Date());
topic.setUpdatedTime(topic.getCreatedTime());
result = topicMapper.insertSelective(topic);
} else {
topic.setCreatedTime(new Date());
result = topicMapper.update(topic.getIdTopic(),topic.getTopicTitle(),topic.getTopicUri()
,topic.getTopicIconPath(),topic.getTopicNva(),topic.getTopicStatus()
,topic.getTopicSort(),topic.getTopicDescription());
}
Map map = new HashMap(1);
if (result == 0) {
map.put("message","操作失败!");
} else {
map.put("topic", topic);
}
return map;
}
}

View File

@ -123,4 +123,22 @@ public class AdminController {
return GlobalResultGenerator.genSuccessResult(map);
}
@GetMapping("/topic/detail/{idTopic}")
public GlobalResult topicDetail(@PathVariable Integer idTopic){
Topic topic = topicService.findById(idTopic.toString());
return GlobalResultGenerator.genSuccessResult(topic);
}
@PostMapping("/topic/post")
public GlobalResult addTopic(@RequestBody Topic topic){
Map map = topicService.saveTopic(topic);
return GlobalResultGenerator.genSuccessResult(map);
}
@PutMapping("/topic/post")
public GlobalResult updateTopic(@RequestBody Topic topic){
Map map = topicService.saveTopic(topic);
return GlobalResultGenerator.genSuccessResult(map);
}
}

View File

@ -34,6 +34,11 @@
<id column="tag_description" property="tagDescription"/>
<id column="tag_icon_path" property="tagIconPath"/>
</resultMap>
<update id="update">
update vertical_topic set topic_title = #{topicTitle},topic_uri = #{topicUri},topic_icon_path = #{topicIconPath}
,topic_nva = #{topicNva},topic_status = #{topicStatus},topic_sort = #{topicSort},topic_description = #{topicDescription}
where id = #{idTopic}
</update>
<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>