mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 15:55:49 +00:00
Arreglo de entidades y de la configuracion mysql
This commit is contained in:
parent
018195af62
commit
98a78f15bd
6 changed files with 52 additions and 29 deletions
|
@ -20,6 +20,7 @@ import java.time.LocalDateTime;
|
|||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.Table;
|
||||
|
@ -48,6 +49,7 @@ public class Offer extends BaseEntity {
|
|||
private StatusOffer type;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name="client_id")
|
||||
private Client client;
|
||||
|
||||
public LocalDateTime getStart() {
|
||||
|
|
|
@ -15,27 +15,32 @@
|
|||
*/
|
||||
package org.springframework.cheapy.model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Future;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
@Entity
|
||||
@Table(name = "time_offers")
|
||||
public class TimeOffer extends Offer {
|
||||
|
||||
@DateTimeFormat(pattern = "HH:mm")
|
||||
@NotBlank
|
||||
private String schedule;
|
||||
private LocalTime init;
|
||||
|
||||
@DateTimeFormat(pattern = "HH:mm")
|
||||
@NotBlank
|
||||
private LocalTime finish;
|
||||
|
||||
@NotBlank
|
||||
private String discount;
|
||||
|
||||
public String getSchedule() {
|
||||
return schedule;
|
||||
}
|
||||
|
||||
public void setSchedule(String schedule) {
|
||||
this.schedule = schedule;
|
||||
}
|
||||
|
||||
public String getDiscount() {
|
||||
return discount;
|
||||
|
|
|
@ -8,9 +8,8 @@ import javax.validation.constraints.NotBlank;
|
|||
|
||||
|
||||
@MappedSuperclass
|
||||
public class User {
|
||||
public class User extends BaseEntity {
|
||||
|
||||
@Id
|
||||
@NotBlank
|
||||
String username;
|
||||
|
||||
|
|
|
@ -5,3 +5,10 @@ spring.datasource.username=${MYSQL_USER:cheapy}
|
|||
spring.datasource.password=${MYSQL_PASS:cheapy}
|
||||
# SQL is written to be idempotent so this is safe
|
||||
spring.datasource.initialization-mode=always
|
||||
|
||||
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
|
||||
spring.jpa.properties.javax.persistence.schema-generation.drop-source=metadata
|
||||
# Naming strategy
|
||||
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
|
||||
# Allows Hibernate to generate SQL optimized for a particular DBMS
|
||||
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
|
||||
|
|
|
@ -1,23 +1,30 @@
|
|||
# database init, supports mysql too
|
||||
database=h2
|
||||
spring.datasource.schema=classpath*:db/${database}/schema.sql
|
||||
database=mysql
|
||||
#spring.datasource.schema=classpath*:db/${database}/schema.sql
|
||||
spring.datasource.data=classpath*:db/${database}/data.sql
|
||||
|
||||
spring.h2.console.enabled=true
|
||||
spring.profiles.active=mysql
|
||||
# Web
|
||||
spring.thymeleaf.mode=HTML
|
||||
|
||||
# JPA
|
||||
spring.jpa.hibernate.ddl-auto=none
|
||||
spring.jpa.open-in-view=false
|
||||
spring.jpa.hibernate.ddl-auto=create-drop
|
||||
spring.jpa.show-sql=true
|
||||
spring.jpa.properties.hibernate.format_sql=true
|
||||
spring.jpa.properties.javax.persistence.schema-generation.drop-source=script
|
||||
spring.jpa.properties.javax.persistence.schema-generation.drop-script-source=drop-tables.sql
|
||||
|
||||
# Internationalization
|
||||
spring.messages.basename=messages/messages
|
||||
|
||||
|
||||
# Views
|
||||
spring.mvc.view.prefix: /WEB-INF/jsp/
|
||||
spring.mvc.view.suffix: .jsp
|
||||
|
||||
# Actuator
|
||||
|
||||
# Actuator / Management
|
||||
management.endpoints.web.base-path=/manage
|
||||
management.endpoints.web.exposure.include=*
|
||||
|
||||
# Logging
|
||||
|
@ -27,5 +34,3 @@ logging.level.org.springframework=INFO
|
|||
|
||||
# Maximum time static resources should be cached
|
||||
spring.resources.cache.cachecontrol.max-age=12h
|
||||
|
||||
spring.profiles.active=mysql
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
INSERT IGNORE INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023');
|
||||
INSERT IGNORE INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749');
|
||||
INSERT IGNORE INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763');
|
||||
INSERT IGNORE INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198');
|
||||
INSERT IGNORE INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765');
|
||||
INSERT IGNORE INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654');
|
||||
INSERT IGNORE INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387');
|
||||
INSERT IGNORE INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683');
|
||||
INSERT IGNORE INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
|
||||
INSERT IGNORE INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487');
|
||||
INSERT INTO owners VALUES (1, 'Javi', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023');
|
||||
INSERT INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749');
|
||||
INSERT INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763');
|
||||
INSERT INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198');
|
||||
INSERT INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765');
|
||||
INSERT INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654');
|
||||
INSERT INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387');
|
||||
INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683');
|
||||
INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
|
||||
INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487');
|
||||
|
||||
|
||||
INSERT INTO food_offers(start, end, code, type, client_id, food, discount, units) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'jkhlljk', 'active', null, 'macarrones', '15%', 10);
|
||||
|
||||
INSERT INTO time_offers(start, end, code, type, client_id, init, finish, discount) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'jkhlljk', 'active', null, '12:00:00', '13:00:00', '10%');
|
Loading…
Reference in a new issue