mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 06:45:49 +00:00
Definição de um repositório para produtos com listagem do DB
Alterações em cores do CSS
This commit is contained in:
parent
e2c425844f
commit
a01f24891f
7 changed files with 54 additions and 18 deletions
|
@ -1,13 +1,25 @@
|
|||
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;
|
||||
|
||||
public Product(String description){
|
||||
this.description = description;
|
||||
}
|
||||
//public Product(String description){
|
||||
// this.description = description;
|
||||
//}
|
||||
|
||||
public String getDescription(){
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,18 +5,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 {
|
||||
//Injeção de dependencias
|
||||
private 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("p1"));
|
||||
prods.add(new Product("p2"));
|
||||
return "products/productsList";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package org.springframework.samples.petclinic.product;
|
||||
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface ProductRepository extends Repository<Product, Integer>{
|
||||
Collection<Product> findAll();
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
.navbar {
|
||||
border-top: 4px solid #6db33f;
|
||||
border-top: 4px solid #03030a;
|
||||
background-color: #34302d;
|
||||
margin-bottom: 0px;
|
||||
border-bottom: 0;
|
||||
|
@ -56,7 +56,7 @@
|
|||
}
|
||||
.navbar li:hover > a {
|
||||
color: #eeeeee;
|
||||
background-color: #6db33f;
|
||||
background-color: #03030a;
|
||||
}
|
||||
|
||||
.navbar-toggle {
|
||||
|
|
|
@ -13,24 +13,24 @@
|
|||
*/
|
||||
@icon-font-path: "../../webjars/bootstrap/fonts/";
|
||||
|
||||
@spring-green: #6db33f;
|
||||
@spring-dark-green: #5fa134;
|
||||
@spring-blue: #0375B4;
|
||||
@spring-dark-blue: #194fb4;
|
||||
@spring-brown: #34302D;
|
||||
@spring-grey: #838789;
|
||||
@spring-light-grey: #f1f1f1;
|
||||
|
||||
@body-bg: @spring-light-grey;
|
||||
@text-color: @spring-brown;
|
||||
@link-color: @spring-dark-green;
|
||||
@link-hover-color: @spring-dark-green;
|
||||
@link-color: @spring-dark-blue;
|
||||
@link-hover-color: @spring-dark-blue;
|
||||
|
||||
@navbar-default-link-color: @spring-light-grey;
|
||||
@navbar-default-link-active-color: @spring-light-grey;
|
||||
@navbar-default-link-hover-color: @spring-light-grey;
|
||||
@navbar-default-link-hover-bg: @spring-green;
|
||||
@navbar-default-link-hover-bg: @spring-blue;
|
||||
@navbar-default-toggle-icon-bar-bg: @spring-light-grey;
|
||||
@navbar-default-toggle-hover-bg: transparent;
|
||||
@navbar-default-link-active-bg: @spring-green;
|
||||
@navbar-default-link-active-bg: @spring-blue;
|
||||
|
||||
@border-radius-base: 0;
|
||||
@border-radius-large: 0;
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
@btn-default-color: @spring-light-grey;
|
||||
@btn-default-bg: @spring-brown;
|
||||
@btn-default-border: @spring-green;
|
||||
@btn-default-border: @spring-blue;
|
||||
|
||||
@nav-tabs-active-link-hover-color: @spring-light-grey;
|
||||
@nav-tabs-active-link-hover-bg: @spring-brown;
|
||||
|
@ -46,7 +46,7 @@
|
|||
@nav-tabs-border-color: @spring-brown;
|
||||
|
||||
@pagination-active-bg: @spring-brown;
|
||||
@pagination-active-border: @spring-green;
|
||||
@pagination-active-border: @spring-blue;
|
||||
@table-border-color: @spring-brown;
|
||||
|
||||
.table > thead > tr > th {
|
||||
|
@ -125,7 +125,7 @@ h1 {
|
|||
}
|
||||
|
||||
.splash {
|
||||
background: @spring-green;
|
||||
background: @spring-blue;
|
||||
color: @spring-brown;
|
||||
display: none;
|
||||
}
|
||||
|
|
|
@ -51,3 +51,7 @@ 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, 'Penincilina');
|
||||
INSERT INTO products VALUES (2, 'Vermifugo');
|
||||
INSERT INTO products VALUES (3, 'Anto-pulgas');
|
||||
|
|
|
@ -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)
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue