예제 #1
0
  /** 关注我的/我关注的用户列表 */
  @SuppressWarnings("unchecked")
  @Override
  public DataGrid dataGridAccount(LvFollow lvFollow, PageHelper ph) {
    List<LvAccount> al = new ArrayList<LvAccount>();

    DataGrid dg = dataGridByType(ph, lvFollow, lvFollowDao);
    List<TlvAccount> l = dg.getRows();
    if (l != null && l.size() > 0) {
      String[] openIds = new String[l.size()];
      int i = 0;
      for (TlvAccount t : l) {
        LvAccount a = new LvAccount();
        MyBeanUtils.copyProperties(t, a, true);
        al.add(a);
        openIds[i++] = t.getOpenId().toString();
      }
      HashMap<Integer, Integer> photoNums = lvAccountPhotoDao.getCountPhotoNum(openIds);
      for (LvAccount a : al) {
        Integer num = photoNums.get(a.getOpenId());
        if (num != null) a.setPhotoNum(num);
      }
    }
    dg.setRows(al);
    return dg;
  }
예제 #2
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;
  }
예제 #3
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;
  }