Ejemplo n.º 1
0
 /**
  * 功能描述:得到用户id为userId的数据统计对象,未找到时返回null
  *
  * @param userId
  * @return
  * @throws DBException
  */
 public DataCount findDataCountByUserId(Long userId) throws DBException {
   DataCount dataCount = dataCountDao.getDataCountByUserId(userId);
   if (dataCount == null) {
     DataCount newDataCount = new DataCount();
     newDataCount.setUserId(userId);
     this.save(newDataCount);
     dataCount = newDataCount;
   }
   return dataCount;
 }
Ejemplo n.º 2
0
 /**
  * 功能描述:用户查操作评语时设置统计表的新评语字段值减1
  *
  * @param userId
  * @return
  * @throws DBException
  */
 public boolean minusNewTeacherAppraise(Long userId) throws DBException {
   DataCount dataCount = findDataCountByUserId(userId);
   // 判断是否存在这样的用户统计实体
   if (dataCount != null) {
     Long newTeacherAppraise = dataCount.getNewTeacherAppraise();
     if (newTeacherAppraise != null && newTeacherAppraise.longValue() > 0) {
       dataCount.setNewTeacherAppraise(new Long(newTeacherAppraise.longValue() - 1));
       dataCountDao.update(dataCount);
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 3
0
 /**
  * 功能描述:用户进入打招呼页面后,把统计表的新招呼字段清零
  *
  * @param userId
  * @return
  * @throws DBException
  */
 public boolean clearNewSalutation(Long userId) throws DBException {
   DataCount dataCount = findDataCountByUserId(userId);
   // 判断是否存在这样的用户统计实体
   if (dataCount != null) {
     Long newSalutation = dataCount.getNewSalutation();
     if (newSalutation != null) {
       dataCount.setNewSalutation(new Long(0));
       dataCountDao.update(dataCount);
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 4
0
 /**
  * 功能描述:有一个好友发送短消息时,为短消息的接收方的统计表的新短消息字段值加1
  *
  * @param userId
  * @return
  * @throws DBException
  */
 public boolean addNewShortMessage(Long userId) throws DBException {
   DataCount dataCount = findDataCountByUserId(userId);
   // 判断是否存在这样的用户统计实体
   if (dataCount != null) {
     Long newShortMessage = dataCount.getNewShortMessage();
     if (newShortMessage != null) {
       dataCount.setNewShortMessage(new Long(newShortMessage.longValue() + 1));
       dataCountDao.update(dataCount);
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 5
0
 /**
  * Function: 删除DataCount对象
  *
  * @param DataCount obj ;
  */
 public void delete(DataCount obj) {
   dataCountDao.delete(obj);
 }
Ejemplo n.º 6
0
 /**
  * Function: 保存DataCount对象
  *
  * @param DataCount obj ;
  */
 public long save(DataCount obj) {
   return ((Long) dataCountDao.save(obj)).longValue();
 }
Ejemplo n.º 7
0
 /**
  * Function: 更新DataCount对象
  *
  * @param DataCount obj ;
  */
 public void update(DataCount obj) {
   dataCountDao.update(obj);
 }
Ejemplo n.º 8
0
 /**
  * Function: 根据主键对象,获取DataCount对象
  *
  * @param id
  * @return DataCount obj ;
  */
 public DataCount load(long id) {
   DataCount obj = dataCountDao.load(new Long(id));
   return obj;
 }
Ejemplo n.º 9
0
  /**
   * Function: 得到发帖数最多的十个用户
   *
   * <p>Produce describe:
   *
   * @return
   * @author: wu3889 2008-4-8
   * @throws DBException
   */
  public List getQuestionTopTenUserVoList() throws DBException {

    List list = dataCountDao.getQuestionTopTenUserList();

    List tpTenUserVoList = new ArrayList();

    DataCount dataCountPo = null;

    // 用户对象
    User userPo = new User();

    QuestionTopTenUserVo questionTopTenUserVo = null;

    if (list != null && list.size() > 0) {

      for (int i = 0; i < list.size(); i++) {

        dataCountPo = (DataCount) list.get(i);

        questionTopTenUserVo = new QuestionTopTenUserVo();

        userPo = new User();
        // 得到用户对象
        userPo = userDao.load(dataCountPo.getUserId());

        if (userPo != null) {

          // 昵称
          if (userPo.getNickName() != null) {
            questionTopTenUserVo.setNickName(userPo.getNickName());
            questionTopTenUserVo.setCutName(
                DoText.getInterceptString(userPo.getNickName(), 5, "..."));
          }

          // 用户头像
          if (userPo.getHeadPhotoLink() != null) {
            questionTopTenUserVo.setUserPhotoLink(userPo.getHeadPhotoLink());
          }

          // 发帖数
          if (dataCountPo.getQuestionTotal() != null)
            questionTopTenUserVo.setQuestionTotal(dataCountPo.getQuestionTotal());

          // Id
          questionTopTenUserVo.setId(userPo.getId());

          // 判断用户角色
          if (treUserRoleBo.checkUserIsRole(
                  userPo.getId(),
                  roleBo.getRoleId(
                      SystemConstant.ROLE_ROLE_KIND_1, SystemConstant.ROLE_ROLE_NO_GARDEN_USER_3))
              || treUserRoleBo.checkUserIsRole(
                  userPo.getId(),
                  roleBo.getRoleId(
                      SystemConstant.ROLE_ROLE_KIND_1,
                      SystemConstant.ROLE_ROLE_NO_GARDEN_USER_1))) {
            // 园长或者老师
            questionTopTenUserVo.setFlag("1");

          } else if (treUserRoleBo.checkUserIsRole(
                  userPo.getId(),
                  roleBo.getRoleId(
                      SystemConstant.ROLE_ROLE_KIND_2, SystemConstant.ROLE_ROLE_NO_MONEY_USER_1))
              || treUserRoleBo.checkUserIsRole(
                  userPo.getId(),
                  roleBo.getRoleId(
                      SystemConstant.ROLE_ROLE_KIND_2, SystemConstant.ROLE_ROLE_NO_MONEY_USER_2))) {
            // 注册会员或者收费会员
            questionTopTenUserVo.setFlag("2");
          }

          tpTenUserVoList.add(questionTopTenUserVo);
        }
      }
    }

    return tpTenUserVoList;
  }