コード例 #1
0
ファイル: TopicServiceImpl.java プロジェクト: joynn/onboard
  @Override
  public Topic getTopicByTypeAndId(String type, int id) {
    Topic example = new Topic();
    example.setRefId(id);
    example.setRefType(type);

    List<Topic> topics = topicMapper.selectByExample(new TopicExample(example));
    if (topics != null && !topics.isEmpty()) {
      // 只可能有一个topic
      Topic topic = topics.get(0);
      if (topic.getLastUpdator() == null) {
        topic.setLastUpdator(userMapper.selectByPrimaryKey(topic.getLastUpdatorId()));
      }

      String a = topic.getExcerpt();
      String b = HtmlTextParser.getPlainText(a);

      topic.setExcerpt(HtmlTextParser.getPlainText(topic.getExcerpt()));

      BaseOperateItem identifiable =
          identifiableManager.getIdentifiableByTypeAndId(topic.getRefType(), topic.getRefId());
      if (identifiable != null) {
        topic.setTargetCreator(
            userMapper.selectByPrimaryKey(((BaseProjectItem) identifiable).getCreatorId()));
      }

      return topic;
    }

    return null;
  }
コード例 #2
0
ファイル: TopicServiceImpl.java プロジェクト: joynn/onboard
 private void checkTopicExcerptLength(Topic topic) {
   String excerpt = topic.getExcerpt();
   if (excerpt != null) {
     excerpt = excerpt.substring(0, Math.min(MAX_EXCERPT_LENGTH, excerpt.length()));
     topic.setExcerpt(excerpt);
   }
 }
コード例 #3
0
ファイル: TopicServiceImpl.java プロジェクト: joynn/onboard
  @Override
  public List<Topic> getTopicListByProjectId(int projectId, int start, int limit) {
    Topic topic = new Topic(false);
    topic.setProjectId(projectId);
    topic.setStick(false);
    TopicExample example = new TopicExample(topic);
    example.setLimit(start, limit);
    example.setOrderByClause("updated desc");

    List<Topic> topics = Lists.newArrayList();
    if (start == 0) {
      topics = getCollectedTopics(projectId);
    }
    topics.addAll(topicMapper.selectByExample(example));

    for (Topic t : topics) {
      t.setExcerpt(HtmlTextParser.getPlainText(t.getExcerpt()));
      t.setLastUpdator(userMapper.selectByPrimaryKey(t.getLastUpdatorId()));
      BaseOperateItem identifiable =
          identifiableManager.getIdentifiableByTypeAndId(t.getRefType(), t.getRefId());
      if (identifiable != null) {
        t.setTargetCreator(
            userMapper.selectByPrimaryKey(((BaseProjectItem) identifiable).getCreatorId()));
      }
    }
    return topics;
  }
コード例 #4
0
ファイル: TopicServiceImpl.java プロジェクト: joynn/onboard
 @Override
 public Topic createTopic(Topic topic) {
   // Date now = new Date();
   // topic.setCreated(now);
   // topic.setUpdated(now);
   topic.setStick(false);
   topic.setExcerpt(HtmlTextParser.getPlainText(topic.getExcerpt()));
   checkTopicTitleLength(topic);
   topicMapper.insert(topic);
   return topic;
 }