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.Entity;
|
||||||
import javax.persistence.EnumType;
|
import javax.persistence.EnumType;
|
||||||
import javax.persistence.Enumerated;
|
import javax.persistence.Enumerated;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
@ -48,6 +49,7 @@ public class Offer extends BaseEntity {
|
||||||
private StatusOffer type;
|
private StatusOffer type;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
|
@JoinColumn(name="client_id")
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
public LocalDateTime getStart() {
|
public LocalDateTime getStart() {
|
||||||
|
|
|
@ -15,27 +15,32 @@
|
||||||
*/
|
*/
|
||||||
package org.springframework.cheapy.model;
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import javax.validation.constraints.Future;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "time_offers")
|
@Table(name = "time_offers")
|
||||||
public class TimeOffer extends Offer {
|
public class TimeOffer extends Offer {
|
||||||
|
|
||||||
|
@DateTimeFormat(pattern = "HH:mm")
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private String schedule;
|
private LocalTime init;
|
||||||
|
|
||||||
|
@DateTimeFormat(pattern = "HH:mm")
|
||||||
|
@NotBlank
|
||||||
|
private LocalTime finish;
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private String discount;
|
private String discount;
|
||||||
|
|
||||||
public String getSchedule() {
|
|
||||||
return schedule;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSchedule(String schedule) {
|
|
||||||
this.schedule = schedule;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDiscount() {
|
public String getDiscount() {
|
||||||
return discount;
|
return discount;
|
||||||
|
|
|
@ -8,9 +8,8 @@ import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public class User {
|
public class User extends BaseEntity {
|
||||||
|
|
||||||
@Id
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
String username;
|
String username;
|
||||||
|
|
||||||
|
|
|
@ -5,3 +5,10 @@ spring.datasource.username=${MYSQL_USER:cheapy}
|
||||||
spring.datasource.password=${MYSQL_PASS:cheapy}
|
spring.datasource.password=${MYSQL_PASS:cheapy}
|
||||||
# SQL is written to be idempotent so this is safe
|
# SQL is written to be idempotent so this is safe
|
||||||
spring.datasource.initialization-mode=always
|
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 init, supports mysql too
|
||||||
database=h2
|
database=mysql
|
||||||
spring.datasource.schema=classpath*:db/${database}/schema.sql
|
#spring.datasource.schema=classpath*:db/${database}/schema.sql
|
||||||
spring.datasource.data=classpath*:db/${database}/data.sql
|
spring.datasource.data=classpath*:db/${database}/data.sql
|
||||||
|
spring.h2.console.enabled=true
|
||||||
|
spring.profiles.active=mysql
|
||||||
# Web
|
# Web
|
||||||
spring.thymeleaf.mode=HTML
|
spring.thymeleaf.mode=HTML
|
||||||
|
|
||||||
# JPA
|
# JPA
|
||||||
spring.jpa.hibernate.ddl-auto=none
|
spring.jpa.hibernate.ddl-auto=create-drop
|
||||||
spring.jpa.open-in-view=false
|
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
|
# Internationalization
|
||||||
spring.messages.basename=messages/messages
|
spring.messages.basename=messages/messages
|
||||||
|
|
||||||
|
|
||||||
# Views
|
# Views
|
||||||
spring.mvc.view.prefix: /WEB-INF/jsp/
|
spring.mvc.view.prefix: /WEB-INF/jsp/
|
||||||
spring.mvc.view.suffix: .jsp
|
spring.mvc.view.suffix: .jsp
|
||||||
|
|
||||||
# Actuator
|
|
||||||
|
# Actuator / Management
|
||||||
|
management.endpoints.web.base-path=/manage
|
||||||
management.endpoints.web.exposure.include=*
|
management.endpoints.web.exposure.include=*
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
@ -26,6 +33,4 @@ logging.level.org.springframework=INFO
|
||||||
# logging.level.org.springframework.context.annotation=TRACE
|
# logging.level.org.springframework.context.annotation=TRACE
|
||||||
|
|
||||||
# Maximum time static resources should be cached
|
# Maximum time static resources should be cached
|
||||||
spring.resources.cache.cachecontrol.max-age=12h
|
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 INTO owners VALUES (1, 'Javi', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023');
|
||||||
INSERT IGNORE INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749');
|
INSERT 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 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 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 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 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 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 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 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 (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