Пример #1
0
  /** 取消关注 */
  public int delete(LvFollow f) {
    f = get(f.getFromOpenId(), f.getToOpenId());
    if (f == null) return -1;

    delete(f.getId());

    LvAccount a = accountService.get(f.getToOpenId());
    a.setFollowNum(a.getFollowNum() - 1);
    accountService.edit(a);

    return 1;
  }
Пример #2
0
  @Override
  public int add(LvFollow lvFollow) {
    LvFollow f = get(lvFollow.getFromOpenId(), lvFollow.getToOpenId());
    if (f != null) {
      lvFollow.setId(f.getId());
      this.edit(lvFollow);
      return -1;
    }
    TlvFollow t = new TlvFollow();
    BeanUtils.copyProperties(lvFollow, t);
    t.setId(UUID.randomUUID().toString());
    lvFollowDao.save(t);

    LvAccount a = accountService.get(lvFollow.getToOpenId());
    a.setFollowNum(a.getFollowNum() + 1);
    accountService.edit(a);

    return 1;
  }