主题管理
This commit is contained in:
parent
d6f5d1ef85
commit
2798408108
@ -14,4 +14,6 @@ public interface TopicMapper extends Mapper<Topic> {
|
|||||||
TopicDTO selectTopicByTopicUri(@Param("topicUri") String topicUri);
|
TopicDTO selectTopicByTopicUri(@Param("topicUri") String topicUri);
|
||||||
|
|
||||||
List<TagDTO> selectTopicTag(@Param("idTopic") Integer idTopic);
|
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);
|
||||||
}
|
}
|
||||||
|
@ -25,4 +25,6 @@ public interface TopicService extends Service<Topic> {
|
|||||||
* @return
|
* @return
|
||||||
* */
|
* */
|
||||||
Map findTopicByTopicUri(String topicUri, Integer page, Integer rows);
|
Map findTopicByTopicUri(String topicUri, Integer page, Integer rows);
|
||||||
|
|
||||||
|
Map saveTopic(Topic topic);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import com.rymcu.vertical.service.TopicService;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -49,4 +50,26 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
|
|||||||
map.put("pagination", pagination);
|
map.put("pagination", pagination);
|
||||||
return map;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,4 +123,22 @@ public class AdminController {
|
|||||||
return GlobalResultGenerator.genSuccessResult(map);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,11 @@
|
|||||||
<id column="tag_description" property="tagDescription"/>
|
<id column="tag_description" property="tagDescription"/>
|
||||||
<id column="tag_icon_path" property="tagIconPath"/>
|
<id column="tag_icon_path" property="tagIconPath"/>
|
||||||
</resultMap>
|
</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="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 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>
|
||||||
|
Loading…
Reference in New Issue
Block a user