Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@
<description>Proyecto para Ingeniería del Software</description>

<properties>
<java.version>11</java.version>
<java.version>8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand Down
1 change: 0 additions & 1 deletion src/main/java/bo/ucb/edu/ingsoft/IngsoftApplication.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package bo.ucb.edu.ingsoft;


import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

Expand Down
56 changes: 20 additions & 36 deletions src/main/java/bo/ucb/edu/ingsoft/bl/GameBl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import bo.ucb.edu.ingsoft.dao.*;
import bo.ucb.edu.ingsoft.dto.*;
import bo.ucb.edu.ingsoft.models.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
Expand All @@ -14,39 +14,23 @@
import java.util.List;

@Service
@Slf4j
@AllArgsConstructor(onConstructor = @__({@Autowired}))
public class GameBl {

private GameDao gameDao;
private TransactionDao transactionDao;
private DeveloperDao developerDao;
private EsrbDao esrbDao;
private GamesDirectxDao gamesDirectxDao;
private GamesLanguagesDao languagesDao;
private GamesOsDao gamesOsDao;
private GenreDao genreDao;
private PhotoDao photoDao;
private PriceDao priceDao;
private UserDao userDao;
private PublisherDao publisherDao;
private GameRequirementDao gameRequirementDao;

private static final Logger LOGGER = LoggerFactory.getLogger(GameBl.class);
@Autowired
public GameBl(GameDao gameDao, TransactionDao transactionDao, DeveloperDao developerDao, EsrbDao esrbDao, GamesDirectxDao gamesDirectxDao, GamesLanguagesDao languagesDao, GamesOsDao gamesOsDao, GenreDao genreDao, PhotoDao photoDao, PriceDao priceDao, UserDao userDao, PublisherDao publisherDao, GameRequirementDao gameRequirementDao) {
this.gameDao = gameDao;
this.transactionDao = transactionDao;
this.developerDao = developerDao;
this.esrbDao = esrbDao;
this.gamesDirectxDao = gamesDirectxDao;
this.languagesDao = languagesDao;
this.gamesOsDao = gamesOsDao;
this.genreDao = genreDao;
this.photoDao = photoDao;
this.priceDao = priceDao;
this.userDao = userDao;
this.publisherDao = publisherDao;
this.gameRequirementDao = gameRequirementDao;
}
private final GameDao gameDao;
private final TransactionDao transactionDao;
private final DeveloperDao developerDao;
private final EsrbDao esrbDao;
private final GamesDirectxDao gamesDirectxDao;
private final GamesLanguagesDao languagesDao;
private final GamesOsDao gamesOsDao;
private final GenreDao genreDao;
private final PhotoDao photoDao;
private final PriceDao priceDao;
private final UserDao userDao;
private final PublisherDao publisherDao;
private final GameRequirementDao gameRequirementDao;

/*
POST (/publisher/{id}/game) The publisher create a new game
Expand Down Expand Up @@ -476,12 +460,12 @@ public GameDetailsRequest getGameInformation(Integer gameId) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Unable to find resource");
}

LOGGER.info(game.toString());
log.info(game.toString());
// Getting the language ids in a list
List<Integer> gamesLanguagesDao = languagesDao.findGameLanguages(gameId);

// Print language id
LOGGER.info(gamesLanguagesDao.toString());
log.info(gamesLanguagesDao.toString());

// Getting the language information in a list
List<Language> languageList = languagesDao.findByIdLanguage(gamesLanguagesDao);
Expand Down Expand Up @@ -535,7 +519,7 @@ public GameDetailsRequest getGameInformation(Integer gameId) {
gameDetailsRequest.setPrice(price.getPrice());

// Print game details data
LOGGER.info(gameDetailsRequest.toString());
log.info(gameDetailsRequest.toString());

return gameDetailsRequest;
}
Expand Down
42 changes: 14 additions & 28 deletions src/main/java/bo/ucb/edu/ingsoft/bl/PublisherBl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import bo.ucb.edu.ingsoft.dao.*;
import bo.ucb.edu.ingsoft.dto.*;
import bo.ucb.edu.ingsoft.models.*;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
Expand All @@ -13,36 +14,21 @@


@Service
@AllArgsConstructor(onConstructor = @__({@Autowired}))
public class PublisherBl {

private PublisherDao publisherDao;
private UserDao userDao;
private TransactionDao transactionDao;
private OrderDao orderDao;
private GameDao gameDao;
private DeveloperDao developerDao;
private PriceDao priceDao;
private PhotoDao photoDao;
private CountryDao countryDao;
private LanguageDao languageDao;
private GenreDao genreDao;
private EsrbDao esrbDao;

@Autowired
public PublisherBl(PublisherDao publisherDao, UserDao userDao, TransactionDao transactionDao, OrderDao orderDao, GameDao gameDao, DeveloperDao developerDao, PriceDao priceDao, PhotoDao photoDao, CountryDao countryDao, LanguageDao languageDao, GenreDao genreDao, EsrbDao esrbDao) {
this.publisherDao = publisherDao;
this.userDao = userDao;
this.transactionDao = transactionDao;
this.orderDao = orderDao;
this.gameDao = gameDao;
this.developerDao = developerDao;
this.priceDao = priceDao;
this.photoDao = photoDao;
this.countryDao = countryDao;
this.languageDao = languageDao;
this.genreDao = genreDao;
this.esrbDao = esrbDao;
}
private final PublisherDao publisherDao;
private final UserDao userDao;
private final TransactionDao transactionDao;
private final OrderDao orderDao;
private final GameDao gameDao;
private final DeveloperDao developerDao;
private final PriceDao priceDao;
private final PhotoDao photoDao;
private final CountryDao countryDao;
private final LanguageDao languageDao;
private final GenreDao genreDao;
private final EsrbDao esrbDao;

/*
POST (/publisher) The admin create a new publisher
Expand Down
46 changes: 20 additions & 26 deletions src/main/java/bo/ucb/edu/ingsoft/bl/StoreBl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import bo.ucb.edu.ingsoft.dao.*;
import bo.ucb.edu.ingsoft.dto.*;
import bo.ucb.edu.ingsoft.models.*;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -12,32 +14,24 @@
import java.util.List;

@Service
@AllArgsConstructor(onConstructor = @__({@Autowired}))
@Slf4j
public class StoreBl {
private GameDao gameDao;
private PriceDao priceDao;
private PhotoDao photoDao;
private UserDao userDao;
private OrderDao orderDao;
private DeveloperDao developerDao;

private static final Logger LOGGER = LoggerFactory.getLogger(StoreBl.class);

@Autowired
public StoreBl(GameDao gameDao, PriceDao priceDao, PhotoDao photoDao, UserDao userDao, OrderDao orderDao, DeveloperDao developerDao) {
this.gameDao = gameDao;
this.priceDao = priceDao;
this.photoDao = photoDao;
this.userDao = userDao;
this.orderDao = orderDao;
this.developerDao = developerDao;
}
private final GameDao gameDao;
private final PriceDao priceDao;
private final PhotoDao photoDao;
private final UserDao userDao;
private final OrderDao orderDao;
private final DeveloperDao developerDao;



/*
The user gets a paginated view of the homepage
*/
public List<GamesRequest> getGames(Integer page, String query, Boolean highlight, Boolean latest, Boolean sale, String publisher) {
List<GamesRequest> list = new ArrayList<GamesRequest>();
LOGGER.info(query);
log.info(query);
//Setup the query's page limit fir the SQL query
Integer recordsPerPage = 10;
Integer offsetValue = (page - 1) * recordsPerPage;
Expand All @@ -47,7 +41,7 @@ public List<GamesRequest> getGames(Integer page, String query, Boolean highlight
}
GameHelper gameHelper = new GameHelper(recordsPerPage, offsetValue, query, highlight, latest, sale, publisher);
List<Game> games = gameDao.findPage(gameHelper);
LOGGER.info(games.toString());
log.info(games.toString());
//Verifying the existance of the games.
if (!games.isEmpty()) {
List<Integer> ids = new ArrayList<Integer>();
Expand All @@ -70,25 +64,25 @@ public List<GamesRequest> getGames(Integer page, String query, Boolean highlight

public PaymentRequest getGamePayment(PaymentRequest paymentRequest, Transaction transaction) {
// Print transaction information
LOGGER.info(transaction.toString());
log.info(transaction.toString());

// Getting game information by game id
Game game = gameDao.getGameInfo(paymentRequest.getIdGame());

// Print game information
LOGGER.info(game.toString());
log.info(game.toString());

// Getting user information by user id from paymentRequest
User user = userDao.findByUserId(paymentRequest.getIdUser());

// Print user information
LOGGER.info(user.toString());
log.info(user.toString());

// Getting price information by game id
Price price = priceDao.findById(game.getIdGame());

// Print price information
LOGGER.info(price.toString());
log.info(price.toString());

// Loading data from user and transaction into Order
Orders orders = new Orders();
Expand All @@ -109,7 +103,7 @@ public PaymentRequest getGamePayment(PaymentRequest paymentRequest, Transaction
orders.setIdOrder(orderDao.getLastInsertId());

// Print orders information
LOGGER.info(orders.toString());
log.info(orders.toString());

// Loading data from game, orders and price into order details
OrderDetails orderDetails = new OrderDetails();
Expand All @@ -128,7 +122,7 @@ public PaymentRequest getGamePayment(PaymentRequest paymentRequest, Transaction
orderDao.createOrderDetails(orderDetails);

// Print orderDetails information
LOGGER.info(orderDetails.toString());
log.info(orderDetails.toString());

// Setting data from game, price and user to return the result
paymentRequest.setTitle(game.getName());
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/bo/ucb/edu/ingsoft/bl/TransactionBl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

import bo.ucb.edu.ingsoft.dao.TransactionDao;
import bo.ucb.edu.ingsoft.dto.Transaction;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor(onConstructor = @__({@Autowired}))
public class TransactionBl {

private TransactionDao transactionDao;

@Autowired
public TransactionBl(TransactionDao transactionDao) {
this.transactionDao = transactionDao;
}
private final TransactionDao transactionDao;

public Transaction createTransaction (Transaction transaction) {
// Registramos la transacción en la Base de Datos
Expand Down
Loading