Exemplo n.º 1
0
  public int insert(Game game) {
    Assert.notNull(game, "The game must not be null");
    Assert.hasLength(game.getAccount(), "Account must not be empty");

    game.setGmtCreated(new Date());
    game.setGmtModified(new Date());

    return gameDao.insert(game);
  }
Exemplo n.º 2
0
  public int save(Game game) {
    Assert.notNull(game, "The game must not be null");

    if (game.getId() != null && game.getId().intValue() > 0) {
      return update(game);
    } else {
      return insert(game);
    }
  }
Exemplo n.º 3
0
  public int update(Game game) {
    Assert.notNull(game, "The game must be not null");
    Assert.notNull(game.getId(), "The id must be not null");
    Assert.hasLength(game.getAccount(), "Account must not be empty");

    game.setGmtModified(new Date());

    return gameDao.update(game);
  }
Exemplo n.º 4
0
  public List<Game> queryListByConditions(
      Integer page, Integer pageSize, String account, String keyWord) {
    Integer offset = (page - 1) * pageSize;

    Game game = new Game();
    game.setAccount(account);

    return gameDao.queryListByConditions(offset, pageSize, game, keyWord);
  }
Exemplo n.º 5
0
  public int deleteByIdAndAccount(Integer id, String account) {
    Assert.notNull(id, "The id must be not null");
    Assert.hasLength(account, "Account must not be empty");

    Game game = new Game();
    game.setId(id);
    game.setAccount(account);

    return gameDao.delete(game);
  }
Exemplo n.º 6
0
  public List<GameVO> queryListByStartTime(Integer page, Integer pageSize, Date startTime) {
    Integer offset = (page - 1) * pageSize;

    Game game = new Game();
    game.setStartTime(startTime);
    game.setStatus(1);

    List<Game> list = gameDao.queryListByConditions(offset, pageSize, game, null);

    return transformation(list);
  }
Exemplo n.º 7
0
  public int countListByConditions(String account, String keyWord) {
    Game game = new Game();
    game.setAccount(account);

    return gameDao.countListByConditions(game, keyWord);
  }
Exemplo n.º 8
0
  public int countListByStartTime(Date startTime) {
    Game game = new Game();
    game.setStartTime(startTime);

    return gameDao.countListByConditions(game, null);
  }
Exemplo n.º 9
0
  private List<GameVO> transformation(List<Game> games) {
    List<GameVO> list = new ArrayList<GameVO>();

    for (Game g : games) {
      GameVO gvo =
          new GameVO(
              g.getId(),
              g.getAccount(),
              g.getName(),
              g.getStartTime(),
              g.getServerName(),
              g.getUrl(),
              g.getCategory(),
              g.getGiftName(),
              g.getPlatform(),
              g.getGmtCreated(),
              g.getGmtModified());

      if (g.getStartTime() == null) {
        gvo.setServerStatus(0);
      } else {

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);

        if (calendar.getTimeInMillis() >= g.getStartTime().getTime()) {
          gvo.setServerStatus(1);
        } else {
          gvo.setServerStatus(2);
        }
      }

      list.add(gvo);
    }

    return list;
  }