Skip to content

Commit

Permalink
FEAT:fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
rivo pelu committed Dec 10, 2024
1 parent 8459a9b commit 6499f71
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/main/java/com/pos/app/entities/CustomerTable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.pos.app.entities;


import jakarta.persistence.*;
import lombok.*;

@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "customer_table")
public class CustomerTable extends BaseEntity {

@Column(name = "table_number")
private Integer tableNumber;

@Column(name = "customer_name")
private String customerName;

@JoinColumn(name = "merchant_id")
@ManyToOne
private Merchant merchant;

@JoinColumn(name = "client_id")
@ManyToOne
private Client client;

}
29 changes: 29 additions & 0 deletions src/main/java/com/pos/app/entities/Merchant.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.pos.app.entities;

import jakarta.persistence.*;
import lombok.*;

@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "merchant")
public class Merchant extends BaseEntity {

@Column(name = "name")
private String name;
@Column(name = "address")
private String address;
@Column(name = "note")
private String note;

@JoinColumn(name = "client_id")
@ManyToOne
private Client client;




}
4 changes: 4 additions & 0 deletions src/main/java/com/pos/app/entities/Order.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public class Order {
@Column(name = "is_active")
private Boolean isActive;

@JoinColumn(name = "customer_table")
@ManyToOne
private CustomerTable customerTable;

@PrePersist
public void prePersist() {
if (this.id == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">

<changeSet id="1.7.0" author="rivo pelu">
<createTable tableName="merchant">
<!-- BASE ENTITY START-->
<column name="id" type="varchar(255)">
<constraints nullable="false" primaryKey="true" unique="true"/>
</column>
<column name="active" type="int(1)" defaultValue="1">
<constraints nullable="false"/>
</column>
<column name="created_by" type="varchar(255)" defaultValue="SYSTEM">
<constraints nullable="false"/>
</column>
<column name="created_date" type="long">
<constraints nullable="false"/>
</column>
<column name="deleted_by" type="varchar(255)">
<constraints nullable="true"/>
</column>
<column name="deleted_date" type="long">
<constraints nullable="true"/>
</column>
<column name="updated_by" type="varchar(255)">
<constraints nullable="true"/>
</column>
<column name="updated_date" type="long">
<constraints nullable="true"/>
</column>
<!-- BASE ENTITY END-->
<column name="name" type="varchar(255)">
<constraints nullable="false"/>
</column>
<column name="address" type="text">
<constraints nullable="true"/>
</column>
<column name="note" type="text">
<constraints nullable="true"/>
</column>
<column name="client_id" type="varchar(255)">
<constraints nullable="false"/>
</column>

</createTable>

<!-- CUSTOMER TABLE-->
<createTable tableName="customer_table">
<!-- BASE ENTITY START-->
<column name="id" type="varchar(255)">
<constraints nullable="false" primaryKey="true" unique="true"/>
</column>
<column name="active" type="int(1)" defaultValue="1">
<constraints nullable="false"/>
</column>
<column name="created_by" type="varchar(255)" defaultValue="SYSTEM">
<constraints nullable="false"/>
</column>
<column name="created_date" type="long">
<constraints nullable="false"/>
</column>
<column name="deleted_by" type="varchar(255)">
<constraints nullable="true"/>
</column>
<column name="deleted_date" type="long">
<constraints nullable="true"/>
</column>
<column name="updated_by" type="varchar(255)">
<constraints nullable="true"/>
</column>
<column name="updated_date" type="long">
<constraints nullable="true"/>
</column>
<!-- BASE ENTITY END-->
<column name="table_number" type="int">
<constraints nullable="true"/>
</column>
<column name="customer_name" type="varchar(255)">
<constraints nullable="true"/>
</column>
<column name="merchant_id" type="varchar(255)">
<constraints nullable="false"/>
</column>

<column name="client_id" type="varchar(255)">
<constraints nullable="false"/>
</column>
</createTable>
<addForeignKeyConstraint baseTableName="customer_table"
baseColumnNames="client_id"
constraintName="client_customer_table_fk"
referencedTableName="client"
referencedColumnNames="id"/>
<addForeignKeyConstraint baseTableName="customer_table"
baseColumnNames="merchant_id"
constraintName="merchant_customer_table_fk"
referencedTableName="merchant"
referencedColumnNames="id"/>
<addForeignKeyConstraint baseTableName="merchant"
baseColumnNames="client_id"
constraintName="merchant_client_fk"
referencedTableName="client"
referencedColumnNames="id"/>
</changeSet>
</databaseChangeLog>
1 change: 1 addition & 0 deletions src/main/resources/db/changelog/changelog-master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
<include file="classpath:db/changelog/1.6.2_add_table_transaction_notification_subscription.xml"/>
<include file="classpath:db/changelog/1.6.3_add_fk_notification_subscription_order.xml"/>
<include file="classpath:db/changelog/1.6.4_rename_column_note_to_address.xml"/>
<include file="classpath:db/changelog/1.7.0_add_table_merchant_and_customer_table.xml"/>
</databaseChangeLog>

0 comments on commit 6499f71

Please sign in to comment.