Пример #1
0
  @SuppressWarnings({"rawtypes", "unchecked"})
  private DataGrid dataGridByType(PageHelper ph, LvFollow lvFollow, BaseDaoI dao) {
    ph.setSort("createTime");
    ph.setOrder("desc");

    DataGrid dg = new DataGrid();
    dg.setPage(Long.valueOf(ph.getPage()));
    dg.setPageSize(Long.valueOf(ph.getRows()));

    String hql = "select a from TlvAccount a ,TlvFollow t  ";
    Map<String, Object> params = new HashMap<String, Object>();
    // 我关注的用户
    if (lvFollow.getFromOpenId() != null) {
      hql += "where a.openId = t.toOpenId and t.fromOpenId = :openId";
      params.put("openId", lvFollow.getFromOpenId());
      // 关注我的用户
    } else if (lvFollow.getToOpenId() != null) {
      hql += "where a.openId = t.fromOpenId and t.toOpenId = :openId";
      params.put("openId", lvFollow.getToOpenId());
    }
    List<TlvAccount> l = dao.find(hql + orderHql(ph), params, ph.getPage(), ph.getRows());
    dg.setTotal(dao.count("select count(*) " + hql.substring(8), params));
    dg.setRows(l);
    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 void edit(LvFollow lvFollow) {
   TlvFollow t = lvFollowDao.get(TlvFollow.class, lvFollow.getId());
   if (t != null) {
     MyBeanUtils.copyProperties(lvFollow, t, new String[] {"id", "createdatetime"}, true);
     // t.setModifydatetime(new Date());
   }
 }
Пример #4
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;
  }