mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 14:55:51 +00:00
Sextou éusguri
This commit is contained in:
parent
961fc26b74
commit
ba6b618e60
14 changed files with 157 additions and 34 deletions
|
@ -0,0 +1,28 @@
|
||||||
|
package org.springframework.samples.petclinic.employer;
|
||||||
|
|
||||||
|
public class Employer {
|
||||||
|
private String name;
|
||||||
|
private double salarie;
|
||||||
|
|
||||||
|
public Employer(String name, double salarie) {
|
||||||
|
this.name = name;
|
||||||
|
this.salarie = salarie;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getSalarie() {
|
||||||
|
return salarie;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSalarie(double salarie) {
|
||||||
|
this.salarie = salarie;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package org.springframework.samples.petclinic.employer;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class EmployerController{
|
||||||
|
|
||||||
|
@GetMapping("/employers")
|
||||||
|
public String showEmployerList(Model model){
|
||||||
|
List<Employer> emplo = new ArrayList<Employer>();
|
||||||
|
model.addAttribute("employers",emplo);
|
||||||
|
emplo.add(new Employer("Geio",2900));
|
||||||
|
emplo.add(new Employer("Poua",5000));
|
||||||
|
emplo.add(new Employer("Heijo",3500));
|
||||||
|
emplo.add(new Employer("Reina",7502));
|
||||||
|
emplo.add(new Employer("Ghest",4500));
|
||||||
|
emplo.add(new Employer("Undermetal",2900));
|
||||||
|
emplo.add(new Employer("Rolando",2900));
|
||||||
|
return "employers/employersList";
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,18 @@
|
||||||
package org.springframework.samples.petclinic.product;
|
package org.springframework.samples.petclinic.product;
|
||||||
|
|
||||||
public class Product {
|
import org.springframework.samples.petclinic.model.BaseEntity;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "products")
|
||||||
|
public class Product extends BaseEntity {
|
||||||
private String description;
|
private String description;
|
||||||
Product(String desc){
|
|
||||||
this.description = desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) { this.description = description; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,18 +6,23 @@ import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class ProductController {
|
public class ProductController {
|
||||||
|
|
||||||
|
private final ProductRepository products;
|
||||||
|
|
||||||
|
public ProductController(ProductRepository products){
|
||||||
|
this.products = products;
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/products")
|
@GetMapping("/products")
|
||||||
public String showProductList(Model model){
|
public String showProductList(Model model){
|
||||||
List<Product> prods = new ArrayList<Product>();
|
Collection<Product> prods = products.findAll();
|
||||||
model.addAttribute("products",prods);
|
model.addAttribute("products",prods);
|
||||||
prods.add(new Product("Aninha"));
|
|
||||||
prods.add(new Product("Leozinho"));
|
|
||||||
return "products/productsList";
|
return "products/productsList";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.springframework.samples.petclinic.product;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
|
import org.springframework.data.repository.Repository;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public interface ProductRepository extends Repository<Product,Integer> {
|
||||||
|
Collection<Product> findAll() throws DataAccessException;
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
.navbar {
|
.navbar {
|
||||||
border-top: 4px solid #6db33f;
|
border-top: 4px solid #6db33f;
|
||||||
background-color: #34302d;
|
background-color: #838789;
|
||||||
margin-bottom: 0px;
|
margin-bottom: 0px;
|
||||||
border-bottom: 0;
|
border-bottom: 0;
|
||||||
border-left: 0;
|
border-left: 0;
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
.navbar li:hover > a {
|
.navbar li:hover > a {
|
||||||
color: #eeeeee;
|
color: #bbbbbb;
|
||||||
background-color: #6db33f;
|
background-color: #6db33f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
@spring-brown: #34302D;
|
@spring-brown: #34302D;
|
||||||
@spring-grey: #838789;
|
@spring-grey: #838789;
|
||||||
@spring-light-grey: #f1f1f1;
|
@spring-light-grey: #f1f1f1;
|
||||||
|
@spring-purple: #322d34;
|
||||||
|
@spring-red: #ff1235;
|
||||||
|
|
||||||
@body-bg: @spring-light-grey;
|
@body-bg: @spring-light-grey;
|
||||||
@text-color: @spring-brown;
|
@text-color: @spring-brown;
|
||||||
|
@ -51,16 +53,16 @@
|
||||||
|
|
||||||
.table > thead > tr > th {
|
.table > thead > tr > th {
|
||||||
background-color: lighten(@spring-brown, 3%);
|
background-color: lighten(@spring-brown, 3%);
|
||||||
color: @spring-light-grey;
|
color: @spring-red;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-filter {
|
.table-filter {
|
||||||
background-color: @spring-brown;
|
background-color: @spring-purple;
|
||||||
padding: 9px 12px;
|
padding: 9px 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav > li > a {
|
.nav > li > a {
|
||||||
color: @spring-grey;
|
color: @spring-red;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-default {
|
.btn-default {
|
||||||
|
@ -76,7 +78,7 @@
|
||||||
&:active,
|
&:active,
|
||||||
&.active,
|
&.active,
|
||||||
.open .dropdown-toggle& {
|
.open .dropdown-toggle& {
|
||||||
background-color: @spring-brown;
|
background-color: @spring-purple;
|
||||||
border-color: @spring-brown;
|
border-color: @spring-brown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +127,7 @@ h1 {
|
||||||
}
|
}
|
||||||
|
|
||||||
.splash {
|
.splash {
|
||||||
background: @spring-green;
|
background: @spring-brown;
|
||||||
color: @spring-brown;
|
color: @spring-brown;
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
|
ᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕ
|
||||||
|
|
||||||
|
ᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕvᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕ
|
||||||
|
ᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕ
|
||||||
|
ᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕvᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕv
|
||||||
|
vᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕ
|
||||||
|
ᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕ
|
||||||
|
ᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕ
|
||||||
|
|
||||||
|
|
||||||
|\ _,,,--,,_
|
ᘉƗᑕᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕ
|
||||||
/,`.-'`' ._ \-;;,_
|
|
||||||
_______ __|,4- ) )_ .;.(__`'-'__ ___ __ _ ___ _______
|
|
||||||
| | '---''(_/._)-'(_\_) | | | | | | | | |
|
|
||||||
| _ | ___|_ _| | | | | |_| | | | __ _ _
|
|
||||||
| |_| | |___ | | | | | | | | | | \ \ \ \
|
|
||||||
| ___| ___| | | | _| |___| | _ | | _| \ \ \ \
|
|
||||||
| | | |___ | | | |_| | | | | | | |_ ) ) ) )
|
|
||||||
|___| |_______| |___| |_______|_______|___|_| |__|___|_______| / / / /
|
|
||||||
==================================================================/_/_/_/
|
|
||||||
|
|
||||||
:: Built with Spring Boot :: ${spring-boot.version}
|
|
||||||
|
|
||||||
|
|
|
@ -51,3 +51,11 @@ INSERT INTO visits VALUES (1, 7, '2013-01-01', 'rabies shot');
|
||||||
INSERT INTO visits VALUES (2, 8, '2013-01-02', 'rabies shot');
|
INSERT INTO visits VALUES (2, 8, '2013-01-02', 'rabies shot');
|
||||||
INSERT INTO visits VALUES (3, 8, '2013-01-03', 'neutered');
|
INSERT INTO visits VALUES (3, 8, '2013-01-03', 'neutered');
|
||||||
INSERT INTO visits VALUES (4, 7, '2013-01-04', 'spayed');
|
INSERT INTO visits VALUES (4, 7, '2013-01-04', 'spayed');
|
||||||
|
|
||||||
|
INSERT INTO products VALUES (1,'produto P1');
|
||||||
|
INSERT INTO products VALUES (2,'produto P2');
|
||||||
|
INSERT INTO products VALUES (3,'produto P3');
|
||||||
|
INSERT INTO products VALUES (4,'produto P4');
|
||||||
|
INSERT INTO products VALUES (5,'produto P5');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ DROP TABLE visits IF EXISTS;
|
||||||
DROP TABLE pets IF EXISTS;
|
DROP TABLE pets IF EXISTS;
|
||||||
DROP TABLE types IF EXISTS;
|
DROP TABLE types IF EXISTS;
|
||||||
DROP TABLE owners IF EXISTS;
|
DROP TABLE owners IF EXISTS;
|
||||||
|
DROP TABLE products IF EXISTS;
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE vets (
|
CREATE TABLE vets (
|
||||||
|
@ -62,3 +63,8 @@ CREATE TABLE visits (
|
||||||
);
|
);
|
||||||
ALTER TABLE visits ADD CONSTRAINT fk_visits_pets FOREIGN KEY (pet_id) REFERENCES pets (id);
|
ALTER TABLE visits ADD CONSTRAINT fk_visits_pets FOREIGN KEY (pet_id) REFERENCES pets (id);
|
||||||
CREATE INDEX visits_pet_id ON visits (pet_id);
|
CREATE INDEX visits_pet_id ON visits (pet_id);
|
||||||
|
|
||||||
|
CREATE TABLE products (
|
||||||
|
id INTEGER IDENTITY PRIMARY KEY,
|
||||||
|
description VARCHAR(80)
|
||||||
|
);
|
||||||
|
|
25
src/main/resources/templates/employers/employersList.html
Normal file
25
src/main/resources/templates/employers/employersList.html
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="https://www.thymeleaf.org"
|
||||||
|
th:replace="~{fragments/layout :: layout (~{::body},'employers')}">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<title>Employers List</title>
|
||||||
|
<h1>Employers List</h1>
|
||||||
|
<table id="employers" class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Names</th>
|
||||||
|
<th>Salaries</th>
|
||||||
|
</tr>
|
||||||
|
<thead/>
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="employer: ${employers}">
|
||||||
|
<td th:text="${employer.name}" ></td>
|
||||||
|
<td th:text="${employer.salarie}"></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -3,9 +3,9 @@
|
||||||
<html xmlns:th="https://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'error')}">
|
<html xmlns:th="https://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'error')}">
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<img src="../static/resources/images/pets.png" th:src="@{/resources/images/pets.png}"/>
|
<img src="../static/resources/images/error.gif" th:src="@{/resources/images/error.gif}"/>
|
||||||
<h2>Something happened...</h2>
|
<h2>Oh shit...</h2>
|
||||||
<p th:text="${message}">Exception message</p>
|
<p>Deu ruim manito!!!!</p>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
|
@ -64,6 +64,11 @@
|
||||||
<span>Products</span>
|
<span>Products</span>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<li th:replace="::menuItem ('/employers','employers','employers','th-list','Employers')">
|
||||||
|
<span class="glyphicon glyphicon-th-list" aria-hidden="true"></span>
|
||||||
|
<span>Employers</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li th:replace="::menuItem ('/oups','error','trigger a RuntimeException to see how it is handled','warning-sign','Error')">
|
<li th:replace="::menuItem ('/oups','error','trigger a RuntimeException to see how it is handled','warning-sign','Error')">
|
||||||
<span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span>
|
<span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span>
|
||||||
<span>Error</span>
|
<span>Error</span>
|
||||||
|
|
|
@ -4,10 +4,13 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h2 th:text="#{welcome}">Welcome</h2>
|
<h1 th:text="#{welcome}">Welcome</h1>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<img class="img-responsive" src="../static/resources/images/pets.png" th:src="@{/resources/images/pets.png}"/>
|
<img class="img-responsive" src="../static/resources/images/hello.gif" th:src="@{/resources/images/hello.gif}"/>
|
||||||
|
</div>
|
||||||
|
<div class="col-xm">
|
||||||
|
<img class="img-responsive" src="../static/resources/images/wink.gif" th:src="@{/resources/images/wink.gif}"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue