Sextou éusguri

This commit is contained in:
MatheusMariani 2019-08-12 17:02:16 -03:00
parent 961fc26b74
commit ba6b618e60
14 changed files with 157 additions and 34 deletions

View file

@ -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;
}
}

View file

@ -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";
}
}

View file

@ -1,12 +1,18 @@
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;
Product(String desc){
this.description = desc;
}
public String getDescription() {
return description;
}
public void setDescription(String description) { this.description = description; }
}

View file

@ -6,18 +6,23 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@Controller
public class ProductController {
private final ProductRepository products;
public ProductController(ProductRepository products){
this.products = products;
}
@GetMapping("/products")
public String showProductList(Model model){
List<Product> prods = new ArrayList<Product>();
Collection<Product> prods = products.findAll();
model.addAttribute("products",prods);
prods.add(new Product("Aninha"));
prods.add(new Product("Leozinho"));
return "products/productsList";
}
}

View file

@ -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;
}

View file

@ -1,6 +1,6 @@
.navbar {
border-top: 4px solid #6db33f;
background-color: #34302d;
background-color: #838789;
margin-bottom: 0px;
border-bottom: 0;
border-left: 0;
@ -55,7 +55,7 @@
margin-bottom: 0;
}
.navbar li:hover > a {
color: #eeeeee;
color: #bbbbbb;
background-color: #6db33f;
}

View file

@ -18,6 +18,8 @@
@spring-brown: #34302D;
@spring-grey: #838789;
@spring-light-grey: #f1f1f1;
@spring-purple: #322d34;
@spring-red: #ff1235;
@body-bg: @spring-light-grey;
@text-color: @spring-brown;
@ -51,16 +53,16 @@
.table > thead > tr > th {
background-color: lighten(@spring-brown, 3%);
color: @spring-light-grey;
color: @spring-red;
}
.table-filter {
background-color: @spring-brown;
background-color: @spring-purple;
padding: 9px 12px;
}
.nav > li > a {
color: @spring-grey;
color: @spring-red;
}
.btn-default {
@ -76,7 +78,7 @@
&:active,
&.active,
.open .dropdown-toggle& {
background-color: @spring-brown;
background-color: @spring-purple;
border-color: @spring-brown;
}
}
@ -125,7 +127,7 @@ h1 {
}
.splash {
background: @spring-green;
background: @spring-brown;
color: @spring-brown;
display: none;
}

View file

@ -1,15 +1,11 @@
ᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕ
ᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᗰᗩƬᕼᕮᑌᔕ ᕮƬᑕƗᘉƗᑕvᗩƬᔕ ᑭᕮƬᑕᒪƗᘉƗᑕ
ᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕ
ᗰᗩƬᕼᕮᑌᔕ ᕮƬᑕƗᘉƗᑕvᗩƬᕮƬᑕƗᘉƗᑕv
vᗩƬᔕ ᑭᕮƬᑕᒪƗᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕ
ᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕ
ᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕ
|\ _,,,--,,_
/,`.-'`' ._ \-;;,_
_______ __|,4- ) )_ .;.(__`'-'__ ___ __ _ ___ _______
| | '---''(_/._)-'(_\_) | | | | | | | | |
| _ | ___|_ _| | | | | |_| | | | __ _ _
| |_| | |___ | | | | | | | | | | \ \ \ \
| ___| ___| | | | _| |___| | _ | | _| \ \ \ \
| | | |___ | | | |_| | | | | | | |_ ) ) ) )
|___| |_______| |___| |_______|_______|___|_| |__|___|_______| / / / /
==================================================================/_/_/_/
:: Built with Spring Boot :: ${spring-boot.version}
ᘉƗᑕᗰᗩƬᕼᕮᑌᔕ ᑭᕮƬᑕᒪƗᘉƗᑕ

View file

@ -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 (3, 8, '2013-01-03', 'neutered');
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');

View file

@ -5,6 +5,7 @@ DROP TABLE visits IF EXISTS;
DROP TABLE pets IF EXISTS;
DROP TABLE types IF EXISTS;
DROP TABLE owners IF EXISTS;
DROP TABLE products IF EXISTS;
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);
CREATE INDEX visits_pet_id ON visits (pet_id);
CREATE TABLE products (
id INTEGER IDENTITY PRIMARY KEY,
description VARCHAR(80)
);

View 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>

View file

@ -3,9 +3,9 @@
<html xmlns:th="https://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'error')}">
<body>
<img src="../static/resources/images/pets.png" th:src="@{/resources/images/pets.png}"/>
<h2>Something happened...</h2>
<p th:text="${message}">Exception message</p>
<img src="../static/resources/images/error.gif" th:src="@{/resources/images/error.gif}"/>
<h2>Oh shit...</h2>
<p>Deu ruim manito!!!!</p>
</body>
</html>

View file

@ -64,6 +64,11 @@
<span>Products</span>
</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')">
<span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span>
<span>Error</span>

View file

@ -4,10 +4,13 @@
<body>
<h2 th:text="#{welcome}">Welcome</h2>
<h1 th:text="#{welcome}">Welcome</h1>
<div class="row">
<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>