-
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.
- Loading branch information
Showing
48 changed files
with
1,369 additions
and
71 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/base/entity/BaseLocation.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,21 @@ | ||
package com.lcaohoanq.shoppe.base.entity; | ||
|
||
import jakarta.persistence.MappedSuperclass; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@MappedSuperclass | ||
public class BaseLocation { | ||
|
||
private String name; | ||
private String address; | ||
private String city; | ||
private String country; | ||
|
||
} |
98 changes: 98 additions & 0 deletions
98
SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/config/VNPayConfig.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,98 @@ | ||
package com.lcaohoanq.shoppe.config; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Random; | ||
import javax.crypto.Mac; | ||
import javax.crypto.spec.SecretKeySpec; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@ConfigurationProperties(prefix = "vnpay.api") | ||
@Getter | ||
@Setter | ||
public class VNPayConfig { | ||
|
||
private String vnp_Version; | ||
private String vnp_Command; | ||
private String vnp_OrderType; | ||
private String vnp_PayUrl; | ||
private String vnp_Returnurl; | ||
private String vnp_TmnCode; // kiểm tra email sau | ||
private String vnp_HashSecret; // khi đăng ký Test | ||
private String vnp_apiUrl; | ||
|
||
public String hashAllFields(Map fields) { | ||
List fieldNames = new ArrayList(fields.keySet()); | ||
Collections.sort(fieldNames); | ||
StringBuilder sb = new StringBuilder(); | ||
Iterator itr = fieldNames.iterator(); | ||
while (itr.hasNext()) { | ||
String fieldName = (String) itr.next(); | ||
String fieldValue = (String) fields.get(fieldName); | ||
if ((fieldValue != null) && (fieldValue.length() > 0)) { | ||
sb.append(fieldName); | ||
sb.append("="); | ||
sb.append(fieldValue); | ||
} | ||
if (itr.hasNext()) { | ||
sb.append("&"); | ||
} | ||
} | ||
return hmacSHA512(getVnp_HashSecret(), sb.toString()); | ||
} | ||
|
||
public static String hmacSHA512(final String key, final String data) { | ||
try { | ||
|
||
if (key == null || data == null) { | ||
throw new NullPointerException(); | ||
} | ||
final Mac hmac512 = Mac.getInstance("HmacSHA512"); | ||
byte[] hmacKeyBytes = key.getBytes(); | ||
final SecretKeySpec secretKey = new SecretKeySpec(hmacKeyBytes, "HmacSHA512"); | ||
hmac512.init(secretKey); | ||
byte[] dataBytes = data.getBytes(StandardCharsets.UTF_8); | ||
byte[] result = hmac512.doFinal(dataBytes); | ||
StringBuilder sb = new StringBuilder(2 * result.length); | ||
for (byte b : result) { | ||
sb.append(String.format("%02x", b & 0xff)); | ||
} | ||
return sb.toString(); | ||
|
||
} catch (Exception ex) { | ||
return ""; | ||
} | ||
} | ||
|
||
public static String getIpAddress(HttpServletRequest request) { | ||
String ipAdress; | ||
try { | ||
ipAdress = request.getHeader("X-FORWARDED-FOR"); | ||
if (ipAdress == null) { | ||
ipAdress = request.getLocalAddr(); | ||
} | ||
} catch (Exception e) { | ||
ipAdress = "Invalid IP:" + e.getMessage(); | ||
} | ||
return ipAdress; | ||
} | ||
|
||
public static String getRandomNumber(int len) { | ||
Random rnd = new Random(); | ||
String chars = "0123456789"; | ||
StringBuilder sb = new StringBuilder(len); | ||
for (int i = 0; i < len; i++) { | ||
sb.append(chars.charAt(rnd.nextInt(chars.length()))); | ||
} | ||
return sb.toString(); | ||
} | ||
} |
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
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
5 changes: 5 additions & 0 deletions
5
SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/domain/category/CategoryService.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
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
5 changes: 5 additions & 0 deletions
5
...ver/springboot/src/main/java/com/lcaohoanq/shoppe/domain/inventory/IInventoryService.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.lcaohoanq.shoppe.domain.inventory; | ||
|
||
public interface IInventoryService { | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/domain/inventory/Inventory.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,56 @@ | ||
package com.lcaohoanq.shoppe.domain.inventory; | ||
|
||
import com.fasterxml.jackson.annotation.JsonManagedReference; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.lcaohoanq.shoppe.base.entity.BaseEntity; | ||
import com.lcaohoanq.shoppe.domain.product.Product; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.OneToMany; | ||
import jakarta.persistence.SequenceGenerator; | ||
import jakarta.persistence.Table; | ||
import java.util.List; | ||
import java.util.Set; | ||
import javax.print.event.PrintJobAttributeEvent; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Table(name = "inventories") | ||
@Entity | ||
public class Inventory extends BaseEntity { | ||
|
||
@Id | ||
@SequenceGenerator(name = "inventories_seq", sequenceName = "inventories_id_seq", allocationSize = 1) | ||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "inventories_seq") | ||
@Column(name="id", unique=true, nullable=false) | ||
@JsonProperty("id") | ||
private Long id; | ||
|
||
@JsonManagedReference | ||
@OneToMany(mappedBy = "inventory") | ||
@JsonProperty("inventory_locations") | ||
private Set<InventoryLocation> inventoryLocations; | ||
|
||
@OneToMany(mappedBy = "inventory") | ||
@JsonManagedReference | ||
private Set<Product> products; | ||
|
||
private Long quantity; | ||
|
||
private Long reserved; //Reserved quantity for orders | ||
|
||
@Column(name = "reorder_point") | ||
private Long reorderPoint; //The quantity that triggers a reorder | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...r/springboot/src/main/java/com/lcaohoanq/shoppe/domain/inventory/InventoryController.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,16 @@ | ||
package com.lcaohoanq.shoppe.domain.inventory; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("${api.prefix}/inventories") | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class InventoryController { | ||
|
||
|
||
|
||
} |
43 changes: 43 additions & 0 deletions
43
...ver/springboot/src/main/java/com/lcaohoanq/shoppe/domain/inventory/InventoryLocation.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,43 @@ | ||
package com.lcaohoanq.shoppe.domain.inventory; | ||
|
||
|
||
import com.fasterxml.jackson.annotation.JsonBackReference; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.lcaohoanq.shoppe.base.entity.BaseLocation; | ||
import jakarta.persistence.Column; | ||
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.SequenceGenerator; | ||
import jakarta.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Table(name = "inventory_locations") | ||
@Entity | ||
public class InventoryLocation extends BaseLocation { | ||
|
||
@Id | ||
@SequenceGenerator(name = "inventory_locations_seq", sequenceName = "inventory_locations_id_seq", allocationSize = 1) | ||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "inventory_locations_seq") | ||
@Column(name="id", unique=true, nullable=false) | ||
@JsonProperty("id") | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JsonBackReference | ||
@JoinColumn(name = "inventory_id", nullable = false) | ||
private Inventory inventory; | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...r/springboot/src/main/java/com/lcaohoanq/shoppe/domain/inventory/InventoryRepository.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,7 @@ | ||
package com.lcaohoanq.shoppe.domain.inventory; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface InventoryRepository extends JpaRepository<Inventory, Long> { | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
...rver/springboot/src/main/java/com/lcaohoanq/shoppe/domain/inventory/InventoryService.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,8 @@ | ||
package com.lcaohoanq.shoppe.domain.inventory; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class InventoryService implements IInventoryService { | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
.../springboot/src/main/java/com/lcaohoanq/shoppe/domain/logistic/IOrderShippingService.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.lcaohoanq.shoppe.domain.logistic; | ||
|
||
public interface IOrderShippingService { | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
...pringboot/src/main/java/com/lcaohoanq/shoppe/domain/logistic/IShippingCarrierService.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.lcaohoanq.shoppe.domain.logistic; | ||
|
||
public interface IShippingCarrierService { | ||
|
||
} |
61 changes: 61 additions & 0 deletions
61
SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/domain/logistic/OrderShipping.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,61 @@ | ||
package com.lcaohoanq.shoppe.domain.logistic; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.lcaohoanq.shoppe.base.entity.BaseEntity; | ||
import com.lcaohoanq.shoppe.domain.order.Order; | ||
import jakarta.persistence.Column; | ||
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.SequenceGenerator; | ||
import jakarta.persistence.Table; | ||
import java.util.Date; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Entity | ||
@Table(name = "orders_shipping") | ||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
public class OrderShipping extends BaseEntity { | ||
|
||
@Id | ||
@SequenceGenerator(name = "orders_shipping_seq", sequenceName = "orders_shipping_id_seq", allocationSize = 1) | ||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "orders_shipping_seq") | ||
@Column(name="id", unique=true, nullable=false) | ||
@JsonProperty("id") | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "order_id", nullable = false) | ||
private Order order; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "shipping_carrier_id", nullable = false) | ||
private ShippingCarrier shippingCarrier; | ||
|
||
@Column(name = "tracking_number") | ||
private String trackingNumber; | ||
|
||
@Column(name = "shipping_fee") | ||
private Float shippingFee; | ||
|
||
@Column(name = "shipping_status") | ||
private String shippingStatus; | ||
|
||
@Column(name = "shipping_date") | ||
private Date shippingDate; | ||
|
||
@Column(name = "estimated_delivery") | ||
private Date estimatedDelivery; | ||
|
||
} |
Oops, something went wrong.