mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-04-24 19:32:49 +00:00
Compare commits
8 commits
972573f141
...
5b74887026
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5b74887026 | ||
![]() |
332abbcb8a | ||
![]() |
e15623d232 | ||
![]() |
2ab1cef91f | ||
![]() |
1615fda9b2 | ||
![]() |
6bc5bd4af6 | ||
![]() |
98ccc1e2e4 | ||
![]() |
94d6335022 |
4 changed files with 11 additions and 5 deletions
|
@ -17,6 +17,8 @@ cd spring-petclinic
|
||||||
java -jar target/*.jar
|
java -jar target/*.jar
|
||||||
```
|
```
|
||||||
|
|
||||||
|
(On Windows, or if your shell doesn't expand the glob, you might need to specify the JAR file name explicitly on the command line at the end there.)
|
||||||
|
|
||||||
You can then access the Petclinic at <http://localhost:8080/>.
|
You can then access the Petclinic at <http://localhost:8080/>.
|
||||||
|
|
||||||
<img width="1042" alt="petclinic-screenshot" src="https://cloud.githubusercontent.com/assets/838318/19727082/2aee6d6c-9b8e-11e6-81fe-e889a5ddfded.png">
|
<img width="1042" alt="petclinic-screenshot" src="https://cloud.githubusercontent.com/assets/838318/19727082/2aee6d6c-9b8e-11e6-81fe-e889a5ddfded.png">
|
||||||
|
|
|
@ -110,9 +110,9 @@ class OwnerController {
|
||||||
owner = ownersResults.iterator().next();
|
owner = ownersResults.iterator().next();
|
||||||
return "redirect:/owners/" + owner.getId();
|
return "redirect:/owners/" + owner.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
// multiple owners found
|
// multiple owners found
|
||||||
return addPaginationModel(page, model, ownersResults);
|
return addPaginationModel(page, model, ownersResults);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String addPaginationModel(int page, Model model, Page<Owner> paginated) {
|
private String addPaginationModel(int page, Model model, Page<Owner> paginated) {
|
||||||
|
|
|
@ -24,6 +24,9 @@ import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository class for <code>Owner</code> domain objects All method names are compliant
|
* Repository class for <code>Owner</code> domain objects All method names are compliant
|
||||||
* with Spring Data naming conventions so this interface can easily be extended for Spring
|
* with Spring Data naming conventions so this interface can easily be extended for Spring
|
||||||
|
@ -52,7 +55,9 @@ public interface OwnerRepository extends JpaRepository<Owner, Integer> {
|
||||||
* @return a Collection of matching {@link Owner}s (or an empty Collection if none
|
* @return a Collection of matching {@link Owner}s (or an empty Collection if none
|
||||||
* found)
|
* found)
|
||||||
*/
|
*/
|
||||||
Page<Owner> findByLastNameStartingWith(String lastName, Pageable pageable);
|
|
||||||
|
@Query("SELECT o FROM Owner o WHERE LOWER(CONCAT(o.firstName, ' ', o.lastName)) LIKE LOWER(CONCAT('%', :namePart, '%'))")
|
||||||
|
Page<Owner> findByLastNameStartingWith(@Param("namePart") String namePart, Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve an {@link Owner} from the data store by id.
|
* Retrieve an {@link Owner} from the data store by id.
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
class="form-horizontal" id="search-owner-form">
|
class="form-horizontal" id="search-owner-form">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="control-group" id="lastNameGroup">
|
<div class="control-group" id="lastNameGroup">
|
||||||
<label class="col-sm-2 control-label">Last name </label>
|
<label class="col-sm-2 control-label">Search by Name</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input class="form-control" th:field="*{lastName}" size="30"
|
<input class="form-control" th:field="*{lastName}" size="30"
|
||||||
maxlength="80" /> <span class="help-inline"><div
|
maxlength="80" /> <span class="help-inline"><div
|
||||||
|
@ -21,8 +21,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-offset-2 col-sm-10">
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
<button type="submit" class="btn btn-primary">Find
|
<button type="submit" class="btn btn-primary">Search</button>
|
||||||
Owner</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue