コード例 #1
0
 private void handleNewTermEvent(NewTermEvent event) {
   Long termId = event.getTermId();
   TermDO term = termService.findByPrimaryKey(termId);
   PageInfo page = new PageInfo();
   page.setPageSize(Integer.MAX_VALUE);
   page.setPageStart(0);
   List<UserDO> followers = userService.getFollowMeUsers(term.getCreatorId(), page);
   for (UserDO follower : followers) {
     TermRelationDO anu = new TermRelationDO();
     anu.setTermId(termId);
     anu.setRelatedId(follower.getId());
     anu.setRelatedType("User");
     anu.setRelation("FOLLOW");
     termService.createTermRelation(anu, follower.getId());
   }
 }
コード例 #2
0
  @Override
  public void onEvent(Event event) {
    if (event instanceof DeleteEntityEvent) {
      DeleteEntityEvent deleteEntityEvent = (DeleteEntityEvent) event;
      TermRelationDO example = new TermRelationDO();
      example.setRelatedId(deleteEntityEvent.getEntityId());
      example.setRelatedType(deleteEntityEvent.getEntityType());
      termRelationDAO.deleteByExample(example);
    }

    if (event instanceof DeleteTermEvent) {
      DeleteTermEvent deleteEvent = (DeleteTermEvent) event;
      TermRelationDO example = new TermRelationDO();
      example.setTermId(deleteEvent.getEntityId());
      termRelationDAO.deleteByExample(example);
    }

    if (event instanceof NewTermEvent) {
      handleNewTermEvent((NewTermEvent) event);
    }
  }