mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 15:55:49 +00:00
Paginacion en todos las ofertas y reseñas
This commit is contained in:
parent
ca65afb304
commit
1cc7a9daa5
21 changed files with 581 additions and 414 deletions
|
@ -1,32 +1,34 @@
|
|||
|
||||
package org.springframework.cheapy.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cheapy.model.NuOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface NuOfferRepository extends Repository<NuOffer, Integer> {
|
||||
public interface NuOfferRepository extends PagingAndSortingRepository<NuOffer, Integer> {
|
||||
|
||||
NuOffer findNuOfferById(int nuOfferId);
|
||||
|
||||
|
||||
@Query("SELECT nuOffer FROM NuOffer nuOffer")
|
||||
@Transactional(readOnly = true)
|
||||
List<NuOffer> findAllNuOffer();
|
||||
List<NuOffer> findAllNuOffer(Pageable p);
|
||||
|
||||
//void save(NuOffer nuOffer);
|
||||
|
||||
void save(NuOffer nuOffer);
|
||||
|
||||
@Query("SELECT nuOffer FROM NuOffer nuOffer WHERE nuOffer.status =:status")
|
||||
@Transactional(readOnly = true)
|
||||
List<NuOffer> findActiveNuOffer(StatusOffer status);
|
||||
|
||||
List<NuOffer> findActiveNuOffer(StatusOffer status, Pageable p);
|
||||
|
||||
@Query("SELECT nuOffer FROM NuOffer nuOffer WHERE nuOffer.client.id =:id")
|
||||
@Transactional(readOnly = true)
|
||||
List<NuOffer> findByUserId(@Param("id") Integer id);
|
||||
|
||||
|
||||
@Query("SELECT nuOffer FROM NuOffer nuOffer WHERE nuOffer.client.id =:id AND nuOffer.status!= 'inactive'")
|
||||
@Transactional(readOnly = true)
|
||||
List<NuOffer> findNuOfferActOclByUserId(@Param("id") Integer id);
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
|
||||
package org.springframework.cheapy.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cheapy.model.Review;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface ReviewRepository extends Repository<Review, Integer> {
|
||||
public interface ReviewRepository extends PagingAndSortingRepository<Review, Integer> {
|
||||
|
||||
@Query("SELECT r FROM Review r")
|
||||
@Transactional(readOnly = true)
|
||||
List<Review> findAllReviews();
|
||||
List<Review> findAllReviews(Pageable p);
|
||||
|
||||
//void save(Review review);
|
||||
|
||||
void save(Review review);
|
||||
|
||||
@Query("SELECT r FROM Review r WHERE id =:id")
|
||||
@Transactional(readOnly = true)
|
||||
Review findReviewById(@Param("id") Integer id);
|
||||
|
|
|
@ -1,34 +1,36 @@
|
|||
|
||||
package org.springframework.cheapy.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cheapy.model.SpeedOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface SpeedOfferRepository extends Repository<SpeedOffer, Integer> {
|
||||
public interface SpeedOfferRepository extends PagingAndSortingRepository<SpeedOffer, Integer> {
|
||||
|
||||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE id =:id")
|
||||
@Transactional(readOnly = true)
|
||||
SpeedOffer findById(@Param("id") Integer id);
|
||||
|
||||
SpeedOffer findByIdSO(@Param("id") Integer id);
|
||||
|
||||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer")
|
||||
@Transactional(readOnly = true)
|
||||
List<SpeedOffer> findAllSpeedOffer();
|
||||
|
||||
void save(SpeedOffer speedOffer);
|
||||
|
||||
List<SpeedOffer> findAllSpeedOffer(Pageable p);
|
||||
|
||||
//void save(SpeedOffer speedOffer);
|
||||
|
||||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE speedOffer.status =:status")
|
||||
@Transactional(readOnly = true)
|
||||
List<SpeedOffer> findActiveSpeedOffer(StatusOffer status);
|
||||
|
||||
List<SpeedOffer> findActiveSpeedOffer(StatusOffer status, Pageable p);
|
||||
|
||||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE speedOffer.client.id =:id")
|
||||
@Transactional(readOnly = true)
|
||||
List<SpeedOffer> findByUserId(@Param("id") Integer id);
|
||||
|
||||
|
||||
@Query("SELECT speedOffer FROM SpeedOffer speedOffer WHERE speedOffer.client.id =:id AND speedOffer.status!= 'inactive'")
|
||||
@Transactional(readOnly = true)
|
||||
List<SpeedOffer> findSpeedOfferActOclByUserId(@Param("id") Integer id);
|
||||
|
|
|
@ -1,32 +1,35 @@
|
|||
|
||||
package org.springframework.cheapy.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cheapy.model.FoodOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.model.TimeOffer;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface TimeOfferRepository extends Repository<TimeOffer, Integer> {
|
||||
public interface TimeOfferRepository extends PagingAndSortingRepository<FoodOffer, Integer> {
|
||||
|
||||
TimeOffer findTimeOfferById(int timeOfferId);
|
||||
|
||||
|
||||
@Query("SELECT timeOffer FROM TimeOffer timeOffer")
|
||||
@Transactional(readOnly = true)
|
||||
List<TimeOffer> findAllTimeOffer();
|
||||
List<TimeOffer> findAllTimeOffer(Pageable p);
|
||||
|
||||
void save(TimeOffer timeOffer);
|
||||
|
||||
|
||||
@Query("SELECT timeOffer FROM TimeOffer timeOffer WHERE timeOffer.status =:status")
|
||||
@Transactional(readOnly = true)
|
||||
List<TimeOffer> findActiveTimeOffer(StatusOffer status);
|
||||
|
||||
List<TimeOffer> findActiveTimeOffer(StatusOffer status, Pageable p);
|
||||
|
||||
@Query("SELECT timeOffer FROM TimeOffer timeOffer WHERE timeOffer.client.id =:id")
|
||||
@Transactional(readOnly = true)
|
||||
List<TimeOffer> findByUserId(@Param("id") Integer id);
|
||||
|
||||
|
||||
@Query("SELECT timeOffer FROM TimeOffer timeOffer WHERE timeOffer.client.id =:id AND timeOffer.status!= 'inactive'")
|
||||
@Transactional(readOnly = true)
|
||||
List<TimeOffer> findTimeOfferActOclByUserId(@Param("id") Integer id);
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
|
||||
package org.springframework.cheapy.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.NuOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.repository.NuOfferRepository;
|
||||
import java.util.List;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -15,6 +17,7 @@ public class NuOfferService {
|
|||
|
||||
private NuOfferRepository nuOfferRepository;
|
||||
|
||||
|
||||
@Autowired
|
||||
public NuOfferService(final NuOfferRepository nuOfferRepository) {
|
||||
this.nuOfferRepository = nuOfferRepository;
|
||||
|
@ -26,28 +29,28 @@ public class NuOfferService {
|
|||
}
|
||||
|
||||
@Transactional
|
||||
public List<NuOffer> findAllNuOffer() {
|
||||
return this.nuOfferRepository.findAllNuOffer();
|
||||
public List<NuOffer> findAllNuOffer(final Pageable page) {
|
||||
return this.nuOfferRepository.findAllNuOffer(page);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveNuOffer(final NuOffer nuOffer) throws DataAccessException {
|
||||
this.nuOfferRepository.save(nuOffer);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void saveUpdateNuOffer(final NuOffer nuOfferNew, final NuOffer nuOfferOld) throws DataAccessException {
|
||||
this.nuOfferRepository.save(nuOfferNew);
|
||||
}
|
||||
|
||||
public List<NuOffer> findActiveNuOffer() {
|
||||
return this.nuOfferRepository.findActiveNuOffer(StatusOffer.active);
|
||||
|
||||
public List<NuOffer> findActiveNuOffer(final Pageable page) {
|
||||
return this.nuOfferRepository.findActiveNuOffer(StatusOffer.active, page);
|
||||
}
|
||||
|
||||
|
||||
public List<NuOffer> findNuOfferByUserId(final int id) {
|
||||
return this.nuOfferRepository.findByUserId(id);
|
||||
}
|
||||
|
||||
|
||||
public List<NuOffer> findNuOfferActOclByUserId(final int id) {
|
||||
return this.nuOfferRepository.findNuOfferActOclByUserId(id);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
package org.springframework.cheapy.service;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -5,15 +6,17 @@ import java.util.List;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.Review;
|
||||
import org.springframework.cheapy.repository.ReviewRepository;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class ReviewService {
|
||||
|
||||
private ReviewRepository reviewRepository;
|
||||
|
||||
|
||||
@Autowired
|
||||
public ReviewService(final ReviewRepository reviewRepository) {
|
||||
this.reviewRepository = reviewRepository;
|
||||
|
@ -25,8 +28,8 @@ public class ReviewService {
|
|||
}
|
||||
|
||||
@Transactional
|
||||
public List<Review> findAllReviews() {
|
||||
return this.reviewRepository.findAllReviews();
|
||||
public List<Review> findAllReviews(final Pageable page) {
|
||||
return this.reviewRepository.findAllReviews(page);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
package org.springframework.cheapy.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.SpeedOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.repository.SpeedOfferRepository;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -23,27 +25,27 @@ public class SpeedOfferService {
|
|||
|
||||
@Transactional
|
||||
public SpeedOffer findSpeedOfferById(final int id) {
|
||||
return this.speedOfferRepository.findById(id);
|
||||
return this.speedOfferRepository.findByIdSO(id);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public List<SpeedOffer> findAllSpeedOffer() { //
|
||||
return this.speedOfferRepository.findAllSpeedOffer();
|
||||
public List<SpeedOffer> findAllSpeedOffer(final Pageable page) { //
|
||||
return this.speedOfferRepository.findAllSpeedOffer(page);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveSpeedOffer(final SpeedOffer speedOffer) throws DataAccessException { //
|
||||
this.speedOfferRepository.save(speedOffer);
|
||||
}
|
||||
|
||||
public List<SpeedOffer> findActiveSpeedOffer() {
|
||||
return this.speedOfferRepository.findActiveSpeedOffer(StatusOffer.active);
|
||||
|
||||
public List<SpeedOffer> findActiveSpeedOffer(final Pageable page) {
|
||||
return this.speedOfferRepository.findActiveSpeedOffer(StatusOffer.active, page);
|
||||
}
|
||||
|
||||
|
||||
public List<SpeedOffer> findSpeedOfferByUserId(final int id) {
|
||||
return this.speedOfferRepository.findByUserId(id);
|
||||
}
|
||||
|
||||
|
||||
public List<SpeedOffer> findSpeedOfferActOclByUserId(final int id) {
|
||||
return this.speedOfferRepository.findSpeedOfferActOclByUserId(id);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
package org.springframework.cheapy.service;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -6,12 +7,13 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.model.TimeOffer;
|
||||
import org.springframework.cheapy.repository.TimeOfferRepository;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class TimeOfferService {
|
||||
|
||||
private TimeOfferRepository timeOfferRepository;
|
||||
|
||||
|
||||
|
@ -23,24 +25,23 @@ public class TimeOfferService {
|
|||
public TimeOffer findTimeOfferById(final int id) {
|
||||
return this.timeOfferRepository.findTimeOfferById(id);
|
||||
}
|
||||
|
||||
public List<TimeOffer> findAllTimeOffer() {
|
||||
return this.timeOfferRepository.findAllTimeOffer();
|
||||
|
||||
public List<TimeOffer> findAllTimeOffer(final Pageable page) {
|
||||
return this.timeOfferRepository.findAllTimeOffer(page);
|
||||
}
|
||||
|
||||
|
||||
public void saveTimeOffer(final TimeOffer TimeOffer) throws DataAccessException {
|
||||
public void saveTimeOffer(final TimeOffer TimeOffer) throws DataAccessException {
|
||||
this.timeOfferRepository.save(TimeOffer);
|
||||
}
|
||||
|
||||
public List<TimeOffer> findActiveTimeOffer() {
|
||||
return this.timeOfferRepository.findActiveTimeOffer(StatusOffer.active);
|
||||
|
||||
public List<TimeOffer> findActiveTimeOffer(final Pageable p) {
|
||||
return this.timeOfferRepository.findActiveTimeOffer(StatusOffer.active, p);
|
||||
}
|
||||
|
||||
|
||||
public List<TimeOffer> findTimeOfferByUserId(final int id) {
|
||||
return this.timeOfferRepository.findByUserId(id);
|
||||
}
|
||||
|
||||
|
||||
public List<TimeOffer> findTimeOfferActOclByUserId(final int id) {
|
||||
return this.timeOfferRepository.findTimeOfferActOclByUserId(id);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ import org.springframework.cheapy.model.FoodOffer;
|
|||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
import org.springframework.cheapy.service.FoodOfferService;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
|
@ -24,10 +26,11 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
@Controller
|
||||
public class FoodOfferController {
|
||||
|
||||
private static final String VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM = "offers/food/createOrUpdateFoodOfferForm";
|
||||
private static final String VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM = "offers/food/createOrUpdateFoodOfferForm";
|
||||
|
||||
private final FoodOfferService foodOfferService;
|
||||
private final ClientService clientService;
|
||||
|
||||
private final FoodOfferService foodOfferService;
|
||||
private final ClientService clientService;
|
||||
|
||||
public FoodOfferController(final FoodOfferService foodOfferService, final ClientService clientService) {
|
||||
this.foodOfferService = foodOfferService;
|
||||
|
@ -47,24 +50,25 @@ public class FoodOfferController {
|
|||
|
||||
private boolean checkOffer(final FoodOffer session, final FoodOffer offer) {
|
||||
boolean res = false;
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus()
|
||||
&& (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !(session.getStatus().equals(StatusOffer.inactive))) {
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus() && (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !session.getStatus().equals(StatusOffer.inactive)) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkDates(final FoodOffer foodOffer) {
|
||||
boolean res = false;
|
||||
if(foodOffer.getEnd()==null || foodOffer.getStart()==null || foodOffer.getEnd().isAfter(foodOffer.getStart())) {
|
||||
if (foodOffer.getEnd() == null || foodOffer.getStart() == null || foodOffer.getEnd().isAfter(foodOffer.getStart())) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/offers/foodOfferList")
|
||||
public String processFindForm(Map<String, Object> model) {
|
||||
List<FoodOffer> foodOfferLs=this.foodOfferService.findActiveFoodOffer();
|
||||
|
||||
@GetMapping("/offers/foodOfferList/{page}")
|
||||
public String processFindForm(@PathVariable("page") final int page, final Map<String, Object> model) {
|
||||
Pageable elements = PageRequest.of(page, 5);
|
||||
|
||||
List<FoodOffer> foodOfferLs = this.foodOfferService.findActiveFoodOffer(elements);
|
||||
model.put("foodOfferLs", foodOfferLs);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/food/foodOffersList";
|
||||
|
@ -72,32 +76,32 @@ public class FoodOfferController {
|
|||
}
|
||||
|
||||
@GetMapping("/offers/food/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
public String initCreationForm(final Map<String, Object> model) {
|
||||
FoodOffer foodOffer = new FoodOffer();
|
||||
model.put("foodOffer", foodOffer);
|
||||
return VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping("/offers/food/new")
|
||||
public String processCreationForm(@Valid FoodOffer foodOffer, BindingResult result) {
|
||||
|
||||
if(!this.checkDates(foodOffer)) {
|
||||
result.rejectValue("end","" ,"La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
if (result.hasErrors()) {
|
||||
return VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
foodOffer.setClient(client);
|
||||
foodOffer.setStatus(StatusOffer.hidden);
|
||||
this.foodOfferService.saveFoodOffer(foodOffer);
|
||||
return "redirect:/offers/food/" + foodOffer.getId();
|
||||
|
||||
public String processCreationForm(@Valid final FoodOffer foodOffer, final BindingResult result) {
|
||||
|
||||
if (!this.checkDates(foodOffer)) {
|
||||
result.rejectValue("end", "", "La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
if (result.hasErrors()) {
|
||||
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
foodOffer.setClient(client);
|
||||
foodOffer.setStatus(StatusOffer.hidden);
|
||||
this.foodOfferService.saveFoodOffer(foodOffer);
|
||||
return "redirect:/offers/food/" + foodOffer.getId();
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/food/{foodOfferId}/activate")
|
||||
public String activateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, ModelMap modelMap) {
|
||||
public String activateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap modelMap) {
|
||||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
if (foodOffer.getClient().equals(client)) {
|
||||
|
@ -112,26 +116,25 @@ public class FoodOfferController {
|
|||
}
|
||||
|
||||
@GetMapping("/offers/food/{foodOfferId}")
|
||||
public String processShowForm(@PathVariable("foodOfferId") int foodOfferId, Map<String, Object> model) {
|
||||
public String processShowForm(@PathVariable("foodOfferId") final int foodOfferId, final Map<String, Object> model) {
|
||||
|
||||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
if(foodOffer.getStatus().equals(StatusOffer.active)) {
|
||||
if (foodOffer.getStatus().equals(StatusOffer.active)) {
|
||||
model.put("foodOffer", foodOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/food/foodOffersShow";
|
||||
|
||||
}else if(foodOffer.getStatus().equals(StatusOffer.hidden)&&(this.checkIdentity(foodOfferId))) {
|
||||
model.put("foodOffer", foodOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/food/foodOffersShow";
|
||||
}else {
|
||||
|
||||
} else if (foodOffer.getStatus().equals(StatusOffer.hidden) && this.checkIdentity(foodOfferId)) {
|
||||
model.put("foodOffer", foodOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/food/foodOffersShow";
|
||||
} else {
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/food/{foodOfferId}/edit")
|
||||
public String updateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model,
|
||||
HttpServletRequest request) {
|
||||
public String updateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model, final HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(foodOfferId)) {
|
||||
return "error";
|
||||
|
@ -146,8 +149,7 @@ public class FoodOfferController {
|
|||
}
|
||||
|
||||
@PostMapping(value = "/offers/food/{foodOfferId}/edit")
|
||||
public String updateFoodOffer(@Valid final FoodOffer foodOfferEdit, final BindingResult result,
|
||||
final ModelMap model, HttpServletRequest request) {
|
||||
public String updateFoodOffer(@Valid final FoodOffer foodOfferEdit, final BindingResult result, final ModelMap model, final HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(foodOfferEdit.getId())) {
|
||||
return "error";
|
||||
|
@ -157,22 +159,21 @@ public class FoodOfferController {
|
|||
if (!this.checkOffer(foodOffer, foodOfferEdit)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
if(!this.checkDates(foodOfferEdit)) {
|
||||
result.rejectValue("end","" ,"La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("foodOffer", foodOfferEdit);
|
||||
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
}
|
||||
BeanUtils.copyProperties(this.foodOfferService.findFoodOfferById(foodOfferEdit.getId()), foodOfferEdit,
|
||||
"start", "end", "food", "discount");
|
||||
this.foodOfferService.saveFoodOffer(foodOfferEdit);
|
||||
return "redirect:/offers/food/" + foodOfferEdit.getId();
|
||||
|
||||
if (!this.checkDates(foodOfferEdit)) {
|
||||
result.rejectValue("end", "", "La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("foodOffer", foodOfferEdit);
|
||||
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
}
|
||||
BeanUtils.copyProperties(this.foodOfferService.findFoodOfferById(foodOfferEdit.getId()), foodOfferEdit, "start", "end", "food", "discount");
|
||||
this.foodOfferService.saveFoodOffer(foodOfferEdit);
|
||||
return "redirect:/offers/food/" + foodOfferEdit.getId();
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/food/{foodOfferId}/disable")
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
package org.springframework.cheapy.web;
|
||||
|
||||
import java.security.Principal;
|
||||
|
@ -14,6 +15,8 @@ import org.springframework.cheapy.model.NuOffer;
|
|||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
import org.springframework.cheapy.service.NuOfferService;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
|
@ -24,16 +27,17 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
@Controller
|
||||
public class NuOfferController {
|
||||
|
||||
private static final String VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM = "offers/nu/createOrUpdateNuOfferForm";
|
||||
private static final String VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM = "offers/nu/createOrUpdateNuOfferForm";
|
||||
|
||||
private final NuOfferService nuOfferService;
|
||||
private final ClientService clientService;
|
||||
|
||||
private final NuOfferService nuOfferService;
|
||||
private final ClientService clientService;
|
||||
|
||||
public NuOfferController(final NuOfferService nuOfferService, final ClientService clientService) {
|
||||
this.nuOfferService = nuOfferService;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkIdentity(final int nuOfferId) {
|
||||
boolean res = false;
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
|
@ -47,43 +51,44 @@ public class NuOfferController {
|
|||
|
||||
private boolean checkOffer(final NuOffer session, final NuOffer offer) {
|
||||
boolean res = false;
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus()
|
||||
&& (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !(session.getStatus().equals(StatusOffer.inactive))) {
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus() && (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !session.getStatus().equals(StatusOffer.inactive)) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkDates(final NuOffer nuOffer) {
|
||||
boolean res = false;
|
||||
if(nuOffer.getEnd()==null || nuOffer.getStart()==null || nuOffer.getEnd().isAfter(nuOffer.getStart())) {
|
||||
if (nuOffer.getEnd() == null || nuOffer.getStart() == null || nuOffer.getEnd().isAfter(nuOffer.getStart())) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkConditions(final NuOffer nuOffer) {
|
||||
boolean res = false;
|
||||
if(nuOffer.getGold()==null || nuOffer.getSilver()==null || nuOffer.getBronze()==null) {
|
||||
|
||||
}else if(nuOffer.getGold() >= nuOffer.getSilver() && nuOffer.getSilver() >= nuOffer.getBronze()) {
|
||||
if (nuOffer.getGold() == null || nuOffer.getSilver() == null || nuOffer.getBronze() == null) {
|
||||
|
||||
} else if (nuOffer.getGold() >= nuOffer.getSilver() && nuOffer.getSilver() >= nuOffer.getBronze()) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkDiscounts(final NuOffer NuOffer) {
|
||||
boolean res = false;
|
||||
if(NuOffer.getDiscountGold()==null || NuOffer.getDiscountSilver()==null || NuOffer.getDiscountBronze()==null) {
|
||||
}else if(NuOffer.getDiscountGold() >= NuOffer.getDiscountSilver() && NuOffer.getDiscountSilver() >= NuOffer.getDiscountBronze()) {
|
||||
if (NuOffer.getDiscountGold() == null || NuOffer.getDiscountSilver() == null || NuOffer.getDiscountBronze() == null) {
|
||||
} else if (NuOffer.getDiscountGold() >= NuOffer.getDiscountSilver() && NuOffer.getDiscountSilver() >= NuOffer.getDiscountBronze()) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/offers/nuOfferList")
|
||||
public String processFindForm(Map<String, Object> model) {
|
||||
List<NuOffer> foodOfferLs=this.nuOfferService.findActiveNuOffer();
|
||||
|
||||
@GetMapping("/offers/nuOfferList/{page}")
|
||||
public String processFindForm(@PathVariable("page") final int page, final Map<String, Object> model) {
|
||||
Pageable elements = PageRequest.of(page, 5);
|
||||
|
||||
List<NuOffer> foodOfferLs = this.nuOfferService.findActiveNuOffer(elements);
|
||||
model.put("nuOfferLs", foodOfferLs);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/nu/nuOffersList";
|
||||
|
@ -91,40 +96,40 @@ public class NuOfferController {
|
|||
}
|
||||
|
||||
@GetMapping("/offers/nu/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
public String initCreationForm(final Map<String, Object> model) {
|
||||
NuOffer nuOffer = new NuOffer();
|
||||
model.put("nuOffer", nuOffer);
|
||||
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping("/offers/nu/new")
|
||||
public String processCreationForm(@Valid NuOffer nuOffer, BindingResult result) {
|
||||
|
||||
if(!this.checkDates(nuOffer)) {
|
||||
result.rejectValue("end","" ,"La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
if(!this.checkConditions(nuOffer)) {
|
||||
result.rejectValue("gold","" ,"Oro debe ser mayor o igual que plata, y plata mayor o igual que bronce");
|
||||
|
||||
}
|
||||
if(!this.checkDiscounts(nuOffer)) {
|
||||
result.rejectValue("discountGold","" ,"El descuento de Oro debe ser mayor o igual que el de plata, y el de plata mayor o igual que el de bronce");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
nuOffer.setStatus(StatusOffer.hidden);
|
||||
public String processCreationForm(@Valid final NuOffer nuOffer, final BindingResult result) {
|
||||
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
if (!this.checkDates(nuOffer)) {
|
||||
result.rejectValue("end", "", "La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
nuOffer.setClient(client);
|
||||
}
|
||||
if (!this.checkConditions(nuOffer)) {
|
||||
result.rejectValue("gold", "", "Oro debe ser mayor o igual que plata, y plata mayor o igual que bronce");
|
||||
|
||||
}
|
||||
if (!this.checkDiscounts(nuOffer)) {
|
||||
result.rejectValue("discountGold", "", "El descuento de Oro debe ser mayor o igual que el de plata, y el de plata mayor o igual que el de bronce");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
nuOffer.setStatus(StatusOffer.hidden);
|
||||
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
|
||||
nuOffer.setClient(client);
|
||||
|
||||
this.nuOfferService.saveNuOffer(nuOffer);
|
||||
return "redirect:/offers/nu/" + nuOffer.getId();
|
||||
|
||||
this.nuOfferService.saveNuOffer(nuOffer);
|
||||
return "redirect:/offers/nu/" + nuOffer.getId();
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/nu/{nuOfferId}/activate")
|
||||
|
@ -144,26 +149,25 @@ public class NuOfferController {
|
|||
}
|
||||
|
||||
@GetMapping("/offers/nu/{nuOfferId}")
|
||||
public String processShowForm(@PathVariable("nuOfferId") int nuOfferId, Map<String, Object> model) {
|
||||
public String processShowForm(@PathVariable("nuOfferId") final int nuOfferId, final Map<String, Object> model) {
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
if(nuOffer.getStatus().equals(StatusOffer.active)) {
|
||||
if (nuOffer.getStatus().equals(StatusOffer.active)) {
|
||||
model.put("nuOffer", nuOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/nu/nuOffersShow";
|
||||
}else if(nuOffer.getStatus().equals(StatusOffer.hidden)&&(this.checkIdentity(nuOfferId))) {
|
||||
model.put("nuOffer", nuOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/nu/nuOffersShow";
|
||||
|
||||
}else {
|
||||
} else if (nuOffer.getStatus().equals(StatusOffer.hidden) && this.checkIdentity(nuOfferId)) {
|
||||
model.put("nuOffer", nuOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/nu/nuOffersShow";
|
||||
|
||||
} else {
|
||||
return "error";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/nu/{nuOfferId}/edit")
|
||||
public String updateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final ModelMap model,
|
||||
HttpServletRequest request) {
|
||||
public String updateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final ModelMap model, final HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(nuOfferId)) {
|
||||
return "error";
|
||||
|
@ -178,8 +182,7 @@ public class NuOfferController {
|
|||
}
|
||||
|
||||
@PostMapping(value = "/offers/nu/{nuOfferId}/edit")
|
||||
public String updateNuOffer(@Valid final NuOffer nuOfferEdit, final BindingResult result, final ModelMap model,
|
||||
HttpServletRequest request) {
|
||||
public String updateNuOffer(@Valid final NuOffer nuOfferEdit, final BindingResult result, final ModelMap model, final HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(nuOfferEdit.getId())) {
|
||||
return "error";
|
||||
|
@ -190,35 +193,32 @@ public class NuOfferController {
|
|||
return "error";
|
||||
}
|
||||
|
||||
if(!this.checkDates(nuOfferEdit)) {
|
||||
result.rejectValue("end","" ,"La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
if(!this.checkConditions(nuOfferEdit)) {
|
||||
result.rejectValue("gold","" ,"Oro debe ser mayor o igual que plata, y plata mayor o igual que bronce");
|
||||
|
||||
}
|
||||
if(!this.checkDiscounts(nuOfferEdit)) {
|
||||
result.rejectValue("discountGold","" ,"El descuento de Oro debe ser mayor o igual que el de plata, y el de plata mayor o igual que el de bronce");
|
||||
|
||||
}
|
||||
|
||||
if (!this.checkDates(nuOfferEdit)) {
|
||||
result.rejectValue("end", "", "La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("nuOffer", nuOfferEdit);
|
||||
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
if (!this.checkConditions(nuOfferEdit)) {
|
||||
result.rejectValue("gold", "", "Oro debe ser mayor o igual que plata, y plata mayor o igual que bronce");
|
||||
|
||||
}
|
||||
if (!this.checkDiscounts(nuOfferEdit)) {
|
||||
result.rejectValue("discountGold", "", "El descuento de Oro debe ser mayor o igual que el de plata, y el de plata mayor o igual que el de bronce");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("nuOffer", nuOfferEdit);
|
||||
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
}
|
||||
BeanUtils.copyProperties(this.nuOfferService.findNuOfferById(nuOfferEdit.getId()), nuOfferEdit, "start", "end", "gold", "discount_gold", "silver", "discount_silver", "bronze", "discount_bronze");
|
||||
this.nuOfferService.saveNuOffer(nuOfferEdit);
|
||||
return "redirect:/offers/nu/" + nuOfferEdit.getId();
|
||||
|
||||
}
|
||||
BeanUtils.copyProperties(this.nuOfferService.findNuOfferById(nuOfferEdit.getId()), nuOfferEdit, "start",
|
||||
"end", "gold", "discount_gold", "silver", "discount_silver", "bronze", "discount_bronze");
|
||||
this.nuOfferService.saveNuOffer(nuOfferEdit);
|
||||
return "redirect:/offers/nu/" + nuOfferEdit.getId();
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/nu/{nuOfferId}/disable")
|
||||
public String disableNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal,
|
||||
final ModelMap model) {
|
||||
public String disableNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(nuOfferId)) {
|
||||
return "error";
|
||||
|
@ -230,8 +230,7 @@ public class NuOfferController {
|
|||
}
|
||||
|
||||
@PostMapping(value = "/offers/nu/{nuOfferId}/disable")
|
||||
public String disableNuOfferForm(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal,
|
||||
final ModelMap model) {
|
||||
public String disableNuOfferForm(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(nuOfferId)) {
|
||||
return "error";
|
||||
|
|
|
@ -43,9 +43,9 @@ public class OfertaController {
|
|||
Pageable elements = PageRequest.of(0, 3);
|
||||
|
||||
List<FoodOffer> foodOfferLs = this.foodOfferService.findActiveFoodOffer(elements);
|
||||
List<NuOffer> nuOfferLs = this.nuOfferService.findActiveNuOffer();
|
||||
List<SpeedOffer> speedOfferLs = this.speedOfferService.findActiveSpeedOffer();
|
||||
List<TimeOffer> timeOfferLs = this.timeOfferService.findActiveTimeOffer();
|
||||
List<NuOffer> nuOfferLs = this.nuOfferService.findActiveNuOffer(elements);
|
||||
List<SpeedOffer> speedOfferLs = this.speedOfferService.findActiveSpeedOffer(elements);
|
||||
List<TimeOffer> timeOfferLs = this.timeOfferService.findActiveTimeOffer(elements);
|
||||
|
||||
model.put("foodOfferLs", foodOfferLs);
|
||||
model.put("nuOfferLs", nuOfferLs);
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
package org.springframework.cheapy.web;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -9,6 +10,8 @@ import org.springframework.cheapy.model.Review;
|
|||
import org.springframework.cheapy.model.User;
|
||||
import org.springframework.cheapy.service.ReviewService;
|
||||
import org.springframework.cheapy.service.UserService;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
|
@ -19,10 +22,10 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
@Controller
|
||||
public class ReviewController {
|
||||
|
||||
private static final String VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM = "reviews/createOrUpdateReviewForm";
|
||||
private final ReviewService reviewService;
|
||||
private final UserService userService;
|
||||
|
||||
private static final String VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM = "reviews/createOrUpdateReviewForm";
|
||||
private final ReviewService reviewService;
|
||||
private final UserService userService;
|
||||
|
||||
public ReviewController(final ReviewService reviewService, final UserService userService) {
|
||||
this.reviewService = reviewService;
|
||||
|
@ -38,46 +41,44 @@ public class ReviewController {
|
|||
}
|
||||
return res;
|
||||
}
|
||||
@GetMapping("/reviews")
|
||||
public String processFindForm( Map<String, Object> model) {
|
||||
@GetMapping("/reviewsList/{page}")
|
||||
public String processFindForm(@PathVariable("page") final int page, final Map<String, Object> model) {
|
||||
Pageable elements = PageRequest.of(page, 6);
|
||||
|
||||
List<Review> reviewsLs=this.reviewService.findAllReviews();
|
||||
List<Review> reviewsLs = this.reviewService.findAllReviews(elements);
|
||||
model.put("reviewsLs", reviewsLs);
|
||||
|
||||
|
||||
return "reviews/reviewsList";
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/reviews/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
public String initCreationForm(final Map<String, Object> model) {
|
||||
Review review = new Review();
|
||||
model.put("review", review);
|
||||
return VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM;
|
||||
return ReviewController.VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping("/reviews/new")
|
||||
public String processCreationForm(@Valid Review review, BindingResult result) {
|
||||
public String processCreationForm(@Valid final Review review, final BindingResult result) {
|
||||
if (result.hasErrors()) {
|
||||
return VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM;
|
||||
return ReviewController.VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM;
|
||||
} else {
|
||||
User escritor = this.userService.getCurrentUser();
|
||||
review.setEscritor(escritor);
|
||||
|
||||
|
||||
this.reviewService.saveReview(review);
|
||||
return "redirect:/reviews/" + review.getId();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/reviews/{reviewId}")
|
||||
public String processShowForm(@PathVariable("reviewId") int reviewId, Map<String, Object> model) {
|
||||
public String processShowForm(@PathVariable("reviewId") final int reviewId, final Map<String, Object> model) {
|
||||
|
||||
Review review = this.reviewService.findReviewById(reviewId);
|
||||
|
||||
model.put("review", review);
|
||||
|
||||
|
||||
|
||||
return "reviews/reviewsShow";
|
||||
|
||||
}
|
||||
|
@ -105,7 +106,7 @@ public class ReviewController {
|
|||
} else {
|
||||
User escritor = this.userService.getCurrentUser();
|
||||
reviewEdit.setEscritor(escritor);
|
||||
|
||||
|
||||
this.reviewService.saveReview(reviewEdit);
|
||||
return "redirect:/reviews/" + reviewEdit.getId();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
package org.springframework.cheapy.web;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
@ -13,6 +14,8 @@ import org.springframework.cheapy.model.SpeedOffer;
|
|||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
import org.springframework.cheapy.service.SpeedOfferService;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
|
@ -23,10 +26,11 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
@Controller
|
||||
public class SpeedOfferController {
|
||||
|
||||
private static final String VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM = "offers/speed/createOrUpdateSpeedOfferForm";
|
||||
private static final String VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM = "offers/speed/createOrUpdateSpeedOfferForm";
|
||||
|
||||
private final SpeedOfferService speedOfferService;
|
||||
private final ClientService clientService;
|
||||
|
||||
private final SpeedOfferService speedOfferService;
|
||||
private final ClientService clientService;
|
||||
|
||||
public SpeedOfferController(final SpeedOfferService speedOfferService, final ClientService clientService) {
|
||||
this.speedOfferService = speedOfferService;
|
||||
|
@ -46,43 +50,44 @@ public class SpeedOfferController {
|
|||
|
||||
private boolean checkOffer(final SpeedOffer session, final SpeedOffer offer) {
|
||||
boolean res = false;
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus()
|
||||
&& (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !(session.getStatus().equals(StatusOffer.inactive))) {
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus() && (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !session.getStatus().equals(StatusOffer.inactive)) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkDates(final SpeedOffer speedOffer) {
|
||||
boolean res = false;
|
||||
if(speedOffer.getEnd()==null || speedOffer.getStart()==null || speedOffer.getEnd().isAfter(speedOffer.getStart())) {
|
||||
if (speedOffer.getEnd() == null || speedOffer.getStart() == null || speedOffer.getEnd().isAfter(speedOffer.getStart())) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkConditions(final SpeedOffer speedOffer) {
|
||||
boolean res = false;
|
||||
if(speedOffer.getGold()==null || speedOffer.getSilver()==null || speedOffer.getBronze()==null) {
|
||||
|
||||
}else if(speedOffer.getGold() <= speedOffer.getSilver() && speedOffer.getSilver() <= speedOffer.getBronze()) {
|
||||
if (speedOffer.getGold() == null || speedOffer.getSilver() == null || speedOffer.getBronze() == null) {
|
||||
|
||||
} else if (speedOffer.getGold() <= speedOffer.getSilver() && speedOffer.getSilver() <= speedOffer.getBronze()) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkDiscounts(final SpeedOffer speedOffer) {
|
||||
boolean res = false;
|
||||
if(speedOffer.getDiscountGold()==null || speedOffer.getDiscountSilver()==null || speedOffer.getDiscountBronze()==null) {
|
||||
}else if(speedOffer.getDiscountGold() >= speedOffer.getDiscountSilver() && speedOffer.getDiscountSilver() >= speedOffer.getDiscountBronze()) {
|
||||
if (speedOffer.getDiscountGold() == null || speedOffer.getDiscountSilver() == null || speedOffer.getDiscountBronze() == null) {
|
||||
} else if (speedOffer.getDiscountGold() >= speedOffer.getDiscountSilver() && speedOffer.getDiscountSilver() >= speedOffer.getDiscountBronze()) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/offers/speedOfferList")
|
||||
public String processFindForm(Map<String, Object> model) {
|
||||
List<SpeedOffer> speedOfferLs=this.speedOfferService.findActiveSpeedOffer();
|
||||
|
||||
@GetMapping("/offers/speedOfferList/{page}")
|
||||
public String processFindForm(@PathVariable("page") final int page, final Map<String, Object> model) {
|
||||
Pageable elements = PageRequest.of(page, 5);
|
||||
|
||||
List<SpeedOffer> speedOfferLs = this.speedOfferService.findActiveSpeedOffer(elements);
|
||||
model.put("speedOfferLs", speedOfferLs);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/speed/speedOffersList";
|
||||
|
@ -90,42 +95,42 @@ public class SpeedOfferController {
|
|||
}
|
||||
|
||||
@GetMapping("/offers/speed/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
public String initCreationForm(final Map<String, Object> model) {
|
||||
SpeedOffer speedOffer = new SpeedOffer();
|
||||
model.put("speedOffer", speedOffer);
|
||||
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping("/offers/speed/new")
|
||||
public String processCreationForm(@Valid SpeedOffer speedOffer, BindingResult result) {
|
||||
|
||||
if(!this.checkDates(speedOffer)) {
|
||||
result.rejectValue("end","" ,"La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
if(!this.checkConditions(speedOffer)) {
|
||||
result.rejectValue("gold","" ,"Oro debe ser menor o igual que plata, y plata menor o igual que bronce");
|
||||
|
||||
}
|
||||
if(!this.checkDiscounts(speedOffer)) {
|
||||
result.rejectValue("discountGold","" ,"El descuento de Oro debe ser menor o igual que el de plata, y el de plata menor o igual que el de bronce");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
speedOffer.setClient(client);
|
||||
speedOffer.setStatus(StatusOffer.hidden);
|
||||
this.speedOfferService.saveSpeedOffer(speedOffer);
|
||||
return "redirect:/offers/speed/" + speedOffer.getId();
|
||||
|
||||
public String processCreationForm(@Valid final SpeedOffer speedOffer, final BindingResult result) {
|
||||
|
||||
if (!this.checkDates(speedOffer)) {
|
||||
result.rejectValue("end", "", "La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
if (!this.checkConditions(speedOffer)) {
|
||||
result.rejectValue("gold", "", "Oro debe ser menor o igual que plata, y plata menor o igual que bronce");
|
||||
|
||||
}
|
||||
if (!this.checkDiscounts(speedOffer)) {
|
||||
result.rejectValue("discountGold", "", "El descuento de Oro debe ser menor o igual que el de plata, y el de plata menor o igual que el de bronce");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
speedOffer.setClient(client);
|
||||
speedOffer.setStatus(StatusOffer.hidden);
|
||||
this.speedOfferService.saveSpeedOffer(speedOffer);
|
||||
return "redirect:/offers/speed/" + speedOffer.getId();
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/speed/{speedOfferId}/activate")
|
||||
public String activateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, ModelMap modelMap) {
|
||||
public String activateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap modelMap) {
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
if (speedOffer.getClient().equals(client)) {
|
||||
|
@ -139,24 +144,24 @@ public class SpeedOfferController {
|
|||
}
|
||||
|
||||
@GetMapping("/offers/speed/{speedOfferId}")
|
||||
public String processShowForm(@PathVariable("speedOfferId") int speedOfferId, Map<String, Object> model) {
|
||||
public String processShowForm(@PathVariable("speedOfferId") final int speedOfferId, final Map<String, Object> model) {
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
if(speedOffer.getStatus().equals(StatusOffer.active)) {
|
||||
if (speedOffer.getStatus().equals(StatusOffer.active)) {
|
||||
model.put("speedOffer", speedOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/speed/speedOffersShow";
|
||||
}else if(speedOffer.getStatus().equals(StatusOffer.hidden)&&(this.checkIdentity(speedOfferId))) {
|
||||
model.put("speedOffer", speedOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/speed/speedOffersShow";
|
||||
|
||||
}else {
|
||||
} else if (speedOffer.getStatus().equals(StatusOffer.hidden) && this.checkIdentity(speedOfferId)) {
|
||||
model.put("speedOffer", speedOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/speed/speedOffersShow";
|
||||
|
||||
} else {
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/speed/{speedOfferId}/edit")
|
||||
public String updateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model, HttpServletRequest request) {
|
||||
public String updateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model, final HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(speedOfferId)) {
|
||||
return "error";
|
||||
|
@ -172,8 +177,7 @@ public class SpeedOfferController {
|
|||
}
|
||||
|
||||
@PostMapping(value = "/offers/speed/{speedOfferId}/edit")
|
||||
public String updateSpeedOffer(@Valid final SpeedOffer speedOfferEdit, final BindingResult result,
|
||||
final ModelMap model, HttpServletRequest request) {
|
||||
public String updateSpeedOffer(@Valid final SpeedOffer speedOfferEdit, final BindingResult result, final ModelMap model, final HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(speedOfferEdit.getId())) {
|
||||
return "error";
|
||||
|
@ -184,29 +188,27 @@ public class SpeedOfferController {
|
|||
return "error";
|
||||
}
|
||||
|
||||
if(!this.checkDates(speedOfferEdit)) {
|
||||
result.rejectValue("end","" ,"La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
if(!this.checkConditions(speedOfferEdit)) {
|
||||
result.rejectValue("gold","" ,"Oro debe ser menor o igual que plata, y plata menor o igual que bronce");
|
||||
|
||||
}
|
||||
if(!this.checkDiscounts(speedOfferEdit)) {
|
||||
result.rejectValue("discountGold","" ,"El descuento de Oro debe ser mayor o igual que el de plata, y el de plata mayor o igual que el de bronce");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("speedOffer", speedOfferEdit);
|
||||
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
if (!this.checkDates(speedOfferEdit)) {
|
||||
result.rejectValue("end", "", "La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
BeanUtils.copyProperties(this.speedOfferService.findSpeedOfferById(speedOfferEdit.getId()), speedOfferEdit,
|
||||
"start", "end", "gold", "discount_gold", "silver", "discount_silver", "bronze", "discount_bronze");
|
||||
this.speedOfferService.saveSpeedOffer(speedOfferEdit);
|
||||
return "redirect:/offers/speed/" + speedOfferEdit.getId();
|
||||
|
||||
}
|
||||
if (!this.checkConditions(speedOfferEdit)) {
|
||||
result.rejectValue("gold", "", "Oro debe ser menor o igual que plata, y plata menor o igual que bronce");
|
||||
|
||||
}
|
||||
if (!this.checkDiscounts(speedOfferEdit)) {
|
||||
result.rejectValue("discountGold", "", "El descuento de Oro debe ser mayor o igual que el de plata, y el de plata mayor o igual que el de bronce");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("speedOffer", speedOfferEdit);
|
||||
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
}
|
||||
BeanUtils.copyProperties(this.speedOfferService.findSpeedOfferById(speedOfferEdit.getId()), speedOfferEdit, "start", "end", "gold", "discount_gold", "silver", "discount_silver", "bronze", "discount_bronze");
|
||||
this.speedOfferService.saveSpeedOffer(speedOfferEdit);
|
||||
return "redirect:/offers/speed/" + speedOfferEdit.getId();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
package org.springframework.cheapy.web;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
@ -13,6 +14,8 @@ import org.springframework.cheapy.model.StatusOffer;
|
|||
import org.springframework.cheapy.model.TimeOffer;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
import org.springframework.cheapy.service.TimeOfferService;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
|
@ -23,11 +26,12 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
@Controller
|
||||
public class TimeOfferController {
|
||||
|
||||
private static final String VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM = "offers/time/createOrUpdateTimeOfferForm";
|
||||
private final TimeOfferService timeOfferService;
|
||||
private final ClientService clientService;
|
||||
private static final String VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM = "offers/time/createOrUpdateTimeOfferForm";
|
||||
private final TimeOfferService timeOfferService;
|
||||
private final ClientService clientService;
|
||||
|
||||
public TimeOfferController(final TimeOfferService timeOfferService, ClientService clientService) {
|
||||
|
||||
public TimeOfferController(final TimeOfferService timeOfferService, final ClientService clientService) {
|
||||
this.timeOfferService = timeOfferService;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
|
@ -45,32 +49,33 @@ public class TimeOfferController {
|
|||
|
||||
private boolean checkOffer(final TimeOffer session, final TimeOffer offer) {
|
||||
boolean res = false;
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus()
|
||||
&& (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !(session.getStatus().equals(StatusOffer.inactive))) {
|
||||
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus() && (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !session.getStatus().equals(StatusOffer.inactive)) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkDates(final TimeOffer timeOffer) {
|
||||
boolean res = false;
|
||||
if(timeOffer.getEnd()==null || timeOffer.getStart()==null || timeOffer.getEnd().isAfter(timeOffer.getStart())) {
|
||||
if (timeOffer.getEnd() == null || timeOffer.getStart() == null || timeOffer.getEnd().isAfter(timeOffer.getStart())) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkTimes(final TimeOffer timeOffer) {
|
||||
boolean res = false;
|
||||
if(timeOffer.getFinish()==null || timeOffer.getInit()==null || timeOffer.getFinish().isAfter(timeOffer.getInit())) {
|
||||
if (timeOffer.getFinish() == null || timeOffer.getInit() == null || timeOffer.getFinish().isAfter(timeOffer.getInit())) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/offers/timeOfferList")
|
||||
public String processFindForm(Map<String, Object> model) {
|
||||
List<TimeOffer> timeOfferLs=this.timeOfferService.findActiveTimeOffer();
|
||||
|
||||
@GetMapping("/offers/timeOfferList/{page}")
|
||||
public String processFindForm(@PathVariable("page") final int page, final Map<String, Object> model) {
|
||||
Pageable elements = PageRequest.of(page, 5);
|
||||
|
||||
List<TimeOffer> timeOfferLs = this.timeOfferService.findActiveTimeOffer(elements);
|
||||
model.put("timeOfferLs", timeOfferLs);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/time/timeOffersList";
|
||||
|
@ -78,38 +83,38 @@ public class TimeOfferController {
|
|||
}
|
||||
|
||||
@GetMapping("/offers/time/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
public String initCreationForm(final Map<String, Object> model) {
|
||||
TimeOffer timeOffer = new TimeOffer();
|
||||
model.put("timeOffer", timeOffer);
|
||||
return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
return TimeOfferController.VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping("/offers/time/new")
|
||||
public String processCreationForm(@Valid TimeOffer timeOffer, BindingResult result) {
|
||||
|
||||
if(!this.checkDates(timeOffer)) {
|
||||
result.rejectValue("end","" ,"La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
|
||||
if(!this.checkTimes(timeOffer)) {
|
||||
result.rejectValue("finish","" ,"La hora de fin debe ser posterior a la de inicio");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
timeOffer.setStatus(StatusOffer.hidden);
|
||||
public String processCreationForm(@Valid final TimeOffer timeOffer, final BindingResult result) {
|
||||
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
if (!this.checkDates(timeOffer)) {
|
||||
result.rejectValue("end", "", "La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
timeOffer.setClient(client);
|
||||
}
|
||||
|
||||
if (!this.checkTimes(timeOffer)) {
|
||||
result.rejectValue("finish", "", "La hora de fin debe ser posterior a la de inicio");
|
||||
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
return TimeOfferController.VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
timeOffer.setStatus(StatusOffer.hidden);
|
||||
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
|
||||
timeOffer.setClient(client);
|
||||
|
||||
this.timeOfferService.saveTimeOffer(timeOffer);
|
||||
return "redirect:/offers/time/" + timeOffer.getId();
|
||||
|
||||
this.timeOfferService.saveTimeOffer(timeOffer);
|
||||
return "redirect:/offers/time/" + timeOffer.getId();
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/time/{timeOfferId}/activate")
|
||||
|
@ -129,26 +134,25 @@ public class TimeOfferController {
|
|||
}
|
||||
|
||||
@GetMapping("/offers/time/{timeOfferId}")
|
||||
public String processShowForm(@PathVariable("timeOfferId") int timeOfferId, Map<String, Object> model) {
|
||||
public String processShowForm(@PathVariable("timeOfferId") final int timeOfferId, final Map<String, Object> model) {
|
||||
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||
if(timeOffer.getStatus().equals(StatusOffer.active)) {
|
||||
if (timeOffer.getStatus().equals(StatusOffer.active)) {
|
||||
model.put("timeOffer", timeOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/time/timeOffersShow";
|
||||
|
||||
} else if(timeOffer.getStatus().equals(StatusOffer.hidden)&&(this.checkIdentity(timeOfferId))) {
|
||||
model.put("timeOffer", timeOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/time/timeOffersShow";
|
||||
|
||||
}else {
|
||||
|
||||
} else if (timeOffer.getStatus().equals(StatusOffer.hidden) && this.checkIdentity(timeOfferId)) {
|
||||
model.put("timeOffer", timeOffer);
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "offers/time/timeOffersShow";
|
||||
|
||||
} else {
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/time/{timeOfferId}/edit")
|
||||
public String updateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model,
|
||||
HttpServletRequest request) {
|
||||
public String updateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model, final HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(timeOfferId)) {
|
||||
return "error";
|
||||
|
@ -164,8 +168,7 @@ public class TimeOfferController {
|
|||
}
|
||||
|
||||
@PostMapping(value = "/offers/time/{timeOfferId}/edit")
|
||||
public String updateTimeOffer(@Valid final TimeOffer timeOfferEdit, final BindingResult result,
|
||||
final ModelMap model, HttpServletRequest request) {
|
||||
public String updateTimeOffer(@Valid final TimeOffer timeOfferEdit, final BindingResult result, final ModelMap model, final HttpServletRequest request) {
|
||||
|
||||
if (!this.checkIdentity(timeOfferEdit.getId())) {
|
||||
return "error";
|
||||
|
@ -176,26 +179,23 @@ public class TimeOfferController {
|
|||
return "error";
|
||||
}
|
||||
|
||||
|
||||
if(!this.checkDates(timeOfferEdit)) {
|
||||
result.rejectValue("end","" ,"La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
if(!this.checkTimes(timeOfferEdit)) {
|
||||
result.rejectValue("finish","" ,"La hora de fin debe ser posterior a la de inicio");
|
||||
|
||||
}
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("timeOffer", timeOfferEdit);
|
||||
return TimeOfferController.VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
if (!this.checkDates(timeOfferEdit)) {
|
||||
result.rejectValue("end", "", "La fecha de fin debe ser posterior a la fecha de inicio");
|
||||
|
||||
}
|
||||
|
||||
BeanUtils.copyProperties(this.timeOfferService.findTimeOfferById(timeOfferEdit.getId()), timeOfferEdit,
|
||||
"start", "end", "init", "finish", "discount");
|
||||
this.timeOfferService.saveTimeOffer(timeOfferEdit);
|
||||
return "redirect:/offers/time/" + timeOfferEdit.getId();
|
||||
|
||||
}
|
||||
if (!this.checkTimes(timeOfferEdit)) {
|
||||
result.rejectValue("finish", "", "La hora de fin debe ser posterior a la de inicio");
|
||||
|
||||
}
|
||||
if (result.hasErrors()) {
|
||||
model.addAttribute("timeOffer", timeOfferEdit);
|
||||
return TimeOfferController.VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
}
|
||||
|
||||
BeanUtils.copyProperties(this.timeOfferService.findTimeOfferById(timeOfferEdit.getId()), timeOfferEdit, "start", "end", "init", "finish", "discount");
|
||||
this.timeOfferService.saveTimeOffer(timeOfferEdit);
|
||||
return "redirect:/offers/time/" + timeOfferEdit.getId();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -9,23 +9,34 @@
|
|||
|
||||
<cheapy:layout pageName="ofertas de plato especifico">
|
||||
|
||||
<spring:url value="/offers/nuOfferList" var="nuOfferUrl">
|
||||
<spring:url value="/offers/foodOfferList/{page}" var="foodOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/nuOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de plato especifico</button>
|
||||
|
||||
<spring:url value="/offers/nuOfferList/{page}" var="nuOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas por número de comensales</button>
|
||||
|
||||
<spring:url value="/offers/speedOfferList" var="speedOfferUrl">
|
||||
<spring:url value="/offers/speedOfferList/{page}" var="speedOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/speedOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de velocidad</button>
|
||||
|
||||
<spring:url value="/offers/timeOfferList" var="timeOfferUrl">
|
||||
<spring:url value="/offers/timeOfferList/{page}" var="timeOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/timeOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de franja horaria</button>
|
||||
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="foodOffers"/></h2>
|
||||
|
||||
|
@ -80,6 +91,23 @@
|
|||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<c:if test='${page!=0}'>
|
||||
<spring:url value="/offers/foodOfferList/{page}" var="foodOfferListUrl">
|
||||
<spring:param name="page" value="${page-1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. anterior</button>
|
||||
</c:if>
|
||||
<c:out value='${page}'></c:out>
|
||||
<c:if test="${fn:length(foodOfferLs) == 5}">
|
||||
<spring:url value="/offers/foodOfferList/{page}" var="foodOfferListUrl">
|
||||
<spring:param name="page" value="${page+1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. siguiente</button>
|
||||
</c:if>
|
||||
</c:if>
|
||||
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -9,24 +9,35 @@
|
|||
|
||||
<cheapy:layout pageName="ofertas">
|
||||
|
||||
<spring:url value="/offers/foodOfferList" var="foodOfferUrl">
|
||||
<spring:url value="/offers/foodOfferList/{page}" var="foodOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/foodOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de plato especifico</button>
|
||||
|
||||
<spring:url value="/offers/speedOfferList" var="speedOfferUrl">
|
||||
<spring:url value="/offers/nuOfferList/{page}" var="nuOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/speedOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas por número de comensales</button>
|
||||
|
||||
<spring:url value="/offers/speedOfferList/{page}" var="speedOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de velocidad</button>
|
||||
|
||||
<spring:url value="/offers/timeOfferList" var="timeOfferUrl">
|
||||
<spring:url value="/offers/timeOfferList/{page}" var="timeOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/timeOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de franja horaria</button>
|
||||
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="nuOffers"/></h2>
|
||||
<c:if test="${empty nuOfferLs }">
|
||||
<p id="vacio" >No hay ninguna oferta por número de comensales activa.</p>
|
||||
|
@ -77,6 +88,23 @@
|
|||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<c:if test='${page!=0}'>
|
||||
<spring:url value="/offers/nuOfferList/{page}" var="nuOfferListUrl">
|
||||
<spring:param name="page" value="${page-1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. anterior</button>
|
||||
</c:if>
|
||||
<c:out value='${page}'></c:out>
|
||||
<c:if test="${fn:length(nuOfferLs) == 5}">
|
||||
<spring:url value="/offers/nuOfferList/{page}" var="nuOfferListUrl">
|
||||
<spring:param name="page" value="${page+1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. siguiente</button>
|
||||
</c:if>
|
||||
</c:if>
|
||||
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -9,34 +9,38 @@
|
|||
|
||||
<cheapy:layout pageName="ofertas">
|
||||
|
||||
<spring:url value="/offers/foodOfferList" var="foodOfferUrl">
|
||||
<spring:url value="/offers/foodOfferList/{page}" var="foodOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/foodOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de plato especifico</button>
|
||||
|
||||
<spring:url value="/offers/nuOfferList" var="nuOfferUrl">
|
||||
<spring:url value="/offers/nuOfferList/{page}" var="nuOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/nuOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas por número de comensales</button>
|
||||
|
||||
<spring:url value="/offers/speedOfferList" var="speedOfferUrl">
|
||||
<spring:url value="/offers/speedOfferList/{page}" var="speedOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/speedOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de velocidad</button>
|
||||
|
||||
<spring:url value="/offers/timeOfferList" var="timeOfferUrl">
|
||||
<spring:url value="/offers/timeOfferList/{page}" var="timeOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/timeOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de franja horaria</button>
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="foodOffers"/></h2>
|
||||
|
||||
<c:if test="${empty foodOfferLs }">
|
||||
<p id="vacio" >No hay ninguna oferta por plato específico activa.</p>
|
||||
<p id="vacio" >No hay ninguna oferta por plato específico activa.</p>
|
||||
</c:if>
|
||||
<c:if test="${not empty foodOfferLs }">
|
||||
|
||||
|
@ -88,6 +92,9 @@
|
|||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ver más</button>
|
||||
</div>
|
||||
|
||||
</c:if>
|
||||
|
@ -143,6 +150,9 @@
|
|||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ver más</button>
|
||||
</div>
|
||||
|
||||
</c:if>
|
||||
|
@ -200,6 +210,10 @@
|
|||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<spring:url value="/offers/speedOfferList" var="speedOfferUrl"></spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ver más</button>
|
||||
</div>
|
||||
|
||||
</c:if>
|
||||
|
@ -254,9 +268,12 @@
|
|||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<spring:url value="/offers/timeOfferList" var="timeOfferUrl"></spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ver más</button>
|
||||
</div>
|
||||
</c:if>
|
||||
|
||||
|
||||
|
|
|
@ -9,24 +9,35 @@
|
|||
|
||||
<cheapy:layout pageName="ofertas">
|
||||
|
||||
<spring:url value="/offers/foodOfferList" var="foodOfferUrl">
|
||||
<spring:url value="/offers/foodOfferList/{page}" var="foodOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/foodOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de plato especifico</button>
|
||||
|
||||
<spring:url value="/offers/nuOfferList" var="nuOfferUrl">
|
||||
<spring:url value="/offers/nuOfferList/{page}" var="nuOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/nuOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas por número de comensales</button>
|
||||
|
||||
<spring:url value="/offers/timeOfferList" var="timeOfferUrl">
|
||||
<spring:url value="/offers/speedOfferList/{page}" var="speedOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/timeOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de velocidad</button>
|
||||
|
||||
<spring:url value="/offers/timeOfferList/{page}" var="timeOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de franja horaria</button>
|
||||
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="speedOffers"/></h2>
|
||||
<c:if test="${empty speedOfferLs }">
|
||||
<p id="vacio" >No hay ninguna oferta por tiempo empleado en comer activa.</p>
|
||||
|
@ -78,5 +89,22 @@
|
|||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<c:if test='${page!=0}'>
|
||||
<spring:url value="/offers/speedOfferList/{page}" var="speedOfferListUrl">
|
||||
<spring:param name="page" value="${page-1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. anterior</button>
|
||||
</c:if>
|
||||
<c:out value='${page}'></c:out>
|
||||
<c:if test="${fn:length(speedOfferLs) == 5}">
|
||||
<spring:url value="/offers/speedOfferList/{page}" var="speedOfferListUrl">
|
||||
<spring:param name="page" value="${page+1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. siguiente</button>
|
||||
</c:if>
|
||||
</c:if>
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -9,23 +9,34 @@
|
|||
|
||||
<cheapy:layout pageName="ofertas">
|
||||
|
||||
<spring:url value="/offers/foodOfferList" var="foodOfferUrl">
|
||||
<spring:url value="/offers/foodOfferList/{page}" var="foodOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/foodOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de plato especifico</button>
|
||||
|
||||
<spring:url value="/offers/nuOfferList" var="nuOfferUrl">
|
||||
<spring:url value="/offers/nuOfferList/{page}" var="nuOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/nuOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas por número de comensales</button>
|
||||
|
||||
<spring:url value="/offers/speedOfferList" var="speedOfferUrl">
|
||||
<spring:url value="/offers/speedOfferList/{page}" var="speedOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='/offers/speedOfferList'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de velocidad</button>
|
||||
|
||||
<spring:url value="/offers/timeOfferList/{page}" var="timeOfferListUrl">
|
||||
<spring:param name="page" value="0"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Ofertas de franja horaria</button>
|
||||
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="timeOffers"/></h2>
|
||||
<c:if test="${empty timeOfferLs }">
|
||||
|
@ -77,6 +88,23 @@
|
|||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<c:if test='${page!=0}'>
|
||||
<spring:url value="/offers/timeOfferList/{page}" var="timeOfferListUrl">
|
||||
<spring:param name="page" value="${page-1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. anterior</button>
|
||||
</c:if>
|
||||
<c:out value='${page}'></c:out>
|
||||
<c:if test="${fn:length(timeOfferLs) == 5}">
|
||||
<spring:url value="/offers/foodOfferList/{page}" var="timeOfferListUrl">
|
||||
<spring:param name="page" value="${page+1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. siguiente</button>
|
||||
</c:if>
|
||||
</c:if>
|
||||
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<c:choose>
|
||||
<c:when test="${fn:length(reviewsLs) == 0}">
|
||||
<c:when test="${empty reviewsLs}">
|
||||
<tr><td colspan="4"><em><c:out value="No se ha realizado ninguna valoración por el momento."/></em></td></tr>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
|
@ -56,4 +56,21 @@
|
|||
</c:choose>
|
||||
</tbody>
|
||||
</table>
|
||||
<c:if test='${page!=0}'>
|
||||
<spring:url value="/reviewsList/{page}" var="reviewsListUrl">
|
||||
<spring:param name="page" value="${page-1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(reviewsListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. anterior</button>
|
||||
</c:if>
|
||||
<c:out value='${page}'></c:out>
|
||||
<c:if test="${fn:length(reviewsLs) == 6}">
|
||||
<spring:url value="/reviewsList/{page}" var="reviewsListUrl">
|
||||
<spring:param name="page" value="${page+1}"/>
|
||||
</spring:url>
|
||||
<button type="button" role="link" onclick="window.location='${fn:escapeXml(reviewsListUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Pág. siguiente</button>
|
||||
</c:if>
|
||||
</cheapy:layout>
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
</cheapy:menuItem>
|
||||
-->
|
||||
<sec:authorize access="isAuthenticated()">
|
||||
<cheapy:menuItem active="${name eq 'reviews'}" url="/reviews" title="opiniones">
|
||||
<cheapy:menuItem active="${name eq 'reviews'}" url="/reviewsList/0" title="opiniones">
|
||||
<span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span>
|
||||
<span>Reseñas</span>
|
||||
</cheapy:menuItem>
|
||||
|
|
Loading…
Reference in a new issue