-
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.
- Loading branch information
Craig Cook
committed
Sep 6, 2017
1 parent
38ba334
commit 33f6fdb
Showing
12 changed files
with
105 additions
and
194 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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,24 +1,40 @@ | ||
package org.cccs.dtd.domain; | ||
|
||
import java.util.UUID; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
|
||
/** | ||
* Created by boycook on 04/02/2014. | ||
*/ | ||
public class Movie extends AbstractEntity implements Entity { | ||
public Movie() { | ||
this(null, null); | ||
@Entity | ||
public class Movie { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
private long id; | ||
|
||
private String name; | ||
private String description; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public Movie(UUID id) { | ||
this(id, null, null); | ||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public Movie(String name, String description) { | ||
this(UUID.randomUUID(), name, description); | ||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
protected Movie(UUID id, String name, String description) { | ||
super(id, name, description, Type.MOVIE); | ||
public long getId() { | ||
return id; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/org/cccs/dtd/persistence/MovieRepository.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,15 @@ | ||
package org.cccs.dtd.persistence; | ||
|
||
import org.cccs.dtd.domain.Movie; | ||
import org.springframework.data.repository.PagingAndSortingRepository; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.data.rest.core.annotation.RepositoryRestResource; | ||
|
||
import java.util.List; | ||
|
||
@RepositoryRestResource(collectionResourceRel = "movies", path = "movies") | ||
public interface MovieRepository extends PagingAndSortingRepository<Movie, Long> { | ||
|
||
List<Movie> findByName(@Param("name") String name); | ||
|
||
} |
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 |
---|---|---|
@@ -1,32 +1,31 @@ | ||
package org.cccs.dtd.web; | ||
|
||
import org.cccs.dtd.cache.Store; | ||
import org.cccs.dtd.domain.Movie; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* Controller object | ||
* Created by craig on 03/09/2017. | ||
*/ | ||
|
||
@Controller | ||
@Controller() | ||
public class MovieController { | ||
|
||
private Store store; | ||
|
||
public MovieController() { | ||
this.store = new Store(); | ||
this.store.addItem(new Movie("Star Wars IV", "A New Hope")); | ||
this.store.addItem(new Movie("Star Wars V", "The Empire Strikes Back")); | ||
this.store.addItem(new Movie("Star Wars VI", "Return of the Jedi")); | ||
this.store.addItem(new Movie("Star Wars I", "The Phantom Menace")); | ||
// this.store = new StoreX(); | ||
// this.store.addItem(new Movie("Star Wars IV", "A New Hope")); | ||
// this.store.addItem(new Movie("Star Wars V", "The Empire Strikes Back")); | ||
// this.store.addItem(new Movie("Star Wars VI", "Return of the Jedi")); | ||
// this.store.addItem(new Movie("Star Wars I", "The Phantom Menace")); | ||
} | ||
|
||
@RequestMapping("/movies") | ||
String getMovies(Model model) { | ||
model.addAttribute("movies", store.getAll()); | ||
model.addAttribute("movies", new ArrayList<Movie>()); | ||
return "movies"; | ||
} | ||
} |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
welcome.message: Welcome to Movie Service | ||
welcome.message: Welcome to Movie Service | ||
spring.data.rest.basePath=/api |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.