Hi, hw are you?
+ + \ No newline at end of file diff --git a/17020763_Dao_Kha_Hoang/JavaWeb/src/main/java/com/CodeCamp2019/model/Customer.java b/17020763_Dao_Kha_Hoang/JavaWeb/src/main/java/com/CodeCamp2019/model/Customer.java new file mode 100644 index 0000000..c44213a --- /dev/null +++ b/17020763_Dao_Kha_Hoang/JavaWeb/src/main/java/com/CodeCamp2019/model/Customer.java @@ -0,0 +1,101 @@ +package com.CodeCamp2019.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import javax.persistence.*; + +@Entity +@Table(name = "Customer") +@JsonIgnoreProperties("hibernateLazyInitializer") +public class Customer { + + @Id + @Column(name = "id") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private int id; + + @Column(name = "name") + private String name; + + @Column(name = "email") + private String email; + + @Column(name = "phone") + private String phone; + @Column(name = "balance") + private int balance; + public Customer(){ + this.id = -1; + this.name = ""; + this.email = ""; + this.phone = ""; + this.balance = 0; + } + public Customer(Customer cu1){ + this.id = cu1.id; + this.name = cu1.name; + this.email = cu1.email; + this.phone = cu1.phone; + this.balance = cu1.balance; + } + public Customer(int id, String name, String email, String phone, int balance){ + this.id = id; + this.name = name; + this.email = email; + this.phone = phone; + this.balance = balance; + } + + + public void setName(String name) { + this.name = name; + } + + public void setEmail(String email) { + this.email = email; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public void setBalance(int balance) { + this.balance = balance; + } + + public void setId(int id) { + this.id = id; + } + + public int getId(){ + return this.id; + } + public String getName(){ + return this.name; + } + public String getEmail(){ + return this.email; + } + public String getPhone(){ + return this.phone; + } + public int getBalance(){ + return this.balance; + } + + public boolean isNull(){ + if(this.id != -1) return false; + return true; + } + /* + + create table Customer( + id int(5) not null auto_increment, + name varchar(50) not null, + email varchar(50) not null, + phone varchar(11) not null, + balance int(50) not null, + primary key (id) + ) engine=InnoDB Auto_increment=1 default charset=utf8; + */ +} diff --git a/17020763_Dao_Kha_Hoang/JavaWeb/src/main/java/com/CodeCamp2019/repository/CustomerRepository.java b/17020763_Dao_Kha_Hoang/JavaWeb/src/main/java/com/CodeCamp2019/repository/CustomerRepository.java new file mode 100644 index 0000000..5fac56e --- /dev/null +++ b/17020763_Dao_Kha_Hoang/JavaWeb/src/main/java/com/CodeCamp2019/repository/CustomerRepository.java @@ -0,0 +1,12 @@ +package com.CodeCamp2019.repository; + +import com.CodeCamp2019.model.Customer; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface CustomerRepository extends JpaRepositoryID | +FullName | +Phone | +Plance | ++ | + | |
---|---|---|---|---|---|---|
${cus.id} | +${cus.name} | +${cus.email} | +${cus.phone} | +${cus.balance} | ++ + | ++ + | +