Skip to content

Commit

Permalink
Merge pull request #11 from TheFutureLegends/Phuoc
Browse files Browse the repository at this point in the history
Release 2
  • Loading branch information
Buithienphuoc authored Aug 29, 2020
2 parents a46f1a8 + 0d82ad5 commit 15cde6d
Show file tree
Hide file tree
Showing 52 changed files with 1,915 additions and 1,032 deletions.
16 changes: 16 additions & 0 deletions .travis.yml
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]
29 changes: 22 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- <dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>-->
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
Expand Down Expand Up @@ -70,13 +70,28 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<version>2.3.2.RELEASE</version>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.3.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>3.3.3</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
119 changes: 0 additions & 119 deletions sept.iml

This file was deleted.

3 changes: 3 additions & 0 deletions src/main/java/learn/thymeleaf/sept/SeptApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@SpringBootApplication
public class SeptApplication {
Expand Down
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";
}
}
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";
}
}
Loading

0 comments on commit 15cde6d

Please sign in to comment.