forked from nashtech-garage/yas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nashtech-garage#981 update promotion database and entities (nashtech-…
- Loading branch information
1 parent
49ab7b8
commit a4fc129
Showing
12 changed files
with
188 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
promotion/src/main/java/com/yas/promotion/model/PromotionApply.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.yas.promotion.model; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Entity | ||
@Table(name = "promotion_apply") | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor(access = AccessLevel.PACKAGE) | ||
@Builder | ||
public class PromotionApply extends AbstractAuditEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "promotion_id") | ||
private Promotion promotion; | ||
|
||
private Long productId; | ||
|
||
private Long categoryId; | ||
|
||
private Long brandId; | ||
} |
38 changes: 38 additions & 0 deletions
38
promotion/src/main/java/com/yas/promotion/model/PromotionUsage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.yas.promotion.model; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Entity | ||
@Table(name = "promotion_usage") | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor(access = AccessLevel.PACKAGE) | ||
@Builder | ||
public class PromotionUsage { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "promotion_id") | ||
private Promotion promotion; | ||
|
||
private Long productId; | ||
|
||
private String userId; | ||
|
||
private Long orderId; | ||
} |
5 changes: 5 additions & 0 deletions
5
promotion/src/main/java/com/yas/promotion/model/enumeration/ApplyTo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.yas.promotion.model.enumeration; | ||
|
||
public enum ApplyTo { | ||
PRODUCT, CATEGORY, BRAND | ||
} |
5 changes: 5 additions & 0 deletions
5
promotion/src/main/java/com/yas/promotion/model/enumeration/DiscountType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.yas.promotion.model.enumeration; | ||
|
||
public enum DiscountType { | ||
PERCENTAGE, FIXED; | ||
} |
5 changes: 5 additions & 0 deletions
5
promotion/src/main/java/com/yas/promotion/model/enumeration/UsageType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.yas.promotion.model.enumeration; | ||
|
||
public enum UsageType { | ||
LIMITED, UNLIMITED | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
promotion/src/main/java/com/yas/promotion/viewmodel/PromotionListVm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 9 additions & 1 deletion
10
promotion/src/main/java/com/yas/promotion/viewmodel/PromotionPostVm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
promotion/src/main/java/com/yas/promotion/viewmodel/PromotionVm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
promotion/src/main/resources/db/changelog/ddl/changelog-0002.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--liquibase formatted sql | ||
|
||
--changeset nguyenvanhadncntt:issue-981-1 | ||
ALTER TABLE promotion ADD COLUMN discount_type VARCHAR(25) NOT NULL; | ||
ALTER TABLE promotion ADD COLUMN usage_limit INT; | ||
ALTER TABLE promotion ADD COLUMN usage_count INT DEFAULT 0 NOT NULL; | ||
ALTER TABLE promotion ADD COLUMN usage_type VARCHAR(25) DEFAULT 'UNLIMITED' NOT NULL ; | ||
ALTER TABLE promotion ADD COLUMN apply_to VARCHAR(25) NOT NULL; | ||
ALTER TABLE promotion ADD COLUMN minimum_order_purchase_amount bigint; | ||
|
||
--changeset nguyenvanhadncntt:issue-981-2 | ||
CREATE TABLE promotion_usage ( | ||
id SERIAL PRIMARY KEY, | ||
promotion_id bigint NOT NULL, | ||
user_id varchar(255) NOT NULL, | ||
order_id bigint NOT NULL , | ||
product_id bigint NOT NULL, | ||
created_by varchar(255), | ||
created_on timestamp with time zone, | ||
last_modified_by varchar(255), | ||
last_modified_on timestamp with time zone, | ||
foreign key (promotion_id) references promotion(id) | ||
); | ||
|
||
--changeset nguyenvanhadncntt:issue-981-3 | ||
CREATE TABLE promotion_apply ( | ||
id SERIAL PRIMARY KEY, | ||
promotion_id bigint NOT NULL, | ||
brand_id bigint, | ||
category_id bigint, | ||
product_id bigint, | ||
created_by varchar(255), | ||
created_on timestamp with time zone, | ||
last_modified_by varchar(255), | ||
last_modified_on timestamp with time zone, | ||
foreign key (promotion_id) references promotion(id) | ||
); |