-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from TheFutureLegends/Phuoc
Release 2
- Loading branch information
Showing
52 changed files
with
1,915 additions
and
1,032 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
language: java | ||
jdk: | ||
- openjdk14 | ||
|
||
os: | ||
- linux | ||
- osx | ||
|
||
jobs: | ||
include: | ||
- stage: Test | ||
script: ./mvnw clean test | ||
notifications: | ||
email: | ||
- [email protected] | ||
- [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/main/java/learn/thymeleaf/sept/controller/AdminMovieController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package learn.thymeleaf.sept.controller; | ||
|
||
import learn.thymeleaf.sept.entity.Movie; | ||
import learn.thymeleaf.sept.service.MovieService; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@Controller | ||
@RequestMapping("/admin/movie") | ||
public class AdminMovieController { | ||
|
||
private final MovieService movieService; | ||
|
||
public AdminMovieController(MovieService movieService) { | ||
this.movieService = movieService; | ||
} | ||
|
||
@GetMapping("/list") | ||
public String listMovies(Model theModel, String keyword) { | ||
|
||
// get employees from db | ||
List<Movie> movies = movieService.findAll(); | ||
// check if there is a search keyword | ||
if(keyword != null){ | ||
theModel.addAttribute("movies", movieService.findByMovieName(keyword)); | ||
} | ||
else { | ||
// add to the spring model | ||
theModel.addAttribute("movies", movies); | ||
} | ||
|
||
return "admin/movie/list"; | ||
} | ||
|
||
@GetMapping("/showFormForUpdate") | ||
public String showFormForUpdate(@RequestParam("movieId")int theId, Model theModel){ | ||
//get the employee from service | ||
Movie movie = movieService.findById(theId); | ||
//set the employee as a model attribute to pre-populate the form | ||
theModel.addAttribute("movie", movie); | ||
// send over to our form | ||
return "admin/movie/add-update-form"; | ||
} | ||
|
||
@GetMapping("/delete") | ||
public String delete(@RequestParam("movieId")int theId){ | ||
//get the employee | ||
movieService.deleteById(theId); | ||
//redirect to list | ||
return "redirect:/admin/movie/list"; | ||
} | ||
|
||
@GetMapping("/showFormForAdd") | ||
public String showFormForAdd(Model theModel) { | ||
|
||
// create model attribute to bind form data | ||
Movie movie = new Movie(); | ||
|
||
theModel.addAttribute("movie", movie); | ||
|
||
return "admin/movie/add-update-form"; | ||
} | ||
|
||
@PostMapping("/save") | ||
public String saveMovie(@ModelAttribute("movie") Movie movie) { | ||
|
||
// save the employee | ||
movieService.create(movie); | ||
|
||
// use a redirect to prevent duplicate submissions | ||
return "redirect:/admin/movie/list"; | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
src/main/java/learn/thymeleaf/sept/controller/AdminReservationController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package learn.thymeleaf.sept.controller; | ||
|
||
import learn.thymeleaf.sept.entity.Reservation; | ||
import learn.thymeleaf.sept.service.ReservationService; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@Controller | ||
@RequestMapping("/admin/reservation") | ||
public class AdminReservationController { | ||
|
||
private final ReservationService reservationService; | ||
|
||
public AdminReservationController(ReservationService reservationService) { | ||
this.reservationService = reservationService; | ||
} | ||
|
||
@GetMapping("/list") | ||
public String listReservations(Model theModel, String keyword) { | ||
|
||
// get employees from db | ||
List<Reservation> reservations = reservationService.findAll(); | ||
// check if there is a search keyword | ||
if(keyword != null){ | ||
theModel.addAttribute("reservations", reservationService.findByReservationName(keyword)); | ||
} | ||
else { | ||
// add to the spring model | ||
theModel.addAttribute("reservations", reservations); | ||
} | ||
|
||
return "admin/reservation/list"; | ||
} | ||
|
||
@GetMapping("/showFormForUpdate") | ||
public String showFormForUpdate(@RequestParam("reservationId")int theId, Model theModel){ | ||
//get the employee from service | ||
Reservation reservation = reservationService.findById(theId); | ||
//set the employee as a model attribute to pre-populate the form | ||
theModel.addAttribute("reservation", reservation); | ||
// send over to our form | ||
return "admin/reservation/add-update-form"; | ||
} | ||
|
||
@GetMapping("/delete") | ||
public String delete(@RequestParam("reservationId")int theId){ | ||
//get the employee | ||
reservationService.deleteById(theId); | ||
//redirect to list | ||
return "redirect:/admin/reservation/list"; | ||
} | ||
|
||
@GetMapping("/showFormForAdd") | ||
public String showFormForAdd(Model theModel) { | ||
|
||
// create model attribute to bind form data | ||
Reservation reservation = new Reservation(); | ||
|
||
theModel.addAttribute("reservation", reservation); | ||
|
||
return "admin/reservation/add-update-form"; | ||
} | ||
|
||
@PostMapping("/save") | ||
public String saveReservation(@ModelAttribute("reservation") Reservation reservation) { | ||
|
||
// save the employee | ||
reservationService.create(reservation); | ||
|
||
// use a redirect to prevent duplicate submissions | ||
return "redirect:/admin/reservation/list"; | ||
} | ||
} |
Oops, something went wrong.