コード例 #1
0
ファイル: GameServiceImpl.java プロジェクト: rolyer/kfcms
  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);
  }
コード例 #2
0
ファイル: GameServiceImpl.java プロジェクト: rolyer/kfcms
  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);
    }
  }
コード例 #3
0
ファイル: GameServiceImpl.java プロジェクト: rolyer/kfcms
  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);
  }
コード例 #4
0
ファイル: GameServiceImpl.java プロジェクト: rolyer/kfcms
  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);
  }
コード例 #5
0
ファイル: GameServiceImpl.java プロジェクト: rolyer/kfcms
  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);
  }
コード例 #6
0
ファイル: GameServiceImpl.java プロジェクト: rolyer/kfcms
  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);
  }
コード例 #7
0
ファイル: GameServiceImpl.java プロジェクト: rolyer/kfcms
  public int countListByConditions(String account, String keyWord) {
    Game game = new Game();
    game.setAccount(account);

    return gameDao.countListByConditions(game, keyWord);
  }
コード例 #8
0
ファイル: GameServiceImpl.java プロジェクト: rolyer/kfcms
  public int countListByStartTime(Date startTime) {
    Game game = new Game();
    game.setStartTime(startTime);

    return gameDao.countListByConditions(game, null);
  }
コード例 #9
0
ファイル: GameServiceImpl.java プロジェクト: rolyer/kfcms
  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;
  }