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());
   }
 }
 public List<TermRelationDO> pageByExample(TermRelationDO termRelationDO, PageInfo page) {
   Map<String, Object> params = new HashMap<String, Object>();
   params.put("id", termRelationDO.getId());
   params.put("gmtCreate", termRelationDO.getGmtCreate());
   params.put("gmtModify", termRelationDO.getGmtModify());
   params.put("creatorId", termRelationDO.getCreatorId());
   params.put("modifierId", termRelationDO.getModifierId());
   params.put("relatedId", termRelationDO.getRelatedId());
   params.put("termId", termRelationDO.getTermId());
   params.put("relation", termRelationDO.getRelation());
   params.put("relatedType", termRelationDO.getRelatedType());
   params.put("relationData", termRelationDO.getRelationData());
   params.put("pageStart", page.getPageStart());
   params.put("pageSize", page.getPageSize());
   List<TermRelationDO> list =
       getSqlMapClientTemplate().queryForList("TermRelation.pageByExample", params);
   return list;
 }
  @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);
    }
  }