-
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.
Merge pull request #30 from leung018/update-to-uuid
Update-to-uuid
- Loading branch information
Showing
21 changed files
with
156 additions
and
118 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
4 changes: 3 additions & 1 deletion
4
src/main/java/com/leungcheng/spring_simple_backend/auth/UserAuthenticatedInfo.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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
package com.leungcheng.spring_simple_backend.auth; | ||
|
||
public record UserAuthenticatedInfo(String userId) {} | ||
import java.util.UUID; | ||
|
||
public record UserAuthenticatedInfo(UUID userId) {} |
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
4 changes: 3 additions & 1 deletion
4
src/main/java/com/leungcheng/spring_simple_backend/controller/ProductNotFoundException.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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package com.leungcheng.spring_simple_backend.controller; | ||
|
||
import java.util.UUID; | ||
|
||
class ProductNotFoundException extends RuntimeException { | ||
ProductNotFoundException(String id) { | ||
ProductNotFoundException(UUID id) { | ||
super("Could not find product " + id); | ||
} | ||
} |
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
src/main/java/com/leungcheng/spring_simple_backend/domain/ProductRepository.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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package com.leungcheng.spring_simple_backend.domain; | ||
|
||
import java.util.UUID; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface ProductRepository extends CrudRepository<Product, String> {} | ||
public interface ProductRepository extends CrudRepository<Product, UUID> {} |
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
src/main/java/com/leungcheng/spring_simple_backend/domain/UserRepository.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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
package com.leungcheng.spring_simple_backend.domain; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface UserRepository extends CrudRepository<User, String> { | ||
public interface UserRepository extends CrudRepository<User, UUID> { | ||
Optional<User> findByUsername(String username); | ||
} |
15 changes: 8 additions & 7 deletions
15
src/main/java/com/leungcheng/spring_simple_backend/domain/order/Order.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 |
---|---|---|
@@ -1,39 +1,40 @@ | ||
package com.leungcheng.spring_simple_backend.domain.order; | ||
|
||
import jakarta.persistence.*; | ||
import java.util.UUID; | ||
|
||
@Entity | ||
@Table( | ||
name = "orders", | ||
uniqueConstraints = {@UniqueConstraint(columnNames = {"requestId", "buyerUserId"})}) | ||
public class Order { | ||
@Id private final String id = java.util.UUID.randomUUID().toString(); | ||
private String buyerUserId; | ||
@Id private final UUID id = UUID.randomUUID(); | ||
private UUID buyerUserId; | ||
private PurchaseItems purchaseItems; | ||
|
||
private String requestId; | ||
private UUID requestId; | ||
|
||
private Order() {} | ||
|
||
Order(String buyerUserId, PurchaseItems purchaseItems, String requestId) { | ||
Order(UUID buyerUserId, PurchaseItems purchaseItems, UUID requestId) { | ||
this.buyerUserId = buyerUserId; | ||
this.purchaseItems = purchaseItems; | ||
this.requestId = requestId; | ||
} | ||
|
||
public String getId() { | ||
public UUID getId() { | ||
return id; | ||
} | ||
|
||
public String getBuyerUserId() { | ||
public UUID getBuyerUserId() { | ||
return buyerUserId; | ||
} | ||
|
||
public PurchaseItems getPurchaseItems() { | ||
return purchaseItems; | ||
} | ||
|
||
public String getRequestId() { | ||
public UUID getRequestId() { | ||
return requestId; | ||
} | ||
} |
5 changes: 3 additions & 2 deletions
5
src/main/java/com/leungcheng/spring_simple_backend/domain/order/OrderRepository.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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
package com.leungcheng.spring_simple_backend.domain.order; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface OrderRepository extends CrudRepository<Order, String> { | ||
Optional<Order> findByBuyerUserIdAndRequestId(String buyerUserId, String requestId); | ||
public interface OrderRepository extends CrudRepository<Order, UUID> { | ||
Optional<Order> findByBuyerUserIdAndRequestId(UUID buyerUserId, UUID requestId); | ||
} |
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
Oops, something went wrong.