Пример #1
0
 @Override
 public Topic unstickTopic(int id) {
   Topic topicExample = new Topic(false);
   topicExample.setId(id);
   topicExample.setStick(false);
   topicMapper.updateByPrimaryKeySelective(topicExample);
   return topicMapper.selectByPrimaryKey(id);
 }
Пример #2
0
  @Override
  public Topic createOrUpdateTopic(Topic topic) {

    if (topic == null) {
      return null;
    }

    Topic t = new Topic();
    t.setRefId(topic.getRefId());
    t.setRefType(topic.getRefType());
    TopicExample example = new TopicExample(t);

    List<Topic> topics = topicMapper.selectByExample(example);
    if (topics.size() == 0) {
      createTopic(topic);
      return topic;
    } else {
      topic.setId(topics.get(0).getId());
      topic.setCreated(null);
      updateTopic(topic);
      return topic;
    }
  }